Skip to content

Commit 4cd09f3

Browse files
committed
LoongArch: Adjust VDSO/VSYSCALL for 32BIT/64BIT
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>
1 parent b15dfda commit 4cd09f3

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

arch/loongarch/include/asm/vdso/gettimeofday.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <asm/unistd.h>
1313
#include <asm/vdso/vdso.h>
1414

15+
#ifdef CONFIG_GENERIC_GETTIMEOFDAY
16+
1517
#define VDSO_HAS_CLOCK_GETRES 1
1618

1719
static __always_inline long gettimeofday_fallback(
@@ -89,6 +91,8 @@ static inline bool loongarch_vdso_hres_capable(void)
8991
}
9092
#define __arch_vdso_hres_capable loongarch_vdso_hres_capable
9193

94+
#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
95+
9296
#endif /* !__ASSEMBLER__ */
9397

9498
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */

arch/loongarch/kernel/time.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ static struct clocksource clocksource_const = {
212212
.read = read_const_counter,
213213
.mask = CLOCKSOURCE_MASK(64),
214214
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
215+
#ifdef CONFIG_GENERIC_GETTIMEOFDAY
215216
.vdso_clock_mode = VDSO_CLOCKMODE_CPU,
217+
#endif
216218
};
217219

218220
int __init constant_clocksource_init(void)

arch/loongarch/vdso/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# Include the generic Makefile to check the built vdso.
55
include $(srctree)/lib/vdso/Makefile.include
66

7-
obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o vgetrandom.o \
7+
obj-vdso-y := elf.o vgetcpu.o vgetrandom.o \
88
vgetrandom-chacha.o sigreturn.o
9+
obj-vdso-$(CONFIG_GENERIC_GETTIMEOFDAY) += vgettimeofday.o
910

1011
# Common compiler flags between ABIs.
1112
ccflags-vdso := \
@@ -16,6 +17,10 @@ ccflags-vdso := \
1617
$(CLANG_FLAGS) \
1718
-D__VDSO__
1819

20+
ifdef CONFIG_32BIT
21+
ccflags-vdso += -DBUILD_VDSO32
22+
endif
23+
1924
cflags-vdso := $(ccflags-vdso) \
2025
-isystem $(shell $(CC) -print-file-name=include) \
2126
$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \

arch/loongarch/vdso/vdso.lds.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <generated/asm-offsets.h>
88
#include <vdso/datapage.h>
99

10-
OUTPUT_FORMAT("elf64-loongarch", "elf64-loongarch", "elf64-loongarch")
11-
1210
OUTPUT_ARCH(loongarch)
1311

1412
SECTIONS
@@ -63,9 +61,11 @@ VERSION
6361
LINUX_5.10 {
6462
global:
6563
__vdso_getcpu;
64+
#ifdef CONFIG_GENERIC_GETTIMEOFDAY
6665
__vdso_clock_getres;
6766
__vdso_clock_gettime;
6867
__vdso_gettimeofday;
68+
#endif
6969
__vdso_getrandom;
7070
__vdso_rt_sigreturn;
7171
local: *;

arch/loongarch/vdso/vgetcpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ static __always_inline int read_cpu_id(void)
1010
{
1111
int cpu_id;
1212

13+
#ifdef CONFIG_64BIT
1314
__asm__ __volatile__(
1415
" rdtime.d $zero, %0\n"
1516
: "=r" (cpu_id)
1617
:
1718
: "memory");
19+
#else
20+
__asm__ __volatile__(
21+
" rdtimel.w $zero, %0\n"
22+
: "=r" (cpu_id)
23+
:
24+
: "memory");
25+
#endif
1826

1927
return cpu_id;
2028
}

0 commit comments

Comments
 (0)