* [PATCH] genirq/core: Fall back to a static default affinity mask
@ 2026-10-31 13:38 Avi Weiss
0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-10-31 13:38 UTC (permalink / raw)
To: tglx; +Cc: radu, linux-kernel, Avi Weiss
With CONFIG_CPUMASK_OFFSTACK=y, init_irq_default_affinity() does not
check whether zalloc_cpumask_var() succeeds. If the GFP_NOWAIT allocation
fails, cpumask_empty() dereferences a NULL mask during early boot.
Use a private static cpumask when allocation fails, keeping the default
IRQ affinity mask available and writable.
In a QEMU guest, a test-only allocation failure triggered the boot fault
without this change. The patched kernel booted with the same injected
failure and allowed the default affinity mask to be read and written.
Normal and irqaffinity=0 boots also passed.
Fixes: d036e67b40f5 ("cpumask: convert kernel/irq")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
kernel/irq/irqdesc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 3a818f07a101..1ea020425381 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -25,6 +25,9 @@
static struct lock_class_key irq_desc_lock_class;
#if defined(CONFIG_SMP)
+#ifdef CONFIG_CPUMASK_OFFSTACK
+static cpumask_t irq_default_affinity_fallback;
+#endif
static int __init irq_affinity_setup(char *str)
{
alloc_bootmem_cpumask_var(&irq_default_affinity);
@@ -40,8 +43,12 @@ __setup("irqaffinity=", irq_affinity_setup);
static void __init init_irq_default_affinity(void)
{
- if (!cpumask_available(irq_default_affinity))
- zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+ if (!cpumask_available(irq_default_affinity) &&
+ !zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT)) {
+#ifdef CONFIG_CPUMASK_OFFSTACK
+ irq_default_affinity = &irq_default_affinity_fallback;
+#endif
+ }
if (cpumask_empty(irq_default_affinity))
cpumask_setall(irq_default_affinity);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-31 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 13:38 [PATCH] genirq/core: Fall back to a static default affinity mask Avi Weiss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®