Skip to content

Implement VDSO for x86_64-linux-user

Richard Henderson qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14linux-user: Handle filesz < memsz for any PT_LOAD segment.linux-user/elfload.c+55 -970 replies
1/14linux-user: Handle filesz < memsz for any PT_LOAD segment.linux-user/elfload.c+55 -970 replies
2/14Add more DT_* and AT_* constants to qemu's copy of elf.h.elf.h linux-user/elfload.c+44 -90 replies
2/14Add more DT_* and AT_* constants to qemu's copy of elf.h.elf.h linux-user/elfload.c+44 -90 replies
3/14linux-user: Reindent elfload.c.linux-user/elfload.c+301 -2930 replies
3/14linux-user: Reindent elfload.c.linux-user/elfload.c+301 -2930 replies
4/14linux-user: Reduce lseek+reads while loading elf files.linux-user/elfload.c linux-user/linuxload.c linux-user/qemu.h+58 -710 replies
4/14linux-user: Reduce lseek+reads while loading elf files.linux-user/elfload.c linux-user/linuxload.c linux-user/qemu.h+58 -710 replies
5/14linux-user: Fix ELF_DATA for Alpha.linux-user/elfload.c+1 -10 replies
5/14linux-user: Fix ELF_DATA for Alpha.linux-user/elfload.c+1 -10 replies
6/14linux-user: Clean up byte-swapping in elfload.c.linux-user/elfload.c+48 -710 replies
6/14linux-user: Clean up byte-swapping in elfload.c.linux-user/elfload.c+48 -710 replies
7/14linux-user: Load symbols from the interpreter.linux-user/elfload.c+101 -880 replies
7/14linux-user: Load symbols from the interpreter.linux-user/elfload.c+101 -880 replies
8/14linux-user: Improve consistency checking in elf headers.linux-user/elfload.c+33 -240 replies
8/14linux-user: Improve consistency checking in elf headers.linux-user/elfload.c+33 -240 replies
9/14linux-user: Put the stack guard page at the top.linux-user/elfload.c+16 -130 replies
9/14linux-user: Put the stack guard page at the top.linux-user/elfload.c+16 -130 replies
10/14linux-user: Remove partial support for a.out interpreters.linux-user/elfload.c+9 -710 replies
10/14linux-user: Remove partial support for a.out interpreters.linux-user/elfload.c+9 -710 replies
11/14linux-user: Extract load_elf_image from load_elf_interp.linux-user/elfload.c+167 -1740 replies
11/14linux-user: Extract load_elf_image from load_elf_interp.linux-user/elfload.c+167 -1740 replies
12/14linux-user: Re-use load_elf_image for the main binary.linux-user/elfload.c+53 -2162 replies
12/14linux-user: Re-use load_elf_image for the main binary.linux-user/elfload.c+56 -2160 replies
13/14linux-user: Build vdso for x64.Makefile pc-bios/Makefile pc-bios/vdso-linux-x64.S +2 more+190 -10 replies
13/14linux-user: Build vdso for x64.Makefile pc-bios/Makefile pc-bios/vdso-linux-x64.S +2 more+190 -10 replies
14/14linux-user: Load a VDSO for x86-64.linux-user/elfload.c+193 -80 replies
14/14linux-user: Load a VDSO for x86-64.linux-user/elfload.c+193 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 00/14] Implement VDSO for x86_64-linux-user

To do this in any clean sort of way, I rewrote a substantial portion of elfload.c. Doing otherwise would have wound up with 3 entirely separate bits of code to load an elf image.

The first patch seems out of order, since I did this work on a branch that already contained some previously submitted fixes for Alpha.

The third patch is *only* white-space changes. There were too many functions that I was touching that were improperly indented for qemu's style. Fixing this once at the beginning minimizes the irrelevant whitespace changes that emacs autoindent would have introduced when moving code around later.

The patch sequence has been tested at each point with all of the targets in linux-user-test-0.3.

Since that doesn't actually test gettimeofday, I also tested the final result against a small program that simply reads and prints the timeval with the system glibc, and examining the logs to verify that we do in fact call the __vdso_getttimeofday in the loaded vdso. I didn't test with the linux-user-test-0.3 image because I have no way of properly linking with that library, and programs linked against my system glibc crash when run vs the uClibc library.

I'll admit that the Makefiles aren't quite right for building the VDSO. I couldn't quite figure out what needed to be done. The binary image included in patch 13 is exactly what you'd get with the link command included in the pc-bios/Makefile, provided that you can get that link command executed. I'd appreciate some help with this point.

Finally, do be aware that I was not able to use qemu_find_file to load the vdso image, since that function is only built for system builds, and I'd rather this patch sequence be independent of cleanups involving vl.c. ;-) As a short-term hack, I always load the vdso image from the install directory. Which does mean that x86-64 emulation will not currently work from the build directory alone.

r~

Richard Henderson (14):
linux-user: Handle filesz < memsz for any PT_LOAD segment. Add more DT_* and AT_* constants to qemu's copy of elf.h.
linux-user: Reindent elfload.c.
linux-user: Reduce lseek+reads while loading elf files.
linux-user: Fix ELF_DATA for Alpha.
linux-user: Clean up byte-swapping in elfload.c.
linux-user: Load symbols from the interpreter.
linux-user: Improve consistency checking in elf headers.
linux-user: Put the stack guard page at the top.
linux-user: Remove partial support for a.out interpreters.
linux-user: Extract load_elf_image from load_elf_interp.
linux-user: Re-use load_elf_image for the main binary.
linux-user: Build vdso for x64.
linux-user: Load a VDSO for x86-64.

 Makefile                  |    3 +-
 elf.h                     |   44 ++
 linux-user/elfload.c      | 1683 +++++++++++++++++++++------------------------
 linux-user/linuxload.c    |   17 +-
 linux-user/qemu.h         |    7 +-
 pc-bios/Makefile          |    5 +
 pc-bios/vdso-linux-x64.S  |  102 +++
 pc-bios/vdso-linux-x64.ld |   81 +++
 pc-bios/vdso-linux-x64.so |  Bin 0 -> 7515 bytes
 9 files changed, 1037 insertions(+), 905 deletions(-)
 create mode 100644 pc-bios/vdso-linux-x64.S
 create mode 100644 pc-bios/vdso-linux-x64.ld
 create mode 100755 pc-bios/vdso-linux-x64.so