mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <amirmohammad.eftekhar@cispa.de>
To: <seanjc@google.com>, <pbonzini@redhat.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<amirmohammadeftekhar@gmail.com>,
	Amirmohammad Eftekhar <amirmohammad.eftekhar@cispa.de>
Subject: [PATCH v3 1/2] KVM: nVMX: Reject nested VM-entry in a non-active state blocked by STI/MOV-SS
Date: Thu, 22 Oct 2026 23:51:45 +0200	[thread overview]
Message-ID: <20261022215146.233479-2-amirmohammad.eftekhar@cispa.de> (raw)
In-Reply-To: <atqDVkHjdJ2iF9Uv@google.com>

From: Amirmohammad Eftekhar <amirmohammad.eftekhar@cispa.de>

nested_check_guest_non_reg_state() only checks that guest_activity_state is
one of ACTIVE/HLT/WAIT_SIPI; it does not enforce the SDM's requirement that
the activity state indicate the active state when the interruptibility-state
field blocks by STI or MOV SS.  KVM cannot rely on hardware to catch the
miss: prepare_vmcs02() never writes GUEST_ACTIVITY_STATE, so vmcs02 always
carries the active state and the physical VMLAUNCH cannot reject the illegal
combination.  Add the cross-check.

Signed-off-by: Amirmohammad Eftekhar <amirmohammad.eftekhar@cispa.de>
---
 arch/x86/kvm/vmx/nested.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index b25216862740..6e2ec1912f12 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -3311,6 +3311,11 @@ static int nested_check_guest_non_reg_state(struct vmcs12 *vmcs12)
 	       vmcs12->guest_activity_state != GUEST_ACTIVITY_WAIT_SIPI))
 		return -EINVAL;
 
+	if (CC(vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE &&
+	       (vmcs12->guest_interruptibility_info &
+		(GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS))))
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
2.34.1


  parent reply	other threads:[~2026-10-22 21:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 21:12 [PATCH] KVM: nVMX: Reject nested VM-entry in wait-for-SIPI with a pending event injection Amirmohammad Eftekhar
2026-10-22 21:42 ` Sean Christopherson
2026-10-22 21:51   ` [PATCH v3 0/2] KVM: nVMX: Add the activity-state cross-checks VM-entry requires amirmohammad.eftekhar
2026-10-22 21:51   ` amirmohammad.eftekhar [this message]
2026-10-22 21:51   ` [PATCH v3 2/2] KVM: nVMX: Reject nested VM-entry in wait-for-SIPI with a pending event injection amirmohammad.eftekhar

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=20261022215146.233479-2-amirmohammad.eftekhar@cispa.de \
    --to=amirmohammad.eftekhar@cispa.de \
    --cc=amirmohammadeftekhar@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®