aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm_host.h
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-03-03 15:41:11 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2022-04-02 05:34:41 -0400
commitd0d96121d03d6d9cf608d948247a9f24f5a02da9 (patch)
tree769ad25f70e79433c9a41cf71194cc7b102831e2 /include/linux/kvm_host.h
parentKVM: SVM: Fix kvm_cache_regs.h inclusions for is_guest_mode() (diff)
downloadlinux-dev-d0d96121d03d6d9cf608d948247a9f24f5a02da9.tar.xz
linux-dev-d0d96121d03d6d9cf608d948247a9f24f5a02da9.zip
KVM: Use enum to track if cached PFN will be used in guest and/or host
Replace the guest_uses_pa and kernel_map booleans in the PFN cache code with a unified enum/bitmask. Using explicit names makes it easier to review and audit call sites. Opportunistically add a WARN to prevent passing garbage; instantating a cache without declaring its usage is either buggy or pointless. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20220303154127.202856-2-dwmw2@infradead.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r--include/linux/kvm_host.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 678fd7914521..be9bbc0c6200 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1231,11 +1231,12 @@ void kvm_vcpu_mark_page_dirty(struct kvm_vcpu *vcpu, gfn_t gfn);
* @gpc: struct gfn_to_pfn_cache object.
* @vcpu: vCPU to be used for marking pages dirty and to be woken on
* invalidation.
- * @guest_uses_pa: indicates that the resulting host physical PFN is used while
- * @vcpu is IN_GUEST_MODE; invalidations of the cache from MMU
- * notifiers (but not for KVM memslot changes!) will also force
- * @vcpu to exit the guest to refresh the cache.
- * @kernel_map: requests a kernel virtual mapping (kmap / memremap).
+ * @usage: indicates if the resulting host physical PFN is used while
+ * the @vcpu is IN_GUEST_MODE (in which case invalidation of
+ * the cache from MMU notifiers---but not for KVM memslot
+ * changes!---will also force @vcpu to exit the guest and
+ * refresh the cache); and/or if the PFN used directly
+ * by KVM (and thus needs a kernel virtual mapping).
* @gpa: guest physical address to map.
* @len: sanity check; the range being access must fit a single page.
* @dirty: mark the cache dirty immediately.
@@ -1250,9 +1251,8 @@ void kvm_vcpu_mark_page_dirty(struct kvm_vcpu *vcpu, gfn_t gfn);
* accessing the target page.
*/
int kvm_gfn_to_pfn_cache_init(struct kvm *kvm, struct gfn_to_pfn_cache *gpc,
- struct kvm_vcpu *vcpu, bool guest_uses_pa,
- bool kernel_map, gpa_t gpa, unsigned long len,
- bool dirty);
+ struct kvm_vcpu *vcpu, enum pfn_cache_usage usage,
+ gpa_t gpa, unsigned long len, bool dirty);
/**
* kvm_gfn_to_pfn_cache_check - check validity of a gfn_to_pfn_cache.