summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
10 daysKVM: arm64: Support FFA_NOTIFICATION_INFO_GET in host handlerSebastian Ene
Allow the host to send FF-A notification queries to Trustzone and proxy these messages from pKVM. Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://patch.msgid.link/20260907171930.4037166-7-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: Support FFA_NOTIFICATION_GET in host handlerSebastian Ene
Allow FF-A notification GET messages to be proxied from the pKVM hypervisor to Trustzone and verify the arguments sent from the host driver. Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://patch.msgid.link/20260907171930.4037166-6-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: Support FFA_NOTIFICATION_SET in host handlerSebastian Ene
Allow FF-A notification SET messages to be proxied from the pKVM hypervisor to Trustzone and verify the arguments. Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://patch.msgid.link/20260907171930.4037166-5-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: Support FFA_NOTIFICATION_UNBIND in host handlerSebastian Ene
Verify the arguments of the FF-A notification unbind call and forward the message to Trustzone. Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://patch.msgid.link/20260907171930.4037166-4-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: Support FFA_NOTIFICATION_BIND in host handlerSebastian Ene
Verify the arguments of the FF-A notification bind call and forward the message to Trustzone. Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://patch.msgid.link/20260907171930.4037166-3-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: Forward FFA_NOTIFICATION_BITMAP calls to TrustzoneSebastian Ene
Allow FF-A notification bitmap messages to be forwarded to Trustzone from the host kernel driver and enforce the host vmid check. Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://patch.msgid.link/20260907171930.4037166-2-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysmmc: Merge branch fixes into nextUlf Hansson
Merge the mmc fixes for v7.3-rc[n] into the next branch, to allow them to get tested together with the mmc changes that are targeted for the next release. Signed-off-by: Ulf Hansson <ulfh@kernel.org>
10 daysmmc: dw_mmc: remove unused slot memberShawn Lin
struct dw_mci_slot does not exist anymore and nothing ever references host->slot; the member is a leftover from the multi-slot design this driver was upstreamed with, where the slot struct lived in the same header. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
10 daysmmc: sdhci-of-aspeed: Remove children before releasing SDC resourcesMyeonghun Pak
Probe failure and removal leave SDHCI child devices registered after the parent clock and managed resources are released. Unregister the OF children in reverse order before disabling the parent clock on both paths. Use of_platform_device_destroy() because manual child creation does not set the flag required by of_platform_depopulate(). This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: bb7b8ec62dfb ("mmc: sdhci-of-aspeed: Add support for the ASPEED SD controller") Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Assisted-by: OpenAI:GPT-5.6 Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson <ulfh@kernel.org>
10 dayskunit: qemu_configs: Add microblaze configurationsThomas Weißschuh
Add basic configurations to run kunit tests on big and little endian microblaze. Suggested-by: Michal Simek <monstr@monstr.eu> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: David Gow <david@davidgow.net> Link: https://patch.msgid.link/20260914-kunit-microblaze-v2-5-7d5756e858f8@weissschuh.net Signed-off-by: Michal Simek <michal.simek@amd.com>
10 daysKVM: selftests: Add VGICv5 sparse vCPU IDs testSascha Bischoff
GICv5 uses the userspace-provided vCPU ID as the VPE ID. This must work when vCPU IDs are sparse and differ from the dense internal vCPU index. Add a test that creates vCPUs with IDs 17 and 3 and runs both vCPUs to check that ICC_IAFFIDR_EL1 reports the correct VPE ID on each. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-50-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 IST save/restore coverageSascha Bischoff
Add end-to-end VGICv5 IST save/restore coverage. The earlier IST attribute test checks only API rejection cases; this test verifies that interrupt state saved from the ISTs can be restored into a fresh VM before first run and then consumed by the guest. Build a source VM that configures SPI and LPI enable, priority, and affinity state from the guest. Inject selected SPIs from userspace, save the IRS register state, and save both the SPI and LPI IST images through KVM_DEV_ARM_VGIC_GRP_IST using userspace-provided buffers. Create a restore VM and verify that IST restore is rejected before the IRS state has been restored. Restore the IRS registers, validate bad or missing LPI storage, and restore the saved SPI and LPI IST images. Before the host LPI IST is allocated, verify that userspace can change or invalidate IRS_IST_BASER. Once the IST images have been restored and the host LPI IST exists, verify that matching IRS_IST_BASER and IRS_IST_CFGR values can be replayed, while changing either register or clearing IRS_IST_BASER.Valid is rejected. Before running any destination vCPU, save the ISTs again and compare the re-saved buffers against the original saved buffers so that dropped serialised state fails independently of interrupt delivery. Finally, run the restored guest and check pending and enabled SPI and LPI state across two VPEs, priority ordering through ICC_PCR_EL1, delivery of an interrupt that was pending but disabled at save time, and affinity for interrupts injected after restore. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-49-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 LPI delivery testsSascha Bischoff
Add a two-VPE VGICv5 LPI delivery test. LPIs depend on an IST whose base is provided by the guest through IRS_IST_BASER, which causes KVM to allocate and provide an LPI IST to the hardware. Exercise the virtual IRS ID registers and IST base configuration path before checking interrupt delivery. Back the guest's LPI IST with a dedicated userspace memslot and identity-map it into the guest at the same IPA and VA. This lets the guest provide that address to the emulated IRS through IRS_IST_BASER while the host test still allocates and owns the backing memory. Have VPE0 enable the IRS, derive a valid linear LPI IST configuration from the virtual IRS ID registers, provide the IST base through IRS_IST_BASER, configure one LPI for each VPE, and send an LPI to VPE1. While the BASER is valid, attempt to change its address and verify that the write is ignored. VPE1 consumes the first LPI and replies with a second, which VPE0 consumes before completing the test. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-48-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 SPI injection testsSascha Bischoff
Add VGICv5 SPI delivery coverage through KVM_IRQ_LINE. SPIs are configured through the virtual IRS and delivered through the GICv5 CPU interface, so the test needs to exercise both the userspace injection path and the guest-side IRS programming path. Map the virtual IRS into the guest, enable the IRS, configure SPI trigger mode and target VPE from the guest, and check delivery of a default SPI and SPI 1023, the last SPI in the maximum configured range. This also exercises VGIC initialization and the IRS selector at KVM's upper bound. Verify that invalid SPI numbers are rejected, that lowering an edge-triggered SPI after it is pending does not recall it, and that level-sensitive SPIs are delivered. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-47-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 CPU sysreg attribute testsSascha Bischoff
Add coverage for the VGICv5 CPU_SYSREGS attribute group. The vCPU-local CPU interface registers are part of the VGICv5 userspace ABI, so KVM must expose the supported registers and reject invalid register or vCPU selectors. Verify that CPU_SYSREGS access is rejected before VGIC initialization, that all exposed VGICv5 CPU interface registers can be read and written back, and that unsupported sysregs, invalid MPIDRs and bad userspace pointers are rejected. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-46-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 USERSPACE_PPIS testsSascha Bischoff
Add coverage for the VGICv5 USERSPACE_PPIS control attribute. VGICv5 only allows userspace to drive PPIs that KVM explicitly advertises, so the selftest should verify the discovery path and the corresponding KVM_IRQ_LINE rejection cases. Verify that KVM reports the control attribute and that the returned bitmap contains SW_PPI. Also check that the upper 64 bits are zero, as KVM only exposes architected PPIs (the lower 64 entries). Finally, verify that writes, bad userspace pointers, PPIs outside the advertised bitmap, and the first out-of-range PPI number are rejected. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-45-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 IST attribute testsSascha Bischoff
Add API coverage for the VGICv5 IST attribute group. This does not test that IST save/restore preserves interrupt state; it only checks the attribute plumbing and the cases KVM must reject before the end-to-end restore path can rely on the interface. Verify that KVM reports the IST attribute group, rejects unknown attributes, rejects save/restore before initialization, rejects bad userspace pointers, and rejects IST restore after the VM has run. Also cover the userspace IST descriptor validation: a VM with SPIs must provide a SPI IST buffer of the expected size, and LPI storage must not be supplied when no LPI IST is configured. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-44-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 IRS_REGS attribute testsSascha Bischoff
Add coverage for the VGICv5 IRS_REGS attribute group. Migration needs a userspace-visible view of the virtual IRS register state, but KVM must expose only valid registers and reject state that cannot be restored safely. Verify that KVM_HAS_DEVICE_ATTR reports the IRS_REGS group before the IRS base is configured, while register reads and writes are rejected before VGIC initialisation. Once the VGIC is initialised, verify that all exposed registers can be read and their values written back. Check that bad offsets, incorrect alignment, and bad userspace pointers are rejected. Also check ID register restore validation, idle status register values, and IRS_IST_BASER restore handling. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-43-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 NR_IRQS attribute testsSascha Bischoff
Add coverage for the VGICv5 NR_IRQS attribute. VGICv5 exposes a userspace-selectable SPI count, and KVM must reject values outside its supported range or values that would change the interrupt layout after it has been fixed. Verify that the attribute defaults to zero before initialisation, rejects too few SPIs, non-32-aligned counts, and a 32-aligned count beyond the 1024-SPI maximum. Also verify that the maximum count is accepted and can be initialised, that the selected count is reported, that initialisation selects the default count, and that subsequent changes are rejected. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-42-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: selftests: Add VGICv5 IRS address attribute testsSascha Bischoff
Add coverage for the VGICv5 IRS address attribute. The address is the base of the guest-visible MMIO region used to configure the virtual IRS, so userspace must provide a valid base address before the VM can run. Verify that KVM reports the attribute, returns VGIC_ADDR_UNDEF before it is configured, rejects misaligned and out-of-IPA-range addresses, accepts a valid base, rejects a second base, and fails vCPU entry if the VGIC is initialized without an IRS address. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-41-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysDocumentation: KVM: Add the VGICv5 IRS save/restore sequencesSascha Bischoff
Document the ordering requirements for saving and restoring the GICv5 IRS state. The IST state is exposed through KVM_DEV_ARM_VGIC_GRP_IST and is copied to or from userspace-provided buffers. Saving the ISTs therefore does not update guest memory, so userspace does not need to serialize guest memory after saving the IST state. On restore, userspace must create the vCPUs, configure the IRS address, restore the number of SPIs, and initialize the VGIC before restoring IRS state. The IRS MMIO registers may be restored in any order, but the final IRS_IDR* state and the IRS_IST_CFGR/IRS_IST_BASER state that describes any LPI IST must be restored before KVM_DEV_ARM_VGIC_GRP_IST. KVM uses that state to validate the userspace IST buffers and allocate any host LPI IST. The IRS_*_STATUSR registers are observational state in KVM. Userspace may save them for validation or debugging, but they are not required as restore input and do not need to be replayed. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-40-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysDocumentation: KVM: Add docs for KVM_DEV_ARM_VGIC_GRP_ISTSascha Bischoff
Document the IST save/restore userspace interface for the VGICv5 device, KVM_DEV_ARM_VGIC_GRP_IST. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-39-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysDocumentation: KVM: Add KVM_DEV_ARM_VGIC_GRP_IRS_REGS to VGICv5 docsSascha Bischoff
Document the KVM_DEV_ARM_VGIC_GRP_IRS_REGS attribute group used to read and write the virtual IRS's MMIO register state. This provides a GICv5-specific interface for state that is conceptually similar to the VGICv3 ITS register interface, but uses IRS terminology instead of ITS. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-38-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysDocumentation: KVM: Document KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS for VGICv5Sascha Bischoff
The virtual GICv5 adopts the same mechanism as GICv3 for userspace reads and writes of the system registers, albeit operating on a different set of registers, of course. Document KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS for GICv5 in the VGICv5 documentation, explicitly calling out the registers it operates on. The main body of documentation has been directly copied from the VGICv3 documentation as it has identical operation. One key thing to note is that for two sets of GICv5 registers - those pertaining to Active and Pending state - the operation of the interface is different to how the actual registers operate. Both of these registers have C and S variants (to set and clear bits) in hardware. However for this interface, we ONLY implement the S variant, AND treat it as a raw write. This simplifies the act of reading or writing the state. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-37-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Implement save/restore mechanisms for ISTsSascha Bischoff
When running a GICv5 VM, there are up to two ISTs that must be saved or restored when migrating a VM. The SPI IST is allocated by the hypervisor, as the guest presumes the memory for the SPI state is allocated by the hardware. The LPI IST is also shadowed in KVM when the guest enables LPIs, so the guest's LPI IST memory is not used directly by the physical GICv5 hardware. As both in-use ISTs are backed by host allocations, userspace provides migration storage for both tables through KVM_DEV_ARM_VGIC_GRP_IST. The userspace descriptor supplies separate SPI and LPI buffers, each containing the architected 32-bit ISTE state for the corresponding interrupt number space. If the guest has not configured an LPI IST, userspace must omit the LPI buffer. On save, acquire every vCPU mutex, returning -EBUSY if any vCPU is already running. Holding these locks blocks KVM_RUN while the IST state is exported. Use IRS_SAVE_VMR to write the IRS's internal state back to the ISTs and check that the VM remained quiescent. After copying each IST, issue a Q-only IRS_SAVE_VMR operation to update IRS_SAVE_VM_STATUSR.Q and repeat the check. If the VM has not remained quiescent since the save began, propagate an error to userspace so that the save can be retried without losing incoming interrupt state. On restore, reject the operation if any vCPU has already run. Validate the userspace buffers and, if the restored IRS state describes an LPI IST, allocate the shadow host IST while the VMTE is still valid. This allows the IRS operation that assigns the IST to update the VMTE. Then make the VMTE invalid before copying the SPI and LPI IST state from the userspace-provided buffers, and make it valid again once the copy is complete. Once restoration completes successfully, clear the pending LPI IST restore state recorded when IRS_IST_BASER.Valid was restored, allowing the guest to run. As part of restoring the ISTs, track pending interrupts and clear their pending state from the restored host ISTs. Once the VM is valid again, make those interrupts pending through the GIC VDPEND system instruction. Once a host LPI IST has been allocated, the guest-visible IRS_IST_BASER and IRS_IST_CFGR state describes that allocation. Userspace may replay values with the same defined fields, but KVM rejects changes while the host IST exists. During save, also require the VMTE IST_ID_BITS value to match IRS_IST_CFGR.LPI_ID_BITS so that userspace buffer validation and the host IST walk use the same number of entries. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-36-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add VGICv5 IST save/restore UAPISascha Bischoff
Introduce KVM_DEV_ARM_VGIC_GRP_IST as the VGICv5 device attribute group used to transfer SPI and LPI IST state between KVM and userspace during migration. The group uses struct kvm_vgic_v5_ist as a descriptor for the userspace-owned SPI and LPI IST buffers. Each buffer contains the architected 32-bit ISTE state for the corresponding interrupt number space, while the host IST layout remains private to KVM. The descriptor is architecture-specific, as it is only the payload of an ARM VGIC device attribute. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-35-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add CoreSight MMIO regs to IRSSascha Bischoff
Expose the CoreSight identification registers in the emulated GICv5 IRS MMIO region. These registers are read-only from the guest's point of view, so return the architectural identification values and ignore writes. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-34-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Handle userspace accesses to IRS MMIO regionSascha Bischoff
As part of saving and restoring the state of a GICv5-based system, userspace must save and restore the IRS MMIO registers. These include important information such as the guest IST configuration, and KVM must present consistent state to the guest after migration. Introduce KVM_DEV_ARM_VGIC_GRP_IRS_REGS and provide accessors to read and write the virtual IRS register state. This is modelled on the GICv3 ITS register interface, as the migration requirements are broadly the same. Reuse the guest MMIO handlers where userspace and guest accesses have the same semantics. Add userspace-specific handling where restoring a register image must not trigger the operation associated with a guest MMIO write. Validate restored ID register fields against the capabilities KVM and the host can support. Restore the emulated IST configuration without allocating or freeing a host IST, and report operation status registers as idle. Accept writes to IRS_SPI_CFGR, IRS_IIDR, and IRS_AIDR without changing their state, allowing userspace to replay the values it previously read. Restoring IRS_IST_BASER.Valid recreates the guest-visible configuration, but the host LPI IST cannot be allocated until userspace supplies its contents. Track this as a pending LPI IST restore and reject guest entry until userspace restores the IST through KVM_DEV_ARM_VGIC_GRP_IST. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-33-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add GICv5 EL1 sysreg userspace accessorsSascha Bischoff
Now that KVM is able to run meaningful VMs with GICv5, it is important to be able to save and restore the GICv5 state in order to support VM migration. Add functions to handle userspace reads and writes of the GICv5 EL1 system registers. Some architected register values are reconstructed from KVM's internal representation rather than stored as raw register state. For example, ICC_CR0_EL1.En and ICC_PCR_EL1.Priority are backed by fields in the saved virtual VMCR, while the PPI Enable, Active, and Pending registers are assembled from per-interrupt vgic_irq state. Userspace writes are translated back into the corresponding internal representation. Wire the accessors into KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS for the GICv5 device, reusing the existing GICv3 CPU sysreg UAPI encoding. Require the VGIC to be initialised before accessing the register state. Allow userspace to read the state after a vCPU has run, but reject writes once any vCPU has run. This ensures that userspace restores the GICv5 CPU interface state before KVM finalises it for guest execution. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-32-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Mask per-vCPU PPI state in vgic_v5_finalize_ppi_state()Sascha Bischoff
Only a subset of the possible PPIs are exposed to a guest when running with a vGICv5. First of all, only the architected PPIs are considered by KVM. Secondly, only a set of those is exposed to a guest: those corresponding to devices that KVM emulates, such as the timers and PMU, and the GICv5 SW_PPI. The finalisation of exposed PPIs happens on first vCPU run, as this is the first time when the full set of exposed devices is known. At this stage a mask is calculated, and this mask is applied both to hide non-exposed PPI state from the guest and to reduce overhead when iterating over the PPIs. While preparing userspace access to the GICv5 system registers, it became apparent that restoring the GICv5 PPI registers can result in a mismatch between the state supplied by userspace and the state KVM intends to expose. Userspace can provide Enable, Active, and Pending state for PPIs that KVM has chosen to hide from the guest. Userspace must restore PPI state before any vCPU runs. The userspace access path added subsequently enforces this ordering. Rework vgic_v5_finalize_ppi_state() to calculate the mask of exposed PPIs and clear any state belonging to non-exposed PPIs. This ensures that only the state KVM intends to expose is visible to the guest. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-31-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add GICv5 SPI injection to irqfdSascha Bischoff
Now that there is support for GICv5 SPIs in KVM, update vgic_irqfd_set_irq() to translate irqchip pins into GICv5 SPI IntIDs before injecting them. Validate IRQCHIP route pins against the GIC model. GICv2 and GICv3 only support 988 pins for SPIs 32 through 1019, while KVM supports up to 1024 GICv5 SPI pins. The common routing table is sized for the largest supported range. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-30-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysDocumentation: KVM: Extend VGICv5 device attribute docsSascha Bischoff
The VGICv5 documentation still describes the device as supporting PPIs only. Update the overview to cover PPI, SPI, and LPI interrupts. PPIs and SPIs can be injected by in-kernel devices or through KVM_IRQ_LINE, while LPI pending state is driven by the guest and handled in hardware through the LPI IST. Document the GICv5 IRS address attribute and its GPA layout requirements. The IRS region must be 64K aligned and covers a 128K range. Also document the GICv5-specific interpretation of KVM_DEV_ARM_VGIC_GRP_NR_IRQS. Unlike GICv2 and GICv3, the value describes only the number of SPIs exposed by the IRS and does not include SGIs or PPIs. The supported range is 32 through 1024 SPIs in multiples of 32, and defaults to 32 when userspace leaves it unset. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-29-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Support SPI injectionSascha Bischoff
GICv5 SPI lifecycle is handled by the GICv5 hardware once the pending state has been injected. This change adds support for injecting SPIs to the core VGIC code and GICv5 code. First of all, allow GICv5 SPIs to be looked up by ID via vgic_get_irq(). Previously, only PPIs were supported. Two irq_ops are used for GICv5 SPI injection. The set_pending_state() irq_op is used to inject the SPI's pending state into the guest. The queue_irq_unlock() irq_op releases the IRQ lock without queueing the SPI on a per-vCPU AP list, as GICv5 does not track in-flight SPI state in KVM. Tracking the affinity and lifecycle of individual SPIs in software would negate much of the benefit of their lifecycle being hardware managed. Limit injection to the configured per-VM SPI range. Since GICv5 SPI IDs start at zero, KVM_IRQ_LINE accepts IDs from zero through one less than the configured number of SPIs, up to 1023. Update the KVM_IRQ_LINE documentation accordingly. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-28-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic: Introduce set_pending_state() to irq_opsSascha Bischoff
There are times, such as with GICv5 SPIs and LPIs, where the hardware itself manages parts of the interrupt lifecycle. This means that pending state can be directly communicated to the hardware instead of being represented only in the VGIC shadow state. In order to accommodate cases where the hardware handles pending state directly, add a new set_pending_state() function pointer to irq_ops. The intent is for this to be used after the VGIC shadow pending state has changed, allowing the backend to mirror the updated state into hardware. This new function is plumbed into kvm_vgic_inject_irq(), and is only called if irq_ops are provided and this function pointer is explicitly set. In the general case, this has no effect. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-27-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add GIC VDPEND hyp callSascha Bischoff
With PPIs, their state is injected via the ICH_PPI_x_EL2 system registers. For SPIs and LPIs, there are no such registers as these would limit the number of interrupts significantly. Instead, SPI and LPI pending state can be managed from the hypervisor using the GIC VDPEND instruction. This provides a way to set an SPI or LPI for a VM as pending or non-pending, i.e., to inject interrupts into a guest. This system instruction is only executable from EL2, and therefore must be wrapped in a hypercall for NVHE/hVHE configurations. With pKVM this hypercall is explicitly a no-op as we currently don't support the combination of GICv5 and pKVM. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-26-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: selftests: Update vGICv5 selftest to set IRS addressSascha Bischoff
This selftest was added before the GICv5 IRS was supported in KVM. Therefore, there was no address to set, and the specific UAPI didn't even exist. Now that the IRS is supported, and setting its address is mandatory before VGIC resources are mapped, set the emulated IRS GPA before initialising the VGIC. Running a GICv5 VM will fail if userspace has not provided the IRS address before the first vCPU run. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-25-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Set IRICHPPIDIS based on IRS enable stateSascha Bischoff
The GICv5 ICH_CONTEXTR_EL2 register has the IRICHPPIDIS field, which allows the hypervisor to disable HPPI selection for SPIs and LPIs. Use this to emulate the guest enabling and disabling the IRS. Program IRICHPPIDIS from the virtual IRS enable state when loading a VPE. This prevents SPIs and LPIs from being delivered until the guest enables the emulated IRS, matching the behaviour of real hardware. Likewise, when making a VPE non-resident as it enters WFI, only calculate the doorbell priority mask and request a doorbell if the virtual IRS is enabled. A disabled IRS cannot select an SPI or LPI to wake the VPE, so neither the priority calculation nor a doorbell request serves any purpose in that state. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-24-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Register the IRS IODEVSascha Bischoff
Now that we have an emulated IRS, it needs to be registered, which ensures that guest accesses to the MMIO regions handled by the device are handled appropriately in KVM. Therefore, as part of vgic_map_resources, the GICv5 IRS IODEV is registered. If the address for the IRS is not provided, bail out reporting an error - this is not a supported config. As part of this change, expose setting the address of the emulated IRS via KVM_VGIC_V5_ADDR_TYPE_IRS to userspace. Also allow userspace to set the number of SPIs handled by the emulated GICv5 implementation, using a GICv5-specific SPI count rather than the legacy total interrupt count. Limit the configurable range to 32 through 1024 SPIs, in multiples of 32. KVM keeps one struct vgic_irq per SPI in a physically contiguous allocation, and allowing the full 16-bit KVM_IRQ_LINE SPI namespace would make that allocation exceed KMALLOC_MAX_SIZE on common arm64 configurations. The default routing has one IRQCHIP route per configured SPI, so size the common IRQ routing table for the largest GICv5 configuration. The model-specific routing validation retains the 988-pin limit for GICv2 and GICv3. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-23-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Initialise per-VM IRS stateSascha Bischoff
A virtual GICv5 needs an emulated IRS in addition to the host IRS state used to back VMTEs, VPEs, and ISTs. Without this, KVM can only provide the CPU-local PPI state and cannot expose the IRS-backed SPI and LPI configuration expected by a GICv5 guest. Allocate the per-VM emulated IRS state when creating a virtual GICv5, and initialise it from vgic_v5_init(). If userspace has not provided a number of SPIs, use the GICv5 default of 32. The IRS init path allocates the SPI state, initialises the virtual IRS register state, and creates the backing SPI IST when SPIs are present. Keep the per-VM IRS object alive for the lifetime of the virtual GICv5. vgic_v5_teardown() only unwinds resources allocated by vgic_v5_init(), so failed initialisation can be retried, while kvm_vgic_dist_destroy() frees the IRS object during final VGIC destruction. This gives virtual GICv5s the IRS backing required for SPIs and LPIs, rather than being limited to PPIs only. Further patches add support for SPI injection and lifecycle tracking. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-22-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add GICv5 IRS IODEV and MMIO emulationSascha Bischoff
In order to properly support GICv5-based VMs in KVM, emulate the CONFIG_FRAME for a virtual IRS. This emulation needs to handle guest accesses to the MMIO region and mimic the behaviour of a real IRS. Introduce an IODEV for the GICv5 IRS and an associated initialisation function that sets up the SPIs and initial IRS state. The MMIO emulation allows the guest to query the IRS_IDx registers, manipulate SPIs, configure ISTs, and so forth. Allow 32-bit accesses to the 64-bit IRS registers in addition to 64-bit accesses. Reconstruct IRS_IST_BASER for reads and merge partial writes so that updating either word preserves the other half. The emulation tracks selector state across MMIO accesses. For example, a guest writes IRS_PE_SELR to select a PE by IAFFID. This is the VPE ID for a VM, but the guest does not know this. If the guest reads IRS_PE_STATUSR, KVM checks whether that IAFFID selects a valid VPE and sets the V bit accordingly. IRS_PE_CR0 is accepted as write-ignored because KVM does not support 1-of-N routing. The same selector and status register model is exposed for SPIs. Track the state of IRS_CR0.IRSEN and introduce KVM_REQ_RELOAD_GICv5 to reload the GICv5 context of running vCPUs when it changes. Only make the request when the enable state changes, avoiding unnecessary IPIs for writes that leave it unchanged. The LPI IST requires KVM to perform actions on behalf of the guest. Treat changes to IRS_IST_BASER.Valid as the lifetime of the guest's IST. On an Invalid-to-Valid transition, validate IRS_IST_CFGR, allocate a shadow host IST, and assign it to the physical IRS through the VMTE. On a Valid-to-Invalid transition, invalidate and free the host IST. Ignore guest address changes while the BASER remains valid, and prevent changes to IRS_IST_CFGR during that time. As far as the guest is concerned, the IST memory it provided is being used by the hardware, but the physical IRS uses the host shadow IST instead. This change provides the core IRS IODEV and MMIO emulation, but does not plumb the device into the rest of KVM yet. The CoreSight identification registers are added separately. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-21-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add KVM_VGIC_V5_ADDR_TYPE_IRS to UAPISascha Bischoff
Define the UAPI address type used by userspace to describe the location of the emulated IRS in guest physical address space, together with the size reserved for that region. As per the GICv5 specification, the IRS has one CONFIG_FRAME and optionally one SETLPI_FRAME per interrupt domain. Within a KVM VM we are only concerned with one interrupt domain. Each of these frames is 64kB in size, so reserve 2x64kB of contiguous memory in the GPA space for a GICv5 IRS. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-20-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add IRS IODEV support to MMIO handlersSascha Bischoff
In order to support proper VMs (that support more than just PPIs) for GICv5, it is important to emulate the GICv5 IRS too. The IRS includes an MMIO interface which is used to interact with and configure the IRS. As part of providing the emulated IRS MMIO interface in KVM, extend enum iodev_type to include a GICv5 IRS device, and extend the MMIO code to handle reads and writes to that type of IO device. This will allow the creation of a GICv5 IRS IO Device in KVM. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-19-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Introduce struct vgic_v5_irs and IRS base addressSascha Bischoff
In order to properly emulate the operation of the IRS from KVM, we require storage for the MMIO register state. This change introduces struct vgic_v5_irs, and adds a pointer to it to the struct vgic_dist. This new data structure contains the storage for IRS MMIO state that is required for emulating the MMIO interface in KVM. This provides persistent storage, and a way to track data across MMIO writes, e.g., selecting an SPI and updating the configuration of it is two MMIO writes. Note that only a pointer to the data structure is added to struct vgic_dist as this new structure is very large, and hence it makes sense to dynamically allocate it and just provide a pointer to retrieve it in struct vgic_dist. In addition to adding a structure to store the MMIO state for the IRS, we add the base address in GPA space to struct vgic_v5_irs. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-18-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Request doorbells when VPEs enter WFISascha Bischoff
When a GICv5 VPE is made non-resident as part of the vcpu entering WFI, request a VPE doorbell so that KVM can be notified when a suitable SPI or LPI becomes pending for that VPE. Program the doorbell priority mask, DBPM, from the effective virtual priority mask before making the VPE non-resident. DBPM is the priority threshold used by the GICv5 hardware to decide whether a pending SPI or LPI is allowed to signal the VPE doorbell. This allows hardware to signal the doorbell only for interrupts that the vcpu can actually take, and avoids waking it for interrupts masked by the guest priority state. If no interrupt can be signalled to the vcpu, leave the doorbell request clear. Attempt to make the doorbell interrupt affine to the current CPU before requesting it. Treat affinity failures as non-fatal and continue using the existing placement. A successful move nudges the wakeup back towards the CPU that last ran the vcpu, where the relevant state is more likely to be cache-hot, while also spreading doorbell interrupts across host PEs as different vcpus enter WFI on different CPUs. Clear stale db_fired state before making the VPE non-resident. Any previous doorbell notification has already been consumed by this point, and clearing it before the non-resident transition ensures that a newly fired doorbell is observed. Finally, teach kvm_vgic_vcpu_pending_irq() to report pending work for a GICv5 vcpu when its VPE doorbell has fired, in addition to the existing pending-PPI check. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-17-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Add resident/non-resident hyp callsSascha Bischoff
GICv5 introduces the concept of VPE residency - a VPE can be either resident or non-resident. When the VPE is resident, the IRS is allowed to select interrupts that target that VPE (or the VM) as the HPPI (Highest Priority Pending Interrupt). As the IRS handles both SPIs and LPIs, these will only be picked as the IRS's HPPI when a VPE is resident. A GICv5 VPE is made resident by writing ICH_CONTEXTR_EL2 with ICH_CONTEXTR_EL2.V set, together with valid VM and VPE IDs. This informs the IRS that a specific VPE is running, and that it can begin HPPI selection for that VPE. Making a VPE non-resident (by making the ICH_CONTEXTR_EL2 invalid) informs the IRS that the VPE is no longer running, and it stops HPPI selection for it. This change introduces two new hyp calls - one to make a VPE resident and its counterpart to make a VPE non-resident. As part of making a VPE resident, the resulting ICH_CONTEXTR_EL2.F bit is checked to catch residency faults. Such a fault indicates a broken VM/VPE setup, so warn and mark the VM dead. Both of these new hypercalls are explicitly no-ops with pKVM as we currently don't support the combination of GICv5 and pKVM. Furthermore, this change extends vgic_v5_load() and vgic_v5_put() to make the VPEs resident and non-resident, respectively. Hence, the VPE is considered resident for the entire load-to-put interval. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-16-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Set up VMTEs and VPE doorbellsSascha Bischoff
A GICv5 VM needs a VM table entry before it can use SPIs and LPIs, which are backed by the host IRS. The VM table itself is created at probe time, but each VM still needs to claim and populate one VMTE before it can use those interrupts. VPE doorbells are allocated from the host LPI irq domain. Without that domain, KVM cannot issue IRS commands or receive doorbell wakeups. Fail the GICv5 KVM probe if the host driver did not create an LPI domain. Allocate a VM ID during vgic_v5_init(). The VM ID is also the index into the VM table, so allocating it selects the VMTE slot that will be used for the lifetime of the VM. Create a per-VM VPE doorbell irq domain, allocate one doorbell interrupt per vCPU, request the interrupts, and keep the doorbell IRQ number in the vCPU's GICv5 state. The doorbell handler marks the VPE doorbell as fired, raises KVM_REQ_IRQ_PENDING, and kicks the target vCPU so that KVM can re-evaluate pending interrupt state. The doorbell domain indexes its interrupts using the dense vcpu_idx, while GICv5 uses the userspace-provided vcpu_id as the VPE ID. Store a backpointer to the VM and use it to resolve the vCPU before issuing VPE-specific IRS commands. This preserves the userspace VPE ID when vCPU IDs are sparse. With the VM ID and doorbells in place, initialise the VMTE backing state, including the VM descriptor, VPE table, and preallocated VPED storage. The doorbells have to exist before making the VMTE valid, as they provide the IRQ-side conduit used by the IRS commands. Make the VMTE valid via the IRS, then populate the VPETE for each vCPU. Add vgic_v5_teardown() to unwind the state in the reverse order. Make the VMTE invalid, clear the per-vCPU VPETEs, release the VMTE backing state, free the doorbell IRQs and irq domain, and finally release the VM ID so that the VMTE slot can be reused by a later VM. If invalidating the VMTE, clearing a VPETE, or releasing the VMTE fails, still free the software doorbells and domain, but keep the VM ID allocated so that the VMTE slot is not reused while hardware-visible state may remain. On init failure, call the same teardown path so that partially created state is unwound consistently. As part of resetting vCPUs, mark them as valid in the VM's VPE table. This informs the IRS that a specific VPE may be made resident. Without this, the IRS will treat the VPE as invalid. Also introduce vgic_v5_send_command(), a wrapper around the VPE doorbells. It takes a struct kvm_vcpu pointer and the command to run, and invokes the function bound to that command through the vCPU's doorbell. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-15-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Implement VPE IRS MMIO OpsSascha Bischoff
Introduce interfaces to make VPEs valid, and to configure them, via the host's IRS. As with the other valid bits in the GICv5 VM tables, VPEs cannot be made valid directly, and instead are made valid via an IRS MMIO Op. Additionally, some of the VPE configuration takes place via the IRS MMIO interface too (via the IRS_VPE_CR0, IRS_VPE_DBR). VPE doorbells are, for example, configured via this interface. The existing VPE-doorbell-based commands are extended with: VPE_MAKE_VALID - Make the VPE valid in the VPET Note: There is no VPE_MAKE_INVALID as VPEs are only made invalid on teardown, at which point the whole VMTE is marked as invalid. Hence, it is not required. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-14-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: vgic: Enforce model-specific vCPU limitsSascha Bischoff
A GICv5 host with FEAT_GCIE_LEGACY can expose either a native vGICv5 or a vGICv3 device. These models do not necessarily have the same vCPU limit: the native GICv5 limit is probed from the IRS VPE capacity, while the GICv3 limit remains the fixed KVM vGICv3 limit. Keep the IRS-derived limit separately for vGICv5 creation. The pre-VGIC KVM_CAP_MAX_VCPUS value continues to expose the largest limit among the still-selectable models, and kvm_vgic_create() clamps the VM to the limit of the VGIC model userspace actually selected. Userspace can create vCPUs before creating a VGIC. Hence, checking only the number of existing vCPUs after reducing the limit is not sufficient. For example, a single vCPU with ID 500 passes the GICv2 count limit even though GICv2 can represent only eight target CPUs. The GICv2 code subsequently uses the vCPU ID in target and SGI source masks, leading to shifts beyond the width of the operand. GICv5 has a similar requirement because the userspace-provided vcpu_id is used as the index into the VPET. This means that the vcpu_id also represents the IAFFID for a VPE, and therefore is visible to the guest. After selecting the model-specific limit, validate every existing vCPU ID against it. KVM_CREATE_VCPU already enforces the same limit for vCPUs created after the VGIC, making the result independent of creation order. Link: https://lore.kernel.org/r/20260807133051.15D381F000E9@smtp.kernel.org Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-13-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Implement VMT/vIST IRS MMIO OpsSascha Bischoff
GICv5 has rules about which fields of a VMTE (or L1 VMT) may be directly written by the host once the table is valid. This ensures that no stale state is cached by the hardware, and provides a clear interface for making VMs, ISTs, etc. valid. The hypervisor is responsible for populating the VMTE for a VM. However, it is not permitted to write the Valid bit, as the VM table is already valid. Instead, the VM is made valid via an IRS MMIO operation. The same applies to the ISTs: they must be made valid via the host IRS. This commit adds support for: * Making level 1 VMTs valid, allowing for dynamic level 2 array allocation * Making VMTEs, and hence VMs, valid or invalid * Making SPI ISTs valid, and LPI ISTs valid or invalid, for a specific VM As part of this commit, the following vcpu_affinity-based commands are plumbed in: VMT_L2_MAP - Make a second level VM table valid VMTE_MAKE_VALID - Make a single VMTE, and hence VM, valid VMTE_MAKE_INVALID - Make a single VMTE, and hence VM, invalid SPI_VIST_MAKE_VALID - Make the SPI IST valid LPI_VIST_MAKE_VALID - Make the LPI IST valid LPI_VIST_MAKE_INVALID - Make the LPI IST invalid The lack of SPI_VIST_MAKE_INVALID is intentional. An IRS command timeout does not indicate whether the command was consumed. If VIST assignment times out, retain both the VMTE and IST allocation and mark the VM dead. This prevents KVM from freeing memory which may still be accessible to hardware. When successfully probing for a GICv5, allocate the VMT and make it valid through the IRS MMIO interface. Treat failures while allocating or assigning the VMT as hard GICv5 probe failures. At that point the IRS VM table state is a prerequisite for vGICv5 operation, and falling back to the legacy path would leave the host without a valid GICv5 VM table setup. Conversely, if vGICv5 registration succeeds but registration of the optional legacy vGICv3 device fails, retain the working vGICv5 device rather than failing the entire probe. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-12-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>
10 daysKVM: arm64: gic-v5: Introduce guest IST alloc and managementSascha Bischoff
GICv5 guests use Interrupt State Tables (ISTs) to track and manage the interrupt state for SPIs and LPIs. These ISTs are provided to the host's IRS via the VMTE. On a host GICv5 system, SPIs do not require any up-front memory allocation prior to their use, unlike LPIs which require the OS to allocate an IST. For a GICv5 guest, the same holds from the guest's point of view: SPIs should require no explicit memory allocation by the guest. This means that KVM must provision the memory passed to the IRS for managing a guest's SPI state. Introduce the machinery needed to allocate a linear SPI IST. A later commit will allocate it as part of VM creation, before running the guest for the first time. The host is responsible for freeing this memory on guest teardown. For LPIs, the guest provisions memory for its LPI IST. KVM does not pass that memory directly to the host IRS. Instead, add support for allocating a shadow LPI IST and passing that to the IRS through the VMTE. The LPI IST may be allocated as a two-level structure when supported and required by the configured LPI ID space, as many more LPIs are expected than SPIs. The host frees this memory on guest teardown. Assigning an IST to a VM requires an IRS operation rather than writing the Valid bit directly in the VMTE. Extend the doorbell command interface with the operations needed to make SPI and LPI ISTs valid or invalid. Together with the existing VMT commands, the command set is: VMT_L2_MAP - Make a second level VM table valid VMTE_MAKE_VALID - Make a single VMTE, and hence VM, valid VMTE_MAKE_INVALID - Make a single VMTE, and hence VM, invalid SPI_VIST_MAKE_VALID - Make the SPI IST valid LPI_VIST_MAKE_VALID - Make the LPI IST valid LPI_VIST_MAKE_INVALID - Make the LPI IST invalid Once implemented, irq_set_vcpu_affinity() will act as an ioctl-like interface for issuing commands specific to either a VM or the particular VPE that the doorbell belongs to. None of these commands are plumbed through to the host IRS at this stage. There is intentionally no SPI_VIST_MAKE_INVALID command. The SPI IST will be allocated as part of VM creation and will remain valid for the lifetime of the VM. It can be freed after the VMTE has been made invalid during teardown. The LPI IST, on the other hand, is driven by the guest, which is free to invalidate and free its LPI IST at any point. Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com> Link: https://patch.msgid.link/20260904113404.4051341-11-sascha.bischoff@arm.com Signed-off-by: Marc Zyngier <maz@kernel.org>