[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z0ZAo4lZcIj0rEZb@google.com>
Date: Tue, 26 Nov 2024 13:41:55 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Binbin Wu <binbin.wu@...ux.intel.com>
Cc: Kai Huang <kai.huang@...el.com>, "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Xiaoyao Li <xiaoyao.li@...el.com>, Yan Y Zhao <yan.y.zhao@...el.com>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>, Adrian Hunter <adrian.hunter@...el.com>,
"dmatlack@...gle.com" <dmatlack@...gle.com>, Weijiang Yang <weijiang.yang@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>, "pbonzini@...hat.com" <pbonzini@...hat.com>,
Isaku Yamahata <isaku.yamahata@...el.com>,
"tony.lindgren@...ux.intel.com" <tony.lindgren@...ux.intel.com>,
"nik.borisov@...e.com" <nik.borisov@...e.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Chao Gao <chao.gao@...el.com>,
Rick P Edgecombe <rick.p.edgecombe@...el.com>, "x86@...nel.org" <x86@...nel.org>, Xin3 Li <xin3.li@...el.com>
Subject: Re: [PATCH 0/7] KVM: TDX: TD vcpu enter/exit
On Tue, Nov 26, 2024, Binbin Wu wrote:
> On 11/26/2024 11:52 AM, Huang, Kai wrote:
> > On Tue, 2024-11-26 at 09:44 +0800, Binbin Wu wrote:
> > >
> > > On 11/26/2024 6:51 AM, Sean Christopherson wrote:
> > >
> > > [...]
> > > > When an NMI happens in non-root, the NMI is acknowledged by the CPU prior to
> > > > performing VM-Exit. In regular VMX, NMIs are blocked after such VM-Exits. With
> > > > TDX, that blocking happens for SEAM root, but the SEAMRET back to VMX root will
> > > > load interruptibility from the SEAMCALL VMCS, and I don't see any code in the
> > > > TDX-Module that propagates that blocking to SEAMCALL VMCS.
> > > I see, thanks for the explanation!
> > >
> > > > Hmm, actually, this means that TDX has a causality inversion, which may become
> > > > visible with FRED's NMI source reporting. E.g. NMI X arrives in SEAM non-root
> > > > and triggers a VM-Exit. NMI X+1 becomes pending while SEAM root is active.
> > > > TDX-Module SEAMRETs to VMX root, NMIs are unblocked, and so NMI X+1 is delivered
> > > > and handled before NMI X.
> > > This example can also cause an issue without FRED.
> > > 1. NMI X arrives in SEAM non-root and triggers a VM-Exit.
> > > 2. NMI X+1 becomes pending while SEAM root is active.
> > > 3. TDX-Module SEAMRETs to VMX root, NMIs are unblocked.
> > > 4. NMI X+1 is delivered and handled before NMI X.
> > > (NMI handler could handle all NMI source events, including the source
> > > triggered NMI X)
> > > 5. KVM calls exc_nmi() to handle the VM Exit caused by NMI X
> > > In step 5, because the source event caused NMI X has been handled, and NMI X
> > > will not be detected as a second half of back-to-back NMIs, according to
> > > Linux NMI handler, it will be considered as an unknown NMI.
> > I don't think KVM should call exc_nmi() anymore if NMI is unblocked upon
> > SEAMRET.
>
> IIUC, KVM has to, because the NMI triggered the VM-Exit can't trigger the
> NMI handler to be invoked automatically even if NMI is unblocked upon SEAMRET.
Yep. The NMI is consumed by the VM-Exit, for all intents and purposes. KVM must
manually invoke the NMI handler.
Which is how the ordering gets messed up: NMI X+1 arrives before KVM has a chance
to manually invoke the handler for NMI X.
Powered by blists - more mailing lists