new file mode 100644
@@ -0,0 +1,2 @@
+/* Minimum stack frame size */
+#define STACK_FRAME_OVERHEAD 160
@@ -1756,6 +1756,9 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,
#define USE_ELF_CORE_DUMP
#define ELF_EXEC_PAGESIZE 4096
+#include "vdso.c.inc"
+#define vdso_image_info() &vdso_image_info
+
#endif /* TARGET_S390X */
#ifdef TARGET_RISCV
@@ -21,14 +21,12 @@
#include "user-internals.h"
#include "signal-common.h"
#include "linux-user/trace.h"
+#include "vdso-asmoffset.h"
#define __NUM_GPRS 16
#define __NUM_FPRS 16
#define __NUM_ACRS 16
-/* Minimum stack frame size */
-#define STACK_FRAME_OVERHEAD 160
-
#define _SIGCONTEXT_NSIG 64
#define _SIGCONTEXT_NSIG_BPW 64 /* FIXME: 31-bit mode -> 32 */
#define _SIGCONTEXT_NSIG_WORDS (_SIGCONTEXT_NSIG / _SIGCONTEXT_NSIG_BPW)
new file mode 100644
@@ -0,0 +1,5 @@
+CROSS_CC ?= s390x-linux-gnu-gcc
+
+vdso.so: vdso.S vdso.ld Makefile.vdso
+ $(CROSS_CC) -nostdlib -shared -Wl,-T,vdso.ld -Wl,--build-id=sha1 \
+ -Wl,-h,linux-vdso64.so.1 -Wl,--hash-style=both vdso.S -o $@
@@ -3,3 +3,9 @@ syscall_nr_generators += {
arguments: [ meson.current_source_dir() / 'syscallhdr.sh', '@INPUT@', '@OUTPUT@', '@EXTRA_ARGS@' ],
output: '@BASENAME@_nr.h')
}
+
+gen = [
+ gen_vdso.process('vdso.so', extra_args: ['-s', '__kernel_sigreturn',
+ '-r', '__kernel_rt_sigreturn'])
+]
+linux_user_ss.add(when: 'TARGET_S390X', if_true: gen)
new file mode 100644
@@ -0,0 +1,61 @@
+/*
+ * s390x linux replacement vdso.
+ *
+ * Copyright 2023 Linaro, Ltd.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <asm/unistd.h>
+#include "vdso-asmoffset.h"
+
+.macro endf name
+ .globl \name
+ .type \name, @function
+ .size \name, . - \name
+.endm
+
+.macro raw_syscall n
+ .ifne \n < 0x100
+ svc \n
+ .else
+ lghi %r1, \n
+ svc 0
+ .endif
+.endm
+
+.macro vdso_syscall name, nr
+\name:
+ .cfi_startproc
+ aghi %r15, -(STACK_FRAME_OVERHEAD + 16)
+ .cfi_adjust_cfa_offset STACK_FRAME_OVERHEAD + 16
+ stg %r14, STACK_FRAME_OVERHEAD(%r15)
+ .cfi_rel_offset %r14, STACK_FRAME_OVERHEAD
+ raw_syscall \nr
+ lg %r14, STACK_FRAME_OVERHEAD(%r15)
+ aghi %r15, STACK_FRAME_OVERHEAD + 16
+ .cfi_restore %r14
+ .cfi_adjust_cfa_offset -(STACK_FRAME_OVERHEAD + 16)
+ br %r14
+ .cfi_endproc
+endf \name
+.endm
+
+vdso_syscall __kernel_gettimeofday, __NR_gettimeofday
+vdso_syscall __kernel_clock_gettime, __NR_clock_gettime
+vdso_syscall __kernel_clock_getres, __NR_clock_getres
+vdso_syscall __kernel_getcpu, __NR_getcpu
+
+/*
+ * TODO unwind info, though we're ok without it.
+ * The kernel supplies bogus empty unwind info, and it is likely ignored
+ * by all users. Without it we get the fallback signal frame handling.
+ */
+
+__kernel_sigreturn:
+ raw_syscall __NR_sigreturn
+endf __kernel_sigreturn
+
+__kernel_rt_sigreturn:
+ raw_syscall __NR_rt_sigreturn
+endf __kernel_rt_sigreturn
new file mode 100644
@@ -0,0 +1,69 @@
+/*
+ * Linker script for linux x86-64 replacement vdso.
+ *
+ * Copyright 2023 Linaro, Ltd.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+VERSION {
+ LINUX_2.6.29 {
+ global:
+ __kernel_gettimeofday;
+ __kernel_clock_gettime;
+ __kernel_clock_getres;
+ __kernel_getcpu;
+ __kernel_restart_syscall;
+ __kernel_rt_sigreturn;
+ __kernel_sigreturn;
+ local: *;
+ };
+}
+
+
+PHDRS {
+ phdr PT_PHDR FLAGS(4) PHDRS;
+ load PT_LOAD FLAGS(7) FILEHDR PHDRS; /* FLAGS=RWX */
+ dynamic PT_DYNAMIC FLAGS(4);
+ eh_frame_hdr PT_GNU_EH_FRAME;
+ note PT_NOTE FLAGS(4);
+}
+
+SECTIONS {
+ . = SIZEOF_HEADERS;
+
+ /*
+ * The following, including the FILEHDRS and PHDRS, are modified
+ * when we relocate the binary. We want them to be initially
+ * writable for the relocation; we'll force them read-only after.
+ */
+ .note : { *(.note*) } :load :note
+ .dynamic : { *(.dynamic) } :load :dynamic
+ .dynsym : { *(.dynsym) } :load
+ .data : {
+ /*
+ * There ought not be any real read-write data.
+ * But since we manipulated the segment layout,
+ * we have to put these sections somewhere.
+ */
+ *(.data*)
+ *(.sdata*)
+ *(.got.plt) *(.got)
+ *(.gnu.linkonce.d.*)
+ *(.bss*)
+ *(.dynbss*)
+ *(.gnu.linkonce.b.*)
+ }
+
+ .rodata : { *(.rodata*) }
+ .hash : { *(.hash) }
+ .gnu.hash : { *(.gnu.hash) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .eh_frame_hdr : { *(.eh_frame_hdr) } :load :eh_frame_hdr
+ .eh_frame : { *(.eh_frame) } :load
+
+ .text : { *(.text*) } :load
+}
new file mode 100755
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/s390x/vdso-asmoffset.h | 2 + linux-user/elfload.c | 3 ++ linux-user/s390x/signal.c | 4 +- linux-user/s390x/Makefile.vdso | 5 +++ linux-user/s390x/meson.build | 6 +++ linux-user/s390x/vdso.S | 61 ++++++++++++++++++++++++++ linux-user/s390x/vdso.ld | 69 ++++++++++++++++++++++++++++++ linux-user/s390x/vdso.so | Bin 0 -> 3464 bytes 8 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 linux-user/s390x/vdso-asmoffset.h create mode 100644 linux-user/s390x/Makefile.vdso create mode 100644 linux-user/s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