[PATCH] KVM: VMX: Disallow 16-bit busy TSS (type 3) for TR in IA-32e mode

From: zhangdaolong

Date: Mon Nov 16 2026 - 02:08:33 EST


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@xxxxxxxxxxxxxx>
---
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