Move x86's 'struct kvm_mmu_memory_cache' to common code in anticipation of moving the entire x86 implementation code to common KVM and reusing it for arm64 and MIPS. Add a new architecture specific asm/kvm_types.h to control the existence and parameters of the struct. The new header is needed to avoid a chicken-and-egg problem with asm/kvm_host.h as all architectures define instances of the struct in their vCPU structs. Add an asm-generic version of kvm_types.h to avoid having empty files on PPC and s390 in the long term, and for arm64 and mips in the short term.
Showing the changes to include/linux (1 of 8 files). Show all
Unified · Split
| @@ -20,6 +20,8 @@ enum kvm_mr_change; · 19 unmodified lines | |||
| 20 | 20 | ||
| 21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| 22 | 22 | ||
| 23 | #include <asm/kvm_types.h> | ||
| 24 | |||
| 23 | /* | 25 | /* |
| 24 | * Address types: | 26 | * Address types: |
| 25 | * | 27 | * |
| @@ -58,4 +60,21 @@ struct gfn_to_pfn_cache { · 32 unmodified lines | |||
| 58 | bool dirty; | 60 | bool dirty; |
| 59 | }; | 61 | }; |
| 60 | 62 | ||
| 63 | #ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE | ||
| 64 | /* | ||
| 65 | * Memory caches are used to preallocate memory ahead of various MMU flows, | ||
| 66 | * e.g. page fault handlers. Gracefully handling allocation failures deep in | ||
| 67 | * MMU flows is problematic, as is triggering reclaim, I/O, etc... while | ||
| 68 | * holding MMU locks. Note, these caches act more like prefetch buffers than | ||
| 69 | * classical caches, i.e. objects are not returned to the cache on being freed. | ||
| 70 | */ | ||
| 71 | struct kvm_mmu_memory_cache { | ||
| 72 | int nobjs; | ||
| 73 | gfp_t gfp_zero; | ||
| 74 | struct kmem_cache *kmem_cache; | ||
| 75 | void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE]; | ||
| 76 | }; | ||
| 77 | #endif | ||
| 78 | |||
| 79 | |||
| 61 | #endif /* __KVM_TYPES_H__ */ | 80 | #endif /* __KVM_TYPES_H__ */ |