From 06648d9ccf5ec6f9453ef09b0fdbdebf020ee0f8 Mon Sep 17 00:00:00 2001 From: 6eanut Date: Thu, 8 Jan 2026 10:04:33 +0800 Subject: executor, sys/linux, pkg: enable syz_kvm_setup_cpu for riscv64 This patch implements syz_kvm_setup_cpu for riscv64 architecture. The pseudo-syscall accepts VM fd, vCPU fd, host memory, and guest code as parameters. Additional parameters (ntext, flags, opts, nopt) are included for interface consistency with other architectures but are currently unused on riscv64. Implementation: - Set up guest memory via KVM_SET_USER_MEMORY_REGION - Copy guest code to guest memory - Initialize guest registers to enable code execution in S-mode - Return 0 on success, -1 on failure Testing: A test file syz_kvm_setup_cpu_riscv64 is included in sys/linux/test/ to verify basic functionality. Known limitations: - ifuzz is not yet compatible with riscv64. Temporary workaround: set text[riscv64] to TextTarget and return nil in createTargetIfuzzConfig for riscv64 to ensure generateText and mutateText work correctly. This patch also adds support for KVM_GET_ONE_REG ioctl. --- sys/linux/dev_kvm_riscv64.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sys/linux/dev_kvm_riscv64.txt') diff --git a/sys/linux/dev_kvm_riscv64.txt b/sys/linux/dev_kvm_riscv64.txt index 1079853a7..c6ecde793 100644 --- a/sys/linux/dev_kvm_riscv64.txt +++ b/sys/linux/dev_kvm_riscv64.txt @@ -12,3 +12,22 @@ ioctl$KVM_SET_GUEST_DEBUG_riscv64(fd fd_kvmcpu, cmd const[KVM_SET_GUEST_DEBUG], kvm_guest_debug_arch_riscv64 { reg array[int64, 8] } + +syz_kvm_setup_cpu$riscv64(fd fd_kvmvm, cpufd fd_kvmcpu, usermem vma[24], text ptr[in, array[kvm_text_riscv64, 1]], ntext len[text], flags const[0], opts ptr[in, array[kvm_setup_opt_riscv64, 1]], nopt len[opts]) + +kvm_setup_opt_riscv64 [ +# unions need at least 2 fields, but we have only 1 now, but we want to have it as union for future extention + featur1 kvm_setup_opt_riscv64_feature + featur2 kvm_setup_opt_riscv64_feature +] + +kvm_setup_opt_riscv64_feature { + typ const[1, int64] + val int64 +} + +kvm_text_riscv64 { + typ const[0, intptr] + text ptr[in, text[riscv64]] + size len[text, intptr] +} -- cgit mrf-deployment