1/* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License. 5 * 6 * This program is distributed in the hope that it will be useful, 7 * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License 12 * along with this program; if not, write to the Free Software 13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 * 15 */ 16 17#ifndef __KVM_TYPES_H__ 18#define __KVM_TYPES_H__ 19 20struct kvm; 21struct kvm_async_pf; 22struct kvm_device_ops; 23struct kvm_interrupt; 24struct kvm_irq_routing_table; 25struct kvm_memory_slot; 26struct kvm_one_reg; 27struct kvm_run; 28struct kvm_userspace_memory_region; 29struct kvm_vcpu; 30struct kvm_vcpu_init; 31struct kvm_memslots; 32 33enum kvm_mr_change; 34 35#include <linux/types.h> 36 37#include <asm/kvm_types.h> 38 39/* 40 * Address types: 41 * 42 * gva - guest virtual address 43 * gpa - guest physical address 44 * gfn - guest frame number 45 * hva - host virtual address 46 * hpa - host physical address 47 * hfn - host frame number 48 */ 49 50typedef unsigned long gva_t; 51typedef u64 gpa_t; 52typedef u64 gfn_t; 53 54#define GPA_INVALID (~(gpa_t)0) 55 56typedef unsigned long hva_t; 57typedef u64 hpa_t; 58typedef u64 hfn_t; 59 60typedef hfn_t kvm_pfn_t; 61 62struct gfn_to_hva_cache { 63 u64 generation; 64 gpa_t gpa; 65 unsigned long hva; 66 unsigned long len; 67 struct kvm_memory_slot *memslot; 68}; 69 70struct gfn_to_pfn_cache { 71 u64 generation; 72 gfn_t gfn; 73 kvm_pfn_t pfn; 74 bool dirty; 75}; 76 77#ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 78/* 79 * Memory caches are used to preallocate memory ahead of various MMU flows, 80 * e.g. page fault handlers. Gracefully handling allocation failures deep in 81 * MMU flows is problematic, as is triggering reclaim, I/O, etc... while 82 * holding MMU locks. Note, these caches act more like prefetch buffers than 83 * classical caches, i.e. objects are not returned to the cache on being freed. 84 */ 85struct kvm_mmu_memory_cache { 86 int nobjs; 87 gfp_t gfp_zero; 88 struct kmem_cache *kmem_cache; 89 void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE]; 90}; 91#endif 92 93 94#endif /* __KVM_TYPES_H__ */ 95