Re: [PATCH 1/2] m68k: Use vDSO for thread pointer access
You raise a good point. The current implementation has glibc directly
reading from the vvar data page, which tightly couples glibc to the
kernel's internal vDSO memory layout.
The more standard approach would be to export a __vdso_get_thread_area
function from the vDSO that glibc calls via the normal vDSO symbol
lookup mechanism. This would:
1. Follow the established vDSO pattern used by clock_gettime,
gettimeofday, etc.
2. Allow the kernel to change the internal vvar layout without breaking glibc
3. Keep the ABI contract at the function level rather than data
structure level
The tradeoff is a small amount of function call overhead, but that's
still much faster than the syscall we're replacing.
I can rework this to export __vdso_get_thread_area from the vDSO and
have glibc use standard vDSO symbol lookup. Would that be the
preferred approach?
Stefan
On Thu, Jan 8, 2026 at 5:33 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Stefan:
>
> > +/*
> > + * Initialize the vDSO pointer on first use.
> > + * Returns the pointer to the vDSO data, or NULL if not available.
> > + */
> > +static inline struct m68k_vdso_data *
> > +__m68k_vdso_get (void)
> > +{
> > + struct m68k_vdso_data *vdso = (struct m68k_vdso_data *) __m68k_vdso_data;
> > +
> > + if (__glibc_unlikely (vdso == NULL))
> > + {
> > + /* Not yet initialized - try to get vDSO base from auxv */
> > + unsigned long sysinfo_ehdr = __getauxval (AT_SYSINFO_EHDR);
> > + if (sysinfo_ehdr != 0)
> > + {
> > + /*
> > + * The kernel passes the address of the vDSO ELF header (code page).
> > + * The vDSO memory layout is:
> > + * base + 0x0000: vvar (data page with TLS pointer, clock state)
> > + * base + 0x1000: timer page (hardware timer registers)
> > + * base + 0x2000: vDSO code (ELF, AT_SYSINFO_EHDR points here)
> > + * So the data page is 2 * PAGE_SIZE before the code page.
> > + */
> > + vdso = (struct m68k_vdso_data *) (sysinfo_ehdr - 2 * 4096);
> > + }
> > + else
> > + {
> > + /* vDSO not available - mark as unavailable */
> > + vdso = (struct m68k_vdso_data *) (uintptr_t) -1;
> > + }
> > + __m68k_vdso_data = vdso;
> > + }
>
> Is this really the documented userspace interface? I would expect that
> we'd have to do a vDSO call to read the thread pointer.
>
> Thanks,
> Florian
>
Reply to: