Richard Henderson <richard.hender...@linaro.org> writes:
> Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > linux-user/s390x/vdso-asmoffset.h | 2 + > linux-user/elfload.c | 3 ++ > linux-user/s390x/signal.c | 4 +- > linux-user/s390x/meson.build | 24 +++++++++++ > linux-user/s390x/vdso.S | 61 ++++++++++++++++++++++++++ > linux-user/s390x/vdso.ld | 69 ++++++++++++++++++++++++++++++ > linux-user/s390x/vdso.so | Bin 0 -> 3464 bytes > 7 files changed, 160 insertions(+), 3 deletions(-) > create mode 100644 linux-user/s390x/vdso-asmoffset.h > create mode 100644 linux-user/s390x/vdso.S > create mode 100644 linux-user/s390x/vdso.ld > create mode 100755 linux-user/s390x/vdso.so > <snip> > diff --git a/linux-user/s390x/meson.build b/linux-user/s390x/meson.build > index 0781ccea1d..09afd98deb 100644 > --- a/linux-user/s390x/meson.build > +++ b/linux-user/s390x/meson.build > @@ -3,3 +3,27 @@ syscall_nr_generators += { > arguments: [ meson.current_source_dir() / > 'syscallhdr.sh', '@INPUT@', '@OUTPUT@', '@EXTRA_ARGS@' ], > output: '@BASENAME@_nr.h') > } > + > +vdso_so = custom_target(output: 'vdso.so', > + input: files('vdso.S', 'vdso.ld'), > + depend_files: files('vdso-asmoffset.h'), > + command: [ > + build_vdso_cmd, > + '-B', meson.project_build_root(), > + '-C', meson.current_source_dir(), > + '-T', 's390x-linux-user', > + '-o', '@OUTPUT@', > + '--', '-nostdlib', '-shared', > + '-Wl,-h,linux-vdso64.so.1', > + '-Wl,--build-id=sha1', > + '-Wl,--hash-style=both', > + '-Wl,-T,@INPUT1@', > + '@INPUT0@' > + ]) > + > +vdso_inc = gen_vdso.process('vdso.so', extra_args: [ > + '-s', '__kernel_sigreturn', > + '-r', '__kernel_rt_sigreturn' > + ]) > + Due to the b4 dropping the vdso.so in the patch this fails: Program build-vdso.sh found: YES (/home/alex/lsrc/qemu.git/linux-user/build-vdso.sh) ../../linux-user/s390x/meson.build:24:0: ERROR: File vdso.so does not exist. A full log can be found at /home/alex/lsrc/qemu.git/builds/all/meson-logs/meson-log.txt FAILED: build.ninja /home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/meson --internal regenerate /home/alex/lsrc/qemu.git /home/alex/lsrc/qemu.git/builds/all ninja: error: rebuilding 'build.ninja': subcommand failed BUILD aarch64-softmmu guest-tests tests/tcg/aarch64-softmmu: -march=armv8.3-a detected which makes me think the dependencies are broken anyway because I have a working s390x compiler: ➜ cat tests/tcg/s390x-linux-user/config-target.mak # Automatically generated by configure - do not modify TARGET_NAME=s390x TARGET=s390x-linux-user EXTRA_CFLAGS= CC=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-gcc -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- CCAS=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-gcc -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- AR=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-ar -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- AS=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-as -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- LD=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-ld -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- NM=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-nm -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- OBJCOPY=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-objcopy -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- RANLIB=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-ranlib -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- STRIP=/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 -B /home/alex/lsrc/qemu.git/tests/docker/docker.py --engine docker cc --cc s390x-linux-gnu-strip -i qemu/debian-s390x-cross -s /home/alex/lsrc/qemu.git -- BUILD_STATIC=y QEMU=/home/alex/lsrc/qemu.git/builds/all/qemu-s390x HOST_GDB_SUPPORTS_ARCH=y We really need to express the dependency on docker-image-debian-s390x-cross (when using containers) to ensure we can build the vdso.so and not rely on the copy we have. > +linux_user_ss.add(when: 'TARGET_S390X', if_true: vdso_inc) > diff --git a/linux-user/s390x/vdso.S b/linux-user/s390x/vdso.S > new file mode 100644 > index 0000000000..3332492477 > --- /dev/null > +++ b/linux-user/s390x/vdso.S > @@ -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 > diff --git a/linux-user/s390x/vdso.ld b/linux-user/s390x/vdso.ld > new file mode 100644 > index 0000000000..2a30ff382a > --- /dev/null > +++ b/linux-user/s390x/vdso.ld > @@ -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 > +} > diff --git a/linux-user/s390x/vdso.so b/linux-user/s390x/vdso.so > new file mode 100755 > index > 0000000000000000000000000000000000000000..64130f6f335269b03291653d006225b365be9cd9 > GIT binary patch > literal 3464 > zcmcguUuaup6hAlrn#R#}B6HHJ6^h8v3s#wtDI{HzWs-HJcB~u1U2JZX*fw`0w>2I9 > z>4SqkSsXs>VMq|PDvEm&1Rwf1RK!O?(CHKhzDz`4)-9g%edpXip_vbYU-<6tJHK<z > zcW%!8&bjyXe5nwL7~qX4?8S9}P@0U^51wZ!4ROf8FziM-fitG{$m!98#y(98LK0<) > zF`)T=*Tk6C2o94N!O8KAbs})9bp<|Z(f=FCiu>y{lI$0|t_^w-9%V;CvX_ZVV@~UP > z5ysh1P<-w|K6-fSIDGtl`ke<)|Mc0}bJcWb@yj2!fBy7s_8}PJ^{b5Jk0Yw$Io;cT > zvAm@bv#$o5>1TjUWL@)+V!Xt77o&O(PPe<Q<=ACHly9+~a!c|JEyu*4)&DD)cLVIw > z5#zsb<Wa;~pHGlXgYG*Q;1!7%(pLlg1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