[PATCH v2 00/39] arm64: Add support for FEAT_NMI

Jinjie Ruan ruanjinjie at huawei.com
Thu Nov 19 18:11:33 PST 2026


Hi Kiryl,

在 2026/11/20 0:07, Kiryl Shutsemau (Meta) 写道:
> On Thu, Nov 19, 2026 at 02:50:50PM +0000, Vladimir Murzin wrote:
>> Any chance you can attach debugger or collect traces so we know what those
>> CPUs are doing?
> 
> I think they are idle with SDEI masked when the broadcast lands, and
> the firmware leaves them unable to take interrupts.

You are completely right, I verified that it was true.

> 
> A CPU entering a power-down idle state masks SDEI from the cpu_pm
> notifier. If event 0 lands on it while it is masked, TF-A's
> handle_masked_trigger() returns for event 0 without EOI:
> 
>     CPU A                           CPU B (power-down idle)
>                                     cpu_pm_enter()
>                                       sdei_mask_local_cpu()
>     sdei_nmi_raise_backtrace()
>       SDEI_EVENT_SIGNAL(0, CPU B)
>                                     EL3: sdei_intr_handler()
>                                       acknowledge the SGI
>                                       handle_masked_trigger()
>                                         // event 0: return, no EOI
>                                     cpu_pm_exit()
>                                       sdei_unmask_local_cpu()
> 
> The SGI stays active, so CPU B runs at the SDEI priority from then on:
> no Non-secure interrupts and no more event 0. Other CPUs then hang in
> csd_lock_wait() on their next synchronous cross-call to it.
> 
> I reproduced it on QEMU with TF-A v2.15 minus the check described below.
> 
> After event 0 lands on a masked CPU, ICC_RPR_EL1 there reads 0 and stays
> 0 after SDEI_PE_UNMASK, and RCU reports "1-...!: ... idle=c078/0/0x0 ...
> (false positive?)" as in Jinjie's rc3 log. With an EOI added on that
> path, the same test passes.
> 
> That path has been in TF-A since the SDEI dispatcher was added and is
> still in master. TF-A v2.13 made SDEI_EVENT_SIGNAL refuse a masked
> target, which leaves only a race with a target that masks after the
> check.
> 
> A fix is under review:
> 
>   https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/55414
> 

Sorry, I seem unable to open this link.

> Jinjie, what is your firmware based on?

Sorry, unable to provide the TF-A version — this machine reports its own
HiSilicon firmware.

> 
> Two checks would confirm it:
> 
>   - does dmesg show "SDEI_EVENT_SIGNAL to CPU N failed" after the
>     sysrq-l? None means the firmware accepted the signals to masked
>     CPUs;

Zero. two logs are 0 (rc3 + rc2). The firmware returns success for all
targets, including the masked CPU.

> 
>   - does the broadcast work with cpuidle.off=1? Without power-down idle
>     nothing masks SDEI, so all CPUs should answer.

Yes. Instead of restarting and modifying the cmdline, I turned off
state1 for all 384 CPUs during runtime (leaving only WFI). The same echo
  sysrq-l command:

   answered=384 timeout=0 sdei_fail=0 lockup=0 load=0.39 The machine is
fully functional.


> 
> Ways out I see:
> 
>   - Firmware: end the interrupt on that path, or keep event 0 pending
>     until unmask as 55414 does. That is the real fix, but deployed
>     firmware will not have it for a while.

This method is too dependent on the firmware version.

> 
>   - Kernel: never signal a CPU that has SDEI masked. The signalling CPU
>     and the cpu_pm notifier can handshake: the sender marks the target
>     and IPIs it instead if it is already masked, and the notifier
>     refuses the power-down state while a signal is in flight. SDEI keeps
>     serving every running CPU, and the race goes away whatever the
>     firmware does. It needs a hook in arm_sdei.c.

This method might require a per-CPU mask. If the mask is already set, it
will not send an SDEI but instead use a regular IPI instead. However,
the code modification appears to be relatively complex.

> 
>   - Kernel: send the IPI first and SDEI only to the CPUs that do not
>     answer, as smp_send_stop() does. Simple, but then SDEI runs only
>     when a CPU is really stuck, and a problem like this one stays hidden
>     until the day it is needed.
> 

This will make it more difficult for SDEI issues to arise and be
promptly resolved.

>   - Kernel: use the NMI IPI when there is one, as you suggested. That
>     takes SDEI out of the picture where FEAT_NMI or pseudo-NMI is in use,
>     but not on machines without them, which are the ones SDEI is for.

I fully agree with this priority.

> 
>   - A switch to turn SDEI NMI off, like Jinjie's patch, as an escape
>     hatch whichever way this goes.

Shall I send a patch for the switch?


Best regards,
Jinjie

> 
> Any comments?
> 




More information about the linux-arm-kernel mailing list