In order to reproduce the error I took the code from here (also
attached):
https://gist.github.com/chergert/eb6149916b10d3bf094c
and commented out the #include <asm/vsyscall.h>.

and compiled it with
gcc vdso-getcpu.c -ldl

running the resulting a.out will crash on a s390x qemu guest, but on
ppc64el guest not.
I hope this narrows the scope a bit.

#include <dlfcn.h>
#include <stdio.h>
//#include <asm/vsyscall.h>
#include <sys/auxv.h>

int (*test_getcpu) (unsigned *cpu,
                    unsigned *node,
                    void *cache);

void *
get_vdso_sym (const char *name)
{
  static const char *vdso_names[] = {
    "linux-vdso.so.1",
    "linux-vdso32.so.1",
    "linux-vdso64.so.1",
    NULL
  };
  int i;

  for (i = 0; vdso_names [i]; i++)
    {
      void *lib;
      void *symbol;

      lib = dlopen (vdso_names [i], RTLD_NOW | RTLD_GLOBAL);
      if (lib == NULL)
        continue;

      symbol = dlsym (lib, name);
      if (symbol == NULL)
        goto cleanup;

      if (*(void **)symbol == NULL)
        goto cleanup;

      return symbol;

    cleanup:
      dlclose (lib);
    }
}

int
main (int argc,
      char *argv[])
{
  int ret;
  int cpu = -1;

  test_getcpu = get_vdso_sym ("__kernel_getcpu");
  if (test_getcpu == NULL)
    test_getcpu = get_vdso_sym ("__vdso_getcpu");

  ret = test_getcpu (&cpu, NULL, NULL);

  printf ("ret = %d  cpu = %d\n", ret, cpu);

  return 0;
}

Reply via email to