• Yan Zhao's avatar
    KVM: x86: Add a new page-track hook to handle memslot deletion · b83ab124
    Yan Zhao authored
    Add a new page-track hook, track_remove_region(), that is called when a
    memslot DELETE operation is about to be committed.  The "remove" hook
    will be used by KVMGT and will effectively replace the existing
    track_flush_slot() altogether now that KVM itself doesn't rely on the
    "flush" hook either.
    
    The "flush" hook is flawed as it's invoked before the memslot operation
    is guaranteed to succeed, i.e. KVM might ultimately keep the existing
    memslot without notifying external page track users, a.k.a. KVMGT.  In
    practice, this can't currently happen on x86, but there are no guarantees
    that won't change in the future, not to mention that "flush" does a very
    poor job of describing what is happening.
    
    Pass in the gfn+nr_pages instead of the slot itself so external users,
    i.e. KVMGT, don't need to exposed to KVM internals (memslots).  This will
    help set the stage for additional cleanups to the page-track APIs.
    
    Opportunistically align the existing srcu_read_lock_held() usage so that
    the new case doesn't stand out like a sore thumb (and not aligning the
    new code makes bots unhappy).
    
    Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
    Tested-by: default avatarYongwei Ma <yongwei.ma@intel.com>
    Signed-off-by: default avatarYan Zhao <yan.y.zhao@intel.com>
    Co-developed-by: default avatarSean Christopherson <seanjc@google.com>
    Link: https://lore.kernel.org/r/20230729013535.1070024-19-seanjc@google.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    b83ab124
page_track.c 8.45 KB