All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Chao Gao <chao.gao@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Kai Huang <kai.huang@intel.com>,
	 Rick Edgecombe <rick.p.edgecombe@intel.com>
Subject: Re: [PATCH] KVM: VMX: Inject #UD if guest tries to execute SEAMCALL or TDCALL
Date: Wed, 15 Oct 2025 06:20:41 -0700	[thread overview]
Message-ID: <aO-fqYO_vmwtCn8l@google.com> (raw)
In-Reply-To: <d9328f94-a6a9-4d98-8ea7-9b9e22bc1db6@intel.com>

On Wed, Oct 15, 2025, Xiaoyao Li wrote:
> On 10/15/2025 9:13 AM, Chao Gao 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 true;
> > > 	default:
> > > 		return true;
> > > 	}
> > > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > > index 097304bf1e1d..7326c68f9909 100644
> > > --- a/arch/x86/kvm/vmx/tdx.c
> > > +++ b/arch/x86/kvm/vmx/tdx.c
> > > @@ -2127,6 +2127,9 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
> > > 		return tdx_emulate_mmio(vcpu);
> > > 	case EXIT_REASON_EPT_VIOLATION:
> > > 		return tdx_handle_ept_violation(vcpu);
> > > +	case EXIT_REASON_SEAMCALL:
> > > +		kvm_queue_exception(vcpu, UD_VECTOR);
> > 
> > Emm, the host cannot inject exceptions to TDX guests. Right?
> 
> Right.

Oh, yeah, duh.

> I also tested in TD guest. Actually, the TDX module injects #UD to TD guest
> on SEAMCALL exit.
> 
> The behavior is documented in 11.7.1 "Unconditionally Blocked Instructions"
> of TDX module base spec:
> 
>   Instructions that causes a #UD Unconditionally
> 
>   - SEAMCALL, SEAMRET

Nice!  I'll add a WARN_ON_ONCE() if KVM sees a SEAMCALL TD-Exit.  The SEAMRET
documentation in the TDX-Module spec is amusing since the CPU is supposed to
generate a #UD for SEAMRET, i.e. it's not like the TDX-Module has any choice in
the matter :-)

Thanks!

  reply	other threads:[~2025-10-15 13:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 23:10 [PATCH] KVM: VMX: Inject #UD if guest tries to execute SEAMCALL or TDCALL Sean Christopherson
2025-10-15  0:22 ` dan.j.williams
2025-10-15 13:56   ` Sean Christopherson
2025-10-15 15:49     ` dan.j.williams
2025-10-15  1:13 ` Chao Gao
2025-10-15  3:11   ` Xiaoyao Li
2025-10-15 13:20     ` Sean Christopherson [this message]
2025-10-15 10:36 ` Xiaoyao Li
2025-10-15 13:57   ` Sean Christopherson
2025-10-15 14:45     ` Xiaoyao Li
2025-10-16 18:28       ` Sean Christopherson
2025-10-15 13:38 ` Binbin Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aO-fqYO_vmwtCn8l@google.com \
    --to=seanjc@google.com \
    --cc=chao.gao@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.