1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef __KVM_TYPES_H__
4 #define __KVM_TYPES_H__
10 struct kvm_irq_routing_table;
11 struct kvm_memory_slot;
14 struct kvm_userspace_memory_region;
21 #include <linux/bits.h>
22 #include <linux/types.h>
23 #include <linux/spinlock_types.h>
25 #include <asm/kvm_types.h>
30 * gva - guest virtual address
31 * gpa - guest physical address
32 * gfn - guest frame number
33 * hva - host virtual address
34 * hpa - host physical address
35 * hfn - host frame number
38 typedef unsigned long gva_t;
42 #define GPA_INVALID (~(gpa_t)0)
44 typedef unsigned long hva_t;
48 typedef hfn_t kvm_pfn_t;
50 enum pfn_cache_usage {
51 KVM_GUEST_USES_PFN = BIT(0),
52 KVM_HOST_USES_PFN = BIT(1),
53 KVM_GUEST_AND_HOST_USE_PFN = KVM_GUEST_USES_PFN | KVM_HOST_USES_PFN,
56 struct gfn_to_hva_cache {
61 struct kvm_memory_slot *memslot;
64 struct gfn_to_pfn_cache {
68 struct kvm_memory_slot *memslot;
69 struct kvm_vcpu *vcpu;
70 struct list_head list;
74 enum pfn_cache_usage usage;
79 #ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE
81 * Memory caches are used to preallocate memory ahead of various MMU flows,
82 * e.g. page fault handlers. Gracefully handling allocation failures deep in
83 * MMU flows is problematic, as is triggering reclaim, I/O, etc... while
84 * holding MMU locks. Note, these caches act more like prefetch buffers than
85 * classical caches, i.e. objects are not returned to the cache on being freed.
87 struct kvm_mmu_memory_cache {
90 struct kmem_cache *kmem_cache;
91 void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE];
95 #define HALT_POLL_HIST_COUNT 32
97 struct kvm_vm_stat_generic {
99 u64 remote_tlb_flush_requests;
102 struct kvm_vcpu_stat_generic {
103 u64 halt_successful_poll;
104 u64 halt_attempted_poll;
105 u64 halt_poll_invalid;
107 u64 halt_poll_success_ns;
108 u64 halt_poll_fail_ns;
110 u64 halt_poll_success_hist[HALT_POLL_HIST_COUNT];
111 u64 halt_poll_fail_hist[HALT_POLL_HIST_COUNT];
112 u64 halt_wait_hist[HALT_POLL_HIST_COUNT];
116 #define KVM_STATS_NAME_SIZE 48
118 #endif /* __KVM_TYPES_H__ */