Skip to contentSkip to conversation

vdso: sparc: stub out custom vdso implementation

PATCH In review Arnd Bergmann 7 participants 16 messages Jul 7, 2025 – Jul 23, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 vdso: sparc: stub out custom vdso implementation

From: Arnd Bergmann <[email protected]>

sparc64 is the only remaining architecture that has its own implementation of the vdso clock_gettime/gettimeofday helpers in place of the generic code. This causes a number of issues:

- Changes to the vdso interfaces require adding sparc64 specific hacks even when nothing else needs them

- The prototypes in <vdso/gettime.h> don't match the function implementation, and not including that header to avoid the build error from that causes another warning:

arch/sparc/vdso/vclock_gettime.c:274:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
274 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~

- Nobody has ever implemented the clock_gettime64() vdso that is required for 32-bit compat tasks

- The warning about the missing executable-stack flag was missed:

sparc-linux-ld: warning: arch/sparc/vdso/vdso-note.o: missing .note.GNU-stack section implies executable stack
sparc-linux-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Most of the removed code only exists on sparc in order to dynamically patch the vdso based on the presence of the tick vs vtick based clocksource.

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

---
 arch/sparc/Kconfig                  |   1 -
 arch/sparc/include/asm/vvar.h       |  75 ------
 arch/sparc/kernel/Makefile          |   1 -
 arch/sparc/kernel/vdso.c            |  69 ------
 arch/sparc/vdso/Makefile            |   2 +-
 arch/sparc/vdso/vclock_gettime.c    | 341 +++-------------------------
 arch/sparc/vdso/vdso.lds.S          |   2 -
 arch/sparc/vdso/vdso32/vdso32.lds.S |   3 +-
 arch/sparc/vdso/vma.c               | 265 +--------------------
 9 files changed, 31 insertions(+), 728 deletions(-)
 delete mode 100644 arch/sparc/include/asm/vvar.h
 delete mode 100644 arch/sparc/kernel/vdso.c
arch/sparc/Kconfig +0 -1
index dcfdb7f1dae9..776ce79ef188 100644
@@ -101,7 +101,6 @@ config SPARC64
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
-	select GENERIC_TIME_VSYSCALL
 	select ARCH_CLOCKSOURCE_DATA
 	select ARCH_HAS_PTE_SPECIAL
 	select PCI_DOMAINS if PCI
arch/sparc/include/asm/vvar.h deleted +0 -75

75 lines not on this page · raw message

arch/sparc/kernel/Makefile +0 -1
index 36f2727e1445..7a063cd4b6d3 100644
@@ -43,7 +43,6 @@ obj-$(CONFIG_SPARC32)   += systbls_32.o
 obj-y                   += time_$(BITS).o
 obj-$(CONFIG_SPARC32)   += windows.o
 obj-y                   += cpu.o
-obj-$(CONFIG_SPARC64)	+= vdso.o
 obj-$(CONFIG_SPARC32)   += devices.o
 obj-y                   += ptrace_$(BITS).o
 obj-y                   += unaligned_$(BITS).o
arch/sparc/kernel/vdso.c deleted +0 -69

69 lines not on this page · raw message

arch/sparc/vdso/Makefile +1 -1
index fdc4a8f5a49c..e8315c6acb74 100644
@@ -103,4 +103,4 @@ quiet_cmd_vdso = VDSO    $@
 		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
 		       -T $(filter %.lds,$^) $(filter %.o,$^)
 
-VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic --no-undefined
+VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic --no-undefined -z noexecstack
arch/sparc/vdso/vclock_gettime.c +26 -315

383 lines not on this page · raw message

arch/sparc/vdso/vdso.lds.S +0 -2
index 629ab6900df7..f3caa29a331c 100644
@@ -18,10 +18,8 @@ VERSION {
 	global:
 		clock_gettime;
 		__vdso_clock_gettime;
-		__vdso_clock_gettime_stick;
 		gettimeofday;
 		__vdso_gettimeofday;
-		__vdso_gettimeofday_stick;
 	local: *;
 	};
 }
arch/sparc/vdso/vdso32/vdso32.lds.S +1 -2
index 218930fdff03..cc6cac2429b3 100644
@@ -17,10 +17,9 @@ VERSION {
 	global:
 		clock_gettime;
 		__vdso_clock_gettime;
-		__vdso_clock_gettime_stick;
+		__vdso_clock_gettime64;
 		gettimeofday;
 		__vdso_gettimeofday;
-		__vdso_gettimeofday_stick;
 	local: *;
 	};
 }
arch/sparc/vdso/vma.c +3 -262

308 lines not on this page · raw message

Signature · 1 line
2.39.5
#1 lore raw

PATCH 2/2 clocksource: remove ARCH_CLOCKSOURCE_DATA

From: Arnd Bergmann <[email protected]>

Without the sparc64 vdso, there are no remaining users of ARCH_CLOCKSOURCE_DATA, and it can just be removed.

---
 arch/sparc/Kconfig                   |  1 -
 arch/sparc/include/asm/clocksource.h | 17 -----------------
 arch/sparc/kernel/time_64.c          |  3 ---
 include/linux/clocksource.h          |  6 +-----
 kernel/time/Kconfig                  |  4 ----
 5 files changed, 1 insertion(+), 30 deletions(-)
 delete mode 100644 arch/sparc/include/asm/clocksource.h
arch/sparc/Kconfig +0 -1
index 776ce79ef188..b126a421db9c 100644
@@ -101,7 +101,6 @@ config SPARC64
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
-	select ARCH_CLOCKSOURCE_DATA
 	select ARCH_HAS_PTE_SPECIAL
 	select PCI_DOMAINS if PCI
 	select ARCH_HAS_GIGANTIC_PAGE
arch/sparc/include/asm/clocksource.h deleted +0 -17
deleted file mode 100644
index d63ef224befe..000000000000
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
- */
-
-#ifndef _ASM_SPARC_CLOCKSOURCE_H
-#define _ASM_SPARC_CLOCKSOURCE_H
-
-/* VDSO clocksources */
-#define VCLOCK_NONE   0  /* Nothing userspace can do. */
-#define VCLOCK_TICK   1  /* Use %tick.  */
-#define VCLOCK_STICK  2  /* Use %stick. */
-
-struct arch_clocksource_data {
-	int vclock_mode;
-};
-
-#endif /* _ASM_SPARC_CLOCKSOURCE_H */
arch/sparc/kernel/time_64.c +0 -3
index 422ec5d03160..547c6f8bef36 100644
@@ -838,14 +838,11 @@ void __init time_init_early(void)
 	if (tlb_type == spitfire) {
 		if (is_hummingbird()) {
 			init_tick_ops(&hbtick_operations);
-			clocksource_tick.archdata.vclock_mode = VCLOCK_NONE;
 		} else {
 			init_tick_ops(&tick_operations);
-			clocksource_tick.archdata.vclock_mode = VCLOCK_TICK;
 		}
 	} else {
 		init_tick_ops(&stick_operations);
-		clocksource_tick.archdata.vclock_mode = VCLOCK_STICK;
 	}
 }
 
include/linux/clocksource.h +1 -5
index 65b7c41471c3..12d853b18832 100644
@@ -25,8 +25,7 @@ struct clocksource_base;
 struct clocksource;
 struct module;
 
-#if defined(CONFIG_ARCH_CLOCKSOURCE_DATA) || \
-    defined(CONFIG_GENERIC_GETTIMEOFDAY)
+#if defined(CONFIG_GENERIC_GETTIMEOFDAY)
 #include <asm/clocksource.h>
 #endif
 
@@ -106,9 +105,6 @@ struct clocksource {
 	u64			max_idle_ns;
 	u32			maxadj;
 	u32			uncertainty_margin;
-#ifdef CONFIG_ARCH_CLOCKSOURCE_DATA
-	struct arch_clocksource_data archdata;
-#endif
 	u64			max_cycles;
 	u64			max_raw_delta;
 	const char		*name;
kernel/time/Kconfig +0 -4
index b0b97a60aaa6..d7e67d397c86 100644
@@ -9,10 +9,6 @@
 config CLOCKSOURCE_WATCHDOG
 	bool
 
-# Architecture has extra clocksource data
-config ARCH_CLOCKSOURCE_DATA
-	bool
-
 # Architecture has extra clocksource init called from registration
 config ARCH_CLOCKSOURCE_INIT
 	bool
Signature · 1 line
2.39.5
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] clocksource: remove ARCH_CLOCKSOURCE_DATA

Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Without the sparc64 vdso, there are no remaining users of ARCH_CLOCKSOURCE_DATA, and it can just be removed.

Quoted 8 lines
---
 arch/sparc/Kconfig                   |  1 -
 arch/sparc/include/asm/clocksource.h | 17 -----------------
 arch/sparc/kernel/time_64.c          |  3 ---
 include/linux/clocksource.h          |  6 +-----
 kernel/time/Kconfig                  |  4 ----
 5 files changed, 1 insertion(+), 30 deletions(-)
 delete mode 100644 arch/sparc/include/asm/clocksource.h
#3 lore raw
In reply to Arnd Bergmann

Hello Arnd,

Quoted 3 lines · Arnd Bergmann

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Can this performance hit quantified in any way?

And is there previous serious where this change was made for other archs?

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#4 lore raw
Quoted 8 lines · John Paul Adrian Glaubitz

Hello Arnd,

Quoted 3 lines · Arnd Bergmann

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Can this performance hit quantified in any way?

It's trivial to test calling glibc clock_gettime() in a loop on a specific piece of hardware, the difference should largely depend on how long the timer hardware access takes compared to the syscall overhead.

On machines that have neither TICK nor STICK clocksource, the simpler version should even be minimally faster, on those that have one of the two, there is an added cost for entering the syscall on every clock_gettime() as we do on architectures without vdso.

Quoted 1 line

And is there previous serious where this change was made for other archs?

See
https://lore.kernel.org/lkml/[email protected]/#t
for the thread that led to this one.

There is also commit 5f55e098b8d0 ("parisc: Add 64-bit gettimeofday() and clock_gettime() vDSO functions") that adds similar stubs on parisc.

Arnd

#5 lore raw

Hi,

Quoted 15 lines · Arnd Bergmann
Quoted 8 lines · John Paul Adrian Glaubitz

Hello Arnd,

Quoted 3 lines · Arnd Bergmann

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Can this performance hit quantified in any way?

It's trivial to test calling glibc clock_gettime() in a loop on a specific piece of hardware, the difference should largely depend on how long the timer hardware access takes compared to the syscall overhead.

Quoted 5 lines

On machines that have neither TICK nor STICK clocksource, the simpler version should even be minimally faster, on those that have one of the two, there is an added cost for entering the syscall on every clock_gettime() as we do on architectures without vdso.

OK, thanks. Since Andreas has access to a SPARC T4 as of recently, he should be able to test this. Please allow some time for him to review and test the changes, so we can be sure this doesn't cause any serious regressions.

Quoted 9 lines
Quoted 1 line

And is there previous serious where this change was made for other archs?

See
https://lore.kernel.org/lkml/[email protected]/#t
for the thread that led to this one.

There is also commit 5f55e098b8d0 ("parisc: Add 64-bit gettimeofday() and clock_gettime() vDSO functions") that adds similar stubs on parisc.

OK, thanks for the pointer.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
maintainer
#6 lore raw
Quoted 24 lines · John Paul Adrian Glaubitz

Hi,

Quoted 15 lines · Arnd Bergmann
Quoted 8 lines · John Paul Adrian Glaubitz

Hello Arnd,

Quoted 3 lines · Arnd Bergmann

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Can this performance hit quantified in any way?

It's trivial to test calling glibc clock_gettime() in a loop on a specific piece of hardware, the difference should largely depend on how long the timer hardware access takes compared to the syscall overhead.

Quoted 5 lines

On machines that have neither TICK nor STICK clocksource, the simpler version should even be minimally faster, on those that have one of the two, there is an added cost for entering the syscall on every clock_gettime() as we do on architectures without vdso.

Quoted 3 lines

OK, thanks. Since Andreas has access to a SPARC T4 as of recently, he should be able to test this. Please allow some time for him to review and test the changes, so we can be sure this doesn't cause any serious regressions.

I tested this patch (running Linux in an LDOM under Solaris) and measuring the cost of clock_gettime(), running millions of calls. The calls takes around 13-15 times as long (from around 82-94 nanoseconds per call to around 1220 nanoseconds per call) with this patch compared to without, so not an insignificant performance regression in this environment.

Cheers,
Andreas

#7 lore raw
Quoted 26 lines · Andreas Larsson
Quoted 21 lines · John Paul Adrian Glaubitz
Quoted 14 lines · Arnd Bergmann
Quoted 7 lines · John Paul Adrian Glaubitz
Quoted 3 lines · Arnd Bergmann

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Can this performance hit quantified in any way?

It's trivial to test calling glibc clock_gettime() in a loop on a specific piece of hardware, the difference should largely depend on how long the timer hardware access takes compared to the syscall overhead.

Quoted 5 lines

On machines that have neither TICK nor STICK clocksource, the simpler version should even be minimally faster, on those that have one of the two, there is an added cost for entering the syscall on every clock_gettime() as we do on architectures without vdso.

Quoted 3 lines

OK, thanks. Since Andreas has access to a SPARC T4 as of recently, he should be able to test this. Please allow some time for him to review and test the changes, so we can be sure this doesn't cause any serious regressions.

Quoted 6 lines

I tested this patch (running Linux in an LDOM under Solaris) and measuring the cost of clock_gettime(), running millions of calls. The calls takes around 13-15 times as long (from around 82-94 nanoseconds per call to around 1220 nanoseconds per call) with this patch compared to without, so not an insignificant performance regression in this environment.

Ok, thanks a lot for testing! I guess the good news is that I didn't break functionality here.

Obviously 15x slowdown sounds like a lot, but what I don't know is whether 1.2µs is actually too slow. Is this CLOCK_REALTIME or some other clock? I would expect to see a larger difference for the COARSE version since that saves the hardware access as well.

From what I remember, the original driver for having a VDSO clock_gettime/gettimeofday was Java applications that call it too often. Do you know of anyone using Java on performance-critical sparc64 servers any more, or any other type of workload that depends on these functions being small?

It is probably not all that hard to convert the VDSO to use the generic implementation if you remove the runtime patching between TICK and STICK mode. From the code and the documentation, it seems that any JPS1 compatible CPU (or newer) uses STICK, this would be UltraSPARC III (Cheetah), SPARC64 V (Zeus) and all UltraSPARC T. If you want to give it a try to do the conversion to the generic VDSO, I could respin my patch to only remove the older TICK version and the runtime patching but leave the STICK one. I don't think it's worth my time trying to convert STICK myself since I have no way of testing it.

Another option would be to start by adding a VDSO for LEON CPUs using the ASR22:23 upcounter register. This should be fairly easy to do if you copy the CSR_TIME code from riscv and replace their __arch_get_hw_counter(), and this is probably more relevant than the sparc64 version. Once that works, you can extend it to use STICK on JPS1.

Arnd

#8 lore raw

Hello Arnd,

Quoted 10 lines · Arnd Bergmann

It is probably not all that hard to convert the VDSO to use the generic implementation if you remove the runtime patching between TICK and STICK mode. From the code and the documentation, it seems that any JPS1 compatible CPU (or newer) uses STICK, this would be UltraSPARC III (Cheetah), SPARC64 V (Zeus) and all UltraSPARC T. If you want to give it a try to do the conversion to the generic VDSO, I could respin my patch to only remove the older TICK version and the runtime patching but leave the STICK one. I don't think it's worth my time trying to convert STICK myself since I have no way of testing it.

I could create an account for you on the SPARC T4 that Andreas is currently using for testing, so you could test these changes on real hardware (Linux LDOM running on Solaris 11.4).

In about one month, I could also create an account for you on a SPARC T5 which is much faster and where you have more RAM and disk space available for testing.

Please send me a private email if you're interested.

I can also help with other architectures such as SuperH, MIPS, PowerPC or Alpha. All on real hardware.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#9 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

It is probably not all that hard to convert the VDSO to use the generic implementation if you remove the runtime patching between TICK and STICK mode. From the code and the documentation, it seems that any JPS1 compatible CPU (or newer) uses STICK, this would be UltraSPARC III (Cheetah), SPARC64 V (Zeus) and all UltraSPARC T. If you want to give it a try to do the conversion to the generic VDSO, I could respin my patch to only remove the older TICK version and the runtime patching but leave the STICK one. I don't think it's worth my time trying to convert STICK myself since I have no way of testing it.

Getting rid of the run-time patching is really trivial. The clocksource setup initializes clocksource::archdata::vdso_clockmode already correctly with VCLOCK_NONE, VCLOCK_TICK and VCLOCK_STICK.

So all you need is:

static inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vdso_time_data *vd)

{
	if (likely(clock_mode == VDSO_CLOCKMODE_STICK))
		return vread_stick();

        if (clock_mode == VDSO_CLOCKMODE_TICK))
		return vread_tick();

	return U64_MAX;
}

Plus a 32-bit specific version of vdso_shift_ns(), which means just renaming the 32-bit variant of __shr64() and removing the then pointless notrace annotation.

This should just work out of the box and the performance regression will be minimal if even measurable.

Thanks,

tglx

Reviewed-by Tested-by on v1 1/2
#10 lore raw
In reply to Arnd Bergmann
Quoted 17 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

sparc64 is the only remaining architecture that has its own implementation of the vdso clock_gettime/gettimeofday helpers in place of the generic code. This causes a number of issues:

- Changes to the vdso interfaces require adding sparc64 specific hacks even when nothing else needs them

- The prototypes in <vdso/gettime.h> don't match the function implementation, and not including that header to avoid the build error from that causes another warning:

arch/sparc/vdso/vclock_gettime.c:274:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
274 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~

Quoted 7 lines

- Nobody has ever implemented the clock_gettime64() vdso that is required for 32-bit compat tasks

- The warning about the missing executable-stack flag was missed:

sparc-linux-ld: warning: arch/sparc/vdso/vdso-note.o: missing .note.GNU-stack section implies executable stack
sparc-linux-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

IMO this should be in its own patch.

Quoted 9 lines

Most of the removed code only exists on sparc in order to dynamically patch the vdso based on the presence of the tick vs vtick based clocksource.

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Thanks, this makes things easier.

But why do we even need the stubs? Removing the time functions from the vDSO completely should also work, no?
For parisc there was no reasoning why stubs were used. On uml the stubs are necessary to prevent the libc from calling into the host vsyscall [0], but that looks irrelevant for SPARC.

[0] f1c2bb8b9964 ("um: implement a x86_64 vDSO")

#11 lore raw
Quoted 6 lines · Thomas Weißschuh
Quoted 3 lines · Arnd Bergmann

sparc-linux-ld: warning: arch/sparc/vdso/vdso-note.o: missing .note.GNU-stack section implies executable stack
sparc-linux-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

IMO this should be in its own patch.

Fair enough, I considered splitting up my patch further already but tried to keep it simple. This one does make sense to split out though.

Quoted 15 lines
Quoted 9 lines

Most of the removed code only exists on sparc in order to dynamically patch the vdso based on the presence of the tick vs vtick based clocksource.

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Thanks, this makes things easier.

Quoted 7 lines

But why do we even need the stubs? Removing the time functions from the vDSO completely should also work, no?
For parisc there was no reasoning why stubs were used. On uml the stubs are necessary to prevent the libc from calling into the host vsyscall [0], but that looks irrelevant for SPARC.

[0] f1c2bb8b9964 ("um: implement a x86_64 vDSO")

I was wondering about this myself, I thought this might have been for runtime environments that just assume the vDSO is there, possibly some non-C libraries, or future glibc versions that may error out when the vdso is absent instead of falling back to the syscall.

The 5f55e098b8d0 ("parisc: Add 64-bit gettimeofday() and clock_gettime() vDSO functions") commit and the corresponding glibc patch one don't have any explanation unfortunately, but maybe Helge can explain why this is needed.

The arch/x86/um/vdso/um_vdso.c version for 32-bit seems to still be missing the clock_gettime64() entry, any idea what the resulting behavior is for time64 userspace?

Arnd

#12 lore raw
Quoted 1 line · Arnd Bergmann

On Tue, Jul 8, 2025, at 07:39, Thomas Weißschuh wrote:

(...)

Quoted 6 lines
Quoted 6 lines

But why do we even need the stubs? Removing the time functions from the vDSO completely should also work, no?
For parisc there was no reasoning why stubs were used. On uml the stubs are necessary to prevent the libc from calling into the host vsyscall [0], but that looks irrelevant for SPARC.

Quoted 6 lines
Quoted 1 line

[0] f1c2bb8b9964 ("um: implement a x86_64 vDSO")

I was wondering about this myself, I thought this might have been for runtime environments that just assume the vDSO is there, possibly some non-C libraries, or future glibc versions that may error out when the vdso is absent instead of falling back to the syscall.

libc erroring out if the vdso is missing sounds unlikely to me.

(...)

Quoted 3 lines

The arch/x86/um/vdso/um_vdso.c version for 32-bit seems to still be missing the clock_gettime64() entry, any idea what the resulting behavior is for time64 userspace?

The vsyscall page is for 64-bit userspace only, and I think always ways.

In any case, modern distro kernels don't provide the vsyscall page at all or emulate it through syscall stubs, which are affected by the uml host access issue. Also glibc dropped vsyscall page support in 2020.

Thomas

#13 lore raw
In reply to Arnd Bergmann
Quoted 29 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

sparc64 is the only remaining architecture that has its own implementation of the vdso clock_gettime/gettimeofday helpers in place of the generic code. This causes a number of issues:

- Changes to the vdso interfaces require adding sparc64 specific hacks even when nothing else needs them

- The prototypes in <vdso/gettime.h> don't match the function implementation, and not including that header to avoid the build error from that causes another warning:

arch/sparc/vdso/vclock_gettime.c:274:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
274 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~

- Nobody has ever implemented the clock_gettime64() vdso that is required for 32-bit compat tasks

- The warning about the missing executable-stack flag was missed:

sparc-linux-ld: warning: arch/sparc/vdso/vdso-note.o: missing .note.GNU-stack section implies executable stack
sparc-linux-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Most of the removed code only exists on sparc in order to dynamically patch the vdso based on the presence of the tick vs vtick based clocksource.

Quoted 5 lines

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

FYI I have a series prepared that will move SPARC to the generic vDSO and also addresses the problems listed above and mentioned by tglx.

I'll send it after the merge window.

(...)

Thomas

#14 lore raw

Hi Thomas,

Quoted 34 lines · Thomas Weißschuh
Quoted 33 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

sparc64 is the only remaining architecture that has its own implementation of the vdso clock_gettime/gettimeofday helpers in place of the generic code. This causes a number of issues:

- Changes to the vdso interfaces require adding sparc64 specific hacks even when nothing else needs them

- The prototypes in <vdso/gettime.h> don't match the function implementation, and not including that header to avoid the build error from that causes another warning:

arch/sparc/vdso/vclock_gettime.c:274:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
274 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~

- Nobody has ever implemented the clock_gettime64() vdso that is required for 32-bit compat tasks

- The warning about the missing executable-stack flag was missed:

sparc-linux-ld: warning: arch/sparc/vdso/vdso-note.o: missing .note.GNU-stack section implies executable stack
sparc-linux-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Most of the removed code only exists on sparc in order to dynamically patch the vdso based on the presence of the tick vs vtick based clocksource.

Rip out the whole thing and replace it with a minimal stub as we do on parisc and uml. This introduces a small performance regression when using a libc that is aware of the vdso (glibc-2.29 or higher).

Quoted 6 lines
Quoted 1 line

FYI I have a series prepared that will move SPARC to the generic vDSO and also addresses the problems listed above and mentioned by tglx.

I'll send it after the merge window.

Great, thanks a lot! Andreas can then retest the patch and see if the performance hit is measurable or acceptable at all.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#15 lore raw
In reply to Thomas Weißschuh
Quoted 4 lines · Thomas Weißschuh

FYI I have a series prepared that will move SPARC to the generic vDSO and also addresses the problems listed above and mentioned by tglx.

I'll send it after the merge window.

Just post it as an RFC, so people can test it.