xen/arm: irq: Initialize the per-CPU IRQs while preparing the CPU
authorJulien Grall <jgrall@amazon.com>
Sat, 25 Jun 2022 14:52:39 +0000 (15:52 +0100)
committerJulien Grall <julien@xen.org>
Sat, 25 Jun 2022 14:53:05 +0000 (15:53 +0100)
commit0544c4ee4b48f7e2715e69ff3e73c3d5545b0526
tree55bd866b0a08b9ae39a0642a47d7403990cd27c8
parent7c1f724dd95cf627f72c96d310b6b7d487bc2281
xen/arm: irq: Initialize the per-CPU IRQs while preparing the CPU

Commit 5047cd1d5dea "xen/common: Use enhanced ASSERT_ALLOC_CONTEXT in
xmalloc()" extended the checks in _xmalloc() to catch any use of the
helpers from context with interrupts disabled.

Unfortunately, the rule is not followed when initializing the per-CPU
IRQs:

(XEN) Xen call trace:
(XEN)    [<002389f4>] _xmalloc+0xfc/0x314 (PC)
(XEN)    [<00000000>] 00000000 (LR)
(XEN)    [<0021a7c4>] init_one_irq_desc+0x48/0xd0
(XEN)    [<002807a8>] irq.c#init_local_irq_data+0x48/0xa4
(XEN)    [<00280834>] init_secondary_IRQ+0x10/0x2c
(XEN)    [<00288fa4>] start_secondary+0x194/0x274
(XEN)    [<40010170>] 40010170
(XEN)
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 2:
(XEN) Assertion '!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1)' failed at common/xmalloc_tlsf.c:601
(XEN) ****************************************

This is happening because zalloc_cpumask_var() may allocate memory
if NR_CPUS is > 2 * sizeof(unsigned long).

Avoid the problem by initializing the per-CPU IRQs while preparing the
CPU.

This also has the benefit to remove a BUG_ON() in the secondary CPU
code.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Tested-by: Bertrand Marquis <bertrand.marquis@arm.com>
xen/arch/arm/include/asm/irq.h
xen/arch/arm/irq.c
xen/arch/arm/smpboot.c