Add support for generating OpenSBI domains in the device tree
Subsystems (2)
v5 cover Add support for generating OpenSBI domains in the device tree
Apologies for the double-email, forgot to run checkpatch ...
This patch series adds support for specifying OpenSBI domains on the QEMU command line. A simple example of what this looks like is included in the documentation changes included in this series, along with detailed information on each option to each of the new flags.
v5:
- Add missing Signed-off-by line in the documentation commit
v4:
- Added license comments to the top of each new file
- Made id mandatory for OpenSBI domains
- Added documentation
v3:
- Addressed review comments from v2 by adding default values to new properties. This results in concrete errors at QEMU configuration time if a mandatory property (as mandated by the OpenSBI spec) is not provided.
- Changed command line encoding for the possible-harts field from a CPU bitmask (e.g. where bit X is set if CPU X is a possible hart) to a range format (e.g. the possible harts should be CPUs X-Y, where Y >= X). This does constrain the hart assignment to consecutive ranges of harts, but this constraint is also present for other QEMU subsystems (such as NUMA).
- Added create_fdt_one_device(), which is invoked when scanning the device tree for a memregion's devices. This function allocates a phandle for a region's device if one does not yet exist.
v2:
- Addressed review comments from v1. Specifically, renamed domain.{c,h} -> opensbi_domain.{c,h} to increase clarity of what these files do. Also, more consistently use g_autofree for dynamically allocated variables
- Added an "assign" flag to OpenSBIDomainState, which indicates whether to assign the domain's boot hart to it at domain parsing time.
Gregor Haas (2):
hw/riscv: Add support for generating OpenSBI domains in the device
tree
docs/system/riscv: Add documentation for command-line OpenSBI domains
MAINTAINERS | 8 + docs/system/riscv/opensbi_domains.rst | 156 +++++++ docs/system/target-riscv.rst | 10 + hw/riscv/Kconfig | 4 + hw/riscv/meson.build | 1 + hw/riscv/opensbi_domain.c | 558 ++++++++++++++++++++++++++ hw/riscv/virt.c | 3 + include/hw/riscv/opensbi_domain.h | 69 ++++ 8 files changed, 809 insertions(+) create mode 100644 docs/system/riscv/opensbi_domains.rst create mode 100644 hw/riscv/opensbi_domain.c create mode 100644 include/hw/riscv/opensbi_domain.h
Signature · 1 line
2.46.0
PATCH v5 1/2 hw/riscv: Add support for generating OpenSBI domains in the device tree
OpenSBI has support for domains, which are partitions of CPUs and memory into isolated compartments. Domains can be specified in the device tree according to a standardized format [1], which OpenSBI parses at boot time to initialize all system domains. This patch enables simply specifying domains (and their associated memory regions) on the QEMU command line, from which these are then rendered into the machine's device tree.
At machine initialization time, a new create_fdt_opensbi_domains() function walks the peripherals/peripherals-anon containers, identifies all domains and memregions, and parses them into the relevant device tree structures.
[1] https://github.com/riscv-software-src/opensbi/blob/master/docs/domain_support.md
--- MAINTAINERS | 7 + hw/riscv/Kconfig | 4 + hw/riscv/meson.build | 1 + hw/riscv/opensbi_domain.c | 558 ++++++++++++++++++++++++++++++ hw/riscv/virt.c | 3 + include/hw/riscv/opensbi_domain.h | 69 ++++ 6 files changed, 642 insertions(+) create mode 100644 hw/riscv/opensbi_domain.c create mode 100644 include/hw/riscv/opensbi_domain.h
MAINTAINERS +7 -0
@@ -357,6 +357,13 @@ F: target/riscv/XVentanaCondOps.decode F: target/riscv/insn_trans/trans_xventanacondops.c.inc F: disas/riscv-xventana* +RISC-V OpenSBI domain support +M: Gregor Haas <[email protected]> +L: [email protected] +S: Maintained +F: hw/riscv/opensbi_domain.c +F: include/hw/riscv/opensbi_domain.h + RENESAS RX CPUs R: Yoshinori Sato <[email protected]> S: Orphan
hw/riscv/Kconfig +4 -0
@@ -1,6 +1,9 @@ config RISCV_NUMA bool +config RISCV_OPENSBI_DOMAIN + bool + config IBEX bool
@@ -40,6 +43,7 @@ config RISCV_VIRT imply TPM_TIS_SYSBUS select DEVICE_TREE select RISCV_NUMA + select RISCV_OPENSBI_DOMAIN select GOLDFISH_RTC select PCI select PCI_EXPRESS_GENERIC_BRIDGE
hw/riscv/meson.build +1 -0
@@ -1,6 +1,7 @@ riscv_ss = ss.source_set() riscv_ss.add(files('boot.c')) riscv_ss.add(when: 'CONFIG_RISCV_NUMA', if_true: files('numa.c')) +riscv_ss.add(when: 'CONFIG_RISCV_OPENSBI_DOMAIN', if_true: files('opensbi_domain.c')) riscv_ss.add(files('riscv_hart.c')) riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c')) riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
hw/riscv/opensbi_domain.c new file +558 -0
558 lines not on this page · raw message
hw/riscv/virt.c +3 -0
@@ -55,6 +55,7 @@#include "hw/acpi/aml-build.h" #include "qapi/qapi-visit-common.h" #include "hw/virtio/virtio-iommu.h" +#include "hw/riscv/opensbi_domain.h" /* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */ static bool virt_use_kvm_aia (RISCVVirtState *s)
@@ -1050,6 +1051,8 @@ static void finalize_fdt(RISCVVirtState *s)create_fdt_uart (s, virt_memmap, irq_mmio_phandle);create_fdt_rtc (s, virt_memmap, irq_mmio_phandle); + +create_fdt_opensbi_domains (MACHINE (s)); }static void create_fdt (RISCVVirtState *s,const MemMapEntry *memmap)
include/hw/riscv/opensbi_domain.h new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
2.46.0
PATCH v5 2/2 docs/system/riscv: Add documentation for command-line OpenSBI domains
In reply to Gregor Haas--- MAINTAINERS | 1 + docs/system/riscv/opensbi_domains.rst | 156 ++++++++++++++++++++++++++ docs/system/target-riscv.rst | 10 ++ 3 files changed, 167 insertions(+) create mode 100644 docs/system/riscv/opensbi_domains.rst
MAINTAINERS +1 -0
@@ -361,6 +361,7 @@ RISC-V OpenSBI domain support M: Gregor Haas <[email protected]> L: [email protected] S: Maintained +F: docs/system/riscv/opensbi_domains.rst F: hw/riscv/opensbi_domain.c F: include/hw/riscv/opensbi_domain.h
docs/system/riscv/opensbi_domains.rst new file +156 -0
156 lines not on this page · raw message
docs/system/target-riscv.rst +10 -0
@@ -92,3 +92,13 @@ the images they need. * ``-bios <file>`` Tells QEMU to load the specified file as the firmware. + +RISC-V Devices +-------------- + +There are some RISC-V specific devices that can be specified: + +.. toctree:: + :maxdepth: 1 + + riscv/opensbi_domains
Signature · 1 line
2.46.0