Skip to content

Commit 0790ec1

Browse files
rkrcmarmatosatti
authored andcommitted
KVM: nVMX: mask unrestricted_guest if disabled on L0
If EPT was enabled, unrestricted_guest was allowed in L1 regardless of L0. L1 triple faulted when running L2 guest that required emulation. Another side effect was 'WARN_ON_ONCE(vmx->nested.nested_run_pending)' in L0's dmesg: WARNING: CPU: 0 PID: 0 at arch/x86/kvm/vmx.c:9190 nested_vmx_vmexit+0x96e/0xb00 [kvm_intel] () Prevent this scenario by masking SECONDARY_EXEC_UNRESTRICTED_GUEST when the host doesn't have it enabled. Fixes: 78051e3 ("KVM: nVMX: Disable unrestricted mode if ept=0") Cc: stable@vger.kernel.org Tested-By: Kashyap Chamarthy <kchamart@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
1 parent c586165 commit 0790ec1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,8 +2479,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
24792479
if (enable_ept) {
24802480
/* nested EPT: emulate EPT also to L1 */
24812481
vmx->nested.nested_vmx_secondary_ctls_high |=
2482-
SECONDARY_EXEC_ENABLE_EPT |
2483-
SECONDARY_EXEC_UNRESTRICTED_GUEST;
2482+
SECONDARY_EXEC_ENABLE_EPT;
24842483
vmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT |
24852484
VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT |
24862485
VMX_EPT_INVEPT_BIT;
@@ -2494,6 +2493,10 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
24942493
} else
24952494
vmx->nested.nested_vmx_ept_caps = 0;
24962495

2496+
if (enable_unrestricted_guest)
2497+
vmx->nested.nested_vmx_secondary_ctls_high |=
2498+
SECONDARY_EXEC_UNRESTRICTED_GUEST;
2499+
24972500
/* miscellaneous data */
24982501
rdmsr(MSR_IA32_VMX_MISC,
24992502
vmx->nested.nested_vmx_misc_low,

0 commit comments

Comments
 (0)