diff options
| author | Alexey Kardashevskiy <aik@linux.ibm.com> | 2021-07-14 15:12:39 +1000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-07-19 11:29:36 +0200 |
| commit | 4760a80fad88909b48c1b60dd8c6d7ba991a2416 (patch) | |
| tree | 192e5ac175c3cdbe6ae73ee6c3bd943db015c249 | |
| parent | 40c360bea98928f9826762046ddeefad6405ca09 (diff) | |
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 <aik@linux.ibm.com>
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | docs/pseudo_syscalls.md | 2 | ||||
| -rw-r--r-- | executor/common_kvm_amd64.h | 2 | ||||
| -rw-r--r-- | executor/gen.go | 9 | ||||
| -rw-r--r-- | executor/gen_linux_amd64.go | 7 | ||||
| -rw-r--r-- | executor/kvm_amd64.S (renamed from executor/kvm.S) | 2 | ||||
| -rw-r--r-- | executor/kvm_amd64.S.h (renamed from executor/kvm.S.h) | 0 | ||||
| -rw-r--r-- | executor/kvm_gen.cc | 2 | ||||
| -rw-r--r-- | pkg/csource/gen.go | 2 |
9 files changed, 14 insertions, 14 deletions
diff --git a/.gitattributes b/.gitattributes index 39fac4cbc..2629f82c1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -executor/kvm.S.h linguist-generated +executor/kvm_amd64.S.h linguist-generated diff --git a/docs/pseudo_syscalls.md b/docs/pseudo_syscalls.md index 5247dd6b3..0eeff4e6c 100644 --- a/docs/pseudo_syscalls.md +++ b/docs/pseudo_syscalls.md @@ -41,7 +41,7 @@ one. These header files are defined in [gen.go](../pkg/csource/gen.go): "common_usb.h", "android/android_seccomp.h", "kvm.h", - "kvm.S.h", + "kvm_amd64.S.h", } For instance, if our new pseudo-syscall is Linux-specific, then 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_amd64.S index 1f64e304f..c3d8ac802 100644 --- a/executor/kvm.S +++ b/executor/kvm_amd64.S @@ -1,7 +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. -// kvm_gen.cc generates machine code from this file and saves it into kvm.S.h. +// kvm_gen.cc generates machine code from this file and saves it into kvm_amd64.S.h. // +build diff --git a/executor/kvm.S.h b/executor/kvm_amd64.S.h index 19b884ca0..19b884ca0 100644 --- a/executor/kvm.S.h +++ b/executor/kvm_amd64.S.h 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; } diff --git a/pkg/csource/gen.go b/pkg/csource/gen.go index 196aaf554..dc03010cb 100644 --- a/pkg/csource/gen.go +++ b/pkg/csource/gen.go @@ -41,7 +41,7 @@ func main() { "common_usb.h", "android/android_seccomp.h", "kvm.h", - "kvm.S.h", + "kvm_amd64.S.h", } data = replaceIncludes(executorFilenames, "../../executor/", data) androidFilenames := []string{ |
