• Sean Christopherson's avatar
    KVM: x86: Read and pass all CR0/CR4 role bits to shadow MMU helper · 20f632bd
    Sean Christopherson authored
    Grab all CR0/CR4 MMU role bits from current vCPU state when initializing
    a non-nested shadow MMU.  Extract the masks from kvm_post_set_cr{0,4}(),
    as the CR0/CR4 update masks must exactly match the mmu_role bits, with
    one exception (see below).  The "full" CR0/CR4 will be used by future
    commits to initialize the MMU and its role, as opposed to the current
    approach of pulling everything from vCPU, which is incorrect for certain
    flows, e.g. nested NPT.
    
    CR4.LA57 is an exception, as it can be toggled on VM-Exit (for L1's MMU)
    but can't be toggled via MOV CR4 while long mode is active.  I.e. LA57
    needs to be in the mmu_role, but technically doesn't need to be checked
    by kvm_post_set_cr4().  However, the extra check is completely benign as
    the hardware restrictions simply mean LA57 will never be _the_ cause of
    a MMU reset during MOV CR4.
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20210622175739.3610207-18-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    20f632bd
x86.c 321 KB