Skip to content

Commit e240f6c

Browse files
committed
Merge tag 'pull-riscv-to-apply-20250704' of https://github.com/alistair23/qemu into staging
Second RISC-V PR for 10.1 * sstc extension fixes * Fix zama16b order in isa_edata_arr * Profile handling fixes * Extend PMP region up to 64 * Remove capital 'Z' CPU properties * Add missing named features * Support atomic instruction fetch (Ziccif) * Add max_satp_mode from host cpu * Extend and configure PMP region count * Fix PPN field of Translation-reponse register * Use qemu_chr_fe_write_all() in DBCN_CONSOLE_WRITE_BYTE * Fix fcvt.s.bf16 NaN box checking * Avoid infinite delay of async xmit function * Device tree reg cleanups * Add Kunminghu CPU and platform * Fix missing exit TB flow for ldff_trans * Fix migration failure when aia is configured as aplic-imsic * Fix MEPC/SEPC bit masking for IALIGN * Add a property to set vill bit on reserved usage of vsetvli instruction * Add Svrsw60t59b extension support # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCgAdFiEEaukCtqfKh31tZZKWr3yVEwxTgBMFAmhntt4ACgkQr3yVEwxT # gBMaCQ/9E+LeRY59nz3K3XXUw6XLBfaDECXbKzIn0GM1yXeWTX4dB2h2hoGWdu3R # CRPxWHECN7CeJhd2J23eLfOi+fTUeppJBeR7TcGyoXVC+y0knZv/clQ3OvMFYcgV # xjzzu1yipQlXwY+kmDZ6qL5up/Q+faw7tRaePZaJheRGYpVRnjoKUZq5fe4Ug4RU # Xg6Di86eYyk+Jo0g2exvtzy1rX2eBp7Hz200wWiH5Z1B+3NzgMUHrHuJfNAz8zAt # n8uvruvaLGGtWcQJauRXlAELR6k9tmkfq1Mbqf3FK6muaQCtFD7PXXnjL/rU/z20 # hhxj0psOhBJLd0W5wQ3vLnDf6Wve9zmUdTR9kI0Kt3xUUdfeBuzKcU06F/G8wEsZ # 2sIYQqt0mxoJboY2lpje7TO4H9gvAf76WBOV10FV2gWsqWu2rZQ6herdq3YZYkHX # purUTgyjHn4jl2Y3Kzj0Gq1SHo0yaA/sD6xNR8X+JqljSruDxtOFU7wkKBbewoIg # OSfwemjRUVsPQZ958042ntwJt81v1604Oky8JSFr5eCFx/aoLJ1vDYh7BKZAogNH # uB/YigGq9+/MVzqJpZI+kZkd+1nzaizeL0FUPRTq0jFA2u+vc3J3svQ/jNXDH2c+ # 5nGuhbkvT0ptmVMBqFV2vjPh6+ScR8t03wHdQ4PmDoXC3o9zbbU= # =CfRy # -----END PGP SIGNATURE----- # gpg: Signature made Fri 04 Jul 2025 07:11:26 EDT # gpg: using RSA key 6AE902B6A7CA877D6D659296AF7C95130C538013 # gpg: Good signature from "Alistair Francis <alistair@alistair23.me>" [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-20250704' of https://github.com/alistair23/qemu: (40 commits) target: riscv: Add Svrsw60t59b extension support target/riscv: Add a property to set vill bit on reserved usage of vsetvli instruction tests/tcg/riscv64: Add test for MEPC bit masking target/riscv: Fix MEPC/SEPC bit masking for IALIGN migration: Fix migration failure when aia is configured as aplic-imsic target/riscv: rvv: Fix missing exit TB flow for ldff_trans hw/riscv: Initial support for BOSC's Xiangshan Kunminghu FPGA prototype target/riscv: Add BOSC's Xiangshan Kunminghu CPU hw/riscv/virt: Use setprop_sized_cells for pcie hw/riscv/virt: Use setprop_sized_cells for iommu hw/riscv/virt: Use setprop_sized_cells for rtc hw/riscv/virt: Use setprop_sized_cells for uart hw/riscv/virt: Use setprop_sized_cells for reset hw/riscv/virt: Use setprop_sized_cells for virtio hw/riscv/virt: Use setprop_sized_cells for plic hw/riscv/virt: Use setprop_sized_cells for aclint hw/riscv/virt: Use setprop_sized_cells for aplic hw/riscv/virt: Use setprop_sized_cells for memory hw/riscv/virt: Use setprop_sized_cells for clint hw/riscv/virt: Fix clint base address type ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 parents 989dd90 + dc8bffc commit e240f6c

39 files changed

+1151
-212
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,13 @@ S: Maintained
17011701
F: hw/riscv/microblaze-v-generic.c
17021702
F: docs/system/riscv/microblaze-v-generic.rst
17031703

1704+
Xiangshan Kunminghu
1705+
M: Ran Wang <wangran@bosc.ac.cn>
1706+
S: Maintained
1707+
F: docs/system/riscv/xiangshan-kunminghu.rst
1708+
F: hw/riscv/xiangshan_kmh.c
1709+
F: include/hw/riscv/xiangshan_kmh.h
1710+
17041711
RX Machines
17051712
-----------
17061713
rx-gdbsim

configs/devices/riscv64-softmmu/default.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
# CONFIG_RISCV_VIRT=n
1212
# CONFIG_MICROCHIP_PFSOC=n
1313
# CONFIG_SHAKTI_C=n
14+
# CONFIG_XIANGSHAN_KUNMINGHU=n
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
BOSC Xiangshan Kunminghu FPGA prototype platform (``xiangshan-kunminghu``)
2+
==========================================================================
3+
The ``xiangshan-kunminghu`` machine is compatible with our FPGA prototype
4+
platform.
5+
6+
XiangShan is an open-source high-performance RISC-V processor project.
7+
The third generation processor is called Kunminghu. Kunminghu is a 64-bit
8+
RV64GCBSUHV processor core. More information can be found in our Github
9+
repository:
10+
https://github.com/OpenXiangShan/XiangShan
11+
12+
Supported devices
13+
-----------------
14+
The ``xiangshan-kunminghu`` machine supports the following devices:
15+
16+
* Up to 16 xiangshan-kunminghu cores
17+
* Core Local Interruptor (CLINT)
18+
* Incoming MSI Controller (IMSIC)
19+
* Advanced Platform-Level Interrupt Controller (APLIC)
20+
* 1 UART
21+
22+
Boot options
23+
------------
24+
The ``xiangshan-kunminghu`` machine can start using the standard ``-bios``
25+
functionality for loading the boot image. You need to compile and link
26+
the firmware, kernel, and Device Tree (FDT) into a single binary file,
27+
such as ``fw_payload.bin``.
28+
29+
Running
30+
-------
31+
Below is an example command line for running the ``xiangshan-kunminghu``
32+
machine:
33+
34+
.. code-block:: bash
35+
36+
$ qemu-system-riscv64 -machine xiangshan-kunminghu \
37+
-smp 16 -m 16G \
38+
-bios path/to/opensbi/platform/generic/firmware/fw_payload.bin \
39+
-nographic

docs/system/target-riscv.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ undocumented; you can get a complete list by running
7171
riscv/shakti-c
7272
riscv/sifive_u
7373
riscv/virt
74+
riscv/xiangshan-kunminghu
7475

7576
RISC-V CPU firmware
7677
-------------------

hw/char/sifive_uart.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ static void sifive_uart_write_tx_fifo(SiFiveUARTState *s, const uint8_t *buf,
128128
s->txfifo |= SIFIVE_UART_TXFIFO_FULL;
129129
}
130130

131-
timer_mod(s->fifo_trigger_handle, current_time +
132-
TX_INTERRUPT_TRIGGER_DELAY_NS);
131+
if (!timer_pending(s->fifo_trigger_handle)) {
132+
timer_mod(s->fifo_trigger_handle, current_time +
133+
TX_INTERRUPT_TRIGGER_DELAY_NS);
134+
}
133135
}
134136

135137
static uint64_t

hw/intc/riscv_aclint.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "qemu/module.h"
2929
#include "hw/sysbus.h"
3030
#include "target/riscv/cpu.h"
31+
#include "target/riscv/time_helper.h"
3132
#include "hw/qdev-properties.h"
3233
#include "hw/intc/riscv_aclint.h"
3334
#include "qemu/timer.h"
@@ -240,6 +241,10 @@ static void riscv_aclint_mtimer_write(void *opaque, hwaddr addr,
240241
riscv_aclint_mtimer_write_timecmp(mtimer, RISCV_CPU(cpu),
241242
mtimer->hartid_base + i,
242243
mtimer->timecmp[i]);
244+
riscv_timer_write_timecmp(env, env->stimer, env->stimecmp, 0, MIP_STIP);
245+
riscv_timer_write_timecmp(env, env->vstimer, env->vstimecmp,
246+
env->htimedelta, MIP_VSTIP);
247+
243248
}
244249
return;
245250
}

hw/intc/riscv_aplic.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,18 @@ static const Property riscv_aplic_properties[] = {
962962
DEFINE_PROP_BOOL("mmode", RISCVAPLICState, mmode, 0),
963963
};
964964

965+
static bool riscv_aplic_state_needed(void *opaque)
966+
{
967+
RISCVAPLICState *aplic = opaque;
968+
969+
return riscv_use_emulated_aplic(aplic->msimode);
970+
}
971+
965972
static const VMStateDescription vmstate_riscv_aplic = {
966973
.name = "riscv_aplic",
967-
.version_id = 2,
968-
.minimum_version_id = 2,
974+
.version_id = 3,
975+
.minimum_version_id = 3,
976+
.needed = riscv_aplic_state_needed,
969977
.fields = (const VMStateField[]) {
970978
VMSTATE_UINT32(domaincfg, RISCVAPLICState),
971979
VMSTATE_UINT32(mmsicfgaddr, RISCVAPLICState),

hw/intc/riscv_imsic.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,16 @@ static const Property riscv_imsic_properties[] = {
398398
DEFINE_PROP_UINT32("num-irqs", RISCVIMSICState, num_irqs, 0),
399399
};
400400

401+
static bool riscv_imsic_state_needed(void *opaque)
402+
{
403+
return !kvm_irqchip_in_kernel();
404+
}
405+
401406
static const VMStateDescription vmstate_riscv_imsic = {
402407
.name = "riscv_imsic",
403-
.version_id = 1,
404-
.minimum_version_id = 1,
408+
.version_id = 2,
409+
.minimum_version_id = 2,
410+
.needed = riscv_imsic_state_needed,
405411
.fields = (const VMStateField[]) {
406412
VMSTATE_VARRAY_UINT32(eidelivery, RISCVIMSICState,
407413
num_pages, 0,

hw/riscv/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,12 @@ config SPIKE
119119
select HTIF
120120
select RISCV_ACLINT
121121
select SIFIVE_PLIC
122+
123+
config XIANGSHAN_KUNMINGHU
124+
bool
125+
default y
126+
depends on RISCV64
127+
select RISCV_ACLINT
128+
select RISCV_APLIC
129+
select RISCV_IMSIC
130+
select SERIAL_MM

hw/riscv/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ riscv_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c'))
1313
riscv_ss.add(when: 'CONFIG_RISCV_IOMMU', if_true: files(
1414
'riscv-iommu.c', 'riscv-iommu-pci.c', 'riscv-iommu-sys.c', 'riscv-iommu-hpm.c'))
1515
riscv_ss.add(when: 'CONFIG_MICROBLAZE_V', if_true: files('microblaze-v-generic.c'))
16+
riscv_ss.add(when: 'CONFIG_XIANGSHAN_KUNMINGHU', if_true: files('xiangshan_kmh.c'))
1617

1718
hw_arch += {'riscv': riscv_ss}

0 commit comments

Comments
 (0)