kvm.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (C) 2012,2013 - ARM Ltd
  3. * Author: Marc Zyngier <marc.zyngier@arm.com>
  4. *
  5. * Derived from arch/arm/include/uapi/asm/kvm.h:
  6. * Copyright (C) 2012 - Virtual Open Systems and Columbia University
  7. * Author: Christoffer Dall <c.dall@virtualopensystems.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __ARM_KVM_H__
  22. #define __ARM_KVM_H__
  23. #define KVM_SPSR_EL1 0
  24. #define KVM_NR_SPSR 1
  25. #ifndef __ASSEMBLY__
  26. #include <asm/types.h>
  27. #include <asm/ptrace.h>
  28. #define __KVM_HAVE_GUEST_DEBUG
  29. #define __KVM_HAVE_IRQ_LINE
  30. #define KVM_REG_SIZE(id) \
  31. (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
  32. struct kvm_regs {
  33. struct user_pt_regs regs; /* sp = sp_el0 */
  34. __u64 sp_el1;
  35. __u64 elr_el1;
  36. __u64 spsr[KVM_NR_SPSR];
  37. struct user_fpsimd_state fp_regs;
  38. };
  39. /* Supported Processor Types */
  40. #define KVM_ARM_TARGET_AEM_V8 0
  41. #define KVM_ARM_TARGET_FOUNDATION_V8 1
  42. #define KVM_ARM_TARGET_CORTEX_A57 2
  43. #define KVM_ARM_NUM_TARGETS 3
  44. /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
  45. #define KVM_ARM_DEVICE_TYPE_SHIFT 0
  46. #define KVM_ARM_DEVICE_TYPE_MASK (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
  47. #define KVM_ARM_DEVICE_ID_SHIFT 16
  48. #define KVM_ARM_DEVICE_ID_MASK (0xffff << KVM_ARM_DEVICE_ID_SHIFT)
  49. /* Supported device IDs */
  50. #define KVM_ARM_DEVICE_VGIC_V2 0
  51. /* Supported VGIC address types */
  52. #define KVM_VGIC_V2_ADDR_TYPE_DIST 0
  53. #define KVM_VGIC_V2_ADDR_TYPE_CPU 1
  54. #define KVM_VGIC_V2_DIST_SIZE 0x1000
  55. #define KVM_VGIC_V2_CPU_SIZE 0x2000
  56. struct kvm_vcpu_init {
  57. __u32 target;
  58. __u32 features[7];
  59. };
  60. struct kvm_sregs {
  61. };
  62. struct kvm_fpu {
  63. };
  64. struct kvm_guest_debug_arch {
  65. };
  66. struct kvm_debug_exit_arch {
  67. };
  68. struct kvm_sync_regs {
  69. };
  70. struct kvm_arch_memory_slot {
  71. };
  72. /* If you need to interpret the index values, here is the key: */
  73. #define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000
  74. #define KVM_REG_ARM_COPROC_SHIFT 16
  75. /* Normal registers are mapped as coprocessor 16. */
  76. #define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT)
  77. #define KVM_REG_ARM_CORE_REG(name) (offsetof(struct kvm_regs, name) / sizeof(__u32))
  78. /* Some registers need more space to represent values. */
  79. #define KVM_REG_ARM_DEMUX (0x0011 << KVM_REG_ARM_COPROC_SHIFT)
  80. #define KVM_REG_ARM_DEMUX_ID_MASK 0x000000000000FF00
  81. #define KVM_REG_ARM_DEMUX_ID_SHIFT 8
  82. #define KVM_REG_ARM_DEMUX_ID_CCSIDR (0x00 << KVM_REG_ARM_DEMUX_ID_SHIFT)
  83. #define KVM_REG_ARM_DEMUX_VAL_MASK 0x00000000000000FF
  84. #define KVM_REG_ARM_DEMUX_VAL_SHIFT 0
  85. /* AArch64 system registers */
  86. #define KVM_REG_ARM64_SYSREG (0x0013 << KVM_REG_ARM_COPROC_SHIFT)
  87. #define KVM_REG_ARM64_SYSREG_OP0_MASK 0x000000000000c000
  88. #define KVM_REG_ARM64_SYSREG_OP0_SHIFT 14
  89. #define KVM_REG_ARM64_SYSREG_OP1_MASK 0x0000000000003800
  90. #define KVM_REG_ARM64_SYSREG_OP1_SHIFT 11
  91. #define KVM_REG_ARM64_SYSREG_CRN_MASK 0x0000000000000780
  92. #define KVM_REG_ARM64_SYSREG_CRN_SHIFT 7
  93. #define KVM_REG_ARM64_SYSREG_CRM_MASK 0x0000000000000078
  94. #define KVM_REG_ARM64_SYSREG_CRM_SHIFT 3
  95. #define KVM_REG_ARM64_SYSREG_OP2_MASK 0x0000000000000007
  96. #define KVM_REG_ARM64_SYSREG_OP2_SHIFT 0
  97. /* KVM_IRQ_LINE irq field index values */
  98. #define KVM_ARM_IRQ_TYPE_SHIFT 24
  99. #define KVM_ARM_IRQ_TYPE_MASK 0xff
  100. #define KVM_ARM_IRQ_VCPU_SHIFT 16
  101. #define KVM_ARM_IRQ_VCPU_MASK 0xff
  102. #define KVM_ARM_IRQ_NUM_SHIFT 0
  103. #define KVM_ARM_IRQ_NUM_MASK 0xffff
  104. /* irq_type field */
  105. #define KVM_ARM_IRQ_TYPE_CPU 0
  106. #define KVM_ARM_IRQ_TYPE_SPI 1
  107. #define KVM_ARM_IRQ_TYPE_PPI 2
  108. /* out-of-kernel GIC cpu interrupt injection irq_number field */
  109. #define KVM_ARM_IRQ_CPU_IRQ 0
  110. #define KVM_ARM_IRQ_CPU_FIQ 1
  111. /* Highest supported SPI, from VGIC_NR_IRQS */
  112. #define KVM_ARM_IRQ_GIC_MAX 127
  113. #endif
  114. #endif /* __ARM_KVM_H__ */