Re: [PATCH] powerpc/vdso: Provide clock_getres_time64()

Thomas Weißschuh
2026-01-22T10:49:08Z

On Thu, Jan 22, 2026 at 11:27:43AM +0100, Christophe Leroy (CS GROUP) wrote:
> Hi Thomas,
>
> Le 22/01/2026 à 10:50, Thomas Weißschuh a écrit :
> > Hi Alexander,
> >
> > On Thu, Jan 22, 2026 at 09:39:09AM +0000, Sverdlin, Alexander wrote:
> > > Hi Thomas, Christophe,
> > >
> > > On Wed, 2026-01-14 at 08:26 +0100, Thomas Weißschuh wrote:
> > > > For consistency with __vdso_clock_gettime64() there should also be a
> > > > 64-bit variant of clock_getres(). This will allow the extension of
> > > > CONFIG_COMPAT_32BIT_TIME to the vDSO and finally the removal of 32-bit
> > > > time types from the kernel and UAPI.
> > > >
> > > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > >
> > > I've bisected this patch to cause the following build failure on my side:
> > >
> > > LDS arch/powerpc/kernel/vdso/vdso32.lds
> > > VDSO32A arch/powerpc/kernel/vdso/sigtramp32-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/gettimeofday-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/datapage-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/cacheflush-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/note-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/getcpu-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/getrandom-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/vgetrandom-chacha-32.o
> > > VDSO32C arch/powerpc/kernel/vdso/vgettimeofday-32.o
> > > VDSO32C arch/powerpc/kernel/vdso/vgetrandom-32.o
> > > VDSO32A arch/powerpc/kernel/vdso/crtsavres-32.o
> > > VDSO32L arch/powerpc/kernel/vdso/vdso32.so.dbg
> > > arch/powerpc/kernel/vdso/vdso32.so.dbg: dynamic relocations are not supported
> > > make[2]: *** [arch/powerpc/kernel/vdso/Makefile:79: arch/powerpc/kernel/vdso/vdso32.so.dbg] Error 1
> > > make[1]: *** [arch/powerpc/Makefile:388: vdso_prepare] Error 2
> >
> > Thanks for the report!
> >
> > > Does it ring any bells? What could I try/test?
> >
> > Not immediately, but I'll look into it.
> >
> > > I'm using gcc-15.2.0 and binutils 2.45.1.
> >
> > Is this a toolchain from https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcdn.kernel.org%2Fpub%2Ftools%2Fcrosstool%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C03b93d2aa659407b3e5a08de599bb85e%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639046722536758587%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=b9WoZvMR2V3RUpOwrJtm6kmXrpnLti%2BeMJ6zpyB%2Fv4k%3D&reserved=0 ?
> > Could you also share your configuration?
>
> I've just been able to reproduce it with ppc64_defconfig +
> CONFIG_CC_OPTIMIZE_FOR_SIZE

Thanks for the hint, no I can reproduce it, too.
>
> VDSO32L arch/powerpc/kernel/vdso/vdso32.so.dbg
> arch/powerpc/kernel/vdso/vdso32.so.dbg: dynamic relocations are not
> supported
> make[2]: *** [arch/powerpc/kernel/vdso/Makefile:79:
> arch/powerpc/kernel/vdso/vdso32.so.dbg] Error 1
> make[1]: *** [arch/powerpc/Makefile:388: vdso_prepare] Error 2
> make: *** [Makefile:248: __sub-make] Error 2
>
> I'll investigate

It seems the compiler decides to call memset(), which is not valid from the
vDSO. We are are using -ffreestanding. Disabling CONFIG_INIT_STACK_ALL_ZERO
fixes the issue. So I guess we should a) figure out why -ffreestanding does
not seem to work here and b) exclude the vDSO from the stack initialization
logic.

000007ac <__c_kernel_clock_getres>:
; __c_kernel_clock_getres():
; arch/powerpc/kernel/vdso/vgettimeofday.c:35
; {
7ac: d0 ff 21 94 stwu 1, -48(1)
7b0: a6 02 08 7c mflr 0
7b4: 30 00 61 39 addi 11, 1, 48
7b8: 34 00 01 90 stw 0, 52(1)
7bc: 01 00 00 48 bl 0x7bc <__c_kernel_clock_getres+0x10>
000007bc: R_PPC_REL24 _savegpr_29
7c0: 78 1b 7e 7c mr 30, 3
7c4: 78 2b bd 7c mr 29, 5
7c8: 78 23 9f 7c mr 31, 4
; lib/vdso/gettimeofday.c:491
; struct __kernel_timespec ts;
7cc: 10 00 a0 38 li 5, 16
7d0: 00 00 80 38 li 4, 0
7d4: 08 00 61 38 addi 3, 1, 8
7d8: 01 00 00 48 bl 0x7d8 <__c_kernel_clock_getres+0x2c>
000007d8: R_PPC_REL24 memset
; lib/vdso/gettimeofday.c:494
; ok = __cvdso_clock_getres_common(vd, clock, &ts);
7dc: 78 f3 c4 7f mr 4, 30
7e0: 78 eb a3 7f mr 3, 29
7e4: 08 00 a1 38 addi 5, 1, 8
7e8: 19 f8 ff 4b bl 0x0 <__cvdso_clock_getres_common>
; lib/vdso/gettimeofday.c:496

(...)

Thomas