[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 for 4.23] Add GIC SGI boot/self tests in Xen



Hi Ayan,

On 17/09/2026 14:13, Halder, Ayan Kumar wrote:
On 17/09/2026 08:57, Grall, Julien wrote:
On 16/09/2026 12:35, Ayan Kumar Halder wrote:
+static void __init expect_sgi(const cpumask_t *mask,
+                              const unsigned int *before, const char *what)
+{
+    s_time_t deadline = NOW() + MILLISECS(100);
+    unsigned int cpu;
+
+    for_each_cpu ( cpu, mask )
+    {
+        while ( sgi_count(cpu) == before[cpu] )
+        {
+            if ( NOW() > deadline )
+                panic("GIC selftest: %s: CPU%u did not receive GIC_SGI_TEST\n",
+                      what, cpu);
+            cpu_relax();
+        }
+    }
+
+    printk("GIC selftest: CPU%u: %s: OK\n", smp_processor_id(), what);
+}
+
+/*
+ * "All but self" is only meaningful once every CPU can take an SGI, so it is
+ * run by whichever CPU observes that it is the last one to get here.
+ */
+static int __init gic_sgi_selftest(void)
+{
+    static atomic_t __initdata seen = ATOMIC_INIT(0);
+    unsigned int before[NR_CPUS] = { };

Sorry I didn't spot this earlier. NR_CPUS can be quite large (up to 16K). So this will blow up the stack.

We discussed this offline at Xen Summit. But I will answer here as well.


As this is a test, we have hardcoded NR_CPUS = 4 in automation/scripts/ qemu-boot-selftest-arm64.sh.

I agree with your current test harness we only test 4 CPUs. However, this is not enforced by the Kconfig in Xen. So anyone could modify the script (or write their own) with a much higher number of NR_CPUS (possibly to match the number of pCPUs on their hardware).

Depending on the value, they could face a stack overflow.


If there are 16K CPUs, our test only checks for 4 cpus only.

However if there is still a concern ....

I would preferred if this is solved. Assuming this is fixed:

Reviewed-by: Julien Grall <julien@xxxxxxx>

Cheers,

--
Julien Grall




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.