x86/kvm/mmu: reset MMU context when 32-bit guest switches PAE
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 30 Apr 2019 17:33:26 +0000 (19:33 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 30 Apr 2019 19:03:58 +0000 (21:03 +0200)
Commit 47c42e6b4192 ("KVM: x86: fix handling of role.cr4_pae and rename it
to 'gpte_size'") introduced a regression: 32-bit PAE guests stopped
working. The issue appears to be: when guest switches (enables) PAE we need
to re-initialize MMU context (set context->root_level, do
reset_rsvds_bits_mask(), ...) but init_kvm_tdp_mmu() doesn't do that
because we threw away is_pae(vcpu) flag from mmu role. Restore it to
kvm_mmu_extended_role (as we now don't need it in base role) to fix
the issue.

Fixes: 47c42e6b4192 ("KVM: x86: fix handling of role.cr4_pae and rename it to 'gpte_size'")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c

index a9d03af340307db6589376cf3bfb29a533910cdd..c79abe7ca093cf3c81f4de1938066426c8984f04 100644 (file)
@@ -295,6 +295,7 @@ union kvm_mmu_extended_role {
                unsigned int valid:1;
                unsigned int execonly:1;
                unsigned int cr0_pg:1;
+               unsigned int cr4_pae:1;
                unsigned int cr4_pse:1;
                unsigned int cr4_pke:1;
                unsigned int cr4_smap:1;
index e10962dfc2032d982f124070b88f7d625d2b8f0b..d9c7b45d231f1582becb071ae6355fc7c63bc79c 100644 (file)
@@ -4781,6 +4781,7 @@ static union kvm_mmu_extended_role kvm_calc_mmu_role_ext(struct kvm_vcpu *vcpu)
        union kvm_mmu_extended_role ext = {0};
 
        ext.cr0_pg = !!is_paging(vcpu);
+       ext.cr4_pae = !!is_pae(vcpu);
        ext.cr4_smep = !!kvm_read_cr4_bits(vcpu, X86_CR4_SMEP);
        ext.cr4_smap = !!kvm_read_cr4_bits(vcpu, X86_CR4_SMAP);
        ext.cr4_pse = !!is_pse(vcpu);