aboutsummaryrefslogtreecommitdiffstats
path: root/executor/kvm_gen.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-01-08 17:20:32 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-01-09 20:28:10 +0100
commitbbd4840872f70e3342308c6965ab196ed2606af1 (patch)
tree519ebfa1fbd6cafadd2efd1038e0c8f869ff37eb /executor/kvm_gen.cc
parentc377a6514d9a4858e818e6d4637870bab2da6370 (diff)
sys: extend kvm support
Add new pseudo syscall syz_kvm_setup_cpu that setups VCPU into interesting states for execution. KVM is too difficult to setup otherwise. Lots of improvements possible, but this is a starting point.
Diffstat (limited to 'executor/kvm_gen.cc')
-rw-r--r--executor/kvm_gen.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/executor/kvm_gen.cc b/executor/kvm_gen.cc
new file mode 100644
index 000000000..5290bd2e7
--- /dev/null
+++ b/executor/kvm_gen.cc
@@ -0,0 +1,33 @@
+// Copyright 2017 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+// +build
+
+#include <stdio.h>
+
+#define PRINT(x) \
+ extern const unsigned char x[], x##_end[]; \
+ print(#x, x, x##_end);
+
+void print(const char* name, const unsigned char* start, const unsigned char* end)
+{
+ printf("const char %s[] = \"", name);
+ for (const unsigned char* p = start; p < end; p++)
+ printf("\\x%02x", *p);
+ printf("\";\n");
+}
+
+int main()
+{
+ printf("// AUTOGENERATED FILE\n");
+ PRINT(kvm_asm16_cpl3);
+ PRINT(kvm_asm32_paged);
+ PRINT(kvm_asm32_vm86);
+ PRINT(kvm_asm32_paged_vm86);
+ PRINT(kvm_asm64_vm86);
+ PRINT(kvm_asm64_enable_long);
+ PRINT(kvm_asm64_init_vm);
+ PRINT(kvm_asm64_vm_exit);
+ PRINT(kvm_asm64_cpl3);
+ return 0;
+}