at v5.16 2.1 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3#ifndef __KVM_TYPES_H__ 4#define __KVM_TYPES_H__ 5 6struct kvm; 7struct kvm_async_pf; 8struct kvm_device_ops; 9struct kvm_interrupt; 10struct kvm_irq_routing_table; 11struct kvm_memory_slot; 12struct kvm_one_reg; 13struct kvm_run; 14struct kvm_userspace_memory_region; 15struct kvm_vcpu; 16struct kvm_vcpu_init; 17struct kvm_memslots; 18 19enum kvm_mr_change; 20 21#include <linux/types.h> 22 23#include <asm/kvm_types.h> 24 25/* 26 * Address types: 27 * 28 * gva - guest virtual address 29 * gpa - guest physical address 30 * gfn - guest frame number 31 * hva - host virtual address 32 * hpa - host physical address 33 * hfn - host frame number 34 */ 35 36typedef unsigned long gva_t; 37typedef u64 gpa_t; 38typedef u64 gfn_t; 39 40#define GPA_INVALID (~(gpa_t)0) 41 42typedef unsigned long hva_t; 43typedef u64 hpa_t; 44typedef u64 hfn_t; 45 46typedef hfn_t kvm_pfn_t; 47 48struct gfn_to_hva_cache { 49 u64 generation; 50 gpa_t gpa; 51 unsigned long hva; 52 unsigned long len; 53 struct kvm_memory_slot *memslot; 54}; 55 56#ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 57/* 58 * Memory caches are used to preallocate memory ahead of various MMU flows, 59 * e.g. page fault handlers. Gracefully handling allocation failures deep in 60 * MMU flows is problematic, as is triggering reclaim, I/O, etc... while 61 * holding MMU locks. Note, these caches act more like prefetch buffers than 62 * classical caches, i.e. objects are not returned to the cache on being freed. 63 */ 64struct kvm_mmu_memory_cache { 65 int nobjs; 66 gfp_t gfp_zero; 67 struct kmem_cache *kmem_cache; 68 void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE]; 69}; 70#endif 71 72#define HALT_POLL_HIST_COUNT 32 73 74struct kvm_vm_stat_generic { 75 u64 remote_tlb_flush; 76 u64 remote_tlb_flush_requests; 77}; 78 79struct kvm_vcpu_stat_generic { 80 u64 halt_successful_poll; 81 u64 halt_attempted_poll; 82 u64 halt_poll_invalid; 83 u64 halt_wakeup; 84 u64 halt_poll_success_ns; 85 u64 halt_poll_fail_ns; 86 u64 halt_wait_ns; 87 u64 halt_poll_success_hist[HALT_POLL_HIST_COUNT]; 88 u64 halt_poll_fail_hist[HALT_POLL_HIST_COUNT]; 89 u64 halt_wait_hist[HALT_POLL_HIST_COUNT]; 90}; 91 92#define KVM_STATS_NAME_SIZE 48 93 94#endif /* __KVM_TYPES_H__ */