diff options
| author | 6eanut <jiakaiPeanut@gmail.com> | 2026-01-08 10:04:33 +0800 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2026-01-20 09:02:10 +0000 |
| commit | 06648d9ccf5ec6f9453ef09b0fdbdebf020ee0f8 (patch) | |
| tree | 870fdbadb35555247853ecb3ae94a400b36d077c /pkg | |
| parent | 300ecf9e8fcda4e7a0cef8249ca1d6d1394ca4f1 (diff) | |
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.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/compiler/types.go | 4 | ||||
| -rw-r--r-- | pkg/vminfo/linux_syscalls.go | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index e022efafe..86876b69d 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -641,7 +641,7 @@ var typeText = &typeDesc{ var typeArgTextType = &typeArg{ Kind: kindIdent, - Names: []string{"target", "x86_real", "x86_16", "x86_32", "x86_64", "arm64", "ppc64"}, + Names: []string{"target", "x86_real", "x86_16", "x86_32", "x86_64", "arm64", "ppc64", "riscv64"}, } func genTextType(t *ast.Type) prog.TextKind { @@ -660,6 +660,8 @@ func genTextType(t *ast.Type) prog.TextKind { return prog.TextArm64 case "ppc64": return prog.TextPpc64 + case "riscv64": + return prog.TextTarget default: panic(fmt.Sprintf("unknown text type %q", t.Ident)) } diff --git a/pkg/vminfo/linux_syscalls.go b/pkg/vminfo/linux_syscalls.go index 605b939d2..11a7b9ddd 100644 --- a/pkg/vminfo/linux_syscalls.go +++ b/pkg/vminfo/linux_syscalls.go @@ -192,6 +192,10 @@ func linuxSyzKvmSupported(ctx *checkContext, call *prog.Syscall) string { if ctx.target.Arch == targets.ARM64 { return "" } + case "syz_kvm_setup_cpu$riscv64": + if ctx.target.Arch == targets.RiscV64 { + return "" + } case "syz_kvm_setup_cpu$ppc64": if ctx.target.Arch == targets.PPC64LE { return "" |
