vdso.h 871 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Author: Huacai Chen <[email protected]>
  4. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  5. */
  6. #ifndef __ASSEMBLY__
  7. #include <asm/asm.h>
  8. #include <asm/page.h>
  9. #include <asm/vdso.h>
  10. struct vdso_pcpu_data {
  11. u32 node;
  12. } ____cacheline_aligned_in_smp;
  13. struct loongarch_vdso_data {
  14. struct vdso_pcpu_data pdata[NR_CPUS];
  15. struct vdso_data data[CS_BASES]; /* Arch-independent data */
  16. };
  17. #define VDSO_DATA_SIZE PAGE_ALIGN(sizeof(struct loongarch_vdso_data))
  18. static inline unsigned long get_vdso_base(void)
  19. {
  20. unsigned long addr;
  21. __asm__(
  22. " la.pcrel %0, _start\n"
  23. : "=r" (addr)
  24. :
  25. :);
  26. return addr;
  27. }
  28. static inline const struct vdso_data *get_vdso_data(void)
  29. {
  30. return (const struct vdso_data *)(get_vdso_base()
  31. - VDSO_DATA_SIZE + SMP_CACHE_BYTES * NR_CPUS);
  32. }
  33. #endif /* __ASSEMBLY__ */