[Intel-gfx] [PATCH v2 20/27] KVM: x86/mmu: Use page-track notifiers iff there are external users
Yan Zhao
yan.y.zhao at intel.com
Wed Mar 15 10:36:08 UTC 2023
On Fri, Mar 10, 2023 at 04:22:51PM -0800, Sean Christopherson wrote:
> Disable the page-track notifier code at compile time if there are no
> external users, i.e. if CONFIG_KVM_EXTERNAL_WRITE_TRACKING=n. KVM itself
> now hooks emulated writes directly instead of relying on the page-track
> mechanism.
>
> Signed-off-by: Sean Christopherson <seanjc at google.com>
> ---
> arch/x86/include/asm/kvm_host.h | 2 ++
> arch/x86/include/asm/kvm_page_track.h | 2 ++
> arch/x86/kvm/mmu/page_track.c | 9 ++++-----
> arch/x86/kvm/mmu/page_track.h | 29 +++++++++++++++++++++++----
> 4 files changed, 33 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 1a4225237564..a3423711e403 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1265,7 +1265,9 @@ struct kvm_arch {
> * create an NX huge page (without hanging the guest).
> */
> struct list_head possible_nx_huge_pages;
> +#ifdef CONFIG_KVM_EXTERNAL_WRITE_TRACKING
> struct kvm_page_track_notifier_head track_notifier_head;
> +#endif
> /*
> * Protects marking pages unsync during page faults, as TDP MMU page
> * faults only take mmu_lock for read. For simplicity, the unsync
> diff --git a/arch/x86/include/asm/kvm_page_track.h b/arch/x86/include/asm/kvm_page_track.h
> index deece45936a5..53c2adb25a07 100644
> --- a/arch/x86/include/asm/kvm_page_track.h
> +++ b/arch/x86/include/asm/kvm_page_track.h
The "#ifdef CONFIG_KVM_EXTERNAL_WRITE_TRACKING" can be moved to the
front of this file?
All the structures are only exposed for external users now.
> @@ -55,6 +55,7 @@ void kvm_slot_page_track_remove_page(struct kvm *kvm,
> struct kvm_memory_slot *slot, gfn_t gfn,
> enum kvm_page_track_mode mode);
>
> +#ifdef CONFIG_KVM_EXTERNAL_WRITE_TRACKING
> enum pg_level kvm_page_track_max_mapping_level(struct kvm *kvm, gfn_t gfn,
> enum pg_level max_level);
>
> @@ -64,5 +65,6 @@ kvm_page_track_register_notifier(struct kvm *kvm,
> void
> kvm_page_track_unregister_notifier(struct kvm *kvm,
> struct kvm_page_track_notifier_node *n);
> +#endif /* CONFIG_KVM_EXTERNAL_WRITE_TRACKING */
>
> #endif
More information about the Intel-gfx
mailing list