Skip to content

Commit 60a07d4

Browse files
committed
Merge tag 'pull-riscv-to-apply-20241220' of https://github.com/alistair23/qemu into staging
RISC-V PR for 10.0 * Correct the validness check of iova * Fix APLIC in_clrip and clripnum write emulation * Support riscv-iommu-sys device * Add Tenstorrent Ascalon CPU * Add AIA userspace irqchip_split support * Add Microblaze V generic board * Upgrade ACPI SPCR table to support SPCR table revision 4 format * Remove tswap64() calls from HTIF * Support 64-bit address of initrd * Introduce svukte ISA extension * Support ssstateen extension * Support for RV64 Xiangshan Nanhu CPU # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEaukCtqfKh31tZZKWr3yVEwxTgBMFAmdkzjgACgkQr3yVEwxT # gBOcyA//e0XhAQciQglCZZCfINdOyI8qSh+P2K0qtrXZ4VERHEMp7UoD5CQr2cZv # h8ij1EkatXCwukVELx0rNckxG33bEFgG1oESnQSrwGE0Iu4csNW24nK5WlUS0/r+ # A5oD2wtzEF+cbhTKrVSDBN/PvlnWTKGEoJRkuXWfz5d4uR9eyQhfED0S2j36lNEC # X1x/OZoKM89XuXtOFe9g55Z5UNzAatcdTISozL0FydiPh7QeVjTLHh28/tt559MX # 7v5aJFlQuZ78z1mIHkZmPSorSrJ0zqhkP6NWe1ae06oMgzwRQQhYLppDILV4ZgUF # 3mSDRoXmBycQXiYNPcHep3LdXfvxr+PpWHSevx8gH1jwm93On7Y/H7Uol6TDXzfC # mrFjalfV5tzrD90ZvB+s5bCMF1q5Z8Dlj0pYF9aN9P1ILoWy3dndFAPJB6uKKDP7 # Qd4qOQ3dVyHAX9jLmVkB6QvAV/vTDrYTsAxaF/EaoLOy0IoKhjTvgda3XzE1MFKA # gVafLluADIfSEdqa2QR2ExL8d1SZVoiObCp5TMLRer0HIpg/vQZwjfdbo4BgQKL3 # 7Q6wBxcZUNqrFgspXjm5WFIrdk2rfS/79OmvpNM6SZaK6BnklntdJHJHtAWujGsm # EM310AUFpHMp2h6Nqnemb3qr5l4d20KSt8DhoPAUq1IE59Kb8XY= # =0iQW # -----END PGP SIGNATURE----- # gpg: Signature made Thu 19 Dec 2024 20:54:00 EST # gpg: using RSA key 6AE902B6A7CA877D6D659296AF7C95130C538013 # gpg: Good signature from "Alistair Francis <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6AE9 02B6 A7CA 877D 6D65 9296 AF7C 9513 0C53 8013 * tag 'pull-riscv-to-apply-20241220' of https://github.com/alistair23/qemu: (39 commits) target/riscv: add support for RV64 Xiangshan Nanhu CPU target/riscv: add ssstateen target/riscv/tcg: hide warn for named feats when disabling via priv_ver target/riscv: Include missing headers in 'internals.h' target/riscv: Include missing headers in 'vector_internals.h' target/riscv: Check svukte is not enabled in RV32 target/riscv: Expose svukte ISA extension target/riscv: Check memory access to meet svukte rule target/riscv: Support hstatus[HUKTE] bit when svukte extension is enabled target/riscv: Support senvcfg[UKTE] bit when svukte extension is enabled target/riscv: Add svukte extension capability variable hw/riscv: Add the checking if DTB overlaps to kernel or initrd hw/riscv: Add a new struct RISCVBootInfo hw/riscv: Support to load DTB after 3GB memory on 64-bit system. hw/char/riscv_htif: Clarify MemoryRegionOps expect 32-bit accesses hw/char/riscv_htif: Explicit little-endian implementation MAINTAINERS: Cover RISC-V HTIF interface tests/qtest/bios-tables-test: Update virt SPCR golden reference for RISC-V hw/acpi: Upgrade ACPI SPCR table to support SPCR table revision 4 format qtest: allow SPCR acpi table changes ... Conflicts: target/riscv/cpu.c Merge conflict with DEFINE_PROP_END_OF_LIST() removal. No Property array terminator is needed anymore. Signed-off-by: Stefan Hajnoczi <[email protected]>
2 parents e3a2077 + 2fc8f50 commit 60a07d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1380
-177
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,10 @@ S: Supported
324324
F: configs/targets/riscv*
325325
F: docs/system/target-riscv.rst
326326
F: target/riscv/
327+
F: hw/char/riscv_htif.c
327328
F: hw/riscv/
328329
F: hw/intc/riscv*
330+
F: include/hw/char/riscv_htif.h
329331
F: include/hw/riscv/
330332
F: linux-user/host/riscv32/
331333
F: linux-user/host/riscv64/
@@ -1626,6 +1628,12 @@ F: docs/system/riscv/sifive_u.rst
16261628
F: hw/*/*sifive*.c
16271629
F: include/hw/*/*sifive*.h
16281630

1631+
AMD Microblaze-V Generic Board
1632+
M: Sai Pavan Boddu <[email protected]>
1633+
S: Maintained
1634+
F: hw/riscv/microblaze-v-generic.c
1635+
F: docs/system/riscv/microblaze-v-generic.rst
1636+
16291637
RX Machines
16301638
-----------
16311639
rx-gdbsim

docs/specs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ guest hardware that is specific to QEMU.
3737
rapl-msr
3838
rocker
3939
riscv-iommu
40+
riscv-aia

docs/specs/riscv-aia.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. _riscv-aia:
2+
3+
RISC-V AIA support for RISC-V machines
4+
======================================
5+
6+
AIA (Advanced Interrupt Architecture) support is implemented in the ``virt``
7+
RISC-V machine for TCG and KVM accelerators.
8+
9+
The support consists of two main modes:
10+
11+
- "aia=aplic": adds one or more APLIC (Advanced Platform Level Interrupt Controller)
12+
devices
13+
- "aia=aplic-imsic": adds one or more APLIC device and an IMSIC (Incoming MSI
14+
Controller) device for each CPU
15+
16+
From an user standpoint, these modes will behave the same regardless of the accelerator
17+
used. From a developer standpoint the accelerator settings will change what it being
18+
emulated in userspace versus what is being emulated by an in-kernel irqchip.
19+
20+
When running TCG, all controllers are emulated in userspace, including machine mode
21+
(m-mode) APLIC and IMSIC (when applicable).
22+
23+
When running KVM:
24+
25+
- no m-mode is provided, so there is no m-mode APLIC or IMSIC emulation regardless of
26+
the AIA mode chosen
27+
- with "aia=aplic", s-mode APLIC will be emulated by userspace
28+
- with "aia=aplic-imsic" there are two possibilities. If no additional KVM option
29+
is provided there will be no APLIC or IMSIC emulation in userspace, and the virtual
30+
machine will use the provided in-kernel APLIC and IMSIC controllers. If the user
31+
chooses to use the irqchip in split mode via "-accel kvm,kernel-irqchip=split",
32+
s-mode APLIC will be emulated while using the s-mode IMSIC from the irqchip
33+
34+
The following table summarizes how the AIA and accelerator options defines what
35+
we will emulate in userspace:
36+
37+
38+
.. list-table:: How AIA and accel options changes controller emulation
39+
:widths: 25 25 25 25 25 25 25
40+
:header-rows: 1
41+
42+
* - Accel
43+
- Accel props
44+
- AIA type
45+
- APLIC m-mode
46+
- IMSIC m-mode
47+
- APLIC s-mode
48+
- IMSIC s-mode
49+
* - tcg
50+
- ---
51+
- aplic
52+
- emul
53+
- n/a
54+
- emul
55+
- n/a
56+
* - tcg
57+
- ---
58+
- aplic-imsic
59+
- emul
60+
- emul
61+
- emul
62+
- emul
63+
* - kvm
64+
- ---
65+
- aplic
66+
- n/a
67+
- n/a
68+
- emul
69+
- n/a
70+
* - kvm
71+
- none
72+
- aplic-imsic
73+
- n/a
74+
- n/a
75+
- in-kernel
76+
- in-kernel
77+
* - kvm
78+
- irqchip=split
79+
- aplic-imsic
80+
- n/a
81+
- n/a
82+
- emul
83+
- in-kernel

docs/specs/riscv-iommu.rst

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ RISC-V IOMMU support for RISC-V machines
66
QEMU implements a RISC-V IOMMU emulation based on the RISC-V IOMMU spec
77
version 1.0 `iommu1.0`_.
88

9-
The emulation includes a PCI reference device, riscv-iommu-pci, that QEMU
10-
RISC-V boards can use. The 'virt' RISC-V machine is compatible with this
11-
device.
9+
The emulation includes a PCI reference device (riscv-iommu-pci) and a platform
10+
bus device (riscv-iommu-sys) that QEMU RISC-V boards can use. The 'virt'
11+
RISC-V machine is compatible with both devices.
1212

1313
riscv-iommu-pci reference device
1414
--------------------------------
@@ -83,6 +83,30 @@ Several options are available to control the capabilities of the device, namely:
8383
- "s-stage": enable s-stage support
8484
- "g-stage": enable g-stage support
8585

86+
riscv-iommu-sys device
87+
----------------------
88+
89+
This device implements the RISC-V IOMMU emulation as a platform bus device that
90+
RISC-V boards can use.
91+
92+
For the 'virt' board the device is disabled by default. To enable it use the
93+
'iommu-sys' machine option:
94+
95+
.. code-block:: bash
96+
97+
$ qemu-system-riscv64 -M virt,iommu-sys=on (...)
98+
99+
There is no options to configure the capabilities of this device in the 'virt'
100+
board using the QEMU command line. The device is configured with the following
101+
riscv-iommu options:
102+
103+
- "ioatc-limit": default value (2Mb)
104+
- "intremap": enabled
105+
- "ats": enabled
106+
- "off": on (DMA disabled)
107+
- "s-stage": enabled
108+
- "g-stage": enabled
109+
86110
.. _iommu1.0: https://github.com/riscv-non-isa/riscv-iommu/releases/download/v1.0/riscv-iommu.pdf
87111

88112
.. _linux-v8: https://lore.kernel.org/linux-riscv/[email protected]/
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Microblaze-V generic board (``amd-microblaze-v-generic``)
2+
=========================================================
3+
The AMD MicroBlaze™ V processor is a soft-core RISC-V processor IP for AMD
4+
adaptive SoCs and FPGAs. The MicroBlaze™ V processor is based on the 32-bit (or
5+
64-bit) RISC-V instruction set architecture (ISA) and contains interfaces
6+
compatible with the classic MicroBlaze™ V processor (i.e it is a drop in
7+
replacement for the classic MicroBlaze™ processor in existing RTL designs).
8+
More information can be found in below document.
9+
10+
https://docs.amd.com/r/en-US/ug1629-microblaze-v-user-guide/MicroBlaze-V-Architecture
11+
12+
The MicroBlaze™ V generic board in QEMU has following supported devices:
13+
14+
- timer
15+
- uartlite
16+
- uart16550
17+
- emaclite
18+
- timer2
19+
- axi emac
20+
- axi dma
21+
22+
The MicroBlaze™ V core in QEMU has the following configuration:
23+
24+
- RV32I base integer instruction set
25+
- "Zicsr" Control and Status register instructions
26+
- "Zifencei" instruction-fetch
27+
- Extensions: m, a, f, c
28+
29+
Running
30+
"""""""
31+
Below is an example command line for launching mainline U-boot
32+
(xilinx_mbv32_defconfig) on the Microblaze-V generic board.
33+
34+
.. code-block:: bash
35+
36+
$ qemu-system-riscv32 -M amd-microblaze-v-generic \
37+
-display none \
38+
-device loader,addr=0x80000000,file=u-boot-spl.bin,cpu-num=0 \
39+
-device loader,addr=0x80200000,file=u-boot.img \
40+
-serial mon:stdio \
41+
-device loader,addr=0x83000000,file=system.dtb \
42+
-m 2g

docs/system/riscv/virt.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ command line:
9494
9595
$ qemu-system-riscv64 -M virt -device riscv-iommu-pci (...)
9696
97+
It also has support for the riscv-iommu-sys platform device:
98+
99+
.. code-block:: bash
100+
101+
$ qemu-system-riscv64 -M virt,iommu-sys=on (...)
102+
97103
Refer to :ref:`riscv-iommu` for more information on how the RISC-V IOMMU support
98104
works.
99105

@@ -123,12 +129,23 @@ The following machine-specific options are supported:
123129
MSIs. When not specified, this option is assumed to be "none" which selects
124130
SiFive PLIC to handle wired interrupts.
125131

132+
This option also interacts with '-accel kvm'. When using "aia=aplic-imsic"
133+
with KVM, it is possible to set the use of the kernel irqchip in split mode
134+
by using "-accel kvm,kernel-irqchip=split". In this case the ``virt`` machine
135+
will emulate the APLIC controller instead of using the APLIC controller from
136+
the irqchip. See :ref:`riscv-aia` for more details on all available AIA
137+
modes.
138+
126139
- aia-guests=nnn
127140

128141
The number of per-HART VS-level AIA IMSIC pages to be emulated for a guest
129142
having AIA IMSIC (i.e. "aia=aplic-imsic" selected). When not specified,
130143
the default number of per-HART VS-level AIA IMSIC pages is 0.
131144

145+
- iommu-sys=[on|off]
146+
147+
Enables the riscv-iommu-sys platform device. Defaults to 'off'.
148+
132149
Running Linux kernel
133150
--------------------
134151

docs/system/target-riscv.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ undocumented; you can get a complete list by running
6666
.. toctree::
6767
:maxdepth: 1
6868

69+
riscv/microblaze-v-generic
6970
riscv/microchip-icicle-kit
7071
riscv/shakti-c
7172
riscv/sifive_u

hw/acpi/aml-build.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
20782078

20792079
void build_spcr(GArray *table_data, BIOSLinker *linker,
20802080
const AcpiSpcrData *f, const uint8_t rev,
2081-
const char *oem_id, const char *oem_table_id)
2081+
const char *oem_id, const char *oem_table_id, const char *name)
20822082
{
20832083
AcpiTable table = { .sig = "SPCR", .rev = rev, .oem_id = oem_id,
20842084
.oem_table_id = oem_table_id };
@@ -2124,9 +2124,21 @@ void build_spcr(GArray *table_data, BIOSLinker *linker,
21242124
build_append_int_noprefix(table_data, f->pci_flags, 4);
21252125
/* PCI Segment */
21262126
build_append_int_noprefix(table_data, f->pci_segment, 1);
2127-
/* Reserved */
2128-
build_append_int_noprefix(table_data, 0, 4);
2129-
2127+
if (rev < 4) {
2128+
/* Reserved */
2129+
build_append_int_noprefix(table_data, 0, 4);
2130+
} else {
2131+
/* UartClkFreq */
2132+
build_append_int_noprefix(table_data, f->uart_clk_freq, 4);
2133+
/* PreciseBaudrate */
2134+
build_append_int_noprefix(table_data, f->precise_baudrate, 4);
2135+
/* NameSpaceStringLength */
2136+
build_append_int_noprefix(table_data, f->namespace_string_length, 2);
2137+
/* NameSpaceStringOffset */
2138+
build_append_int_noprefix(table_data, f->namespace_string_offset, 2);
2139+
/* NamespaceString[] */
2140+
g_array_append_vals(table_data, name, f->namespace_string_length);
2141+
}
21302142
acpi_table_end(linker, &table);
21312143
}
21322144
/*

hw/arm/virt-acpi-build.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,12 @@ spcr_setup(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
463463
.pci_flags = 0,
464464
.pci_segment = 0,
465465
};
466-
467-
build_spcr(table_data, linker, &serial, 2, vms->oem_id, vms->oem_table_id);
466+
/*
467+
* Passing NULL as the SPCR Table for Revision 2 doesn't support
468+
* NameSpaceString.
469+
*/
470+
build_spcr(table_data, linker, &serial, 2, vms->oem_id, vms->oem_table_id,
471+
NULL);
468472
}
469473

470474
/*

hw/char/riscv_htif.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "qemu/timer.h"
3030
#include "qemu/error-report.h"
3131
#include "exec/address-spaces.h"
32-
#include "exec/tswap.h"
32+
#include "qemu/bswap.h"
3333
#include "sysemu/dma.h"
3434
#include "sysemu/runstate.h"
3535

@@ -212,11 +212,11 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
212212
} else {
213213
uint64_t syscall[8];
214214
cpu_physical_memory_read(payload, syscall, sizeof(syscall));
215-
if (tswap64(syscall[0]) == PK_SYS_WRITE &&
216-
tswap64(syscall[1]) == HTIF_DEV_CONSOLE &&
217-
tswap64(syscall[3]) == HTIF_CONSOLE_CMD_PUTC) {
215+
if (le64_to_cpu(syscall[0]) == PK_SYS_WRITE &&
216+
le64_to_cpu(syscall[1]) == HTIF_DEV_CONSOLE &&
217+
le64_to_cpu(syscall[3]) == HTIF_CONSOLE_CMD_PUTC) {
218218
uint8_t ch;
219-
cpu_physical_memory_read(tswap64(syscall[2]), &ch, 1);
219+
cpu_physical_memory_read(le64_to_cpu(syscall[2]), &ch, 1);
220220
/*
221221
* XXX this blocks entire thread. Rewrite to use
222222
* qemu_chr_fe_write and background I/O callbacks
@@ -324,6 +324,11 @@ static void htif_mm_write(void *opaque, hwaddr addr,
324324
static const MemoryRegionOps htif_mm_ops = {
325325
.read = htif_mm_read,
326326
.write = htif_mm_write,
327+
.endianness = DEVICE_LITTLE_ENDIAN,
328+
.impl = {
329+
.min_access_size = 4,
330+
.max_access_size = 4,
331+
},
327332
};
328333

329334
HTIFState *htif_mm_init(MemoryRegion *address_space, Chardev *chr,

0 commit comments

Comments
 (0)