Repository navigation
Commit cd5805d
committed
cca-irq: add initial GICv3 delivery for timer, SGI, and SPI
Add the initial ARM GICv3 interrupt-delivery framework for CCA lower
planes. Route virtual timer PPIs, self-generated SGIs, and shared SPIs
through a partition-owned GIC model and inject eligible interrupts
through the RMM GIC list registers.
Previously, CCA IRQ exits were only logged, trapped GIC accesses did not
provide a complete interrupt path, and local interrupt sources could be
inserted into an LR without respecting the guest-programmed GIC enable
and priority state.
CCA interrupt injection
-----------------------
Add a common CCA virtual-interrupt representation containing an INTID,
priority, group, and pending state.
Preserve the GIC list registers returned by the RMM and inject pending
software-backed Group 1 interrupts into the first free LR. Avoid adding
a duplicate LR when the same INTID is already pending or active.
Enable ICH_HCR_EL2.TC for plane entry and encode software LRs with:
* the virtual INTID in bits 31:0
* the guest-programmed priority in bits 55:48
* Group 1 in bit 60
* HW clear in bit 61
* Pending state in bits 63:62
Leave EOI-maintenance disabled because the CCA backend does not yet
implement the GIC maintenance-interrupt path.
Use an invalid exit-reason sentinel to distinguish a real plane exit
from a host wakeup, and preserve the RMM-returned plane and LR context
before processing the exit.
Virtual timer PPI
-----------------
Handle PlaneExitReason::Irq and recognize an asserted architectural
virtual timer from the RMM-provided CNTV_CTL_EL0 state.
Request the timer PPI only when:
* ENABLE is set
* IMASK is clear
* ISTATUS is set
Obtain the virtual timer INTID from ProcessorTopology instead of
hardcoding PPI 20. This is required because the RMM timer exit reports
the timer source but does not provide an INTID.
Queue the timer as a private interrupt and pass it through the shared
GIC redistributor selection path before LR injection. Delivery therefore
now observes:
* distributor Group 1 enable
* GICR_IGROUPR0
* GICR_ISENABLER0
* GICR active state
* the PPI priority programmed through GICR_IPRIORITYR
* the priority threshold programmed through ICC_PMR_EL1
Decode trapped ICC_PMR_EL1 writes and retain the current priority mask
for each CCA VTL. This fixes timer PPIs bypassing guest GIC enable and
priority configuration.
SGI
---
Decode synchronous ICC_SGI1R_EL1 system-register traps and queue the
requested self-SGI rather than injecting it directly.
Advance the lower-plane PC after emulating ICC_SGI1R_EL1 and
ICC_PMR_EL1 writes so that the trapped instruction is not executed
again after re-entry.
Route queued SGIs through the same private-interrupt selection used by
PPIs. SGI delivery therefore also observes the redistributor enable,
Group 1, active, programmed priority, and ICC_PMR_EL1 state.
Add a TMK self-SGI test using INTID 5 and the Group 1 system-register
interface.
SPI
---
Create a partition-owned GicV3Model for CCA and expose it to the VP
runner so that device interrupt assertion, CCA interrupt polling, and
guest GIC MMIO emulation operate on the same state.
Implement the CCA ControlGic::set_spi_irq path. Record the device line
level, determine the target VPs from GICD_IROUTER state, and wake those
VPs through the interrupt-controller wake reason when a line is newly
asserted.
Track SPI state independently as:
* software pending state
* external line assertion level
* active state
* LR/in-flight ownership
Select a shared interrupt only when it is pending or asserted, enabled,
assigned to Group 1, inactive, routed to the current VP, not already in
flight, and has a priority that passes ICC_PMR_EL1.
Preserve an edge-triggered SPI request after the source line falls by
latching it in the pending state until successful LR injection.
Preserve the asserted state of a level-triggered SPI after injection.
When the RMM retires its LR, clear only the in-flight ownership. If the
device line remains asserted, make the SPI eligible for injection again.
Stop redelivery only after the device deasserts the line.
This fixes level-triggered SPIs being lost after their first injection
and EOI.
Support guest software pending and clearing through GICD_ISPENDR and
GICD_ICPENDR. Deasserting a device line does not clear an independently
created software-pending request.
GIC model and TMK support
-------------------------
Extend the reusable GICv3 model with the distributor and redistributor
state needed by the CCA paths, including:
* Group 1 distributor enable
* interrupt group and enable state
* pending, active, and trigger configuration
* per-INTID priorities
* SPI routing
* GICR SGI/PPI enable, group, pending, active, and priority state
* priority-based private and shared interrupt selection
* MMIO reads and writes for the supported GICD/GICR registers
Define a common TMK AArch64 platform layout:
* GICD at 0xff00_0000
* GICR at 0xff02_0000
* virtual timer PPI 20
* 256 exposed INTIDs: SGI 0-15, PPI 16-31, and SPI 32-255
Add minimal EL1 IRQ support to tmk_core:
* install an aligned VBAR_EL1 exception-vector table
* save and restore registers around IRQ handling
* provide scoped IRQ callback registration
* configure GIC Group 1, interrupt enable, and priority state
* program ICC_SRE_EL1, ICC_PMR_EL1, and ICC_IGRPEN1_EL1
* acknowledge through ICC_IAR1_EL1
* complete through ICC_EOIR1_EL1
* mask and unmask IRQs through DAIF
* provide virtual timer, self-SGI, and software-pending SPI helpers
Route TMK GIC MMIO accesses to the same partition GicV3Model used by
the CCA VP. Add tests for:
* architectural virtual timer PPI delivery
* self-targeted SGI delivery
* software-pended SPI 32 delivery
* level-triggered SPI redelivery until deassertion
* edge-triggered SPI pending latching
* preservation of software-pending state across line deassertion
* SGI/PPI enable and priority filtering
Correct the RSI plane-exit layout so the timer state starts at its
ABI-defined 0x400 offset and assert the resulting structure offsets
and sizes.
Known limitations
-----------------
This is an initial CCA IRQ implementation, not a complete GICv3
implementation.
* PlaneExitReason::Irq currently recognizes only the architectural
virtual timer. PMU, physical timer, and other local PPI sources are
not identified or mapped.
* SGI support is limited to the single-VP/self-target test path. Full
ICC_SGI1R_EL1 affinity routing, target lists, broadcast behavior, and
multi-VP delivery are not implemented or validated.
* The SPI end-to-end test uses GICD_ISPENDR to create a software-pending
SPI. It does not validate a real emulated device asserting and
deasserting ControlGic::set_spi_irq through the complete device/VMM/
Realm path.
* Level- and edge-triggered device SPI behavior is covered by GIC model
unit tests, but still needs end-to-end device validation, including
routing, VP wakeup, EOI/LR retirement, and repeated level delivery.
* The TMK platform currently creates one VP and exposes only INTIDs
0-255. INTIDs 256-1019 are not implemented by this test platform.
* Only the GIC register subset required by the current tests is
implemented. Group 0, complete security-state behavior, ITS/MSI/LPI,
and full architectural GICv3 semantics are not supported.
* LR allocation is first-free. There is no LR eviction, maintenance
interrupt handling, or complete priority-preemption model.
* Private pending storage is bounded, and running-priority, binary-point,
and nested-interrupt behavior are not fully modeled.
* GIC EOI-maintenance events, cross-VTL interrupts, and the CCA
untrusted-SynIC interrupt path remain unimplemented.
* MMIO polling in the TMK tests is a workaround for current RMM/FVP
notification behavior rather than the final asynchronous delivery
mechanism.
* Unsupported CCA IRQ sources are traced and ignored, while unsupported
system-register traps terminate the VP.
* The current CCA backend supports only a single auxiliary plane; multiple
planes and switching between them are not yet supported.
IRQ tests
---------
Add TMK tests covering the initial CCA interrupt-delivery paths:
* Virtual timer PPI: program CNTV_CVAL_EL0, wait for virtual timer PPI 20,
verify delivery through the GIC, and disable the timer in the IRQ handler.
* Self-targeted SGI: generate Group 1 SGI 5 through ICC_SGI1R_EL1 and verify
that it is delivered to the current VP.
* Software-pended SPI: set SPI 32 pending through GICD_ISPENDR and verify
delivery through the distributor and GIC list-register path.
Install the CCA emulation environment once with:
cargo xflowey cca-tests --install-emu
Build and run the CCA runtime test, including these TMK IRQ tests, with:
cargo xflowey cca-tests
To build the test artifacts without running the emulator, use:
cargo xflowey cca-tests --build-only
Note taht "Software-pended SPI” is intentionally precise: this test does not
exercise a real emulated device asserting an SPI line.
Test results
------------
INFO test: test passed, name: "aarch64::irq::virtual_timer_irq"
INFO test: test passed, name: "aarch64::irq::spi_self_pending_irq"
INFO test: test passed, name: "aarch64::irq::sgi_self_irq"
Signed-off-by: Wei Ding <b-weiding@microsoft.com>
Signed-off-by: Ben Aram <b-bearam@microsoft.com>
Signed-off-by: Jiong Wang <b-jiongwang@microsoft.com>1 parent a908f3f commit cd5805d
14 files changed
Lines changed: 1775 additions & 44 deletions
File tree
- openhcl/virt_mshv_vtl
- src
- processor/cca
- tmk
- simple_tmk/src/aarch64
- tmk_core/src
- tmk_protocol/src
- tmk_vmm
- src
- vmm_core/virt_support_gic/src
- vm/aarch64/aarch64defs/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8383 | 8383 | | |
8384 | 8384 | | |
8385 | 8385 | | |
| 8386 | + | |
8386 | 8387 | | |
8387 | 8388 | | |
8388 | 8389 | | |
| |||
8408 | 8409 | | |
8409 | 8410 | | |
8410 | 8411 | | |
| 8412 | + | |
8411 | 8413 | | |
8412 | 8414 | | |
8413 | 8415 | | |
| |||
9665 | 9667 | | |
9666 | 9668 | | |
9667 | 9669 | | |
| 9670 | + | |
9668 | 9671 | | |
9669 | 9672 | | |
9670 | 9673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
157 | 162 | | |
158 | 163 | | |
159 | 164 | | |
| |||
292 | 297 | | |
293 | 298 | | |
294 | 299 | | |
295 | | - | |
296 | | - | |
297 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
| |||
494 | 500 | | |
495 | 501 | | |
496 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
497 | 506 | | |
498 | 507 | | |
499 | 508 | | |
| |||
651 | 660 | | |
652 | 661 | | |
653 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
654 | 682 | | |
655 | 683 | | |
656 | 684 | | |
| |||
705 | 733 | | |
706 | 734 | | |
707 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
708 | 745 | | |
709 | 746 | | |
710 | 747 | | |
| |||
836 | 873 | | |
837 | 874 | | |
838 | 875 | | |
839 | | - | |
840 | 876 | | |
841 | 877 | | |
842 | 878 | | |
| |||
2355 | 2391 | | |
2356 | 2392 | | |
2357 | 2393 | | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
2358 | 2397 | | |
2359 | 2398 | | |
2360 | 2399 | | |
| |||
2381 | 2420 | | |
2382 | 2421 | | |
2383 | 2422 | | |
| 2423 | + | |
| 2424 | + | |
2384 | 2425 | | |
2385 | 2426 | | |
2386 | 2427 | | |
| |||
0 commit comments