definitionOfLeakageHazard.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * kvm_host.h: used for kvm module, and hold ia64-specific sections.
  3. *
  4. * Copyright (C) 2007, Intel Corporation.
  5. *
  6. * Xiantao Zhang <xiantao.zhang@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  19. * Place - Suite 330, Boston, MA 02111-1307 USA.
  20. *
  21. */
  22. #ifndef __ASM_KVM_HOST_H
  23. #define __ASM_KVM_HOST_H
  24. #define KVM_MEMORY_SLOTS 32
  25. /* memory slots that does not exposed to userspace */
  26. #define KVM_PRIVATE_MEM_SLOTS 4
  27. #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
  28. /* define exit reasons from vmm to kvm*/
  29. #define EXIT_REASON_VM_PANIC 0
  30. #define EXIT_REASON_MMIO_INSTRUCTION 1
  31. #define EXIT_REASON_PAL_CALL 2
  32. #define EXIT_REASON_SAL_CALL 3
  33. #define EXIT_REASON_SWITCH_RR6 4
  34. #define EXIT_REASON_VM_DESTROY 5
  35. #define EXIT_REASON_EXTERNAL_INTERRUPT 6
  36. #define EXIT_REASON_IPI 7
  37. #define EXIT_REASON_PTC_G 8
  38. #define EXIT_REASON_DEBUG 20
  39. /*Define vmm address space and vm data space.*/
  40. #define KVM_VMM_SIZE (__IA64_UL_CONST(16)<<20)
  41. #define KVM_VMM_SHIFT 24
  42. #define KVM_VMM_BASE 0xD000000000000000
  43. #define VMM_SIZE (__IA64_UL_CONST(8)<<20)
  44. /*
  45. * Define vm_buffer, used by PAL Services, base address.
  46. * Note: vm_buffer is in the VMM-BLOCK, the size must be < 8M
  47. */
  48. #define KVM_VM_BUFFER_BASE (KVM_VMM_BASE + VMM_SIZE)
  49. #define KVM_VM_BUFFER_SIZE (__IA64_UL_CONST(8)<<20)
  50. /*
  51. * kvm guest's data area looks as follow:
  52. *
  53. * +----------------------+ ------- KVM_VM_DATA_SIZE
  54. * | vcpu[n]'s data | | ___________________KVM_STK_OFFSET
  55. * | | | / |
  56. * | .......... | | /vcpu's struct&stack |
  57. * | .......... | | /---------------------|---- 0
  58. * | vcpu[5]'s data | | / vpd |
  59. * | vcpu[4]'s data | |/-----------------------|
  60. * | vcpu[3]'s data | / vtlb |
  61. * | vcpu[2]'s data | /|------------------------|
  62. * | vcpu[1]'s data |/ | vhpt |
  63. * | vcpu[0]'s data |____________________________|
  64. * +----------------------+ |
  65. * | memory dirty log | |
  66. * +----------------------+ |
  67. * | vm's data struct | |
  68. * +----------------------+ |
  69. * | | |
  70. * | | |
  71. * | | |
  72. * | | |
  73. * | | |
  74. * | | |
  75. * | | |
  76. * | vm's p2m table | |
  77. * | | |
  78. * | | |
  79. * | | | |
  80. * vm's data->| | | |
  81. * +----------------------+ ------- 0
  82. * To support large memory, needs to increase the size of p2m.
  83. * To support more vcpus, needs to ensure it has enough space to
  84. * hold vcpus' data.
  85. */
  86. #define KVM_VM_DATA_SHIFT 26
  87. #define KVM_VM_DATA_SIZE (__IA64_UL_CONST(1) << KVM_VM_DATA_SHIFT)
  88. #define KVM_VM_DATA_BASE (KVM_VMM_BASE + KVM_VM_DATA_SIZE)
  89. #define KVM_P2M_BASE KVM_VM_DATA_BASE
  90. #define KVM_P2M_SIZE (__IA64_UL_CONST(24) << 20)
  91. #define VHPT_SHIFT 16
  92. #define VHPT_SIZE (__IA64_UL_CONST(1) << VHPT_SHIFT)
  93. #define VHPT_NUM_ENTRIES (__IA64_UL_CONST(1) << (VHPT_SHIFT-5))
  94. #define VTLB_SHIFT 16
  95. #define VTLB_SIZE (__IA64_UL_CONST(1) << VTLB_SHIFT)
  96. #define VTLB_NUM_ENTRIES (1UL << (VHPT_SHIFT-5))
  97. #define VPD_SHIFT 16
  98. #define VPD_SIZE (__IA64_UL_CONST(1) << VPD_SHIFT)
  99. #define VCPU_STRUCT_SHIFT 16
  100. #define VCPU_STRUCT_SIZE (__IA64_UL_CONST(1) << VCPU_STRUCT_SHIFT)
  101. /*
  102. * This must match KVM_IA64_VCPU_STACK_{SHIFT,SIZE} arch/ia64/include/asm/kvm.h
  103. */
  104. #define KVM_STK_SHIFT 16
  105. #define KVM_STK_OFFSET (__IA64_UL_CONST(1)<< KVM_STK_SHIFT)
  106. #define KVM_VM_STRUCT_SHIFT 19
  107. #define KVM_VM_STRUCT_SIZE (__IA64_UL_CONST(1) << KVM_VM_STRUCT_SHIFT)
  108. #define KVM_MEM_DIRY_LOG_SHIFT 19
  109. #define KVM_MEM_DIRTY_LOG_SIZE (__IA64_UL_CONST(1) << KVM_MEM_DIRY_LOG_SHIFT)
  110. #ifndef __ASSEMBLY__
  111. /*Define the max vcpus and memory for Guests.*/
  112. #define KVM_MAX_VCPUS (KVM_VM_DATA_SIZE - KVM_P2M_SIZE - KVM_VM_STRUCT_SIZE -\
  113. KVM_MEM_DIRTY_LOG_SIZE) / sizeof(struct kvm_vcpu_data)
  114. #define KVM_MAX_MEM_SIZE (KVM_P2M_SIZE >> 3 << PAGE_SHIFT)
  115. #define VMM_LOG_LEN 256
  116. #include <linux/types.h>
  117. #include <linux/mm.h>
  118. #include <linux/kvm.h>
  119. #include <linux/kvm_para.h>
  120. #include <linux/kvm_types.h>
  121. #include <asm/pal.h>
  122. #include <asm/sal.h>
  123. #include <asm/page.h>
  124. struct kvm_vcpu_data {
  125. char vcpu_vhpt[VHPT_SIZE];
  126. char vcpu_vtlb[VTLB_SIZE];
  127. char vcpu_vpd[VPD_SIZE];
  128. char vcpu_struct[VCPU_STRUCT_SIZE];
  129. };
  130. struct kvm_vm_data {
  131. char kvm_p2m[KVM_P2M_SIZE];
  132. char kvm_vm_struct[KVM_VM_STRUCT_SIZE];
  133. char kvm_mem_dirty_log[KVM_MEM_DIRTY_LOG_SIZE];
  134. struct kvm_vcpu_data vcpu_data[KVM_MAX_VCPUS];
  135. };
  136. #define VCPU_BASE(n) (KVM_VM_DATA_BASE + \
  137. offsetof(struct kvm_vm_data, vcpu_data[n]))
  138. #define KVM_VM_BASE (KVM_VM_DATA_BASE + \
  139. offsetof(struct kvm_vm_data, kvm_vm_struct))
  140. #define KVM_MEM_DIRTY_LOG_BASE KVM_VM_DATA_BASE + \