From 4760a80fad88909b48c1b60dd8c6d7ba991a2416 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Wed, 14 Jul 2021 15:12:39 +1000 Subject: executor: prepare code generator to allow other achitectures At the moment only AMD64 is supported, change file names to emphasise this. Signed-off-by: Alexey Kardashevskiy --- executor/common_kvm_amd64.h | 2 +- executor/gen.go | 9 -- executor/gen_linux_amd64.go | 7 + executor/kvm.S | 313 -------------------------------------------- executor/kvm.S.h | 9 -- executor/kvm_amd64.S | 313 ++++++++++++++++++++++++++++++++++++++++++++ executor/kvm_amd64.S.h | 9 ++ executor/kvm_gen.cc | 2 + 8 files changed, 332 insertions(+), 332 deletions(-) delete mode 100644 executor/gen.go create mode 100644 executor/gen_linux_amd64.go delete mode 100644 executor/kvm.S delete mode 100644 executor/kvm.S.h create mode 100644 executor/kvm_amd64.S create mode 100644 executor/kvm_amd64.S.h (limited to 'executor') diff --git a/executor/common_kvm_amd64.h b/executor/common_kvm_amd64.h index d959b9615..c327ef4b8 100644 --- a/executor/common_kvm_amd64.h +++ b/executor/common_kvm_amd64.h @@ -7,8 +7,8 @@ // See Intel Software Developer’s Manual Volume 3: System Programming Guide // for details on what happens here. -#include "kvm.S.h" #include "kvm.h" +#include "kvm_amd64.S.h" #ifndef KVM_SMI #define KVM_SMI _IO(KVMIO, 0xb7) diff --git a/executor/gen.go b/executor/gen.go deleted file mode 100644 index 66f3880b2..000000000 --- a/executor/gen.go +++ /dev/null @@ -1,9 +0,0 @@ -// 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. - -//go:build amd64 && !freebsd && !darwin && !openbsd && !netbsd -// +build amd64,!freebsd,!darwin,!openbsd,!netbsd - -//go:generate bash -c "gcc kvm_gen.cc kvm.S -o kvm_gen && ./kvm_gen > kvm.S.h && rm ./kvm_gen" - -package executor diff --git a/executor/gen_linux_amd64.go b/executor/gen_linux_amd64.go new file mode 100644 index 000000000..dd68a198b --- /dev/null +++ b/executor/gen_linux_amd64.go @@ -0,0 +1,7 @@ +// 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. + +// nolint: lll +//go:generate bash -c "gcc -DGOARCH_$GOARCH=1 kvm_gen.cc kvm_amd64.S -o kvm_gen && ./kvm_gen > kvm_amd64.S.h && rm ./kvm_gen" + +package executor diff --git a/executor/kvm.S b/executor/kvm.S deleted file mode 100644 index 1f64e304f..000000000 --- a/executor/kvm.S +++ /dev/null @@ -1,313 +0,0 @@ -// 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. - -// kvm_gen.cc generates machine code from this file and saves it into kvm.S.h. - -// +build - -#include "kvm.h" - -.global kvm_asm64_enable_long, kvm_asm64_enable_long_end -kvm_asm64_enable_long: -.code32 - mov %cr0, %eax - or $0x80000000, %eax - mov %eax, %cr0 - ljmp $SEL_CS64, NEXT_INSN -.code64 - mov $SEL_TSS64, %rax - ltr %ax -kvm_asm64_enable_long_end: - nop - -.global kvm_asm32_paged, kvm_asm32_paged_end -kvm_asm32_paged: -.code32 - mov %cr0, %eax - or $0x80000000, %eax - mov %eax, %cr0 -kvm_asm32_paged_end: - nop - -.global kvm_asm32_vm86, kvm_asm32_vm86_end -kvm_asm32_vm86: -.code32 - mov $SEL_TSS32, %ax - ltr %ax - ljmp $SEL_TSS32_VM86, $0 -kvm_asm32_vm86_end: - nop - -.global kvm_asm32_paged_vm86, kvm_asm32_paged_vm86_end -kvm_asm32_paged_vm86: -.code32 - mov %cr0, %eax - or $0x80000000, %eax - mov %eax, %cr0 - mov $SEL_TSS32, %ax - ltr %ax - ljmp $SEL_TSS32_VM86, $0 -kvm_asm32_paged_vm86_end: - nop - -.global kvm_asm16_cpl3, kvm_asm16_cpl3_end -kvm_asm16_cpl3: -.code16 - mov %cr0, %eax - or $1, %eax - mov %eax, %cr0 - mov $SEL_TSS16, %ax - ltr %ax - mov $SEL_DS16_CPL3, %ax - mov %ax, %ds - mov %ax, %es - mov %ax, %fs - mov %ax, %gs - mov $0x100, %sp - movw $PREFIX_SIZE, 0x100 - movw $SEL_CS16_CPL3, 0x102 - movw $0x100, 0x104 - movw $SEL_DS16_CPL3, 0x106 - lret -kvm_asm16_cpl3_end: - nop - -.global kvm_asm64_cpl3, kvm_asm64_cpl3_end -kvm_asm64_cpl3: -.code32 - mov %cr0, %eax - or $0x80000000, %eax - mov %eax, %cr0 - ljmp $SEL_CS64, NEXT_INSN -.code64 - mov $SEL_TSS64, %rax - ltr %ax - mov $SEL_DS64_CPL3, %rax - mov %ax, %ds - mov %ax, %es - mov %ax, %fs - mov %ax, %gs - mov $ADDR_STACK0, %rsp - movq $PREFIX_SIZE, 0(%rsp) - movq $SEL_CS64_CPL3, 4(%rsp) - movq $ADDR_STACK0, 8(%rsp) - movq $SEL_DS64_CPL3, 12(%rsp) - lret -kvm_asm64_cpl3_end: - nop - -.global kvm_asm64_init_vm, kvm_asm64_init_vm_end -kvm_asm64_init_vm: -.code32 - // CR0.PG = 1 - mov %cr0, %eax - or $0x80000000, %eax - mov %eax, %cr0 - ljmp $SEL_CS64, NEXT_INSN -.code64 - mov $SEL_TSS64, %rax - ltr %ax - - // Enable and lock non-SMM VM - mov $MSR_IA32_FEATURE_CONTROL, %rcx - rdmsr - or $0x5, %rax - wrmsr - - // CR4.VMXE = 1 - mov %cr4, %rax - or $0x2000, %rax - mov %rax, %cr4 - - // Write VMCS revision into VMXON and VMCS regions - mov $MSR_IA32_VMX_BASIC, %rcx - rdmsr - mov $ADDR_VAR_VMXON, %rdx - mov %eax, (%rdx) - mov $ADDR_VAR_VMCS, %rdx - mov %eax, (%rdx) - - mov $ADDR_VAR_VMXON_PTR, %rax - vmxon (%rax) - mov $ADDR_VAR_VMCS_PTR, %rax - vmclear (%rax) - vmptrld (%rax) - -#define VMSET(FIELD, VAL) \ - mov $FIELD, %rdx; \ - mov VAL, %rax; \ - vmwrite %rax, %rdx; \ - /**/ - -#define VMSET_LIMITED(FIELD, VAL, MSR) \ - mov $MSR, %rcx; \ - rdmsr; \ - or VAL, %rax; \ - and %rdx, %rax; \ - mov $FIELD, %rdx; \ - vmwrite %rax, %rdx; \ - /**/ - - VMSET_LIMITED(0x00004000, $0x3f, 0x481) // Pin-based VM-execution controls - //VMSET_LIMITED(0x00004002, $0x61999e84, 0x482) // Primary processor-based VM-execution controls - VMSET(0x00004002, $0xf3999e84) - VMSET(0x0000401E, $((1<<0) | (1<<7))) // Secondary processor-based VM-execution controls - VMSET_LIMITED(0x0000400C, $0x36fff, 0x483) // VM-exit controls (F6FFF) - VMSET_LIMITED(0x00004012, $0x17ff, 0x484) // VM-entry controls (51FF) - - VMSET(0x00002C04, $0) // Host IA32_PERF_GLOBAL_CTR - VMSET(0x00002800, $0xffffffffffffffff) // VMCS link pointer - - VMSET(0x00000C02, $SEL_CS64) // host CS - - mov $SEL_DS64, %rax - mov $0x00000C00, %rdx // host ES - vmwrite %rax, %rdx - mov $0x00000C04, %rdx // host SS - vmwrite %rax, %rdx - mov $0x00000C06, %rdx // host DS - vmwrite %rax, %rdx - mov $0x00000C08, %rdx // host FS - vmwrite %rax, %rdx - mov $0x00000C0A, %rdx // host GS - vmwrite %rax, %rdx - mov $SEL_TSS64, %rax - mov $0x00000C0C, %rdx // host TR - vmwrite %rax, %rdx - - VMSET(0x00002C02, $0x500) // host EFER - - VMSET(0x00004C00, $SEL_CS64) // Host IA32_SYSENTER_CS - VMSET(0x00006C10, $0) // Host IA32_SYSENTER_ESP - VMSET(0x00006C12, $0) // Host IA32_SYSENTER_EIP - - mov %cr0, %rax - VMSET(0x00006C00, %rax) // host CR0 - mov %cr3, %rax - VMSET(0x00006C02, %rax) // host CR3 - mov %cr4, %rax - VMSET(0x00006C04, %rax) // host CR4 - - VMSET(0x00006C06, $0) // host FS base - VMSET(0x00006C08, $0) // host GS base - VMSET(0x00006C0A, $ADDR_VAR_TSS64) // host TR base - - VMSET(0x00006C0C, $ADDR_GDT) // host GDTR base - VMSET(0x00006C0E, $ADDR_VAR_IDT) // host IDTR base - - VMSET(0x00006C14, $0) // host RSP - VMSET(0x00006C16, ADDR_VAR_VMEXIT_PTR) // host RIP - - VMSET(0x00000000, $1) // VPID - VMSET(0x00000002, $0) // Posted-interrupt notification vector - //VMSET(0x00000004, $0) // EPTP index - - VMSET(0x00002000, $0) // Address of I/O bitmap A - VMSET(0x00002002, $0) // Address of I/O bitmap B - VMSET(0x00002004, $0) // Address of MSR bitmaps - VMSET(0x00002006, $0) // VM-exit MSR-store address - - mov $0x277, %rcx - rdmsr - shl $32, %rdx - or %rdx, %rax - VMSET(0x00002C00, %rax) // Host IA32_PAT - - VMSET(0x00004004, $0) // Exception bitmap - VMSET(0x0000400A, $0) // CR3-target count - VMSET(0x0000400E, $0) // VM-exit MSR-store count - VMSET(0x00004010, $0) // VM-exit MSR-load count - VMSET(0x00004016, $0) // VM-entry interruption-information field - VMSET(0x00004014, $0) // VM-entry MSR-load count - - VMSET(0x00006000, $0xffffffffffffffff) // CR0 guest/host mask - VMSET(0x00006002, $0xffffffffffffffff) // CR4 guest/host mask - - VMSET(0x0000201C, $0) // EOI-exit bitmap 0 - VMSET(0x0000201E, $0) // EOI-exit bitmap 1 - VMSET(0x00002020, $0) // EOI-exit bitmap 2 - VMSET(0x00002022, $0) // EOI-exit bitmap 3 - - VMSET(0x00000800, $SEL_DS64) // Guest ES selector - VMSET(0x00000802, $SEL_CS64) // Guest CS selector - VMSET(0x00000804, $SEL_DS64) // Guest SS selector - VMSET(0x00000806, $SEL_DS64) // Guest DS selector - VMSET(0x00000808, $SEL_DS64) // Guest FS selector - VMSET(0x0000080A, $SEL_DS64) // Guest GS selector - VMSET(0x0000080C, $0) // Guest LDTR selector - VMSET(0x0000080E, $SEL_TSS64) // Guest TR selector - - VMSET(0x00006812, $0) // Guest LDTR base - VMSET(0x00006814, $ADDR_VAR_TSS64) // Guest TR base - VMSET(0x00006816, $ADDR_GDT) // Guest GDTR base - VMSET(0x00006818, $ADDR_VAR_IDT) // Guest IDTR base - - VMSET(0x00004800, $0xfffff) // Guest ES limit - VMSET(0x00004802, $0xfffff) // Guest CS limit - VMSET(0x00004804, $0xfffff) // Guest SS limit - VMSET(0x00004806, $0xfffff) // Guest DS limit - VMSET(0x00004808, $0xfffff) // Guest FS limit - VMSET(0x0000480A, $0xfffff) // Guest GS limit - VMSET(0x0000480C, $0) // Guest LDTR limit - VMSET(0x0000480E, $0x1fff) // Guest TR limit - VMSET(0x00004810, $0x1fff) // Guest GDTR limit - VMSET(0x00004812, $0x1fff) // Guest IDTR limit - - VMSET(0x00004814, $0x4093) // Guest ES access rights - VMSET(0x00004816, $0x209b) // Guest CS access rights - VMSET(0x00004818, $0x4093) // Guest SS access rights - VMSET(0x0000481A, $0x4093) // Guest DS access rights - VMSET(0x0000481C, $0x4093) // Guest FS access rights - VMSET(0x0000481E, $0x4093) // Guest GS access rights - VMSET(0x00004820, $0x82) // Guest LDTR access rights - VMSET(0x00004822, $0x8b) // Guest TR access rights - - VMSET(0x0000681C, $0) // Guest RSP - VMSET(0x0000681E, $ADDR_VAR_USER_CODE) // Guest RIP - VMSET(0x00006820, $((1<<1))) // Guest RFLAGS - VMSET(0x00002806, $0x500) // Guest IA32_EFER - VMSET(0x0000280A, $0) // Guest PDPTE0 - VMSET(0x0000280C, $0) // Guest PDPTE1 - VMSET(0x0000280E, $0) // Guest PDPTE2 - VMSET(0x00002810, $0) // Guest PDPTE3 - - mov %cr0, %rax - VMSET(0x00006800, %rax) // Guest CR0 - mov %cr3, %rax - VMSET(0x00006802, %rax) // Guest CR3 - mov %cr4, %rax - VMSET(0x00006804, %rax) // Guest CR4 - - // Write 1 additional random field. - mov $ADDR_VAR_VMWRITE_FLD, %rax - mov (%rax), %rdx - mov $ADDR_VAR_VMWRITE_VAL, %rax - mov (%rax), %rcx - xor %rax, %rax - vmread %rdx, %rax - xor %rcx, %rax - vmwrite %rax, %rdx - - vmlaunch - - mov $0x00004400, %rdx - vmread %rdx, %rax - hlt -kvm_asm64_init_vm_end: - nop - -.global kvm_asm64_vm_exit, kvm_asm64_vm_exit_end -kvm_asm64_vm_exit: -.code64 - //vmresume - mov $0x00004400, %rbx // VM-instruction error - vmread %rbx, %rdx - mov $0x00004402, %rbx // Exit reason - vmread %rbx, %rcx - mov $0x00006400, %rax // Exit qualification - vmread %rax, %rax - mov $0x0000681E, %rbx // Guest RIP - vmread %rbx, %rbx - hlt -kvm_asm64_vm_exit_end: - nop diff --git a/executor/kvm.S.h b/executor/kvm.S.h deleted file mode 100644 index 19b884ca0..000000000 --- a/executor/kvm.S.h +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by executor/kvm_gen.cc. DO NOT EDIT. -const char kvm_asm16_cpl3[] = "\x0f\x20\xc0\x66\x83\xc8\x01\x0f\x22\xc0\xb8\xa0\x00\x0f\x00\xd8\xb8\x2b\x00\x8e\xd8\x8e\xc0\x8e\xe0\x8e\xe8\xbc\x00\x01\xc7\x06\x00\x01\x1d\xba\xc7\x06\x02\x01\x23\x00\xc7\x06\x04\x01\x00\x01\xc7\x06\x06\x01\x2b\x00\xcb"; -const char kvm_asm32_paged[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0"; -const char kvm_asm32_vm86[] = "\x66\xb8\xb8\x00\x0f\x00\xd8\xea\x00\x00\x00\x00\xd0\x00"; -const char kvm_asm32_paged_vm86[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\x66\xb8\xb8\x00\x0f\x00\xd8\xea\x00\x00\x00\x00\xd0\x00"; -const char kvm_asm64_enable_long[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8"; -const char kvm_asm64_init_vm[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8\x48\xc7\xc1\x3a\x00\x00\x00\x0f\x32\x48\x83\xc8\x05\x0f\x30\x0f\x20\xe0\x48\x0d\x00\x20\x00\x00\x0f\x22\xe0\x48\xc7\xc1\x80\x04\x00\x00\x0f\x32\x48\xc7\xc2\x00\x60\x00\x00\x89\x02\x48\xc7\xc2\x00\x70\x00\x00\x89\x02\x48\xc7\xc0\x00\x5f\x00\x00\xf3\x0f\xc7\x30\x48\xc7\xc0\x08\x5f\x00\x00\x66\x0f\xc7\x30\x0f\xc7\x30\x48\xc7\xc1\x81\x04\x00\x00\x0f\x32\x48\x83\xc8\x3f\x48\x21\xd0\x48\xc7\xc2\x00\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x40\x00\x00\x48\xb8\x84\x9e\x99\xf3\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x40\x00\x00\x48\xc7\xc0\x81\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x83\x04\x00\x00\x0f\x32\x48\x0d\xff\x6f\x03\x00\x48\x21\xd0\x48\xc7\xc2\x0c\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x84\x04\x00\x00\x0f\x32\x48\x0d\xff\x17\x00\x00\x48\x21\xd0\x48\xc7\xc2\x12\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x2c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x28\x00\x00\x48\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x02\x0c\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc0\x58\x00\x00\x00\x48\xc7\xc2\x00\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc0\xd8\x00\x00\x00\x48\xc7\xc2\x0c\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x2c\x00\x00\x48\xc7\xc0\x00\x05\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x4c\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x0f\x20\xc0\x48\xc7\xc2\x00\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xd8\x48\xc7\xc2\x02\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xe0\x48\xc7\xc2\x04\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc2\x06\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x6c\x00\x00\x48\xc7\xc0\x00\x3a\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x6c\x00\x00\x48\xc7\xc0\x00\x10\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x6c\x00\x00\x48\xc7\xc0\x00\x38\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x6c\x00\x00\x48\x8b\x04\x25\x10\x5f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x00\x00\x00\x48\xc7\xc0\x01\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x00\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x77\x02\x00\x00\x0f\x32\x48\xc1\xe2\x20\x48\x09\xd0\x48\xc7\xc2\x00\x2c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc2\x04\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x60\x00\x00\x48\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x02\x60\x00\x00\x48\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x1c\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x22\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x08\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x08\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x08\x00\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x68\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x68\x00\x00\x48\xc7\xc0\x00\x3a\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x68\x00\x00\x48\xc7\xc0\x00\x10\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x18\x68\x00\x00\x48\xc7\xc0\x00\x38\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x48\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x48\x00\x00\x48\xc7\xc0\x9b\x20\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x18\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1a\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1c\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x48\x00\x00\x48\xc7\xc0\x82\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x22\x48\x00\x00\x48\xc7\xc0\x8b\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1c\x68\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x68\x00\x00\x48\xc7\xc0\x00\x91\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x68\x00\x00\x48\xc7\xc0\x02\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x28\x00\x00\x48\xc7\xc0\x00\x05\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x0f\x20\xc0\x48\xc7\xc2\x00\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xd8\x48\xc7\xc2\x02\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xe0\x48\xc7\xc2\x04\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc0\x18\x5f\x00\x00\x48\x8b\x10\x48\xc7\xc0\x20\x5f\x00\x00\x48\x8b\x08\x48\x31\xc0\x0f\x78\xd0\x48\x31\xc8\x0f\x79\xd0\x0f\x01\xc2\x48\xc7\xc2\x00\x44\x00\x00\x0f\x78\xd0\xf4"; -const char kvm_asm64_vm_exit[] = "\x48\xc7\xc3\x00\x44\x00\x00\x0f\x78\xda\x48\xc7\xc3\x02\x44\x00\x00\x0f\x78\xd9\x48\xc7\xc0\x00\x64\x00\x00\x0f\x78\xc0\x48\xc7\xc3\x1e\x68\x00\x00\x0f\x78\xdb\xf4"; -const char kvm_asm64_cpl3[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8\x48\xc7\xc0\x6b\x00\x00\x00\x8e\xd8\x8e\xc0\x8e\xe0\x8e\xe8\x48\xc7\xc4\x80\x0f\x00\x00\x48\xc7\x04\x24\x1d\xba\x00\x00\x48\xc7\x44\x24\x04\x63\x00\x00\x00\x48\xc7\x44\x24\x08\x80\x0f\x00\x00\x48\xc7\x44\x24\x0c\x6b\x00\x00\x00\xcb"; diff --git a/executor/kvm_amd64.S b/executor/kvm_amd64.S new file mode 100644 index 000000000..c3d8ac802 --- /dev/null +++ b/executor/kvm_amd64.S @@ -0,0 +1,313 @@ +// 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. + +// kvm_gen.cc generates machine code from this file and saves it into kvm_amd64.S.h. + +// +build + +#include "kvm.h" + +.global kvm_asm64_enable_long, kvm_asm64_enable_long_end +kvm_asm64_enable_long: +.code32 + mov %cr0, %eax + or $0x80000000, %eax + mov %eax, %cr0 + ljmp $SEL_CS64, NEXT_INSN +.code64 + mov $SEL_TSS64, %rax + ltr %ax +kvm_asm64_enable_long_end: + nop + +.global kvm_asm32_paged, kvm_asm32_paged_end +kvm_asm32_paged: +.code32 + mov %cr0, %eax + or $0x80000000, %eax + mov %eax, %cr0 +kvm_asm32_paged_end: + nop + +.global kvm_asm32_vm86, kvm_asm32_vm86_end +kvm_asm32_vm86: +.code32 + mov $SEL_TSS32, %ax + ltr %ax + ljmp $SEL_TSS32_VM86, $0 +kvm_asm32_vm86_end: + nop + +.global kvm_asm32_paged_vm86, kvm_asm32_paged_vm86_end +kvm_asm32_paged_vm86: +.code32 + mov %cr0, %eax + or $0x80000000, %eax + mov %eax, %cr0 + mov $SEL_TSS32, %ax + ltr %ax + ljmp $SEL_TSS32_VM86, $0 +kvm_asm32_paged_vm86_end: + nop + +.global kvm_asm16_cpl3, kvm_asm16_cpl3_end +kvm_asm16_cpl3: +.code16 + mov %cr0, %eax + or $1, %eax + mov %eax, %cr0 + mov $SEL_TSS16, %ax + ltr %ax + mov $SEL_DS16_CPL3, %ax + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + mov $0x100, %sp + movw $PREFIX_SIZE, 0x100 + movw $SEL_CS16_CPL3, 0x102 + movw $0x100, 0x104 + movw $SEL_DS16_CPL3, 0x106 + lret +kvm_asm16_cpl3_end: + nop + +.global kvm_asm64_cpl3, kvm_asm64_cpl3_end +kvm_asm64_cpl3: +.code32 + mov %cr0, %eax + or $0x80000000, %eax + mov %eax, %cr0 + ljmp $SEL_CS64, NEXT_INSN +.code64 + mov $SEL_TSS64, %rax + ltr %ax + mov $SEL_DS64_CPL3, %rax + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + mov $ADDR_STACK0, %rsp + movq $PREFIX_SIZE, 0(%rsp) + movq $SEL_CS64_CPL3, 4(%rsp) + movq $ADDR_STACK0, 8(%rsp) + movq $SEL_DS64_CPL3, 12(%rsp) + lret +kvm_asm64_cpl3_end: + nop + +.global kvm_asm64_init_vm, kvm_asm64_init_vm_end +kvm_asm64_init_vm: +.code32 + // CR0.PG = 1 + mov %cr0, %eax + or $0x80000000, %eax + mov %eax, %cr0 + ljmp $SEL_CS64, NEXT_INSN +.code64 + mov $SEL_TSS64, %rax + ltr %ax + + // Enable and lock non-SMM VM + mov $MSR_IA32_FEATURE_CONTROL, %rcx + rdmsr + or $0x5, %rax + wrmsr + + // CR4.VMXE = 1 + mov %cr4, %rax + or $0x2000, %rax + mov %rax, %cr4 + + // Write VMCS revision into VMXON and VMCS regions + mov $MSR_IA32_VMX_BASIC, %rcx + rdmsr + mov $ADDR_VAR_VMXON, %rdx + mov %eax, (%rdx) + mov $ADDR_VAR_VMCS, %rdx + mov %eax, (%rdx) + + mov $ADDR_VAR_VMXON_PTR, %rax + vmxon (%rax) + mov $ADDR_VAR_VMCS_PTR, %rax + vmclear (%rax) + vmptrld (%rax) + +#define VMSET(FIELD, VAL) \ + mov $FIELD, %rdx; \ + mov VAL, %rax; \ + vmwrite %rax, %rdx; \ + /**/ + +#define VMSET_LIMITED(FIELD, VAL, MSR) \ + mov $MSR, %rcx; \ + rdmsr; \ + or VAL, %rax; \ + and %rdx, %rax; \ + mov $FIELD, %rdx; \ + vmwrite %rax, %rdx; \ + /**/ + + VMSET_LIMITED(0x00004000, $0x3f, 0x481) // Pin-based VM-execution controls + //VMSET_LIMITED(0x00004002, $0x61999e84, 0x482) // Primary processor-based VM-execution controls + VMSET(0x00004002, $0xf3999e84) + VMSET(0x0000401E, $((1<<0) | (1<<7))) // Secondary processor-based VM-execution controls + VMSET_LIMITED(0x0000400C, $0x36fff, 0x483) // VM-exit controls (F6FFF) + VMSET_LIMITED(0x00004012, $0x17ff, 0x484) // VM-entry controls (51FF) + + VMSET(0x00002C04, $0) // Host IA32_PERF_GLOBAL_CTR + VMSET(0x00002800, $0xffffffffffffffff) // VMCS link pointer + + VMSET(0x00000C02, $SEL_CS64) // host CS + + mov $SEL_DS64, %rax + mov $0x00000C00, %rdx // host ES + vmwrite %rax, %rdx + mov $0x00000C04, %rdx // host SS + vmwrite %rax, %rdx + mov $0x00000C06, %rdx // host DS + vmwrite %rax, %rdx + mov $0x00000C08, %rdx // host FS + vmwrite %rax, %rdx + mov $0x00000C0A, %rdx // host GS + vmwrite %rax, %rdx + mov $SEL_TSS64, %rax + mov $0x00000C0C, %rdx // host TR + vmwrite %rax, %rdx + + VMSET(0x00002C02, $0x500) // host EFER + + VMSET(0x00004C00, $SEL_CS64) // Host IA32_SYSENTER_CS + VMSET(0x00006C10, $0) // Host IA32_SYSENTER_ESP + VMSET(0x00006C12, $0) // Host IA32_SYSENTER_EIP + + mov %cr0, %rax + VMSET(0x00006C00, %rax) // host CR0 + mov %cr3, %rax + VMSET(0x00006C02, %rax) // host CR3 + mov %cr4, %rax + VMSET(0x00006C04, %rax) // host CR4 + + VMSET(0x00006C06, $0) // host FS base + VMSET(0x00006C08, $0) // host GS base + VMSET(0x00006C0A, $ADDR_VAR_TSS64) // host TR base + + VMSET(0x00006C0C, $ADDR_GDT) // host GDTR base + VMSET(0x00006C0E, $ADDR_VAR_IDT) // host IDTR base + + VMSET(0x00006C14, $0) // host RSP + VMSET(0x00006C16, ADDR_VAR_VMEXIT_PTR) // host RIP + + VMSET(0x00000000, $1) // VPID + VMSET(0x00000002, $0) // Posted-interrupt notification vector + //VMSET(0x00000004, $0) // EPTP index + + VMSET(0x00002000, $0) // Address of I/O bitmap A + VMSET(0x00002002, $0) // Address of I/O bitmap B + VMSET(0x00002004, $0) // Address of MSR bitmaps + VMSET(0x00002006, $0) // VM-exit MSR-store address + + mov $0x277, %rcx + rdmsr + shl $32, %rdx + or %rdx, %rax + VMSET(0x00002C00, %rax) // Host IA32_PAT + + VMSET(0x00004004, $0) // Exception bitmap + VMSET(0x0000400A, $0) // CR3-target count + VMSET(0x0000400E, $0) // VM-exit MSR-store count + VMSET(0x00004010, $0) // VM-exit MSR-load count + VMSET(0x00004016, $0) // VM-entry interruption-information field + VMSET(0x00004014, $0) // VM-entry MSR-load count + + VMSET(0x00006000, $0xffffffffffffffff) // CR0 guest/host mask + VMSET(0x00006002, $0xffffffffffffffff) // CR4 guest/host mask + + VMSET(0x0000201C, $0) // EOI-exit bitmap 0 + VMSET(0x0000201E, $0) // EOI-exit bitmap 1 + VMSET(0x00002020, $0) // EOI-exit bitmap 2 + VMSET(0x00002022, $0) // EOI-exit bitmap 3 + + VMSET(0x00000800, $SEL_DS64) // Guest ES selector + VMSET(0x00000802, $SEL_CS64) // Guest CS selector + VMSET(0x00000804, $SEL_DS64) // Guest SS selector + VMSET(0x00000806, $SEL_DS64) // Guest DS selector + VMSET(0x00000808, $SEL_DS64) // Guest FS selector + VMSET(0x0000080A, $SEL_DS64) // Guest GS selector + VMSET(0x0000080C, $0) // Guest LDTR selector + VMSET(0x0000080E, $SEL_TSS64) // Guest TR selector + + VMSET(0x00006812, $0) // Guest LDTR base + VMSET(0x00006814, $ADDR_VAR_TSS64) // Guest TR base + VMSET(0x00006816, $ADDR_GDT) // Guest GDTR base + VMSET(0x00006818, $ADDR_VAR_IDT) // Guest IDTR base + + VMSET(0x00004800, $0xfffff) // Guest ES limit + VMSET(0x00004802, $0xfffff) // Guest CS limit + VMSET(0x00004804, $0xfffff) // Guest SS limit + VMSET(0x00004806, $0xfffff) // Guest DS limit + VMSET(0x00004808, $0xfffff) // Guest FS limit + VMSET(0x0000480A, $0xfffff) // Guest GS limit + VMSET(0x0000480C, $0) // Guest LDTR limit + VMSET(0x0000480E, $0x1fff) // Guest TR limit + VMSET(0x00004810, $0x1fff) // Guest GDTR limit + VMSET(0x00004812, $0x1fff) // Guest IDTR limit + + VMSET(0x00004814, $0x4093) // Guest ES access rights + VMSET(0x00004816, $0x209b) // Guest CS access rights + VMSET(0x00004818, $0x4093) // Guest SS access rights + VMSET(0x0000481A, $0x4093) // Guest DS access rights + VMSET(0x0000481C, $0x4093) // Guest FS access rights + VMSET(0x0000481E, $0x4093) // Guest GS access rights + VMSET(0x00004820, $0x82) // Guest LDTR access rights + VMSET(0x00004822, $0x8b) // Guest TR access rights + + VMSET(0x0000681C, $0) // Guest RSP + VMSET(0x0000681E, $ADDR_VAR_USER_CODE) // Guest RIP + VMSET(0x00006820, $((1<<1))) // Guest RFLAGS + VMSET(0x00002806, $0x500) // Guest IA32_EFER + VMSET(0x0000280A, $0) // Guest PDPTE0 + VMSET(0x0000280C, $0) // Guest PDPTE1 + VMSET(0x0000280E, $0) // Guest PDPTE2 + VMSET(0x00002810, $0) // Guest PDPTE3 + + mov %cr0, %rax + VMSET(0x00006800, %rax) // Guest CR0 + mov %cr3, %rax + VMSET(0x00006802, %rax) // Guest CR3 + mov %cr4, %rax + VMSET(0x00006804, %rax) // Guest CR4 + + // Write 1 additional random field. + mov $ADDR_VAR_VMWRITE_FLD, %rax + mov (%rax), %rdx + mov $ADDR_VAR_VMWRITE_VAL, %rax + mov (%rax), %rcx + xor %rax, %rax + vmread %rdx, %rax + xor %rcx, %rax + vmwrite %rax, %rdx + + vmlaunch + + mov $0x00004400, %rdx + vmread %rdx, %rax + hlt +kvm_asm64_init_vm_end: + nop + +.global kvm_asm64_vm_exit, kvm_asm64_vm_exit_end +kvm_asm64_vm_exit: +.code64 + //vmresume + mov $0x00004400, %rbx // VM-instruction error + vmread %rbx, %rdx + mov $0x00004402, %rbx // Exit reason + vmread %rbx, %rcx + mov $0x00006400, %rax // Exit qualification + vmread %rax, %rax + mov $0x0000681E, %rbx // Guest RIP + vmread %rbx, %rbx + hlt +kvm_asm64_vm_exit_end: + nop diff --git a/executor/kvm_amd64.S.h b/executor/kvm_amd64.S.h new file mode 100644 index 000000000..19b884ca0 --- /dev/null +++ b/executor/kvm_amd64.S.h @@ -0,0 +1,9 @@ +// Code generated by executor/kvm_gen.cc. DO NOT EDIT. +const char kvm_asm16_cpl3[] = "\x0f\x20\xc0\x66\x83\xc8\x01\x0f\x22\xc0\xb8\xa0\x00\x0f\x00\xd8\xb8\x2b\x00\x8e\xd8\x8e\xc0\x8e\xe0\x8e\xe8\xbc\x00\x01\xc7\x06\x00\x01\x1d\xba\xc7\x06\x02\x01\x23\x00\xc7\x06\x04\x01\x00\x01\xc7\x06\x06\x01\x2b\x00\xcb"; +const char kvm_asm32_paged[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0"; +const char kvm_asm32_vm86[] = "\x66\xb8\xb8\x00\x0f\x00\xd8\xea\x00\x00\x00\x00\xd0\x00"; +const char kvm_asm32_paged_vm86[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\x66\xb8\xb8\x00\x0f\x00\xd8\xea\x00\x00\x00\x00\xd0\x00"; +const char kvm_asm64_enable_long[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8"; +const char kvm_asm64_init_vm[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8\x48\xc7\xc1\x3a\x00\x00\x00\x0f\x32\x48\x83\xc8\x05\x0f\x30\x0f\x20\xe0\x48\x0d\x00\x20\x00\x00\x0f\x22\xe0\x48\xc7\xc1\x80\x04\x00\x00\x0f\x32\x48\xc7\xc2\x00\x60\x00\x00\x89\x02\x48\xc7\xc2\x00\x70\x00\x00\x89\x02\x48\xc7\xc0\x00\x5f\x00\x00\xf3\x0f\xc7\x30\x48\xc7\xc0\x08\x5f\x00\x00\x66\x0f\xc7\x30\x0f\xc7\x30\x48\xc7\xc1\x81\x04\x00\x00\x0f\x32\x48\x83\xc8\x3f\x48\x21\xd0\x48\xc7\xc2\x00\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x40\x00\x00\x48\xb8\x84\x9e\x99\xf3\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x40\x00\x00\x48\xc7\xc0\x81\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x83\x04\x00\x00\x0f\x32\x48\x0d\xff\x6f\x03\x00\x48\x21\xd0\x48\xc7\xc2\x0c\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x84\x04\x00\x00\x0f\x32\x48\x0d\xff\x17\x00\x00\x48\x21\xd0\x48\xc7\xc2\x12\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x2c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x28\x00\x00\x48\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x02\x0c\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc0\x58\x00\x00\x00\x48\xc7\xc2\x00\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc0\xd8\x00\x00\x00\x48\xc7\xc2\x0c\x0c\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x2c\x00\x00\x48\xc7\xc0\x00\x05\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x4c\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x0f\x20\xc0\x48\xc7\xc2\x00\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xd8\x48\xc7\xc2\x02\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xe0\x48\xc7\xc2\x04\x6c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc2\x06\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x6c\x00\x00\x48\xc7\xc0\x00\x3a\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x6c\x00\x00\x48\xc7\xc0\x00\x10\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x6c\x00\x00\x48\xc7\xc0\x00\x38\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x6c\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x6c\x00\x00\x48\x8b\x04\x25\x10\x5f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x00\x00\x00\x48\xc7\xc0\x01\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x00\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc1\x77\x02\x00\x00\x0f\x32\x48\xc1\xe2\x20\x48\x09\xd0\x48\xc7\xc2\x00\x2c\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc2\x04\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x40\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x60\x00\x00\x48\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x02\x60\x00\x00\x48\xc7\xc0\xff\xff\xff\xff\x0f\x79\xd0\x48\xc7\xc2\x1c\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x22\x20\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x08\x00\x00\x48\xc7\xc0\x50\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x08\x00\x00\x48\xc7\xc0\x58\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x08\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x08\x00\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x68\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x68\x00\x00\x48\xc7\xc0\x00\x3a\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x68\x00\x00\x48\xc7\xc0\x00\x10\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x18\x68\x00\x00\x48\xc7\xc0\x00\x38\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x00\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x02\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x04\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x08\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x48\x00\x00\x48\xc7\xc0\xff\xff\x0f\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x48\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x12\x48\x00\x00\x48\xc7\xc0\xff\x1f\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x14\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x16\x48\x00\x00\x48\xc7\xc0\x9b\x20\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x18\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1a\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1c\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x48\x00\x00\x48\xc7\xc0\x93\x40\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x48\x00\x00\x48\xc7\xc0\x82\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x22\x48\x00\x00\x48\xc7\xc0\x8b\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1c\x68\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x1e\x68\x00\x00\x48\xc7\xc0\x00\x91\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x20\x68\x00\x00\x48\xc7\xc0\x02\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x06\x28\x00\x00\x48\xc7\xc0\x00\x05\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0a\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0c\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x0e\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x48\xc7\xc2\x10\x28\x00\x00\x48\xc7\xc0\x00\x00\x00\x00\x0f\x79\xd0\x0f\x20\xc0\x48\xc7\xc2\x00\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xd8\x48\xc7\xc2\x02\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x0f\x20\xe0\x48\xc7\xc2\x04\x68\x00\x00\x48\x89\xc0\x0f\x79\xd0\x48\xc7\xc0\x18\x5f\x00\x00\x48\x8b\x10\x48\xc7\xc0\x20\x5f\x00\x00\x48\x8b\x08\x48\x31\xc0\x0f\x78\xd0\x48\x31\xc8\x0f\x79\xd0\x0f\x01\xc2\x48\xc7\xc2\x00\x44\x00\x00\x0f\x78\xd0\xf4"; +const char kvm_asm64_vm_exit[] = "\x48\xc7\xc3\x00\x44\x00\x00\x0f\x78\xda\x48\xc7\xc3\x02\x44\x00\x00\x0f\x78\xd9\x48\xc7\xc0\x00\x64\x00\x00\x0f\x78\xc0\x48\xc7\xc3\x1e\x68\x00\x00\x0f\x78\xdb\xf4"; +const char kvm_asm64_cpl3[] = "\x0f\x20\xc0\x0d\x00\x00\x00\x80\x0f\x22\xc0\xea\xde\xc0\xad\x0b\x50\x00\x48\xc7\xc0\xd8\x00\x00\x00\x0f\x00\xd8\x48\xc7\xc0\x6b\x00\x00\x00\x8e\xd8\x8e\xc0\x8e\xe0\x8e\xe8\x48\xc7\xc4\x80\x0f\x00\x00\x48\xc7\x04\x24\x1d\xba\x00\x00\x48\xc7\x44\x24\x04\x63\x00\x00\x00\x48\xc7\x44\x24\x08\x80\x0f\x00\x00\x48\xc7\x44\x24\x0c\x6b\x00\x00\x00\xcb"; diff --git a/executor/kvm_gen.cc b/executor/kvm_gen.cc index 92627208b..7df6e9bd7 100644 --- a/executor/kvm_gen.cc +++ b/executor/kvm_gen.cc @@ -20,6 +20,7 @@ void print(const char* name, const unsigned char* start, const unsigned char* en int main() { printf("// Code generated by executor/kvm_gen.cc. DO NOT EDIT.\n"); +#if GOARCH_amd64 PRINT(kvm_asm16_cpl3); PRINT(kvm_asm32_paged); PRINT(kvm_asm32_vm86); @@ -28,5 +29,6 @@ int main() PRINT(kvm_asm64_init_vm); PRINT(kvm_asm64_vm_exit); PRINT(kvm_asm64_cpl3); +#endif return 0; } -- cgit mrf-deployment