Re: [PATCH v2 10/14] arm64/nmi: Manage masking for superpriority interrupts along with DAIF

Mark Rutland
2022-12-12T14:40:16Z

On Sat, Nov 12, 2022 at 03:17:04PM +0000, Mark Brown wrote:
> As we do for pseudo NMIs add code to our DAIF management which keeps
> superpriority interrupts unmasked when we have asynchronous exceptions
> enabled.

Please, no. NAK to pretending this is part of DAIF.

The existing hacks to bodge pseudo-NMI into the DAIF management code are
convoluted, difficult to maintain, and they have known cases where they
*cannot* do the right thing. Those existing hacks have proved to be more
trouble than they're worth, and continuing down that path makes things worse.

We must clean up the existing approach *before* we add the real NMI support.

As mentioned elsewhere, I think this means reworking the way we manage
exception masks, and at least:

(a) Adding entry-specific helpers to manipulate abstract exception masks
covering DAIF + PMR + ALLINT. Those need unmask-at-entry and mask-at-exit
behaviour, and today only need to manage DAIF + PMR.

It should be possible to do this ahead of ALLINT / NMI support.

(b) Adding new "logical exception mask" helpers that treat DAIF + PMR + ALLINT
as separate elements.

This way we can always save+track all elements if we need to (e.g. for
irqflag tracking), but we never have to fake up a DAIF element.

Thanks,
Mark.