Re: [PATCH v7 02/10] x86/fred: Pass event data to the NMI entry point from KVM

From: Sean Christopherson
Date: Thu Jun 12 2025 - 20:18:40 EST


On Thu, Jun 12, 2025, Sohil Mehta wrote:
> Extend the FRED NMI entry point from KVM to take an extra argument to
> allow KVM to invoke the FRED event dispatch framework with event data.
>
> This API is used to pass the NMI-source bitmap for NMI-induced VM exits.
> Read the VMCS exit qualification field to get the NMI-source information
> and store it as event data precisely in the format expected by the FRED
> event framework.
>
> Read the VMCS exit qualification unconditionally since almost all
> upcoming CPUs are expected to enable FRED and NMI-source together. In
> the rare case that NMI-source isn't enabled, the extra VMREAD would be
> harmless since the exit qualification is expected to be zero.

Nit, instead of "is expected to be zero", something like this

harmless since the exit qualification is architecturally guaranteed to be
zero on CPUs that don't support NMI-source reporting. Per the SDM's
"Exit qualification" subsection of "Basic VM-Exit Information":

For all other VM exits, this field is cleared.
--

to make it very explicit that reading the exit qualification on older CPUs is 100%
safe, e.g. even on non-FRED CPUs (see https://lore.kernel.org/all/aBUiwLV4ZY2HdRbz@xxxxxxxxxx).

> Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Originally-by: Zeng Guang <guang.zeng@xxxxxxxxx>
> Signed-off-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
> ---

Acked-by: Sean Christopherson <seanjc@xxxxxxxxxx>