Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: nVMX: Do not set identity page map for L2

Fiddling with CR3 for L2 is L1's job. It may set its own, different
identity map or simple leave it alone if unrestricted guest mode is
enabled. This also fixes reading back the current CR3 on L2 exits for
reporting it to L1.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Jan Kiszka and committed by
Paolo Bonzini
59ab5a8f 9e3e4dbf

+4 -2
+4 -2
arch/x86/kvm/vmx.c
··· 3376 3376 if (enable_ept) { 3377 3377 eptp = construct_eptp(cr3); 3378 3378 vmcs_write64(EPT_POINTER, eptp); 3379 - guest_cr3 = is_paging(vcpu) ? kvm_read_cr3(vcpu) : 3380 - vcpu->kvm->arch.ept_identity_map_addr; 3379 + if (is_paging(vcpu) || is_guest_mode(vcpu)) 3380 + guest_cr3 = kvm_read_cr3(vcpu); 3381 + else 3382 + guest_cr3 = vcpu->kvm->arch.ept_identity_map_addr; 3381 3383 ept_load_pdptrs(vcpu); 3382 3384 } 3383 3385