Commit 4cd09f35 authored by Huacai Chen's avatar Huacai Chen
Browse files

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent b15dfdac
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 */
+2 −0
Original line number Diff line number Diff line
@@ -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)
+6 −1
Original line number Diff line number Diff line
@@ -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))) \
+2 −2
Original line number Diff line number Diff line
@@ -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: *;
+8 −0
Original line number Diff line number Diff line
@@ -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;
}