| 1 | .. _riscv-aia: |
| 2 | |
| 3 | RISC-V AIA support for RISC-V machines |
| 4 | ====================================== |
| 5 | |
| 6 | AIA (Advanced Interrupt Architecture) support is implemented in the ``virt`` |
| 7 | RISC-V machine for TCG and KVM accelerators. |
| 8 | |
| 9 | The support consists of two main modes: |
| 10 | |
| 11 | - *aia=aplic*: adds one or more APLIC (Advanced Platform Level Interrupt Controller) devices |
| 12 | - *aia=aplic-imsic*: adds one or more APLIC device and an IMSIC (Incoming MSI Controller) device for each CPU |
| 13 | |
| 14 | From an user standpoint, these modes will behave the same regardless of the accelerator |
| 15 | used. From a developer standpoint the accelerator settings will change what it being |
| 16 | emulated in userspace versus what is being emulated by an in-kernel irqchip. |
| 17 | |
| 18 | When running TCG, all controllers are emulated in userspace, including machine mode |
| 19 | (m-mode) APLIC and IMSIC (when applicable). |
| 20 | |
| 21 | When running KVM: |
| 22 | |
| 23 | - no m-mode is provided, so there is no m-mode APLIC or IMSIC emulation regardless of |
| 24 | the AIA mode chosen |
| 25 | - with "aia=aplic", s-mode APLIC will be emulated by userspace |
| 26 | - with "aia=aplic-imsic" there are two possibilities. If no additional KVM option |
| 27 | is provided there will be no APLIC or IMSIC emulation in userspace, and the virtual |
| 28 | machine will use the provided in-kernel APLIC and IMSIC controllers. If the user |
| 29 | chooses to use the irqchip in split mode via "-accel kvm,kernel-irqchip=split", |
| 30 | s-mode APLIC will be emulated while using the s-mode IMSIC from the irqchip |
| 31 | |
| 32 | The following table summarizes how the AIA and accelerator options defines what |
| 33 | we will emulate in userspace: |
| 34 | |
| 35 | |
| 36 | .. list-table:: How AIA and accel options changes controller emulation |
| 37 | :widths: 25 25 25 25 25 25 25 |
| 38 | :header-rows: 1 |
| 39 | |
| 40 | * - Accel |
| 41 | - Accel props |
| 42 | - AIA type |
| 43 | - APLIC m-mode |
| 44 | - IMSIC m-mode |
| 45 | - APLIC s-mode |
| 46 | - IMSIC s-mode |
| 47 | * - tcg |
| 48 | - --- |
| 49 | - aplic |
| 50 | - emul |
| 51 | - n/a |
| 52 | - emul |
| 53 | - n/a |
| 54 | * - tcg |
| 55 | - --- |
| 56 | - aplic-imsic |
| 57 | - emul |
| 58 | - emul |
| 59 | - emul |
| 60 | - emul |
| 61 | * - kvm |
| 62 | - --- |
| 63 | - aplic |
| 64 | - n/a |
| 65 | - n/a |
| 66 | - emul |
| 67 | - n/a |
| 68 | * - kvm |
| 69 | - none |
| 70 | - aplic-imsic |
| 71 | - n/a |
| 72 | - n/a |
| 73 | - in-kernel |
| 74 | - in-kernel |
| 75 | * - kvm |
| 76 | - irqchip=split |
| 77 | - aplic-imsic |
| 78 | - n/a |
| 79 | - n/a |
| 80 | - emul |
| 81 | - in-kernel |
| 82 | |
| 83 | |
| 84 | KVM accel option 'riscv-aia' |
| 85 | ---------------------------- |
| 86 | |
| 87 | The KVM accelerator property 'riscv-aia' interacts with the "aia=aplic-imsic" |
| 88 | to determine how the host KVM module will provide the in-kernel IMSIC s-mode |
| 89 | controller. The 'kernel-irqchip' setting has no impact in 'riscv-aia' given |
| 90 | that any available 'kernel-irqchip' setting will always have an in-kernel |
| 91 | IMSIC s-mode. 'riscv-aia' has no impact in APLIC m-mode/s-mode and |
| 92 | IMSIC m-mode settings. |
| 93 | |
| 94 | |
| 95 | .. list-table:: How 'riscv-aia' changes in-kernel IMSIC s-mode provisioning |
| 96 | :widths: 25 25 25 25 |
| 97 | :header-rows: 1 |
| 98 | |
| 99 | * - Accel |
| 100 | - KVM riscv-aia |
| 101 | - AIA type |
| 102 | - IMSIC s-mode |
| 103 | * - kvm |
| 104 | - none |
| 105 | - aplic-imsic |
| 106 | - in-kernel, default to 'auto' |
| 107 | * - kvm |
| 108 | - auto |
| 109 | - aplic-imsic |
| 110 | - in-kernel, hwaccel if available, emul otherwise |
| 111 | * - kvm |
| 112 | - hwaccel |
| 113 | - aplic-imsic |
| 114 | - in-kernel, use IMSIC controller from guest hardware |
| 115 | * - kvm |
| 116 | - emul |
| 117 | - aplic-imsic |
| 118 | - in-kernel, IMSIC is emulated by KVM |