diff options
| author | Alexander Egorenkov <Alexander.Egorenkov@ibm.com> | 2020-06-02 09:18:07 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-06-25 23:08:45 +0200 |
| commit | aea82c003a1826ebd9bf53194bb40fe911f9c23e (patch) | |
| tree | b553b2118a605c2df9e8ac6def779377f310e0ae /pkg | |
| parent | f9147b0836f6cd4196dbc25509e8763435cc857a (diff) | |
sys/linux: first 64bit big-endian architecture s390x
* mmap syscall is special on Linux s390x because
the parameters for this syscall are passed as a struct
on user stack instead of registers.
* Introduce the SyscallTrampolines table into targets.Target
to address the above problem.
* There is a bug in Linux kernel s390x which causes QEMU TCG
to hang when KASAN is enabled. The bug has been fixed
in the forthcoming Linux 5.8 version. Until then do not enable
KASAN when using QEMU TCG, QEMU KVM shall have no problems with
KASAN.
Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/cover/report.go | 5 | ||||
| -rw-r--r-- | pkg/csource/csource.go | 5 | ||||
| -rw-r--r-- | pkg/csource/generated.go | 2 | ||||
| -rw-r--r-- | pkg/host/syscalls_linux.go | 2 | ||||
| -rw-r--r-- | pkg/host/syscalls_linux_test.go | 19 | ||||
| -rw-r--r-- | pkg/osutil/osutil_linux.go | 2 |
6 files changed, 33 insertions, 2 deletions
diff --git a/pkg/cover/report.go b/pkg/cover/report.go index 57e8ed905..1e11d45eb 100644 --- a/pkg/cover/report.go +++ b/pkg/cover/report.go @@ -486,6 +486,8 @@ func PreviousInstructionPC(target *targets.Target, pc uint64) uint64 { return pc - 4 case "mips64le": return pc - 8 + case "s390x": + return pc - 6 default: panic(fmt.Sprintf("unknown arch %q", target.Arch)) } @@ -523,6 +525,9 @@ func archCallInsn(target *targets.Target) ([][]byte, [][]byte) { // This is only known to occur in the test: // b58: bal b30 <__sanitizer_cov_trace_pc> return [][]byte{[]byte("\tjal\t"), []byte("\tbal\t")}, callName + case "s390x": + // 1001de: brasl %r14,2bc090 <__sanitizer_cov_trace_pc> + return [][]byte{[]byte("\tbrasl\t")}, callName default: panic(fmt.Sprintf("unknown arch %q", target.Arch)) } diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index d2ab513cc..8818e4f1c 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -209,7 +209,8 @@ func (ctx *context) generateCalls(p prog.ExecProg, trace bool) ([]string, []uint func (ctx *context) emitCall(w *bytes.Buffer, call prog.ExecCall, ci int, haveCopyout, trace bool) { callName := call.Meta.CallName - native := ctx.sysTarget.SyscallNumbers && !strings.HasPrefix(callName, "syz_") + _, trampoline := ctx.sysTarget.SyscallTrampolines[callName] + native := ctx.sysTarget.SyscallNumbers && !strings.HasPrefix(callName, "syz_") && !trampoline fmt.Fprintf(w, "\t") if haveCopyout || trace { fmt.Fprintf(w, "res = ") @@ -269,6 +270,8 @@ func (ctx *context) emitCallName(w *bytes.Buffer, call prog.ExecCall, native boo fmt.Fprintf(w, "syscall(%v%v", ctx.sysTarget.SyscallPrefix, callName) } else if strings.HasPrefix(callName, "syz_") { fmt.Fprintf(w, "%v(", callName) + } else if trampolineName, ok := ctx.sysTarget.SyscallTrampolines[callName]; ok { + fmt.Fprintf(w, "%v(", trampolineName) } else { args := strings.Repeat(",intptr_t", len(call.Args)) if args != "" { diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 6c1f343be..e374b593f 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -5197,6 +5197,8 @@ struct fs_image_segment { #define sys_memfd_create 360 #elif GOARCH_mips64le #define sys_memfd_create 314 +#elif GOARCH_s390x +#define sys_memfd_create 350 #endif static unsigned long fs_image_segment_check(unsigned long size, unsigned long nsegs, long segments) diff --git a/pkg/host/syscalls_linux.go b/pkg/host/syscalls_linux.go index 3abc7668a..4efd28907 100644 --- a/pkg/host/syscalls_linux.go +++ b/pkg/host/syscalls_linux.go @@ -80,6 +80,8 @@ func parseKallsyms(kallsyms []byte, arch string) map[string]bool { re = regexp.MustCompile(` T ()?sys_([^\n]+)\n`) case "mips64le": re = regexp.MustCompile(` T sys_(mips_)?([^\n]+)\n`) + case "s390x": + re = regexp.MustCompile(` T (__s390_|__s390x_)?sys_([^\n]+)\n`) default: panic("unsupported arch for kallsyms parsing") } diff --git a/pkg/host/syscalls_linux_test.go b/pkg/host/syscalls_linux_test.go index 2064a10e3..aa44369f0 100644 --- a/pkg/host/syscalls_linux_test.go +++ b/pkg/host/syscalls_linux_test.go @@ -125,6 +125,25 @@ c00000000037eb00 T sys_newstat []string{"newstat"}, []string{"stat"}, }, + { + "s390x", + []byte(` +0000000000e4f760 T __sys_bind +0000000000e4f8e8 T __s390_sys_bind +0000000000e4f938 T __s390x_sys_bind +0000000000e4f938 T __se_sys_bind +0000000000e4f988 T __sys_listen +0000000000e4fab0 T __s390_sys_listen +0000000000e4faf8 T __s390x_sys_listen +0000000000e4faf8 T __se_sys_listen +0000000000e4fb40 T __sys_accept4 +0000000000e4fe58 T __s390_sys_accept4 +0000000000e4feb0 T __s390x_sys_accept4 +0000000000e4feb0 T __se_sys_accept4 + `), + []string{"bind", "listen", "accept4"}, + []string{"bind", "listen", "accept4"}, + }, } for _, test := range tests { diff --git a/pkg/osutil/osutil_linux.go b/pkg/osutil/osutil_linux.go index 30544d2e9..64390de25 100644 --- a/pkg/osutil/osutil_linux.go +++ b/pkg/osutil/osutil_linux.go @@ -56,7 +56,7 @@ func removeImmutable(fname string) error { switch runtime.GOARCH { case "386", "arm": cmd = 1074030082 - case "amd64", "arm64": + case "amd64", "arm64", "s390x": cmd = 1074292226 case "ppc64le", "mips64le": cmd = 2148034050 |
