• Lai Jiangshan's avatar
    KVM: x86/mmu: Remove FNAME(invlpg) and use FNAME(sync_spte) to update vTLB instead. · 9fd4a4e3
    Lai Jiangshan authored
    In hardware TLB, invalidating TLB entries means the translations are
    removed from the TLB.
    
    In KVM shadowed vTLB, the translations (combinations of shadow paging
    and hardware TLB) are generally maintained as long as they remain "clean"
    when the TLB of an address space (i.e. a PCID or all) is flushed with
    the help of write-protections, sp->unsync, and kvm_sync_page(), where
    "clean" in this context means that no updates to KVM's SPTEs are needed.
    
    However, FNAME(invlpg) always zaps/removes the vTLB if the shadow page is
    unsync, and thus triggers a remote flush even if the original vTLB entry
    is clean, i.e. is usable as-is.
    
    Besides this, FNAME(invlpg) is largely is a duplicate implementation of
    FNAME(sync_spte) to invalidate a vTLB entry.
    
    To address both issues, reuse FNAME(sync_spte) to share the code and
    slightly modify the semantics, i.e. keep the vTLB entry if it's "clean"
    and avoid remote TLB flush.
    Signed-off-by: default avatarLai Jiangshan <jiangshan.ljs@antgroup.com>
    Link: https://lore.kernel.org/r/20230216235321.735214-3-jiangshanlai@gmail.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
    9fd4a4e3
paging_tmpl.h 27.7 KB