[PATCH v2 00/12] Introduce Virtual IRQ (VIRQ) framework

Raymond Mao raymondmaoca at gmail.com
Thu Oct 29 08:59:17 PDT 2026


From: Raymond Mao <raymond.mao at riscstar.com>

This series introduces a Virtual IRQ (VIRQ) framework for OpenSBI to
support domain-aware wired interrupt couriering.

The main use case is to let OpenSBI receive a host HWIRQ in M-mode,
map it into a per-channel VIRQ number space, route it to a target
domain, notify the target S-mode payload, and let that payload
claim the pending VIRQs through RPMI SYSTEM_IRQ over SBI MPXY.

The implementation is organized as follows:

  - add RPMI SYSTEM_IRQ service support, including SYSIRQ_CLAIM
  - add an optional experimental Yield ecall for explicit completion
  - add irqchip helpers for S-mode pending notification
  - extend domain context switching to support VIRQ-driven
    cross-domain couriering and return-to-previous-domain flow
  - add the core VIRQ mapping, routing, and per-(domain,hart)
    pending queue framework
  - parse sysirq routing rules from DT under /chosen/opensbi-domains
  - derive APLIC target hart routing from sysirq nodes
  - update the irqchip/APLIC path to support deferred completion and
    per-HWIRQ APLIC targets
  - select domain boot harts before activating physical sources
  - document the DT binding and routing rules

The DT routing model is based on "opensbi,mpxy-sysirq" nodes.
Each interrupts-extended entry contributes one routed physical source,
its entry index becomes the VIRQ number within the selected
opensbi,mpxy-channel-id, and opensbi,domain selects the destination
OpenSBI domain.

Claimed sources remain masked while the payload handles their device
conditions. The next valid CLAIM completes the previous batch, or the
payload can complete it explicitly through Yield. Return to a previously
interrupted domain is deferred until pending and claimed work is drained.
The Yield EID is experimental and is not an official SBI assignment.

This version reuses the existing irqchip infrastructure.

Patch 12 contains sample DT overlays for reference only and is marked
[NOT-FOR-UPSTREAM].

The series are also placed at:
https://gitlab.com/riseproject/riscv-optee/opensbi/-/tree/rp022-m1

Test instructions are available at:
https://riscv-optee-docs-c9fea0.gitlab.io/rp022/milestone1/

Changes in v2:

  - Rebase on master and adapt to its irqchip interfaces, dropping the
    old scratch-local provider lookup workaround.
  - Replace the private VIRQ POP/COMPLETE ecall extension with RPMI
    SYSTEM_IRQ 2.0 services over SBI MPXY, including batched SYSIRQ_CLAIM.
  - Add an optional experimental Yield ecall for explicit completion
    after device handling; retain implicit completion through the next
    valid CLAIM.
  - Track outstanding claims per channel and target, preserve failed
    completions for retry, and block return switches until all pending
    and claimed work is drained.
  - Keep SEPC separate from the M-mode trap frame's MEPC and preserve
    the advanced ecall return state across domain switches.
  - Key routes by (chip_uid, hwirq), allowing identical HWIRQ numbers
    on different physical controllers without routing collisions.
  - Select boot harts during domain finalization and activate couriers
    only after boot-hart selection and all mapping/channel setup.
  - Add irqchip-independent courier registration with DT IRQ flags,
    target affinity and rollback; use APLIC IDC indices for affinity.
  - Reject malformed DT argument lists, extra IRQ specifier cells and
    invalid scalar properties; update the binding documentation.

Raymond Mao (12):
  lib: utils: add RPMI SYSTEM_IRQ service support
  lib: sbi: add experimental Yield ECALL extension
  lib: irqchip: add S-mode notification helpers
  lib: sbi: domain: support VIRQ couriering domain context switch
  lib: sbi: domain: ensure boot_hartid is assigned
  lib: sbi: Add Virtual IRQ (VIRQ) subsystem
  lib: sbi: domain: add domain lookup by name
  lib: utils: irqchip: derive APLIC targets from sysirq nodes
  lib: utils: irqchip: Add helper to register VIRQ courier handler
  lib: utils: fdt: parse sysirq routing from DT
  docs: domain: document sysirq VIRQ mapping and routing rules
  [NOT-FOR-UPSTREAM] platform: generic: Add sample dts overlays for
    testing hwirq/domain route rules

 docs/domain_support.md                        |   55 +
 include/sbi/sbi_domain.h                      |    7 +
 include/sbi/sbi_domain_context.h              |   24 +
 include/sbi/sbi_ecall_interface.h             |    6 +
 include/sbi/sbi_irqchip.h                     |    9 +
 include/sbi/sbi_virq.h                        |  513 +++++++
 include/sbi_utils/fdt/fdt_helper.h            |    8 +
 include/sbi_utils/irqchip/aplic.h             |    4 +
 include/sbi_utils/mailbox/rpmi_msgprot.h      |   25 +
 include/sbi_utils/sysirq/rpmi_sysirq.h        |   30 +
 lib/sbi/Kconfig                               |    9 +
 lib/sbi/objects.mk                            |    4 +
 lib/sbi/sbi_domain.c                          |   61 +
 lib/sbi/sbi_domain_context.c                  |  130 +-
 lib/sbi/sbi_ecall_yield.c                     |   42 +
 lib/sbi/sbi_irqchip.c                         |   21 +-
 lib/sbi/sbi_trap.c                            |   11 +
 lib/sbi/sbi_virq.c                            | 1235 +++++++++++++++++
 lib/utils/fdt/fdt_domain.c                    |  116 +-
 lib/utils/fdt/fdt_helper.c                    |   57 +-
 lib/utils/irqchip/aplic.c                     |   57 +-
 lib/utils/irqchip/fdt_irqchip_aplic.c         |  103 ++
 lib/utils/mpxy/objects.mk                     |    2 +
 lib/utils/sysirq/rpmi_sysirq.c                |  266 ++++
 platform/generic/virt/hwirq_bind_domain.dts   |  107 ++
 .../virt/hwirq_bind_domain_linux_bmapp.dts    |  125 ++
 26 files changed, 3017 insertions(+), 10 deletions(-)
 create mode 100644 include/sbi/sbi_virq.h
 create mode 100644 include/sbi_utils/sysirq/rpmi_sysirq.h
 create mode 100644 lib/sbi/sbi_ecall_yield.c
 create mode 100644 lib/sbi/sbi_virq.c
 create mode 100644 lib/utils/sysirq/rpmi_sysirq.c
 create mode 100644 platform/generic/virt/hwirq_bind_domain.dts
 create mode 100644 platform/generic/virt/hwirq_bind_domain_linux_bmapp.dts

-- 
2.25.1




More information about the opensbi mailing list