kvm_types.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __KVM_TYPES_H__
  3. #define __KVM_TYPES_H__
  4. struct kvm;
  5. struct kvm_async_pf;
  6. struct kvm_device_ops;
  7. struct kvm_interrupt;
  8. struct kvm_irq_routing_table;
  9. struct kvm_memory_slot;
  10. struct kvm_one_reg;
  11. struct kvm_run;
  12. struct kvm_userspace_memory_region;
  13. struct kvm_vcpu;
  14. struct kvm_vcpu_init;
  15. struct kvm_memslots;
  16. enum kvm_mr_change;
  17. #include <linux/types.h>
  18. #include <asm/kvm_types.h>
  19. /*
  20. * Address types:
  21. *
  22. * gva - guest virtual address
  23. * gpa - guest physical address
  24. * gfn - guest frame number
  25. * hva - host virtual address
  26. * hpa - host physical address
  27. * hfn - host frame number
  28. */
  29. typedef unsigned long gva_t;
  30. typedef u64 gpa_t;
  31. typedef u64 gfn_t;
  32. #define GPA_INVALID (~(gpa_t)0)
  33. typedef unsigned long hva_t;
  34. typedef u64 hpa_t;
  35. typedef u64 hfn_t;
  36. typedef hfn_t kvm_pfn_t;
  37. struct gfn_to_hva_cache {
  38. u64 generation;
  39. gpa_t gpa;
  40. unsigned long hva;
  41. unsigned long len;
  42. struct kvm_memory_slot *memslot;
  43. };
  44. struct gfn_to_pfn_cache {
  45. u64 generation;
  46. gfn_t gfn;
  47. kvm_pfn_t pfn;
  48. bool dirty;
  49. };
  50. #ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE
  51. /*
  52. * Memory caches are used to preallocate memory ahead of various MMU flows,
  53. * e.g. page fault handlers. Gracefully handling allocation failures deep in
  54. * MMU flows is problematic, as is triggering reclaim, I/O, etc... while
  55. * holding MMU locks. Note, these caches act more like prefetch buffers than
  56. * classical caches, i.e. objects are not returned to the cache on being freed.
  57. */
  58. struct kvm_mmu_memory_cache {
  59. int nobjs;
  60. gfp_t gfp_zero;
  61. struct kmem_cache *kmem_cache;
  62. void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE];
  63. };
  64. #endif
  65. #endif /* __KVM_TYPES_H__ */