All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Romain Caritey" <Romain.Caritey@microchip.com>,
	"Baptiste Le Duc" <baptiste.le-duc@vates.tech>,
	"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Connor Davis" <connojdavis@gmail.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH v1 00/17] [RISC-V] virtual interrupt controller (vAPLIC/vIMSIC) support
Date: Mon, 20 Jul 2026 18:01:58 +0200	[thread overview]
Message-ID: <cover.1784560663.git.oleksii.kurochko@gmail.com> (raw)

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@gmail.com/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



             reply	other threads:[~2026-07-20 16:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 16:01 Oleksii Kurochko [this message]
2026-07-20 16:01 ` [PATCH v1 01/17] xen/riscv: manage IRQ_DISABLED flag in APLIC irq enable/disable callbacks Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 02/17] xen/riscv: add basic VGEIN management for AIA guests Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 03/17] xen/riscv: add missing APLIC register offsets, masks to asm/aplic.h Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 04/17] xen/riscv: introduce device-agnostic MMIO emulation dispatch Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 05/17] xen/riscv: implement virtual APLIC MMIO emulation Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 06/17] xen/riscv: map IMSIC interrupt file for vCPUs Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 07/17] xen/riscv: introduce vCPU AIA initialization Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 08/17] xen/riscv: add IMSIC state save/restore Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 09/17] xen/riscv: add helper to check APLIC MSI mode Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 10/17] xen/riscv: introduce vintc_state_{save,restore}() Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 11/17] xen/riscv: add vAPLIC state save/restore hooks Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 12/17] xen/riscv: extend exception tables with type and data fields Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 13/17] xen/riscv: add unprivileged guest memory read helper Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 14/17] xen/riscv: add guest page fault handling stub Oleksii Kurochko
2026-07-20 16:02 ` [PATCH v1 15/17] xen/riscv: implement trap redirection to a guest Oleksii Kurochko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1784560663.git.oleksii.kurochko@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=Romain.Caritey@microchip.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=baptiste.le-duc@vates.tech \
    --cc=connojdavis@gmail.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.