Skip to content

Commit d74fcfc

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86: Inject #GP if guest attempts to toggle CR4.LA57 in 64-bit mode
Inject a #GP on MOV CR4 if CR4.LA57 is toggled in 64-bit mode, which is illegal per Intel's SDM: CR4.LA57 57-bit linear addresses (bit 12 of CR4) ... blah blah blah ... This bit cannot be modified in IA-32e mode. Note, the pseudocode for MOV CR doesn't call out the fault condition, which is likely why the check was missed during initial development. This is arguably an SDM bug and will hopefully be fixed in future release of the SDM. Fixes: fd8cb43 ("KVM: MMU: Expose the LA57 feature to VM.") Cc: [email protected] Reported-by: Sebastien Boeuf <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 1393b4a commit d74fcfc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/x86/kvm/x86.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
975975
if (is_long_mode(vcpu)) {
976976
if (!(cr4 & X86_CR4_PAE))
977977
return 1;
978+
if ((cr4 ^ old_cr4) & X86_CR4_LA57)
979+
return 1;
978980
} else if (is_paging(vcpu) && (cr4 & X86_CR4_PAE)
979981
&& ((cr4 ^ old_cr4) & pdptr_bits)
980982
&& !load_pdptrs(vcpu, vcpu->arch.walk_mmu,

0 commit comments

Comments
 (0)