public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Kevin Cheng <chengkev@google.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,  yosry.ahmed@linux.dev
Subject: Re: [PATCH V3 2/5] KVM: SVM: Inject #UD for STGI if EFER.SVME=0 and SVM Lock and DEV are not available
Date: Fri, 13 Feb 2026 07:06:41 -0800	[thread overview]
Message-ID: <aY8799P0Ui12R9IG@google.com> (raw)
In-Reply-To: <CAE6NW_afk_zv=-qtz13x6qEDiBanaZGEUou1G4euQpqwJS8DxQ@mail.gmail.com>

On Thu, Feb 12, 2026, Kevin Cheng wrote:
> On Thu, Feb 12, 2026 at 4:18 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Thu, Feb 12, 2026, Sean Christopherson wrote:
> > > On Thu, Jan 22, 2026, Kevin Cheng wrote:
> > > > The AMD APM states that STGI causes a #UD if SVM is not enabled and
> > > > neither SVM Lock nor the device exclusion vector (DEV) are supported.
> > > > Support for DEV is part of the SKINIT architecture. Fix the STGI exit
> > > > handler by injecting #UD when these conditions are met.
> > >
> > > This is entirely pointless.  SVML and SKINIT can never bet set in guest caps.
> > > There are many things that are documented in the SDM/APM that don't have "correct"
> > > handling in KVM, because they're completely unsupported.
> > >
> > > _If_ this is causing someone enough heartburn to want to "fix", just add a comment
> > > in nested_svm_check_permissions() stating that KVM doesn't support SVML or SKINIT.
> >
> > Case in point, patch 4 is flawed because it forces interception of STGI if
> > EFER.SVME=0.  I.e. by trying to handle the impossible, you're introducing new
> > and novel ways for KVM to do things "wrong".
> 
> Just to clarify, do you mean patch 4 is flawed with patch 2? Or is the
> forcing of STGI interception flawed regardless? I am assuming the
> former here

Yes, the former.  Checking only SVME here:

	if (guest_cpuid_is_intel_compatible(vcpu) || !(efer & EFER_SVME)) {
		svm_set_intercept(svm, INTERCEPT_CLGI);
		svm_set_intercept(svm, INTERCEPT_STGI);
		svm_set_intercept(svm, INTERCEPT_VMLOAD);
		svm_set_intercept(svm, INTERCEPT_VMSAVE);

is confusing, because KVM's logic for injecting the #UD would be:

	if (!(vcpu->arch.efer & EFER_SVME) &&
	    !guest_cpu_cap_has(vcpu, X86_FEATURE_SVML) &&
	    !guest_cpu_cap_has(vcpu, X86_FEATURE_SKINIT))
		<#ud>

which raises the question of why the interception code doesn't factor in SVML and
SKINIT.  "wrong" was in quotes, because there's no functional bug, but it's weird
and confusing because KVM is blatantly contradicting itself.

  reply	other threads:[~2026-02-13 15:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22  4:57 [PATCH V3 0/5] Align SVM with APM defined behaviors Kevin Cheng
2026-01-22  4:57 ` [PATCH V3 1/5] KVM: SVM: Move STGI and CLGI intercept handling Kevin Cheng
2026-01-22  4:57 ` [PATCH V3 2/5] KVM: SVM: Inject #UD for STGI if EFER.SVME=0 and SVM Lock and DEV are not available Kevin Cheng
2026-02-12 21:16   ` Sean Christopherson
2026-02-12 21:18     ` Sean Christopherson
2026-02-12 21:57       ` Kevin Cheng
2026-02-13 15:06         ` Sean Christopherson [this message]
2026-01-22  4:57 ` [PATCH V3 3/5] KVM: SVM: Inject #UD for INVLPGA if EFER.SVME=0 Kevin Cheng
2026-01-22  4:57 ` [PATCH V3 4/5] KVM: SVM: Recalc instructions intercepts when EFER.SVME is toggled Kevin Cheng
2026-01-22  4:57 ` [PATCH V3 5/5] KVM: SVM: Raise #UD if VMMCALL instruction is not intercepted Kevin Cheng

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=aY8799P0Ui12R9IG@google.com \
    --to=seanjc@google.com \
    --cc=chengkev@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yosry.ahmed@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox