Christoffer Dall | 7148480 | 2016-05-13 16:41:41 +0200 | [diff] [blame] | 1 | ARM Virtual Generic Interrupt Controller v2 (VGIC) |
| 2 | ================================================== |
Christoffer Dall | 7330672 | 2013-10-25 17:29:18 +0100 | [diff] [blame] | 3 | |
| 4 | Device types supported: |
| 5 | KVM_DEV_TYPE_ARM_VGIC_V2 ARM Generic Interrupt Controller v2.0 |
| 6 | |
Christoffer Dall | 7148480 | 2016-05-13 16:41:41 +0200 | [diff] [blame] | 7 | Only one VGIC instance may be instantiated through either this API or the |
| 8 | legacy KVM_CREATE_IRQCHIP API. The created VGIC will act as the VM interrupt |
| 9 | controller, requiring emulated user-space devices to inject interrupts to the |
| 10 | VGIC instead of directly to CPUs. |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 11 | |
Christoffer Dall | 7148480 | 2016-05-13 16:41:41 +0200 | [diff] [blame] | 12 | GICv3 implementations with hardware compatibility support allow creating a |
| 13 | guest GICv2 through this interface. For information on creating a guest GICv3 |
| 14 | device and guest ITS devices, see arm-vgic-v3.txt. It is not possible to |
| 15 | create both a GICv3 and GICv2 device on the same VM. |
Andre Przywara | ac3d373 | 2014-06-03 10:26:30 +0200 | [diff] [blame] | 16 | |
Andre Przywara | 1085fdc | 2016-07-15 12:43:31 +0100 | [diff] [blame] | 17 | |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 18 | Groups: |
| 19 | KVM_DEV_ARM_VGIC_GRP_ADDR |
| 20 | Attributes: |
| 21 | KVM_VGIC_V2_ADDR_TYPE_DIST (rw, 64-bit) |
| 22 | Base address in the guest physical address space of the GIC distributor |
Andre Przywara | ac3d373 | 2014-06-03 10:26:30 +0200 | [diff] [blame] | 23 | register mappings. Only valid for KVM_DEV_TYPE_ARM_VGIC_V2. |
Andre Przywara | 4fa96afd | 2015-01-13 12:02:13 +0000 | [diff] [blame] | 24 | This address needs to be 4K aligned and the region covers 4 KByte. |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 25 | |
| 26 | KVM_VGIC_V2_ADDR_TYPE_CPU (rw, 64-bit) |
| 27 | Base address in the guest physical address space of the GIC virtual cpu |
Andre Przywara | ac3d373 | 2014-06-03 10:26:30 +0200 | [diff] [blame] | 28 | interface register mappings. Only valid for KVM_DEV_TYPE_ARM_VGIC_V2. |
Andre Przywara | 4fa96afd | 2015-01-13 12:02:13 +0000 | [diff] [blame] | 29 | This address needs to be 4K aligned and the region covers 4 KByte. |
Christoffer Dall | 7148480 | 2016-05-13 16:41:41 +0200 | [diff] [blame] | 30 | Errors: |
| 31 | -E2BIG: Address outside of addressable IPA range |
| 32 | -EINVAL: Incorrectly aligned address |
| 33 | -EEXIST: Address already configured |
| 34 | -ENXIO: The group or attribute is unknown/unsupported for this device |
| 35 | or hardware support is missing. |
| 36 | -EFAULT: Invalid user pointer for attr->addr. |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 37 | |
| 38 | KVM_DEV_ARM_VGIC_GRP_DIST_REGS |
| 39 | Attributes: |
| 40 | The attr field of kvm_device_attr encodes two values: |
| 41 | bits: | 63 .... 40 | 39 .. 32 | 31 .... 0 | |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 42 | values: | reserved | vcpu_index | offset | |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 43 | |
| 44 | All distributor regs are (rw, 32-bit) |
| 45 | |
| 46 | The offset is relative to the "Distributor base address" as defined in the |
| 47 | GICv2 specs. Getting or setting such a register has the same effect as |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 48 | reading or writing the register on the actual hardware from the cpu whose |
| 49 | index is specified with the vcpu_index field. Note that most distributor |
| 50 | fields are not banked, but return the same value regardless of the |
| 51 | vcpu_index used to access the register. |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 52 | Limitations: |
| 53 | - Priorities are not implemented, and registers are RAZ/WI |
Andre Przywara | ac3d373 | 2014-06-03 10:26:30 +0200 | [diff] [blame] | 54 | - Currently only implemented for KVM_DEV_TYPE_ARM_VGIC_V2. |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 55 | Errors: |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 56 | -ENXIO: Getting or setting this register is not yet supported |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 57 | -EBUSY: One or more VCPUs are running |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 58 | -EINVAL: Invalid vcpu_index supplied |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 59 | |
| 60 | KVM_DEV_ARM_VGIC_GRP_CPU_REGS |
| 61 | Attributes: |
| 62 | The attr field of kvm_device_attr encodes two values: |
| 63 | bits: | 63 .... 40 | 39 .. 32 | 31 .... 0 | |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 64 | values: | reserved | vcpu_index | offset | |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 65 | |
| 66 | All CPU interface regs are (rw, 32-bit) |
| 67 | |
| 68 | The offset specifies the offset from the "CPU interface base address" as |
| 69 | defined in the GICv2 specs. Getting or setting such a register has the |
| 70 | same effect as reading or writing the register on the actual hardware. |
| 71 | |
| 72 | The Active Priorities Registers APRn are implementation defined, so we set a |
| 73 | fixed format for our implementation that fits with the model of a "GICv2 |
| 74 | implementation without the security extensions" which we present to the |
| 75 | guest. This interface always exposes four register APR[0-3] describing the |
| 76 | maximum possible 128 preemption levels. The semantics of the register |
| 77 | indicate if any interrupts in a given preemption level are in the active |
| 78 | state by setting the corresponding bit. |
| 79 | |
| 80 | Thus, preemption level X has one or more active interrupts if and only if: |
| 81 | |
| 82 | APRn[X mod 32] == 0b1, where n = X / 32 |
| 83 | |
| 84 | Bits for undefined preemption levels are RAZ/WI. |
| 85 | |
| 86 | Limitations: |
| 87 | - Priorities are not implemented, and registers are RAZ/WI |
Andre Przywara | ac3d373 | 2014-06-03 10:26:30 +0200 | [diff] [blame] | 88 | - Currently only implemented for KVM_DEV_TYPE_ARM_VGIC_V2. |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 89 | Errors: |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 90 | -ENXIO: Getting or setting this register is not yet supported |
Christoffer Dall | c07a019 | 2013-10-25 21:17:31 +0100 | [diff] [blame] | 91 | -EBUSY: One or more VCPUs are running |
Pavel Fedin | 952105a | 2015-10-13 10:01:25 +0300 | [diff] [blame] | 92 | -EINVAL: Invalid vcpu_index supplied |
Marc Zyngier | a98f26f | 2014-07-08 12:09:07 +0100 | [diff] [blame] | 93 | |
| 94 | KVM_DEV_ARM_VGIC_GRP_NR_IRQS |
| 95 | Attributes: |
| 96 | A value describing the number of interrupts (SGI, PPI and SPI) for |
| 97 | this GIC instance, ranging from 64 to 1024, in increments of 32. |
| 98 | |
| 99 | Errors: |
| 100 | -EINVAL: Value set is out of the expected range |
| 101 | -EBUSY: Value has already be set, or GIC has already been initialized |
| 102 | with default values. |
Eric Auger | 065c003 | 2014-12-15 18:43:33 +0100 | [diff] [blame] | 103 | |
| 104 | KVM_DEV_ARM_VGIC_GRP_CTRL |
| 105 | Attributes: |
| 106 | KVM_DEV_ARM_VGIC_CTRL_INIT |
Andre Przywara | 1085fdc | 2016-07-15 12:43:31 +0100 | [diff] [blame] | 107 | request the initialization of the VGIC or ITS, no additional parameter |
| 108 | in kvm_device_attr.addr. |
Eric Auger | 065c003 | 2014-12-15 18:43:33 +0100 | [diff] [blame] | 109 | Errors: |
| 110 | -ENXIO: VGIC not properly configured as required prior to calling |
| 111 | this attribute |
| 112 | -ENODEV: no online VCPU |
| 113 | -ENOMEM: memory shortage when allocating vgic internal data |