[PATCH v4.1 00/10] x86/entry/vdso: clean up the vdso build, vdso updates

H. Peter Anvin posted 10 patches 1 month ago
There is a newer version of this series
arch/x86/Kconfig.cpufeatures                       |   8 +
arch/x86/Makefile                                  |   2 +-
arch/x86/entry/syscall_32.c                        |   2 +-
arch/x86/entry/vdso/.gitignore                     |  11 +-
arch/x86/entry/vdso/Makefile                       | 162 +--------------------
arch/x86/entry/vdso/common/Makefile.include        |  89 +++++++++++
arch/x86/entry/vdso/{vdso-note.S => common/note.S} |   5 +-
arch/x86/entry/vdso/{ => common}/vclock_gettime.c  |   0
arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S |  38 +++--
arch/x86/entry/vdso/{ => common}/vgetcpu.c         |   0
arch/x86/entry/vdso/vdso32/Makefile                |  24 +++
arch/x86/entry/vdso/vdso32/note.S                  |  19 +--
arch/x86/entry/vdso/vdso32/sigreturn.S             | 152 +++++--------------
arch/x86/entry/vdso/vdso32/system_call.S           |  22 ++-
arch/x86/entry/vdso/vdso32/vclock_gettime.c        |   5 +-
arch/x86/entry/vdso/vdso32/vdso32.lds.S            |   2 +-
arch/x86/entry/vdso/vdso32/vgetcpu.c               |   4 +-
arch/x86/entry/vdso/vdso64/Makefile                |  46 ++++++
arch/x86/entry/vdso/vdso64/note.S                  |   1 +
arch/x86/entry/vdso/vdso64/vclock_gettime.c        |   1 +
.../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} |   2 +-
arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S     |   2 +-
arch/x86/entry/vdso/vdso64/vgetcpu.c               |   1 +
.../entry/vdso/{ => vdso64}/vgetrandom-chacha.S    |   0
arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c      |   2 +-
arch/x86/entry/vdso/{ => vdso64}/vsgx.S            |   0
arch/x86/entry/vdso/vma.c                          |  24 ++-
arch/x86/include/asm/cpufeatures.h                 |   2 +-
arch/x86/include/asm/dwarf2.h                      |   1 +
arch/x86/include/asm/elf.h                         |   2 +-
arch/x86/include/asm/vdso.h                        |   6 +-
arch/x86/include/asm/vdso/gettimeofday.h           | 108 +-------------
arch/x86/include/asm/vdso/sys_call.h               | 105 +++++++++++++
arch/x86/kernel/asm-offsets.c                      |   6 +
arch/x86/kernel/cpu/centaur.c                      |   3 -
arch/x86/kernel/cpu/common.c                       |   8 +
arch/x86/kernel/cpu/intel.c                        |   4 +-
arch/x86/kernel/cpu/zhaoxin.c                      |   4 +-
arch/x86/kernel/fred.c                             |   2 +-
arch/x86/kernel/process_64.c                       |   6 +-
arch/x86/kernel/signal_32.c                        |   4 +-
arch/x86/tools/Makefile                            |  15 +-
arch/x86/{entry/vdso => tools}/vdso2c.c            |   0
arch/x86/{entry/vdso => tools}/vdso2c.h            |   0
arch/x86/xen/setup.c                               |  28 ++--
arch/x86/xen/smp_pv.c                              |   5 +-
arch/x86/xen/xen-ops.h                             |   1 -
47 files changed, 444 insertions(+), 490 deletions(-)
[PATCH v4.1 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
Posted by H. Peter Anvin 1 month ago
This is intended as a ping, since I think the v4 got swallowed by the
holidays. v4.1 IS BASICALLY A REBASE AND RESEND OF v4; THE ONLY CODE
CHANGE IS A SINGLE SPACE CHARACTER.

This patchset cleans up the vdso build by building the 32- and 64-bit
vdsos in separate directories, moving the vdso2c tool to
arch/x86/tools, and by merging common code and especially Makefile
rules between the 32- and 64-bit vdsos to the greatest extent
possible.

Be more strict about sanitizing and standardizing the vdso build
options.

Disable CFI for the vdso until the kernel adds user space IBT support.

Modernize the DWARF generation in vdso32/sigreturn.S.

Add macros to cleanly call system calls from vdso source code.

Add the GNU_PROPERTY and GNU_STACK PHDRs to the vdso.

When using int $0x80 (old 32-bit hardware or FRED-capable 64-bit
hardware) skip the stack stuff in the 32-bit kernel entry code and
call int $0x80 directly when used from C code.

Changes from v4 to v4.1:

  - Fix a single bogus whitespace character change in patch 7.
  - Fix the spelling of Uros Bizjak's name in the comment to patch 8.
  - Rebased onto v6.19-rc4.

Changes from v3 to v4:

  - Improved description of patch 01/10.
  - Split out the move of vdso2c to tools into a separate patch.
  - Remove unrelated formatting changes from vdso-layout.lds.S.
  - Fix *-x32.o being missing from "targets".
  - Rebased onto v6.19-rc1.

Changes from v2 to v3:

  In arch/x86/include/asm/vdso/sys_call.h:
  - Remove stray comment from prototyping (Uros Bizjak)
  - Remove VDSO_SYSCALL6() since it would require special
    handling on 32 bits with frame pointers and is
    currently unused. (Uros Bizjak)
  - Indent nested preprocessor directives.

Changes from v1 to v2:

  Too many to count - much of the patchset has been reworked

Patches:

  x86/entry/vdso: rename vdso_image_* to vdso*_image
  x86/entry/vdso: move vdso2c to arch/x86/tools
  x86/entry/vdso: refactor the vdso build
  x86/entry/vdso32: don't rely on int80_landing_pad for adjusting ip
  x86/entry/vdso32: remove SYSCALL_ENTER_KERNEL macro in sigreturn.S
  x86/entry/vdso32: remove open-coded DWARF in sigreturn.S
  x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs
  x86/vdso: abstract out vdso system call internals
  x86/cpufeature: replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32
  x86/entry/vdso32: when using int $0x80, use it directly

---
 arch/x86/Kconfig.cpufeatures                       |   8 +
 arch/x86/Makefile                                  |   2 +-
 arch/x86/entry/syscall_32.c                        |   2 +-
 arch/x86/entry/vdso/.gitignore                     |  11 +-
 arch/x86/entry/vdso/Makefile                       | 162 +--------------------
 arch/x86/entry/vdso/common/Makefile.include        |  89 +++++++++++
 arch/x86/entry/vdso/{vdso-note.S => common/note.S} |   5 +-
 arch/x86/entry/vdso/{ => common}/vclock_gettime.c  |   0
 arch/x86/entry/vdso/{ => common}/vdso-layout.lds.S |  38 +++--
 arch/x86/entry/vdso/{ => common}/vgetcpu.c         |   0
 arch/x86/entry/vdso/vdso32/Makefile                |  24 +++
 arch/x86/entry/vdso/vdso32/note.S                  |  19 +--
 arch/x86/entry/vdso/vdso32/sigreturn.S             | 152 +++++--------------
 arch/x86/entry/vdso/vdso32/system_call.S           |  22 ++-
 arch/x86/entry/vdso/vdso32/vclock_gettime.c        |   5 +-
 arch/x86/entry/vdso/vdso32/vdso32.lds.S            |   2 +-
 arch/x86/entry/vdso/vdso32/vgetcpu.c               |   4 +-
 arch/x86/entry/vdso/vdso64/Makefile                |  46 ++++++
 arch/x86/entry/vdso/vdso64/note.S                  |   1 +
 arch/x86/entry/vdso/vdso64/vclock_gettime.c        |   1 +
 .../entry/vdso/{vdso.lds.S => vdso64/vdso64.lds.S} |   2 +-
 arch/x86/entry/vdso/{ => vdso64}/vdsox32.lds.S     |   2 +-
 arch/x86/entry/vdso/vdso64/vgetcpu.c               |   1 +
 .../entry/vdso/{ => vdso64}/vgetrandom-chacha.S    |   0
 arch/x86/entry/vdso/{ => vdso64}/vgetrandom.c      |   2 +-
 arch/x86/entry/vdso/{ => vdso64}/vsgx.S            |   0
 arch/x86/entry/vdso/vma.c                          |  24 ++-
 arch/x86/include/asm/cpufeatures.h                 |   2 +-
 arch/x86/include/asm/dwarf2.h                      |   1 +
 arch/x86/include/asm/elf.h                         |   2 +-
 arch/x86/include/asm/vdso.h                        |   6 +-
 arch/x86/include/asm/vdso/gettimeofday.h           | 108 +-------------
 arch/x86/include/asm/vdso/sys_call.h               | 105 +++++++++++++
 arch/x86/kernel/asm-offsets.c                      |   6 +
 arch/x86/kernel/cpu/centaur.c                      |   3 -
 arch/x86/kernel/cpu/common.c                       |   8 +
 arch/x86/kernel/cpu/intel.c                        |   4 +-
 arch/x86/kernel/cpu/zhaoxin.c                      |   4 +-
 arch/x86/kernel/fred.c                             |   2 +-
 arch/x86/kernel/process_64.c                       |   6 +-
 arch/x86/kernel/signal_32.c                        |   4 +-
 arch/x86/tools/Makefile                            |  15 +-
 arch/x86/{entry/vdso => tools}/vdso2c.c            |   0
 arch/x86/{entry/vdso => tools}/vdso2c.h            |   0
 arch/x86/xen/setup.c                               |  28 ++--
 arch/x86/xen/smp_pv.c                              |   5 +-
 arch/x86/xen/xen-ops.h                             |   1 -
 47 files changed, 444 insertions(+), 490 deletions(-)
Re: [PATCH v4.1 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
Posted by Thorsten Leemhuis 3 weeks, 2 days ago
[stripped down the list of recipients quite a bit] 

On 1/6/26 22:18, H. Peter Anvin wrote:
> [...]
> This patchset cleans up the vdso build by building the 32- and 64-bit
> vdsos in separate directories, moving the vdso2c tool to
> arch/x86/tools, and by merging common code and especially Makefile
> rules between the 32- and 64-bit vdsos to the greatest extent
> possible. [...]

Lo! My daily -next builds for Fedora failed on x86_64 (other archs
worked fine). Haven't checked, but from the error message I wonder
if this might be due to the changes from this patch-set that showed
up in -next today:

+ /usr/bin/make -s 'HOSTCFLAGS=-O2  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2    ' 'HOSTLDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  ' ARCH=x86_64 INSTALL_MOD_PATH=/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT vdso_install KERNELRELEASE=6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt
readelf: Error: 'arch/x86/entry/vdso/vdso32.so.dbg': No such file
readelf: Error: 'arch/x86/entry/vdso/vdso64.so.dbg': No such file
scripts/Makefile.vdsoinst:33: warning: overriding recipe for target '/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT/lib/modules/6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt/vdso/.build-id/.debug'
scripts/Makefile.vdsoinst:33: warning: ignoring old recipe for target '/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT/lib/modules/6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt/vdso/.build-id/.debug'
make[2]: *** No rule to make target 'arch/x86/entry/vdso/vdso32.so.dbg', needed by '/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT/lib/modules/6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt/vdso/vdso32.so'.  Stop.
make[1]: *** [/builddir/build/BUILD/kernel-6.19.0-build/kernel-next-20260115/linux-6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64/Makefile:1459: vdso_install] Error 2
make: *** [Makefile:256: __sub-make] Error 2

Full log:
https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-x86_64/10010857-next-next-all/builder-live.log.gz

Ciao, Thorsten
Re: [PATCH v4.1 00/10] x86/entry/vdso: clean up the vdso build, vdso updates
Posted by H. Peter Anvin 3 weeks, 1 day ago
On January 14, 2026 11:00:55 PM PST, Thorsten Leemhuis <linux@leemhuis.info> wrote:
>[stripped down the list of recipients quite a bit] 
>
>On 1/6/26 22:18, H. Peter Anvin wrote:
>> [...]
>> This patchset cleans up the vdso build by building the 32- and 64-bit
>> vdsos in separate directories, moving the vdso2c tool to
>> arch/x86/tools, and by merging common code and especially Makefile
>> rules between the 32- and 64-bit vdsos to the greatest extent
>> possible. [...]
>
>Lo! My daily -next builds for Fedora failed on x86_64 (other archs
>worked fine). Haven't checked, but from the error message I wonder
>if this might be due to the changes from this patch-set that showed
>up in -next today:
>
>+ /usr/bin/make -s 'HOSTCFLAGS=-O2  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2    ' 'HOSTLDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  ' ARCH=x86_64 INSTALL_MOD_PATH=/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT vdso_install KERNELRELEASE=6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt
>readelf: Error: 'arch/x86/entry/vdso/vdso32.so.dbg': No such file
>readelf: Error: 'arch/x86/entry/vdso/vdso64.so.dbg': No such file
>scripts/Makefile.vdsoinst:33: warning: overriding recipe for target '/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT/lib/modules/6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt/vdso/.build-id/.debug'
>scripts/Makefile.vdsoinst:33: warning: ignoring old recipe for target '/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT/lib/modules/6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt/vdso/.build-id/.debug'
>make[2]: *** No rule to make target 'arch/x86/entry/vdso/vdso32.so.dbg', needed by '/builddir/build/BUILD/kernel-6.19.0-build/BUILDROOT/lib/modules/6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64+rt/vdso/vdso32.so'.  Stop.
>make[1]: *** [/builddir/build/BUILD/kernel-6.19.0-build/kernel-next-20260115/linux-6.19.0-0.0.next.20260115.439.vanilla.fc44.x86_64/Makefile:1459: vdso_install] Error 2
>make: *** [Makefile:256: __sub-make] Error 2
>
>Full log:
>https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-x86_64/10010857-next-next-all/builder-live.log.gz
>
>Ciao, Thorsten

Looks like it. Specifically it looks like it needs a tweak to make vdso_install. I'll look at it in a few hours.