On Wed, May 14, 2025, Sohil Mehta wrote: > On 5/14/2025 7:15 AM, Sean Christopherson wrote: > > Compile tested only... > > > > No worries. I'll test it out. I am assuming you want this patch to go as > part of this series. Yes please. I can also post it separately, but that seems unnecessary. > > -- > > From: Sean Christopherson <seanjc@xxxxxxxxxx> > > Date: Wed, 14 May 2025 07:07:55 -0700 > > Subject: [PATCH] x86/fred: Provide separate IRQ vs. NMI wrappers for "entry" > > from KVM > > > > Provide separate wrappers for forwarding IRQs vs NMIs from KVM in > > anticipation of adding support for NMI source reporting, which will add > > an NMI-only parameter, i.e. will further pollute the current API with a > > param that is a hardcoded for one of the two call sites. > > > > Opportunistically tag the non-FRED NMI wrapper __always_inline, as the > > compiler could theoretically generate a function call and trigger and a > > (completely benign) "leaving noinstr" warning. > > > > If this is really a concern, wouldn't there be similar semantics in > other places as well? There are, e.g. the stubs in include/linux/context_tracking_state.h and many other places. It looks ridiculous, but the compiler will generate RET+CALL for literal nops if the right sanitizers are enabled. E.g. see commit 432727f1cb6e ("KVM: VMX: Always inline to_vmx() and to_kvm_vmx()"). > > @@ -70,14 +71,26 @@ __visible void fred_entry_from_user(struct pt_regs *regs); > > __visible void fred_entry_from_kernel(struct pt_regs *regs); > > __visible void __fred_entry_from_kvm(struct pt_regs *regs); > > > > -/* Can be called from noinstr code, thus __always_inline */ > > -static __always_inline void fred_entry_from_kvm(unsigned int type, unsigned int vector) > > +/* Must be called from noinstr code, thus __always_inline */ > > +static __always_inline void fred_nmi_from_kvm(void) > > { > > struct fred_ss ss = { > > .ss =__KERNEL_DS, > > - .type = type, > > + .type = EVENT_TYPE_NMI, > > + .vector = NMI_VECTOR, > > + .nmi = true, > > + .lm = 1, > > + }; > > + > > + asm_fred_entry_from_kvm(ss); > > +} > > + > > The original code uses spaces for alignment. Since we are modifying it, > I am thinking of changing it to tabs. Oof, yeah, definitely do that.