[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCaRvwnkXf07Mtue@google.com>
Date: Thu, 15 May 2025 18:15:43 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Sohil Mehta <sohil.mehta@...el.com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, Xin Li <xin@...or.com>,
"H . Peter Anvin" <hpa@...or.com>, Andy Lutomirski <luto@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, Peter Zijlstra <peterz@...radead.org>,
Adrian Hunter <adrian.hunter@...el.com>, Kan Liang <kan.liang@...ux.intel.com>,
Tony Luck <tony.luck@...el.com>, Zhang Rui <rui.zhang@...el.com>,
Steven Rostedt <rostedt@...dmis.org>, Andrew Cooper <andrew.cooper3@...rix.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>, Jacob Pan <jacob.pan@...ux.microsoft.com>,
Andi Kleen <ak@...ux.intel.com>, Kai Huang <kai.huang@...el.com>,
Sandipan Das <sandipan.das@....com>, linux-perf-users@...r.kernel.org,
linux-edac@...r.kernel.org, kvm@...r.kernel.org, linux-pm@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v6 1/9] x86/fred, KVM: VMX: Pass event data to the FRED
entry point from KVM
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@...gle.com>
> > 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.
Powered by blists - more mailing lists