• Junaid Shahid's avatar
    kvm: x86: Add fast CR3 switch code path · 7c390d35
    Junaid Shahid authored
    When using shadow paging, a CR3 switch in the guest results in a VM Exit.
    In the common case, that VM exit doesn't require much processing by KVM.
    However, it does acquire the MMU lock, which can start showing signs of
    contention under some workloads even on a 2 VCPU VM when the guest is
    using KPTI. Therefore, we add a fast path that avoids acquiring the MMU
    lock in the most common cases e.g. when switching back and forth between
    the kernel and user mode CR3s used by KPTI with no guest page table
    changes in between.
    
    For now, this fast path is implemented only for 64-bit guests and hosts
    to avoid the handling of PDPTEs, but it can be extended later to 32-bit
    guests and/or hosts as well.
    Signed-off-by: default avatarJunaid Shahid <junaids@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    7c390d35
x86.c 244 KB