|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 00/17] [RISC-V] virtual interrupt controller (vAPLIC/vIMSIC) support
Hi all,
This series adds the initial virtual interrupt controller (vINTC) support
for RISC-V guests in Xen, based on the Advanced Interrupt Architecture
(AIA): a virtual APLIC (vAPLIC) in MSI mode backed by a virtual IMSIC
(vIMSIC) using hardware guest interrupt files.
Rather than emulating APLIC in direct-delivery mode (which requires
trap-and-emulate for every interrupt and is costly), the series targets
IMSIC from the start. AIA lets a hart implement several "guest interrupt
files" (up to GEILEN), so external interrupts can be delivered to a vCPU
directly by hardware via the VGEIN field of hstatus, without a hypervisor
round-trip. Xen only has to emulate the APLIC MMIO programming interface
and route the guest's intent onto the physical MSI topology; interrupt
delivery itself stays in hardware.
The work breaks down into a few logical blocks:
Physical APLIC/AIA groundwork (patches 1-3)
- Correctly track IRQ_DISABLED across runtime enable/disable and order
the ->status update against the IMSIC CSR write.
- Per-pCPU VGEIN (guest interrupt file) allocator: assign/release a
hardware guest file to a vCPU and program hstatus.VGEIN.
- Add the missing APLIC register offsets/masks needed by both the
physical and virtual APLIC code (no functional change).
Device-agnostic MMIO dispatch + vAPLIC emulation (patches 4-5)
- A per-domain MMIO handler table modelled on Arm's framework, so
emulated devices self-register their GPA ranges and the fault path
stays agnostic via a single try_handle_mmio() entry point.
- vAPLIC MMIO read/write emulation. Writes are gated by the domain's
authorised-IRQ bitmap so a guest cannot touch interrupts it does not
own, and TARGET writes are translated from virtual to physical
hart/guest-file indices. Delegation (SOURCECFG.D) is not yet
supported.
vIMSIC guest interrupt files and state (patches 6-9)
- Stage-2 map a vCPU's physical guest interrupt file to the fixed
per-vCPU GPA page the guest expects at offset 0.
- vcpu_aia_init(): assign a VGEIN, map its guest file and record the
IMSIC state as a consistent unit.
- IMSIC state save/restore (currently tracking which pCPU owns the
guest file, needed because the pCPU id is part of the MSI address).
- has_msi_support() helper to decide whether IMSIC state has to be
saved/restored.
vINTC state save/restore plumbing (patches 10-11)
- vintc_state_{save,restore}() wrappers over new store/restore hooks in
struct vintc_ops, and the vAPLIC implementation of those hooks. No
callers are wired up yet; the context-switch calls arrive with vCPU
context switch support.
Trap and instruction emulation infrastructure (patches 12-17)
- Extend the exception-table format with type/data fields and add
EX_TYPE_TRAP_INFO so fixups can capture sepc/scause/stval.
- riscv_vcpu_unpriv_read() (HLV/HLVX) to read guest memory/instructions
safely, and riscv_vcpu_trap_redirect() to forward a synchronous trap
back into the guest's VS-mode handler.
- A guest page-fault handler that decodes the trapped load/store
instruction (HTINST, or an unprivileged fetch as a fallback) and
dispatches the MMIO access through try_handle_mmio().
Note on versioning: the series is posted as v1 as a freshly split-out
series, but several patches carry v2/v3 changelogs because they were
previously circulated as part of a larger another patches [1] from which the
current depends.
CI tests: https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/2690874319
[1]
https://lore.kernel.org/xen-devel/cover.1784559209.git.oleksii.kurochko@xxxxxxxxx/T/#t
Oleksii Kurochko (17):
xen/riscv: manage IRQ_DISABLED flag in APLIC irq enable/disable
callbacks
xen/riscv: add basic VGEIN management for AIA guests
xen/riscv: add missing APLIC register offsets, masks to asm/aplic.h
xen/riscv: introduce device-agnostic MMIO emulation dispatch
xen/riscv: implement virtual APLIC MMIO emulation
xen/riscv: map IMSIC interrupt file for vCPUs
xen/riscv: introduce vCPU AIA initialization
xen/riscv: add IMSIC state save/restore
xen/riscv: add helper to check APLIC MSI mode
xen/riscv: introduce vintc_state_{save,restore}()
xen/riscv: add vAPLIC state save/restore hooks
xen/riscv: extend exception tables with type and data fields
xen/riscv: add unprivileged guest memory read helper
xen/riscv: add guest page fault handling stub
xen/riscv: implement trap redirection to a guest
xen/riscv: add guest load emulation for trapped MMIO accesses
xen/riscv: add guest store emulation for trapped MMIO accesses
xen/arch/riscv/Makefile | 1 +
xen/arch/riscv/aia.c | 175 ++++++++++++
xen/arch/riscv/aplic-priv.h | 2 +
xen/arch/riscv/aplic.c | 83 +++++-
xen/arch/riscv/domain.c | 4 +
xen/arch/riscv/extable.c | 60 +++-
xen/arch/riscv/guestcopy.c | 145 ++++++++++
xen/arch/riscv/imsic.c | 99 +++++++
xen/arch/riscv/include/asm/aia.h | 10 +
xen/arch/riscv/include/asm/aplic.h | 61 +++++
xen/arch/riscv/include/asm/domain.h | 3 +
xen/arch/riscv/include/asm/extable.h | 62 +++--
xen/arch/riscv/include/asm/gpr-num.h | 33 +++
xen/arch/riscv/include/asm/guest_access.h | 8 +
xen/arch/riscv/include/asm/imsic.h | 17 ++
xen/arch/riscv/include/asm/intc.h | 9 +
xen/arch/riscv/include/asm/mmio.h | 63 +++++
xen/arch/riscv/include/asm/processor.h | 2 +
xen/arch/riscv/include/asm/traps.h | 12 +
xen/arch/riscv/include/asm/vaplic.h | 6 +
xen/arch/riscv/intc.c | 14 +
xen/arch/riscv/mmio.c | 145 ++++++++++
xen/arch/riscv/traps.c | 279 +++++++++++++++++++
xen/arch/riscv/vaplic.c | 319 ++++++++++++++++++++++
24 files changed, 1590 insertions(+), 22 deletions(-)
create mode 100644 xen/arch/riscv/include/asm/gpr-num.h
create mode 100644 xen/arch/riscv/include/asm/mmio.h
create mode 100644 xen/arch/riscv/mmio.c
--
2.54.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |