diff options
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_kvm_riscv64.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/executor/common_kvm_riscv64.h b/executor/common_kvm_riscv64.h index dcccd6dad..500240638 100644 --- a/executor/common_kvm_riscv64.h +++ b/executor/common_kvm_riscv64.h @@ -12,6 +12,7 @@ #include <string.h> #include <sys/ioctl.h> +#if SYZ_EXECUTOR || __NR_syz_kvm_setup_cpu struct kvm_text { uintptr_t type; const void* text; @@ -153,5 +154,25 @@ static volatile long syz_kvm_setup_cpu(volatile long a0, volatile long a1, volat return 0; } +#endif + +#if SYZ_EXECUTOR || __NR_syz_kvm_assert_reg +static long syz_kvm_assert_reg(volatile long a0, volatile long a1, volatile long a2) +{ + int vcpu_fd = (int)a0; + uint64 id = (uint64)a1; + uint64 expect = a2, val = 0; + + struct kvm_one_reg reg = {.id = id, .addr = (uint64)&val}; + int ret = ioctl(vcpu_fd, KVM_GET_ONE_REG, ®); + if (ret) + return ret; + if (val != expect) { + errno = EDOM; + return -1; + } + return 0; +} +#endif #endif // EXECUTOR_COMMON_KVM_RISCV64_H
\ No newline at end of file |
