From: Zihui Guo <youzih27@gmail.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Chao Gao <chao.gao@intel.com>,
Binbin Wu <binbin.wu@linux.intel.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] KVM: nVMX: Reject nested VM-Enter to HLT with a non-zero SS.DPL
Date: Thu, 3 Dec 2026 05:34:47 +0000 [thread overview]
Message-ID: <20261203053449.25917-3-youzih27@gmail.com> (raw)
In-Reply-To: <20261203053449.25917-1-youzih27@gmail.com>
SDM Vol. 3C 29.3.1.5: "The activity-state field must not indicate the
HLT state if the DPL (bits 6:5) in the access-rights field for SS is not
0."
nested_check_guest_non_reg_state() only checks the range of the
activity state. The hardware cannot catch this either, because KVM
emulates the HLT state of L2 and never loads vmcs12's activity state
into vmcs02, so L1 gets a successful VM-Enter where the architecture
requires a VM-Entry failure due to invalid guest state.
Fixes: 6dfacadd5858 ("KVM: nVMX: Add support for activity state HLT")
Signed-off-by: Zihui Guo <youzih27@gmail.com>
---
arch/x86/kvm/vmx/nested.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 92397516885d..82618f74d4ad 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -3288,6 +3288,10 @@ 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_HLT &&
+ VMX_AR_DPL(vmcs12->guest_ss_ar_bytes) != 0))
+ return -EINVAL;
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-12-03 5:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 5:34 [PATCH 0/3] KVM: nVMX: Add missing guest-state checks on nested VM-Enter Zihui Guo
2026-12-03 5:34 ` [PATCH 1/3] KVM: nVMX: Check that the guest's IA32_S_CET is canonical on VM-Enter Zihui Guo
2026-12-03 5:34 ` Zihui Guo [this message]
2026-12-03 5:34 ` [PATCH 3/3] KVM: nVMX: Check the event injected into the HLT state on nested VM-Enter Zihui Guo
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=20261203053449.25917-3-youzih27@gmail.com \
--to=youzih27@gmail.com \
--cc=binbin.wu@linux.intel.com \
--cc=chao.gao@intel.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®