diff options
| author | Alexey Kardashevskiy <aik@linux.ibm.com> | 2021-07-21 21:36:40 +1000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-09-16 21:37:48 +0200 |
| commit | 3611c0a0c1166f09038ed05f21dbbec8f2e29834 (patch) | |
| tree | 2c84d902eb65a119c2d2cfc955316d45041dcbc7 /executor | |
| parent | aae492f20ef39f5f5e91c82092156d458f000d3d (diff) | |
executor/common_kvm_ppc64: enable nested KVM
This is necessary to make KVM actually execute the instructions.
Signed-off-by: Alexey Kardashevskiy <aik@linux.ibm.com>
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_kvm_ppc64.h | 17 |
1 files changed, 17 insertions, 0 deletions
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; |
