]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: Adjust VDSO/VSYSCALL for 32BIT/64BIT
authorHuacai Chen <chenhuacai@loongson.cn>
Mon, 8 Dec 2025 10:09:17 +0000 (18:09 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 8 Dec 2025 10:09:17 +0000 (18:09 +0800)
Adjust VDSO/VSYSCALL because read_cpu_id() for 32BIT/64BIT are
different, and LoongArch32 doesn't support GENERIC_GETTIMEOFDAY now
(will be supported in future).

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/vdso/gettimeofday.h
arch/loongarch/kernel/time.c
arch/loongarch/vdso/Makefile
arch/loongarch/vdso/vdso.lds.S
arch/loongarch/vdso/vgetcpu.c

index dcafabca9bb69586c93c9b61f51de4769f7cf037..bae76767c693a96492cff8c58b31f860150505de 100644 (file)
@@ -12,6 +12,8 @@
 #include <asm/unistd.h>
 #include <asm/vdso/vdso.h>
 
+#ifdef CONFIG_GENERIC_GETTIMEOFDAY
+
 #define VDSO_HAS_CLOCK_GETRES          1
 
 static __always_inline long gettimeofday_fallback(
@@ -89,6 +91,8 @@ static inline bool loongarch_vdso_hres_capable(void)
 }
 #define __arch_vdso_hres_capable loongarch_vdso_hres_capable
 
+#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
+
 #endif /* !__ASSEMBLER__ */
 
 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */
index 5892f6da07a512e855230686d36ded4b7b5b6d79..dbaaabcaf6f09ed3c34c36ab5d9c01a9072d199c 100644 (file)
@@ -212,7 +212,9 @@ static struct clocksource clocksource_const = {
        .read = read_const_counter,
        .mask = CLOCKSOURCE_MASK(64),
        .flags = CLOCK_SOURCE_IS_CONTINUOUS,
+#ifdef CONFIG_GENERIC_GETTIMEOFDAY
        .vdso_clock_mode = VDSO_CLOCKMODE_CPU,
+#endif
 };
 
 int __init constant_clocksource_init(void)
index d8316f993482406c2633b49b1daa475fc415a82c..a8ac0e811e39c1f277214a7ef5cb66a20a537f9c 100644 (file)
@@ -4,8 +4,9 @@
 # Include the generic Makefile to check the built vdso.
 include $(srctree)/lib/vdso/Makefile.include
 
-obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o vgetrandom.o \
+obj-vdso-y := elf.o vgetcpu.o vgetrandom.o \
               vgetrandom-chacha.o sigreturn.o
+obj-vdso-$(CONFIG_GENERIC_GETTIMEOFDAY) += vgettimeofday.o
 
 # Common compiler flags between ABIs.
 ccflags-vdso := \
@@ -16,6 +17,10 @@ ccflags-vdso := \
        $(CLANG_FLAGS) \
        -D__VDSO__
 
+ifdef CONFIG_32BIT
+ccflags-vdso += -DBUILD_VDSO32
+endif
+
 cflags-vdso := $(ccflags-vdso) \
        -isystem $(shell $(CC) -print-file-name=include) \
        $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
index 8ff98649994750e74b30a91270d9d9ea2ba751e8..ac537e02beb1839eeb178b2be25e8d398487c76d 100644 (file)
@@ -7,8 +7,6 @@
 #include <generated/asm-offsets.h>
 #include <vdso/datapage.h>
 
-OUTPUT_FORMAT("elf64-loongarch", "elf64-loongarch", "elf64-loongarch")
-
 OUTPUT_ARCH(loongarch)
 
 SECTIONS
@@ -63,9 +61,11 @@ VERSION
        LINUX_5.10 {
        global:
                __vdso_getcpu;
+#ifdef CONFIG_GENERIC_GETTIMEOFDAY
                __vdso_clock_getres;
                __vdso_clock_gettime;
                __vdso_gettimeofday;
+#endif
                __vdso_getrandom;
                __vdso_rt_sigreturn;
        local: *;
index 5301cd9d0f839eb0fd7b73a1d36e80aaa75d5e76..73af49242ecdc8112007262ff711d14d1f342fa1 100644 (file)
@@ -10,11 +10,19 @@ static __always_inline int read_cpu_id(void)
 {
        int cpu_id;
 
+#ifdef CONFIG_64BIT
        __asm__ __volatile__(
        "       rdtime.d $zero, %0\n"
        : "=r" (cpu_id)
        :
        : "memory");
+#else
+       __asm__ __volatile__(
+       "       rdtimel.w $zero, %0\n"
+       : "=r" (cpu_id)
+       :
+       : "memory");
+#endif
 
        return cpu_id;
 }