Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH] KVM: VMX: Disallow 16-bit busy TSS (type 3) for TR in IA-32e mode
@ 2026-11-16  7:08 zhangdaolong
  2026-11-16  7:29 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: zhangdaolong @ 2026-11-16  7:08 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, zhangdaolong

According to Intel SDM Vol. 3C, "Checks on Guest Segment Registers", the
TR segment type must be 11 (64-bit busy TSS) when the "IA-32e mode guest"
VM-entry control is 1, and may be 3 (16-bit busy TSS) or 11 (32-bit busy
TSS) only when "IA-32e mode guest" is 0.

Currently, tr_valid() unconditionally allows type 3 even when the guest is
in IA-32e mode (long mode). When emulate_invalid_guest_state is enabled,
this causes __vmx_guest_state_valid() to falsely report a valid guest state
for a 64-bit guest with a 16-bit busy TSS, resulting in a hardware VM-Entry
failure (EXIT_REASON_INVALID_STATE / KVM_EXIT_FAIL_ENTRY) instead of
emulating the invalid guest state.

Check is_long_mode(vcpu) in tr_valid() and reject type 3 when the vCPU is
in IA-32e mode.

Fixes: 648dfaa7df2d ("KVM: VMX: Add Guest State Validity Checks")
Signed-off-by: zhangdaolong <dlzhangak@isoftstone.com>
---
 arch/x86/kvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index cc75feec05da..2a5db87fae0e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -3898,7 +3898,7 @@ static bool tr_valid(struct kvm_vcpu *vcpu)
 		return false;
 	if (tr.selector & SEGMENT_TI_MASK)	/* TI = 1 */
 		return false;
-	if (tr.type != 3 && tr.type != 11) /* TODO: Check if guest is in IA32e mode */
+	if (tr.type != 11 && (is_long_mode(vcpu) || tr.type != 3))
 		return false;
 	if (!tr.present)
 		return false;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-16  7:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16  7:08 [PATCH] KVM: VMX: Disallow 16-bit busy TSS (type 3) for TR in IA-32e mode zhangdaolong
2026-11-16  7:29 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox