From 3611c0a0c1166f09038ed05f21dbbec8f2e29834 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Wed, 21 Jul 2021 21:36:40 +1000 Subject: executor/common_kvm_ppc64: enable nested KVM This is necessary to make KVM actually execute the instructions. Signed-off-by: Alexey Kardashevskiy --- executor/common_kvm_ppc64.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'executor') diff --git a/executor/common_kvm_ppc64.h b/executor/common_kvm_ppc64.h index 283824b43..26ccc118d 100644 --- a/executor/common_kvm_ppc64.h +++ b/executor/common_kvm_ppc64.h @@ -84,6 +84,10 @@ struct kvm_ppc_mmuv3_cfg { #define KVM_PPC_MMUV3_GTSE 2 // global translation shootdown enb #endif +#ifndef KVM_CAP_PPC_NESTED_HV +#define KVM_CAP_PPC_NESTED_HV 160 +#endif + struct kvm_text { uintptr_t typ; const void* text; @@ -122,6 +126,16 @@ static int kvm_vcpu_enable_cap(int cpufd, uint32 capability) return ioctl(cpufd, KVM_ENABLE_CAP, &cap); } +static int kvm_vm_enable_cap(int vmfd, uint32 capability, uint64 p1, uint64 p2) +{ + struct kvm_enable_cap cap = { + .cap = capability, + .flags = 0, + .args = {p1, p2}, + }; + return ioctl(vmfd, KVM_ENABLE_CAP, &cap); +} + static void dump_text(const char* mem, unsigned start, unsigned cw, uint32 debug_inst_opcode) { #ifdef DEBUG @@ -171,6 +185,9 @@ static volatile long syz_kvm_setup_cpu(volatile long a0, volatile long a1, volat if (kvm_vcpu_enable_cap(cpufd, KVM_CAP_PPC_PAPR)) return -1; + if (kvm_vm_enable_cap(vmfd, KVM_CAP_PPC_NESTED_HV, true, 0)) + return -1; + for (uintptr_t i = 0; i < guest_mem_size / page_size; i++) { struct kvm_userspace_memory_region memreg; memreg.slot = i; -- cgit mrf-deployment