[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f4509334310ab347d49a1fc45df5053050b70a3f.camel@intel.com>
Date: Fri, 17 Oct 2025 20:34:11 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "seanjc@...gle.com" <seanjc@...gle.com>
CC: "Li, Xiaoyao" <xiaoyao.li@...el.com>, "kvm@...r.kernel.org"
<kvm@...r.kernel.org>, "pbonzini@...hat.com" <pbonzini@...hat.com>,
"Williams, Dan J" <dan.j.williams@...el.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "Edgecombe, Rick P"
<rick.p.edgecombe@...el.com>, "binbin.wu@...ux.intel.com"
<binbin.wu@...ux.intel.com>
Subject: Re: [PATCH v2 1/2] KVM: VMX: Inject #UD if guest tries to execute
SEAMCALL or TDCALL
On Fri, 2025-10-17 at 06:00 -0700, Sean Christopherson wrote:
> On Fri, Oct 17, 2025, Kai Huang wrote:
> >
> > > --- a/arch/x86/kvm/vmx/nested.c
> > > +++ b/arch/x86/kvm/vmx/nested.c
> > > @@ -6728,6 +6728,14 @@ static bool nested_vmx_l1_wants_exit(struct kvm_vcpu *vcpu,
> > > case EXIT_REASON_NOTIFY:
> > > /* Notify VM exit is not exposed to L1 */
> > > return false;
> > > + case EXIT_REASON_SEAMCALL:
> > > + case EXIT_REASON_TDCALL:
> > > + /*
> > > + * SEAMCALL and TDCALL unconditionally VM-Exit, but aren't
> > > + * virtualized by KVM for L1 hypervisors, i.e. L1 should
> > > + * never want or expect such an exit.
> > > + */
> > > + return false;
> >
> > Sorry for commenting late.
> >
> > I think from emulating hardware behaviour's perspective, if L1 doesn't
> > support TDX (obviously true), SEAMCALL/TDCALL in L2 should cause VMEXIT to
> > L1. In other words, L1 is expecting a VMEXIT in such case.
>
> No, because from L1's perspective, the opcodes map to undefined instructions and
> thus should #UD in L2. There's no super explicit enumeration, but IMO it's fair
> to say that for L1 to think the instructions exists, it would need to observe
> IA32_SEAMRR_PHYS_{BASE,MASK} for SEAMCALL, and MSR_IA32_MKTME_KEYID_PARTITIONING
> as well for TDCALL. KVM doesn't emulate any of those instructions, and so L1
> should never expect SEAMCALL or TDCALL to do anything other than #UD.
>
Oh right. I forgot the SEAMCALL/TDCALL VMEXIT only happens on TDX-capable
machine. :-)
>
Powered by blists - more mailing lists