parisc: Add 32-bit gettimeofday() and clock_gettime() vDSO functions

Add vDSO implementations for gettimeofday(), clock_gettime() and
clock_gettime64() kernel syscalls.
Currently those functions are implemented as pure syscall wrappers.

Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
Helge Deller 2024-06-19 01:42:28 +02:00
parent af42d252ea
commit e23d9c0b52
4 changed files with 57 additions and 4 deletions

View file

@ -19,6 +19,6 @@ extern struct vdso_data *vdso_data;
/* Default link addresses for the vDSOs */
#define VDSO_LBASE 0
#define VDSO_VERSION_STRING LINUX_5.18
#define VDSO_VERSION_STRING LINUX_6.11
#endif /* __PARISC_VDSO_H__ */

View file

@ -1,11 +1,25 @@
# List of files in the vdso, has to be asm only for now
# Include the generic Makefile to check the built vdso.
include $(srctree)/lib/vdso/Makefile
KCOV_INSTRUMENT := n
# Disable gcov profiling, ubsan and kasan for VDSO code
GCOV_PROFILE := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n
obj-vdso32 = note.o sigtramp.o restart_syscall.o
obj-cvdso32 = vdso32_generic.o
# Build rules
targets := $(obj-vdso32) vdso32.so
targets := $(obj-vdso32) $(obj-cvdso32) vdso32.so
obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
obj-cvdso32 := $(addprefix $(obj)/, $(obj-cvdso32))
VDSO_CFLAGS_REMOVE := -pg $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_vdso32_generic.o = $(VDSO_CFLAGS_REMOVE)
ccflags-y := -shared -fno-common -fbuiltin -mno-fast-indirect-calls -O2 -mno-long-calls
# -march=1.1 -mschedule=7100LC
@ -26,18 +40,22 @@ $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so FORCE
# Force dependency (incbin is bad)
# link rule for the .so file, .lds has to be first
$(obj)/vdso32.so: $(obj)/vdso32.lds $(obj-vdso32) $(VDSO_LIBGCC) FORCE
$(obj)/vdso32.so: $(obj)/vdso32.lds $(obj-vdso32) $(obj-cvdso32) $(VDSO_LIBGCC) FORCE
$(call if_changed,vdso32ld)
# assembly rules for the .S files
$(obj-vdso32): %.o: %.S FORCE
$(call if_changed_dep,vdso32as)
$(obj-cvdso32): %.o: %.c FORCE
$(call if_changed_dep,vdso32cc)
# actual build commands
quiet_cmd_vdso32ld = VDSO32L $@
cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $(filter-out FORCE, $^) -o $@
quiet_cmd_vdso32as = VDSO32A $@
cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $<
quiet_cmd_vdso32cc = VDSO32C $@
cmd_vdso32cc = $(CROSS32CC) $(c_flags) -c -o $@ $<
# Generate VDSO offsets using helper script
gen-vdsosym := $(src)/gen_vdso_offsets.sh

View file

@ -106,6 +106,9 @@ VERSION
global:
__kernel_sigtramp_rt32;
__kernel_restart_syscall32;
__vdso_gettimeofday;
__vdso_clock_gettime;
__vdso_clock_gettime64;
local: *;
};
}

View file

@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-2.0
#include "asm/unistd.h"
#include <linux/types.h>
#include <uapi/asm/unistd_32.h>
struct timezone;
struct old_timespec32;
struct __kernel_timespec;
struct __kernel_old_timeval;
/* forward declarations */
int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts);
int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts);
int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
struct timezone *tz)
{
return syscall2(__NR_gettimeofday, (long)tv, (long)tz);
}
int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts)
{
return syscall2(__NR_clock_gettime, (long)clock, (long)ts);
}
int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts)
{
return syscall2(__NR_clock_gettime64, (long)clock, (long)ts);
}