mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-26 12:34:41 +08:00
338068b5be
Drop "support" for multiple page-track modes, as there is no evidence that array-based and refcounted metadata is the optimal solution for other modes, nor is there any evidence that other use cases, e.g. for access-tracking, will be a good fit for the page-track machinery in general. E.g. one potential use case of access-tracking would be to prevent guest access to poisoned memory (from the guest's perspective). In that case, the number of poisoned pages is likely to be a very small percentage of the guest memory, and there is no need to reference count the number of access-tracking users, i.e. expanding gfn_track[] for a new mode would be grossly inefficient. And for poisoned memory, host userspace would also likely want to trap accesses, e.g. to inject #MC into the guest, and that isn't currently supported by the page-track framework. A better alternative for that poisoned page use case is likely a variation of the proposed per-gfn attributes overlay (linked), which would allow efficiently tracking the sparse set of poisoned pages, and by default would exit to userspace on access. Link: https://lore.kernel.org/all/Y2WB48kD0J4VGynX@google.com Cc: Ben Gardon <bgardon@google.com> Tested-by: Yongwei Ma <yongwei.ma@intel.com> Link: https://lore.kernel.org/r/20230729013535.1070024-24-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __KVM_X86_PAGE_TRACK_H
|
|
#define __KVM_X86_PAGE_TRACK_H
|
|
|
|
#include <linux/kvm_host.h>
|
|
|
|
#include <asm/kvm_page_track.h>
|
|
|
|
|
|
bool kvm_page_track_write_tracking_enabled(struct kvm *kvm);
|
|
int kvm_page_track_write_tracking_alloc(struct kvm_memory_slot *slot);
|
|
|
|
void kvm_page_track_free_memslot(struct kvm_memory_slot *slot);
|
|
int kvm_page_track_create_memslot(struct kvm *kvm,
|
|
struct kvm_memory_slot *slot,
|
|
unsigned long npages);
|
|
|
|
bool kvm_slot_page_track_is_active(struct kvm *kvm,
|
|
const struct kvm_memory_slot *slot, gfn_t gfn);
|
|
|
|
#ifdef CONFIG_KVM_EXTERNAL_WRITE_TRACKING
|
|
int kvm_page_track_init(struct kvm *kvm);
|
|
void kvm_page_track_cleanup(struct kvm *kvm);
|
|
|
|
void __kvm_page_track_write(struct kvm *kvm, gpa_t gpa, const u8 *new, int bytes);
|
|
void kvm_page_track_delete_slot(struct kvm *kvm, struct kvm_memory_slot *slot);
|
|
|
|
static inline bool kvm_page_track_has_external_user(struct kvm *kvm)
|
|
{
|
|
return !hlist_empty(&kvm->arch.track_notifier_head.track_notifier_list);
|
|
}
|
|
#else
|
|
static inline int kvm_page_track_init(struct kvm *kvm) { return 0; }
|
|
static inline void kvm_page_track_cleanup(struct kvm *kvm) { }
|
|
|
|
static inline void __kvm_page_track_write(struct kvm *kvm, gpa_t gpa,
|
|
const u8 *new, int bytes) { }
|
|
static inline void kvm_page_track_delete_slot(struct kvm *kvm,
|
|
struct kvm_memory_slot *slot) { }
|
|
|
|
static inline bool kvm_page_track_has_external_user(struct kvm *kvm) { return false; }
|
|
|
|
#endif /* CONFIG_KVM_EXTERNAL_WRITE_TRACKING */
|
|
|
|
static inline void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa,
|
|
const u8 *new, int bytes)
|
|
{
|
|
__kvm_page_track_write(vcpu->kvm, gpa, new, bytes);
|
|
|
|
kvm_mmu_track_write(vcpu, gpa, new, bytes);
|
|
}
|
|
|
|
#endif /* __KVM_X86_PAGE_TRACK_H */
|