kvm.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2012 - Virtual Open Systems and Columbia University
  3. * Author: Christoffer Dall <c.dall@virtualopensystems.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License, version 2, as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef __ARM_KVM_H__
  19. #define __ARM_KVM_H__
  20. #include <linux/types.h>
  21. #include <asm/ptrace.h>
  22. #define __KVM_HAVE_GUEST_DEBUG
  23. #define KVM_REG_SIZE(id) \
  24. (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
  25. /* Valid for svc_regs, abt_regs, und_regs, irq_regs in struct kvm_regs */
  26. #define KVM_ARM_SVC_sp svc_regs[0]
  27. #define KVM_ARM_SVC_lr svc_regs[1]
  28. #define KVM_ARM_SVC_spsr svc_regs[2]
  29. #define KVM_ARM_ABT_sp abt_regs[0]
  30. #define KVM_ARM_ABT_lr abt_regs[1]
  31. #define KVM_ARM_ABT_spsr abt_regs[2]
  32. #define KVM_ARM_UND_sp und_regs[0]
  33. #define KVM_ARM_UND_lr und_regs[1]
  34. #define KVM_ARM_UND_spsr und_regs[2]
  35. #define KVM_ARM_IRQ_sp irq_regs[0]
  36. #define KVM_ARM_IRQ_lr irq_regs[1]
  37. #define KVM_ARM_IRQ_spsr irq_regs[2]
  38. /* Valid only for fiq_regs in struct kvm_regs */
  39. #define KVM_ARM_FIQ_r8 fiq_regs[0]
  40. #define KVM_ARM_FIQ_r9 fiq_regs[1]
  41. #define KVM_ARM_FIQ_r10 fiq_regs[2]
  42. #define KVM_ARM_FIQ_fp fiq_regs[3]
  43. #define KVM_ARM_FIQ_ip fiq_regs[4]
  44. #define KVM_ARM_FIQ_sp fiq_regs[5]
  45. #define KVM_ARM_FIQ_lr fiq_regs[6]
  46. #define KVM_ARM_FIQ_spsr fiq_regs[7]
  47. struct kvm_regs {
  48. struct pt_regs usr_regs;/* R0_usr - R14_usr, PC, CPSR */
  49. __u32 svc_regs[3]; /* SP_svc, LR_svc, SPSR_svc */
  50. __u32 abt_regs[3]; /* SP_abt, LR_abt, SPSR_abt */
  51. __u32 und_regs[3]; /* SP_und, LR_und, SPSR_und */
  52. __u32 irq_regs[3]; /* SP_irq, LR_irq, SPSR_irq */
  53. __u32 fiq_regs[8]; /* R8_fiq - R14_fiq, SPSR_fiq */
  54. };
  55. /* Supported Processor Types */
  56. #define KVM_ARM_TARGET_CORTEX_A15 0
  57. #define KVM_ARM_NUM_TARGETS 1
  58. struct kvm_vcpu_init {
  59. __u32 target;
  60. __u32 features[7];
  61. };
  62. struct kvm_sregs {
  63. };
  64. struct kvm_fpu {
  65. };
  66. struct kvm_guest_debug_arch {
  67. };
  68. struct kvm_debug_exit_arch {
  69. };
  70. struct kvm_sync_regs {
  71. };
  72. struct kvm_arch_memory_slot {
  73. };
  74. /* If you need to interpret the index values, here is the key: */
  75. #define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000
  76. #define KVM_REG_ARM_COPROC_SHIFT 16
  77. #define KVM_REG_ARM_32_OPC2_MASK 0x0000000000000007
  78. #define KVM_REG_ARM_32_OPC2_SHIFT 0
  79. #define KVM_REG_ARM_OPC1_MASK 0x0000000000000078
  80. #define KVM_REG_ARM_OPC1_SHIFT 3
  81. #define KVM_REG_ARM_CRM_MASK 0x0000000000000780
  82. #define KVM_REG_ARM_CRM_SHIFT 7
  83. #define KVM_REG_ARM_32_CRN_MASK 0x0000000000007800
  84. #define KVM_REG_ARM_32_CRN_SHIFT 11
  85. /* Normal registers are mapped as coprocessor 16. */
  86. #define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT)
  87. #define KVM_REG_ARM_CORE_REG(name) (offsetof(struct kvm_regs, name) / 4)
  88. #endif /* __ARM_KVM_H__ */