arm-vgic-v3.txt 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. ARM Virtual Generic Interrupt Controller v3 and later (VGICv3)
  2. ==============================================================
  3. Device types supported:
  4. KVM_DEV_TYPE_ARM_VGIC_V3 ARM Generic Interrupt Controller v3.0
  5. Only one VGIC instance may be instantiated through this API. The created VGIC
  6. will act as the VM interrupt controller, requiring emulated user-space devices
  7. to inject interrupts to the VGIC instead of directly to CPUs. It is not
  8. possible to create both a GICv3 and GICv2 on the same VM.
  9. Creating a guest GICv3 device requires a host GICv3 as well.
  10. Groups:
  11. KVM_DEV_ARM_VGIC_GRP_ADDR
  12. Attributes:
  13. KVM_VGIC_V3_ADDR_TYPE_DIST (rw, 64-bit)
  14. Base address in the guest physical address space of the GICv3 distributor
  15. register mappings. Only valid for KVM_DEV_TYPE_ARM_VGIC_V3.
  16. This address needs to be 64K aligned and the region covers 64 KByte.
  17. KVM_VGIC_V3_ADDR_TYPE_REDIST (rw, 64-bit)
  18. Base address in the guest physical address space of the GICv3
  19. redistributor register mappings. There are two 64K pages for each
  20. VCPU and all of the redistributor pages are contiguous.
  21. Only valid for KVM_DEV_TYPE_ARM_VGIC_V3.
  22. This address needs to be 64K aligned.
  23. Errors:
  24. -E2BIG: Address outside of addressable IPA range
  25. -EINVAL: Incorrectly aligned address
  26. -EEXIST: Address already configured
  27. -ENXIO: The group or attribute is unknown/unsupported for this device
  28. or hardware support is missing.
  29. -EFAULT: Invalid user pointer for attr->addr.
  30. KVM_DEV_ARM_VGIC_GRP_DIST_REGS
  31. KVM_DEV_ARM_VGIC_GRP_REDIST_REGS
  32. Attributes:
  33. The attr field of kvm_device_attr encodes two values:
  34. bits: | 63 .... 32 | 31 .... 0 |
  35. values: | mpidr | offset |
  36. All distributor regs are (rw, 32-bit) and kvm_device_attr.addr points to a
  37. __u32 value. 64-bit registers must be accessed by separately accessing the
  38. lower and higher word.
  39. Writes to read-only registers are ignored by the kernel.
  40. KVM_DEV_ARM_VGIC_GRP_DIST_REGS accesses the main distributor registers.
  41. KVM_DEV_ARM_VGIC_GRP_REDIST_REGS accesses the redistributor of the CPU
  42. specified by the mpidr.
  43. The offset is relative to the "[Re]Distributor base address" as defined
  44. in the GICv3/4 specs. Getting or setting such a register has the same
  45. effect as reading or writing the register on real hardware, except for the
  46. following registers: GICD_STATUSR, GICR_STATUSR, GICD_ISPENDR,
  47. GICR_ISPENDR0, GICD_ICPENDR, and GICR_ICPENDR0. These registers behave
  48. differently when accessed via this interface compared to their
  49. architecturally defined behavior to allow software a full view of the
  50. VGIC's internal state.
  51. The mpidr field is used to specify which
  52. redistributor is accessed. The mpidr is ignored for the distributor.
  53. The mpidr encoding is based on the affinity information in the
  54. architecture defined MPIDR, and the field is encoded as follows:
  55. | 63 .... 56 | 55 .... 48 | 47 .... 40 | 39 .... 32 |
  56. | Aff3 | Aff2 | Aff1 | Aff0 |
  57. Note that distributor fields are not banked, but return the same value
  58. regardless of the mpidr used to access the register.
  59. The GICD_STATUSR and GICR_STATUSR registers are architecturally defined such
  60. that a write of a clear bit has no effect, whereas a write with a set bit
  61. clears that value. To allow userspace to freely set the values of these two
  62. registers, setting the attributes with the register offsets for these two
  63. registers simply sets the non-reserved bits to the value written.
  64. Accesses (reads and writes) to the GICD_ISPENDR register region and
  65. GICR_ISPENDR0 registers get/set the value of the latched pending state for
  66. the interrupts.
  67. This is identical to the value returned by a guest read from ISPENDR for an
  68. edge triggered interrupt, but may differ for level triggered interrupts.
  69. For edge triggered interrupts, once an interrupt becomes pending (whether
  70. because of an edge detected on the input line or because of a guest write
  71. to ISPENDR) this state is "latched", and only cleared when either the
  72. interrupt is activated or when the guest writes to ICPENDR. A level
  73. triggered interrupt may be pending either because the level input is held
  74. high by a device, or because of a guest write to the ISPENDR register. Only
  75. ISPENDR writes are latched; if the device lowers the line level then the
  76. interrupt is no longer pending unless the guest also wrote to ISPENDR, and
  77. conversely writes to ICPENDR or activations of the interrupt do not clear
  78. the pending status if the line level is still being held high. (These
  79. rules are documented in the GICv3 specification descriptions of the ICPENDR
  80. and ISPENDR registers.) For a level triggered interrupt the value accessed
  81. here is that of the latch which is set by ISPENDR and cleared by ICPENDR or
  82. interrupt activation, whereas the value returned by a guest read from
  83. ISPENDR is the logical OR of the latch value and the input line level.
  84. Raw access to the latch state is provided to userspace so that it can save
  85. and restore the entire GIC internal state (which is defined by the
  86. combination of the current input line level and the latch state, and cannot
  87. be deduced from purely the line level and the value of the ISPENDR
  88. registers).
  89. Accesses to GICD_ICPENDR register region and GICR_ICPENDR0 registers have
  90. RAZ/WI semantics, meaning that reads always return 0 and writes are always
  91. ignored.
  92. Errors:
  93. -ENXIO: Getting or setting this register is not yet supported
  94. -EBUSY: One or more VCPUs are running
  95. KVM_DEV_ARM_VGIC_CPU_SYSREGS
  96. Attributes:
  97. The attr field of kvm_device_attr encodes two values:
  98. bits: | 63 .... 32 | 31 .... 16 | 15 .... 0 |
  99. values: | mpidr | RES | instr |
  100. The mpidr field encodes the CPU ID based on the affinity information in the
  101. architecture defined MPIDR, and the field is encoded as follows:
  102. | 63 .... 56 | 55 .... 48 | 47 .... 40 | 39 .... 32 |
  103. | Aff3 | Aff2 | Aff1 | Aff0 |
  104. The instr field encodes the system register to access based on the fields
  105. defined in the A64 instruction set encoding for system register access
  106. (RES means the bits are reserved for future use and should be zero):
  107. | 15 ... 14 | 13 ... 11 | 10 ... 7 | 6 ... 3 | 2 ... 0 |
  108. | Op 0 | Op1 | CRn | CRm | Op2 |
  109. All system regs accessed through this API are (rw, 64-bit) and
  110. kvm_device_attr.addr points to a __u64 value.
  111. KVM_DEV_ARM_VGIC_CPU_SYSREGS accesses the CPU interface registers for the
  112. CPU specified by the mpidr field.
  113. Errors:
  114. -ENXIO: Getting or setting this register is not yet supported
  115. -EBUSY: VCPU is running
  116. -EINVAL: Invalid mpidr supplied
  117. KVM_DEV_ARM_VGIC_GRP_NR_IRQS
  118. Attributes:
  119. A value describing the number of interrupts (SGI, PPI and SPI) for
  120. this GIC instance, ranging from 64 to 1024, in increments of 32.
  121. kvm_device_attr.addr points to a __u32 value.
  122. Errors:
  123. -EINVAL: Value set is out of the expected range
  124. -EBUSY: Value has already be set.
  125. KVM_DEV_ARM_VGIC_GRP_CTRL
  126. Attributes:
  127. KVM_DEV_ARM_VGIC_CTRL_INIT
  128. request the initialization of the VGIC, no additional parameter in
  129. kvm_device_attr.addr.
  130. Errors:
  131. -ENXIO: VGIC not properly configured as required prior to calling
  132. this attribute
  133. -ENODEV: no online VCPU
  134. -ENOMEM: memory shortage when allocating vgic internal data
  135. KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO
  136. Attributes:
  137. The attr field of kvm_device_attr encodes the following values:
  138. bits: | 63 .... 32 | 31 .... 10 | 9 .... 0 |
  139. values: | mpidr | info | vINTID |
  140. The vINTID specifies which set of IRQs is reported on.
  141. The info field specifies which information userspace wants to get or set
  142. using this interface. Currently we support the following info values:
  143. VGIC_LEVEL_INFO_LINE_LEVEL:
  144. Get/Set the input level of the IRQ line for a set of 32 contiguously
  145. numbered interrupts.
  146. vINTID must be a multiple of 32.
  147. kvm_device_attr.addr points to a __u32 value which will contain a
  148. bitmap where a set bit means the interrupt level is asserted.
  149. Bit[n] indicates the status for interrupt vINTID + n.
  150. SGIs and any interrupt with a higher ID than the number of interrupts
  151. supported, will be RAZ/WI. LPIs are always edge-triggered and are
  152. therefore not supported by this interface.
  153. PPIs are reported per VCPU as specified in the mpidr field, and SPIs are
  154. reported with the same value regardless of the mpidr specified.
  155. The mpidr field encodes the CPU ID based on the affinity information in the
  156. architecture defined MPIDR, and the field is encoded as follows:
  157. | 63 .... 56 | 55 .... 48 | 47 .... 40 | 39 .... 32 |
  158. | Aff3 | Aff2 | Aff1 | Aff0 |