From 1d642d39cfd613af7c293460ecc2afd9f85f612f Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 13 May 2026 12:38:59 +1000 Subject: [PATCH 1/4] MAINTAINERS: Mark Microchip PolarFire SoC as Odd Fixes Mark the "Microchip PolarFire SoC Icicle Kit" as Odd Fixes and enlist Conor and Sebastian as people to help deal with the fixes. Acked-by: Conor Dooley Acked-by: Sebastian Huber Signed-off-by: Alistair Francis Message-ID: <20260513023859.518484-1-alistair.francis@wdc.com> Signed-off-by: Alistair Francis --- MAINTAINERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index e25df9493c..611845c626 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1760,8 +1760,10 @@ F: target/riscv/xlrbr.decode F: tests/tcg/riscv64/test-crc32.S Microchip PolarFire SoC Icicle Kit +M: Conor Dooley +M: Sebastian Huber L: qemu-riscv@nongnu.org -S: Supported +S: Odd Fixes F: docs/system/riscv/microchip-icicle-kit.rst F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c From ae06586a025afe1929dce5e7c92fe278811c515d Mon Sep 17 00:00:00 2001 From: Yanfeng Liu Date: Sun, 12 Jul 2026 16:45:53 +0800 Subject: [PATCH 2/4] uftrace: riscv privilege level This adds RiscV virtual user and supervisor privilege levels to uftrace plugin to avoid crashing with H extension guests. Signed-off-by: Yanfeng Liu Reviewed-by: Alistair Francis Message-ID: Signed-off-by: Alistair Francis --- contrib/plugins/uftrace.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index 9b0a4963ae..063e32220b 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -109,6 +109,8 @@ typedef enum { RISCV64_SUPERVISOR, RISCV64_RESERVED, RISCV64_MACHINE, + RISCV64_VUSER, + RISCV64_VSUPERVISOR, RISCV64_PRIVILEGE_LEVEL_MAX, } Riscv64PrivilegeLevel; @@ -153,8 +155,10 @@ static void uftrace_write_map(bool system_emulation) const char *path = "./uftrace.data/sid-0.map"; if (system_emulation && access(path, F_OK) == 0) { - /* do not erase existing map in system emulation, as a custom one might - * already have been generated by uftrace_symbols.py */ + /* + * do not erase existing map in system emulation, as a custom one might + * already have been generated by uftrace_symbols.py + */ return; } @@ -706,6 +710,8 @@ static const char *riscv64_get_privilege_level_name(uint8_t pl) case RISCV64_SUPERVISOR: return "Supervisor"; case RISCV64_RESERVED: return "Unknown"; case RISCV64_MACHINE: return "Machine"; + case RISCV64_VUSER: return "VUser"; + case RISCV64_VSUPERVISOR: return "VSupervisor"; default: g_assert_not_reached(); } @@ -986,7 +992,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, score = qemu_plugin_scoreboard_new(sizeof(Cpu)); qemu_plugin_register_vcpu_init_cb(id, vcpu_init, NULL); - qemu_plugin_register_atexit_cb(id, at_exit, (void *) info->system_emulation); + qemu_plugin_register_atexit_cb(id, at_exit, + (void *) info->system_emulation); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans, NULL); return 0; From a539bb911ee1085c69ce00781acd2f13bd3cb82b Mon Sep 17 00:00:00 2001 From: Junze Cao Date: Sat, 11 Jul 2026 20:53:20 +0800 Subject: [PATCH 3/4] tests/functional/riscv64: Add K230 Linux boot tests The K230 machine supports direct Linux boot and firmware boot through the SDK U-Boot, but neither path has functional test coverage. Add one test for each boot path. Both tests use the Yocto initramfs assets and wait for the shell prompt to confirm a successful boot. Fetch the boot assets from the k230-boot-assets repository maintained by Chao Liu. Pin the URLs to a repository commit and verify each asset with its SHA-256 digest. Signed-off-by: Junze Cao Reviewed-by: Alistair Francis Message-ID: <20260711125320.72319-1-caojunze424@gmail.com> Signed-off-by: Alistair Francis --- MAINTAINERS | 1 + tests/functional/riscv64/meson.build | 2 + tests/functional/riscv64/test_k230.py | 108 ++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100755 tests/functional/riscv64/test_k230.py diff --git a/MAINTAINERS b/MAINTAINERS index 611845c626..6bab70a7fa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1830,6 +1830,7 @@ F: hw/riscv/k230.c F: hw/watchdog/k230_wdt.c F: include/hw/riscv/k230.h F: include/hw/watchdog/k230_wdt.h +F: tests/functional/riscv64/test_k230.py F: tests/qtest/k230-wdt-test.c RX Machines diff --git a/tests/functional/riscv64/meson.build b/tests/functional/riscv64/meson.build index c9d4c090fb..d1a3e6c2bf 100644 --- a/tests/functional/riscv64/meson.build +++ b/tests/functional/riscv64/meson.build @@ -2,6 +2,7 @@ test_riscv64_timeouts = { 'boston' : 120, + 'k230' : 120, 'tuxrun' : 120, } @@ -13,6 +14,7 @@ tests_riscv64_system_quick = [ tests_riscv64_system_thorough = [ 'endianness', 'boston', + 'k230', 'sifive_u', 'tt_atlantis', 'tuxrun', diff --git a/tests/functional/riscv64/test_k230.py b/tests/functional/riscv64/test_k230.py new file mode 100755 index 0000000000..6ccbf2d581 --- /dev/null +++ b/tests/functional/riscv64/test_k230.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +# +# Functional tests that boot Linux on a Kendryte K230 machine. +# +# The direct boot test lets QEMU load OpenSBI, Linux, the device tree, and the +# initramfs. The firmware boot test starts the K230 SDK U-Boot and uses bootm +# to launch OpenSBI and Linux from images preloaded into RAM. +# +# Author: +# Junze Cao +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os + +from qemu_test import Asset, LinuxKernelTest +from qemu_test import exec_command_and_wait_for_pattern +from qemu_test import interrupt_interactive_console_until_pattern + + +class K230Machine(LinuxKernelTest): + + ASSET_KERNEL = Asset( + ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/' + 'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/' + 'yocto/direct-boot/Image'), + '3a44970213fa68ad318d308518adfc0bf4bee72ed1b2926f9b468f82ef7d7829') + ASSET_DTB = Asset( + ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/' + 'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/' + 'yocto/direct-boot/k230-canmv.dtb'), + '5050240b48ce0988c73eaefa73e4945a40abca503cf488d22a3adf6ef50bbe4c') + ASSET_INITRD = Asset( + ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/' + 'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/' + 'yocto/direct-boot/rootfs.cpio.gz'), + '4e1869a99a232ee60324f71f3a9e84a79b03ccabb5b73f8a727c5ff5be5c0914') + ASSET_UBOOT = Asset( + ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/' + 'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/common/u-boot'), + '0915b9a92a7c911846a8cf691866ef14ef050a51d04209f884ae8e9ec33f36d2') + ASSET_FW_JUMP = Asset( + ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/' + 'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/' + 'common/fw_jump.uImage'), + 'cf7788e470f1d6e8c85491ecdc2705518db1b6af54080e8c7a3464bad0d902b7') + + def wait_for_linux_shell(self): + self.wait_for_console_pattern('meta-k230 initramfs starting...') + self.wait_for_console_pattern('~ #') + + def test_k230_direct_boot(self): + self.set_machine('k230') + kernel_path = self.ASSET_KERNEL.fetch() + dtb_path = self.ASSET_DTB.fetch() + initrd_path = self.ASSET_INITRD.fetch() + + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-initrd', initrd_path, + '-append', 'console=ttyS0,115200 earlycon=sbi', + '-no-reboot') + self.vm.launch() + self.wait_for_linux_shell() + + def test_k230_uboot_boot(self): + self.set_machine('k230') + kernel_path = self.ASSET_KERNEL.fetch() + dtb_path = self.ASSET_DTB.fetch() + initrd_path = self.ASSET_INITRD.fetch() + uboot_path = self.ASSET_UBOOT.fetch() + fw_jump_path = self.ASSET_FW_JUMP.fetch() + initrd_end = 0x0a100000 + os.path.getsize(initrd_path) + + self.vm.set_console() + self.vm.add_args( + '-bios', uboot_path, + '-device', + f'loader,file={fw_jump_path},addr=0xc100000,force-raw=on', + '-device', + f'loader,file={kernel_path},addr=0x8200000,force-raw=on', + '-device', + f'loader,file={initrd_path},addr=0xa100000,force-raw=on', + '-device', + f'loader,file={dtb_path},addr=0xa000000,force-raw=on', + '-no-reboot') + self.vm.launch() + + interrupt_interactive_console_until_pattern(self, 'K230#') + commands = ( + 'setenv bootargs console=ttyS0,115200 earlycon=sbi', + 'fdt addr 0xa000000', + 'fdt resize 8192', + 'fdt set /chosen linux,initrd-start <0x0 0xa100000>', + f'fdt set /chosen linux,initrd-end <0x0 0x{initrd_end:x}>', + ) + for command in commands: + exec_command_and_wait_for_pattern(self, command, 'K230#') + + exec_command_and_wait_for_pattern( + self, 'bootm 0xc100000 - 0xa000000', + 'Starting kernel ...', failure_message='ERROR') + self.wait_for_linux_shell() + + +if __name__ == '__main__': + LinuxKernelTest.main() From 8fb307591625731060d399aca42373c02c7cb040 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 13 Jul 2026 20:02:44 +0800 Subject: [PATCH 4/4] tests/functional/riscv64: sifive_u: Fix kernel command line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build the complete kernel command line before adding it to the QEMU arguments. This ensures the panic, noreboot and rootwait options are passed to the guest. Fixes: 7db162fa0138 ("tests/functional: Test SPI-SD adapter without SD card connected") Signed-off-by: Bin Meng Reviewed-by: Chao Liu Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20260713120245.781959-1-bin.meng@processmission.com> Signed-off-by: Alistair Francis --- tests/functional/riscv64/test_sifive_u.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/riscv64/test_sifive_u.py b/tests/functional/riscv64/test_sifive_u.py index 847f709da1..54a0f9c648 100755 --- a/tests/functional/riscv64/test_sifive_u.py +++ b/tests/functional/riscv64/test_sifive_u.py @@ -35,9 +35,6 @@ def do_test_riscv64_sifive_u_mmc_spi(self, connect_card): kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'earlycon=sbi console=ttySIF0 ' 'root=/dev/mmcblk0 ') - self.vm.add_args('-kernel', kernel_path, - '-append', kernel_command_line, - '-no-reboot') if connect_card: kernel_command_line += 'panic=-1 noreboot rootwait ' self.vm.add_args('-drive', f'file={rootfs_path},if=sd,format=raw') @@ -46,6 +43,9 @@ def do_test_riscv64_sifive_u_mmc_spi(self, connect_card): kernel_command_line += 'panic=0 noreboot ' pattern = 'Cannot open root device "mmcblk0" or unknown-block(0,0)' + self.vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line, + '-no-reboot') self.vm.launch() self.wait_for_console_pattern(pattern)