arm-vgic-its.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============================================
  3. ARM Virtual Interrupt Translation Service (ITS)
  4. ===============================================
  5. Device types supported:
  6. KVM_DEV_TYPE_ARM_VGIC_ITS ARM Interrupt Translation Service Controller
  7. The ITS allows MSI(-X) interrupts to be injected into guests. This extension is
  8. optional. Creating a virtual ITS controller also requires a host GICv3 (see
  9. arm-vgic-v3.txt), but does not depend on having physical ITS controllers.
  10. There can be multiple ITS controllers per guest, each of them has to have
  11. a separate, non-overlapping MMIO region.
  12. Groups
  13. ======
  14. KVM_DEV_ARM_VGIC_GRP_ADDR
  15. -------------------------
  16. Attributes:
  17. KVM_VGIC_ITS_ADDR_TYPE (rw, 64-bit)
  18. Base address in the guest physical address space of the GICv3 ITS
  19. control register frame.
  20. This address needs to be 64K aligned and the region covers 128K.
  21. Errors:
  22. ======= =================================================
  23. -E2BIG Address outside of addressable IPA range
  24. -EINVAL Incorrectly aligned address
  25. -EEXIST Address already configured
  26. -EFAULT Invalid user pointer for attr->addr.
  27. -ENODEV Incorrect attribute or the ITS is not supported.
  28. ======= =================================================
  29. KVM_DEV_ARM_VGIC_GRP_CTRL
  30. -------------------------
  31. Attributes:
  32. KVM_DEV_ARM_VGIC_CTRL_INIT
  33. request the initialization of the ITS, no additional parameter in
  34. kvm_device_attr.addr.
  35. KVM_DEV_ARM_ITS_CTRL_RESET
  36. reset the ITS, no additional parameter in kvm_device_attr.addr.
  37. See "ITS Reset State" section.
  38. KVM_DEV_ARM_ITS_SAVE_TABLES
  39. save the ITS table data into guest RAM, at the location provisioned
  40. by the guest in corresponding registers/table entries.
  41. The layout of the tables in guest memory defines an ABI. The entries
  42. are laid out in little endian format as described in the last paragraph.
  43. KVM_DEV_ARM_ITS_RESTORE_TABLES
  44. restore the ITS tables from guest RAM to ITS internal structures.
  45. The GICV3 must be restored before the ITS and all ITS registers but
  46. the GITS_CTLR must be restored before restoring the ITS tables.
  47. The GITS_IIDR read-only register must also be restored before
  48. calling KVM_DEV_ARM_ITS_RESTORE_TABLES as the IIDR revision field
  49. encodes the ABI revision.
  50. The expected ordering when restoring the GICv3/ITS is described in section
  51. "ITS Restore Sequence".
  52. Errors:
  53. ======= ==========================================================
  54. -ENXIO ITS not properly configured as required prior to setting
  55. this attribute
  56. -ENOMEM Memory shortage when allocating ITS internal data
  57. -EINVAL Inconsistent restored data
  58. -EFAULT Invalid guest ram access
  59. -EBUSY One or more VCPUS are running
  60. -EACCES The virtual ITS is backed by a physical GICv4 ITS, and the
  61. state is not available without GICv4.1
  62. ======= ==========================================================
  63. KVM_DEV_ARM_VGIC_GRP_ITS_REGS
  64. -----------------------------
  65. Attributes:
  66. The attr field of kvm_device_attr encodes the offset of the
  67. ITS register, relative to the ITS control frame base address
  68. (ITS_base).
  69. kvm_device_attr.addr points to a __u64 value whatever the width
  70. of the addressed register (32/64 bits). 64 bit registers can only
  71. be accessed with full length.
  72. Writes to read-only registers are ignored by the kernel except for:
  73. - GITS_CREADR. It must be restored otherwise commands in the queue
  74. will be re-executed after restoring CWRITER. GITS_CREADR must be
  75. restored before restoring the GITS_CTLR which is likely to enable the
  76. ITS. Also it must be restored after GITS_CBASER since a write to
  77. GITS_CBASER resets GITS_CREADR.
  78. - GITS_IIDR. The Revision field encodes the table layout ABI revision.
  79. In the future we might implement direct injection of virtual LPIs.
  80. This will require an upgrade of the table layout and an evolution of
  81. the ABI. GITS_IIDR must be restored before calling
  82. KVM_DEV_ARM_ITS_RESTORE_TABLES.
  83. For other registers, getting or setting a register has the same
  84. effect as reading/writing the register on real hardware.
  85. Errors:
  86. ======= ====================================================
  87. -ENXIO Offset does not correspond to any supported register
  88. -EFAULT Invalid user pointer for attr->addr
  89. -EINVAL Offset is not 64-bit aligned
  90. -EBUSY one or more VCPUS are running
  91. ======= ====================================================
  92. ITS Restore Sequence:
  93. ---------------------
  94. The following ordering must be followed when restoring the GIC and the ITS:
  95. a) restore all guest memory and create vcpus
  96. b) restore all redistributors
  97. c) provide the ITS base address
  98. (KVM_DEV_ARM_VGIC_GRP_ADDR)
  99. d) restore the ITS in the following order:
  100. 1. Restore GITS_CBASER
  101. 2. Restore all other ``GITS_`` registers, except GITS_CTLR!
  102. 3. Load the ITS table data (KVM_DEV_ARM_ITS_RESTORE_TABLES)
  103. 4. Restore GITS_CTLR
  104. Then vcpus can be started.
  105. ITS Table ABI REV0:
  106. -------------------
  107. Revision 0 of the ABI only supports the features of a virtual GICv3, and does
  108. not support a virtual GICv4 with support for direct injection of virtual
  109. interrupts for nested hypervisors.
  110. The device table and ITT are indexed by the DeviceID and EventID,
  111. respectively. The collection table is not indexed by CollectionID, and the
  112. entries in the collection are listed in no particular order.
  113. All entries are 8 bytes.
  114. Device Table Entry (DTE)::
  115. bits: | 63| 62 ... 49 | 48 ... 5 | 4 ... 0 |
  116. values: | V | next | ITT_addr | Size |
  117. where:
  118. - V indicates whether the entry is valid. If not, other fields
  119. are not meaningful.
  120. - next: equals to 0 if this entry is the last one; otherwise it
  121. corresponds to the DeviceID offset to the next DTE, capped by
  122. 2^14 -1.
  123. - ITT_addr matches bits [51:8] of the ITT address (256 Byte aligned).
  124. - Size specifies the supported number of bits for the EventID,
  125. minus one
  126. Collection Table Entry (CTE)::
  127. bits: | 63| 62 .. 52 | 51 ... 16 | 15 ... 0 |
  128. values: | V | RES0 | RDBase | ICID |
  129. where:
  130. - V indicates whether the entry is valid. If not, other fields are
  131. not meaningful.
  132. - RES0: reserved field with Should-Be-Zero-or-Preserved behavior.
  133. - RDBase is the PE number (GICR_TYPER.Processor_Number semantic),
  134. - ICID is the collection ID
  135. Interrupt Translation Entry (ITE)::
  136. bits: | 63 ... 48 | 47 ... 16 | 15 ... 0 |
  137. values: | next | pINTID | ICID |
  138. where:
  139. - next: equals to 0 if this entry is the last one; otherwise it corresponds
  140. to the EventID offset to the next ITE capped by 2^16 -1.
  141. - pINTID is the physical LPI ID; if zero, it means the entry is not valid
  142. and other fields are not meaningful.
  143. - ICID is the collection ID
  144. ITS Reset State:
  145. ----------------
  146. RESET returns the ITS to the same state that it was when first created and
  147. initialized. When the RESET command returns, the following things are
  148. guaranteed:
  149. - The ITS is not enabled and quiescent
  150. GITS_CTLR.Enabled = 0 .Quiescent=1
  151. - There is no internally cached state
  152. - No collection or device table are used
  153. GITS_BASER<n>.Valid = 0
  154. - GITS_CBASER = 0, GITS_CREADR = 0, GITS_CWRITER = 0
  155. - The ABI version is unchanged and remains the one set when the ITS
  156. device was first created.