[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH 1/2] m68k: Use vDSO for thread pointer access



* 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: