aboutsummaryrefslogtreecommitdiffstats
path: root/executor/test_linux.h
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@linux.ibm.com>2020-11-19 21:01:35 +1100
committerDmitry Vyukov <dvyukov@google.com>2020-11-20 15:31:42 +0100
commit680688040fc26d17a49a9663fbbd6a716c6247b6 (patch)
tree4cb0e538575460b72864d2e782a77371aa7ec173 /executor/test_linux.h
parente72f8f11e096d36aefc41a35c718dced97c45dea (diff)
pkg/ifuzz/powerpc: add powerpc support
This adds KVM's syz_kvm_setup_cpu pseudo syscall. This adds placeholder for options (none implemented yet). This adds instruction generator for ifuzz; this also adds a few pseudo instructions to simulate super/hyper/ultracalls (a PPC64/pseries platform thing). The insns.go is generated from PowerISA_public.v3.0B.pdf [1] by a horrendous python3 script on top of pdftotext. The ISA covers POWER9 which is the latest available POWER CPU at the moment. The next ISA for POWER10 is quite different and we will deal with it later. The // comment after every instruction is a fixed opcode list for verification purposes. This does not define DecodeExt as there is no obvious replacement of the Intel XED library for POWERPC (gapstone-capstone, later, may be). [1] https://openpowerfoundation.org/?resource_lib=power-isa-version-3-0 Signed-off-by: Alexey Kardashevskiy <aik@linux.ibm.com>
Diffstat (limited to 'executor/test_linux.h')
-rw-r--r--executor/test_linux.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/executor/test_linux.h b/executor/test_linux.h
index fcd8d855e..428fba967 100644
--- a/executor/test_linux.h
+++ b/executor/test_linux.h
@@ -75,11 +75,13 @@ static int test_one(int text_type, const char* text, int text_size, int flags, u
dump_cpu_state(cpufd, (char*)vm_mem);
return 1;
}
+#ifdef GOARCH_amd64
if (check_rax && regs.rax != 0xbadc0de) {
printf("wrong result: rax=0x%llx\n", (long long)regs.rax);
dump_cpu_state(cpufd, (char*)vm_mem);
return 1;
}
+#endif
munmap(vm_mem, vm_mem_size);
munmap(cpu_mem, cpu_mem_size);
close(cpufd);
@@ -108,6 +110,7 @@ static int test_kvm()
const char text8[] = "\x66\xb8\xde\xc0\xad\x0b";
if ((res = test_one(8, text8, sizeof(text8) - 1, 0, KVM_EXIT_HLT, true)))
return res;
+#ifdef GOARCH_amd64
if ((res = test_one(8, text8, sizeof(text8) - 1, KVM_SETUP_VIRT86, KVM_EXIT_SHUTDOWN, true)))
return res;
if ((res = test_one(8, text8, sizeof(text8) - 1, KVM_SETUP_VIRT86 | KVM_SETUP_PAGING, KVM_EXIT_SHUTDOWN, true)))
@@ -161,6 +164,7 @@ static int test_kvm()
if ((res = test_one(32, text_rsm, sizeof(text_rsm) - 1, KVM_SETUP_SMM, KVM_EXIT_HLT, false)))
return res;
}
+#endif
return 0;
}
@@ -179,14 +183,17 @@ static unsigned host_kernel_version()
return major * 100 + minor;
}
+#ifdef GOARCH_amd64
static void dump_seg(const char* name, struct kvm_segment* seg)
{
printf("%s: base=0x%llx limit=0x%x sel=0x%x type=%d p=%d dpl=%d, db=%d s=%d l=%d g=%d\n",
name, seg->base, seg->limit, seg->selector, seg->type, seg->present, seg->dpl, seg->db, seg->s, seg->l, seg->g);
}
+#endif
static void dump_cpu_state(int cpufd, char* vm_mem)
{
+#ifdef GOARCH_amd64
struct kvm_sregs sregs;
if (ioctl(cpufd, KVM_GET_SREGS, &sregs)) {
printf("KVM_GET_SREGS failed (%d)\n", errno);
@@ -219,4 +226,5 @@ static void dump_cpu_state(int cpufd, char* vm_mem)
((long long*)vm_mem)[i], ((long long*)vm_mem)[i + 1], ((long long*)vm_mem)[i + 2], ((long long*)vm_mem)[i + 3]);
}
}
+#endif
}