On Thu, May 08, 2025 at 01:23:04PM -0700, H. Peter Anvin wrote: > On May 8, 2025 5:15:44 AM PDT, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > >> Looks good, except when fred_event_data() returns 0. I don't expect it > >> to happen in practice. But, maybe with new hardware and eventually > >> different hypervisors being involved, it is a possibility. > >> > >> We can either call it a bug that an NMI happened without source > >> information. Or be extra nice and do this: > >> > >> if (cpu_feature_enabled(X86_FEATURE_NMI_SOURCE) && type == NMI_LOCAL) { > >> source = fred_event_data(regs); > >> if (!source || (source & BIT(0))) > >> source = ~0UL; > >> } > > > >Perhaps also WARN about the !source case? > > A 0 should be interpreted such that NMI source is not available, e.g. > due to a broken hypervisor or similar. I'm reading that as an agreement for WARN-ing on 0. We should definitely WARN on broken hypervisors and similar.