Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull VDSO updates from Thomas Gleixner:

- Further consolidation of the VDSO infrastructure and the common data
store

- Simplification of the related Kconfig logic

- Improve the VDSO selftest suite

* tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
selftests: vDSO: Drop vdso_test_clock_getres
selftests: vDSO: vdso_test_abi: Add tests for clock_gettime64()
selftests: vDSO: vdso_test_abi: Test CPUTIME clocks
selftests: vDSO: vdso_test_abi: Use explicit indices for name array
selftests: vDSO: vdso_test_abi: Drop clock availability tests
selftests: vDSO: vdso_test_abi: Use ksft_finished()
selftests: vDSO: vdso_test_abi: Correctly skip whole test with missing vDSO
selftests: vDSO: Fix -Wunitialized in powerpc VDSO_CALL() wrapper
vdso: Add struct __kernel_old_timeval forward declaration to gettime.h
vdso: Gate VDSO_GETRANDOM behind HAVE_GENERIC_VDSO
vdso: Drop Kconfig GENERIC_VDSO_TIME_NS
vdso: Drop Kconfig GENERIC_VDSO_DATA_STORE
vdso: Drop kconfig GENERIC_COMPAT_VDSO
vdso: Drop kconfig GENERIC_VDSO_32
riscv: vdso: Untangle Kconfig logic
time: Build generic update_vsyscall() only with generic time vDSO
vdso/gettimeofday: Remove !CONFIG_TIME_NS stubs
vdso: Move ENABLE_COMPAT_VDSO from core to arm64
ARM: VDSO: Remove cntvct_ok global variable
vdso/datastore: Gate time data behind CONFIG_GENERIC_GETTIMEOFDAY

+91 -285
+1 -1
arch/Kconfig
··· 1657 1657 related optimizations for a given architecture. 1658 1658 1659 1659 config ARCH_HAS_VDSO_ARCH_DATA 1660 - depends on GENERIC_VDSO_DATA_STORE 1660 + depends on HAVE_GENERIC_VDSO 1661 1661 bool 1662 1662 1663 1663 config ARCH_HAS_VDSO_TIME_DATA
-2
arch/arm/include/asm/vdso/vsyscall.h
··· 7 7 #include <vdso/datapage.h> 8 8 #include <asm/cacheflush.h> 9 9 10 - extern bool cntvct_ok; 11 - 12 10 static __always_inline 13 11 void __arch_sync_vdso_time_data(struct vdso_time_data *vdata) 14 12 {
+3 -7
arch/arm/kernel/vdso.c
··· 54 54 char *dynstr; /* ptr to .dynstr section */ 55 55 }; 56 56 57 - /* Cached result of boot-time check for whether the arch timer exists, 58 - * and if so, whether the virtual counter is useable. 57 + /* Boot-time check for whether the arch timer exists, and if so, 58 + * whether the virtual counter is usable. 59 59 */ 60 - bool cntvct_ok __ro_after_init; 61 - 62 60 static bool __init cntvct_functional(void) 63 61 { 64 62 struct device_node *np; ··· 157 159 * want programs to incur the slight additional overhead of 158 160 * dispatching through the VDSO only to fall back to syscalls. 159 161 */ 160 - if (!cntvct_ok) { 162 + if (!cntvct_functional()) { 161 163 vdso_nullpatch_one(&einfo, "__vdso_gettimeofday"); 162 164 vdso_nullpatch_one(&einfo, "__vdso_clock_gettime"); 163 165 vdso_nullpatch_one(&einfo, "__vdso_clock_gettime64"); ··· 194 196 195 197 vdso_total_pages = VDSO_NR_PAGES; /* for the data/vvar pages */ 196 198 vdso_total_pages += text_pages; 197 - 198 - cntvct_ok = cntvct_functional(); 199 199 200 200 patch_vdso(vdso_start); 201 201
-2
arch/arm/mm/Kconfig
··· 926 926 default y if ARM_ARCH_TIMER 927 927 select HAVE_GENERIC_VDSO 928 928 select GENERIC_TIME_VSYSCALL 929 - select GENERIC_VDSO_32 930 929 select GENERIC_GETTIMEOFDAY 931 - select GENERIC_VDSO_DATA_STORE 932 930 help 933 931 Place in the process address space an ELF shared object 934 932 providing fast implementations of gettimeofday and
-3
arch/arm64/Kconfig
··· 166 166 select GENERIC_SMP_IDLE_THREAD 167 167 select GENERIC_TIME_VSYSCALL 168 168 select GENERIC_GETTIMEOFDAY 169 - select GENERIC_VDSO_DATA_STORE 170 - select GENERIC_VDSO_TIME_NS 171 169 select HARDIRQS_SW_RESEND 172 170 select HAS_IOPORT 173 171 select HAVE_MOVE_PMD ··· 1748 1750 bool "Enable vDSO for 32-bit applications" 1749 1751 depends on !CPU_BIG_ENDIAN 1750 1752 depends on (CC_IS_CLANG && LD_IS_LLD) || "$(CROSS_COMPILE_COMPAT)" != "" 1751 - select GENERIC_COMPAT_VDSO 1752 1753 default y 1753 1754 help 1754 1755 Place in the process address space of 32-bit applications an
+3 -4
arch/arm64/include/asm/vdso/compat_barrier.h
··· 7 7 8 8 #ifndef __ASSEMBLY__ 9 9 /* 10 - * Warning: This code is meant to be used with 11 - * ENABLE_COMPAT_VDSO only. 10 + * Warning: This code is meant to be used from the compat vDSO only. 12 11 */ 13 - #ifndef ENABLE_COMPAT_VDSO 14 - #error This header is meant to be used with ENABLE_COMPAT_VDSO only 12 + #ifdef __arch64__ 13 + #error This header is meant to be used with from the compat vDSO only 15 14 #endif 16 15 17 16 #ifdef dmb
+3 -3
arch/arm64/include/asm/vdso/compat_gettimeofday.h
··· 2 2 /* 3 3 * Copyright (C) 2018 ARM Limited 4 4 */ 5 - #ifndef __ASM_VDSO_GETTIMEOFDAY_H 6 - #define __ASM_VDSO_GETTIMEOFDAY_H 5 + #ifndef __ASM_VDSO_COMPAT_GETTIMEOFDAY_H 6 + #define __ASM_VDSO_COMPAT_GETTIMEOFDAY_H 7 7 8 8 #ifndef __ASSEMBLY__ 9 9 ··· 163 163 164 164 #endif /* !__ASSEMBLY__ */ 165 165 166 - #endif /* __ASM_VDSO_GETTIMEOFDAY_H */ 166 + #endif /* __ASM_VDSO_COMPAT_GETTIMEOFDAY_H */
+8
arch/arm64/include/asm/vdso/gettimeofday.h
··· 5 5 #ifndef __ASM_VDSO_GETTIMEOFDAY_H 6 6 #define __ASM_VDSO_GETTIMEOFDAY_H 7 7 8 + #ifdef __aarch64__ 9 + 8 10 #ifndef __ASSEMBLY__ 9 11 10 12 #include <asm/alternative.h> ··· 97 95 #endif /* IS_ENABLED(CONFIG_CC_IS_GCC) && IS_ENABLED(CONFIG_PAGE_SIZE_64KB) */ 98 96 99 97 #endif /* !__ASSEMBLY__ */ 98 + 99 + #else /* !__aarch64__ */ 100 + 101 + #include "compat_gettimeofday.h" 102 + 103 + #endif /* __aarch64__ */ 100 104 101 105 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */
-1
arch/arm64/kernel/vdso32/Makefile
··· 57 57 VDSO_CAFLAGS += -march=armv8-a 58 58 59 59 VDSO_CFLAGS := $(VDSO_CAFLAGS) 60 - VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1 61 60 # KBUILD_CFLAGS from top-level Makefile 62 61 VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 63 62 -fno-strict-aliasing -fno-common \
-2
arch/loongarch/Kconfig
··· 110 110 select GENERIC_SCHED_CLOCK 111 111 select GENERIC_SMP_IDLE_THREAD 112 112 select GENERIC_TIME_VSYSCALL 113 - select GENERIC_VDSO_DATA_STORE 114 - select GENERIC_VDSO_TIME_NS 115 113 select GPIOLIB 116 114 select HAS_IOPORT 117 115 select HAVE_ARCH_AUDITSYSCALL
-1
arch/mips/Kconfig
··· 51 51 select GENERIC_SMP_IDLE_THREAD 52 52 select GENERIC_IDLE_POLL_SETUP 53 53 select GENERIC_TIME_VSYSCALL 54 - select GENERIC_VDSO_DATA_STORE 55 54 select GUP_GET_PXX_LOW_HIGH if CPU_MIPS32 && PHYS_ADDR_T_64BIT 56 55 select HAS_IOPORT if !NO_IOPORT_MAP || ISA 57 56 select HAVE_ARCH_COMPILER_H
-2
arch/powerpc/Kconfig
··· 210 210 select GENERIC_PCI_IOMAP if PCI 211 211 select GENERIC_SMP_IDLE_THREAD 212 212 select GENERIC_TIME_VSYSCALL 213 - select GENERIC_VDSO_DATA_STORE 214 - select GENERIC_VDSO_TIME_NS 215 213 select HAS_IOPORT if PCI 216 214 select HAVE_ARCH_AUDITSYSCALL 217 215 select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP
+5 -7
arch/riscv/Kconfig
··· 53 53 select ARCH_HAS_SYSCALL_WRAPPER 54 54 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 55 55 select ARCH_HAS_UBSAN 56 - select ARCH_HAS_VDSO_ARCH_DATA if GENERIC_VDSO_DATA_STORE 56 + select ARCH_HAS_VDSO_ARCH_DATA if HAVE_GENERIC_VDSO 57 57 select ARCH_HAVE_NMI_SAFE_CMPXCHG 58 58 select ARCH_KEEP_MEMBLOCK if ACPI 59 59 select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU ··· 110 110 select GENERIC_CPU_VULNERABILITIES 111 111 select GENERIC_EARLY_IOREMAP 112 112 select GENERIC_ENTRY 113 - select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO 113 + select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO && 64BIT 114 114 select GENERIC_IDLE_POLL_SETUP 115 115 select GENERIC_IOREMAP if MMU 116 116 select GENERIC_IRQ_IPI if SMP ··· 123 123 select GENERIC_PCI_IOMAP 124 124 select GENERIC_SCHED_CLOCK 125 125 select GENERIC_SMP_IDLE_THREAD 126 - select GENERIC_TIME_VSYSCALL if MMU && 64BIT 127 - select GENERIC_VDSO_DATA_STORE if MMU 128 - select GENERIC_VDSO_TIME_NS if HAVE_GENERIC_VDSO 126 + select GENERIC_TIME_VSYSCALL if GENERIC_GETTIMEOFDAY 129 127 select HARDIRQS_SW_RESEND 130 128 select HAS_IOPORT if MMU 131 129 select HAVE_ALIGNED_STRUCT_PAGE ··· 167 169 select HAVE_FUNCTION_ARG_ACCESS_API 168 170 select HAVE_FUNCTION_ERROR_INJECTION 169 171 select HAVE_GCC_PLUGINS 170 - select HAVE_GENERIC_VDSO if MMU && 64BIT 172 + select HAVE_GENERIC_VDSO if MMU 171 173 select HAVE_IRQ_TIME_ACCOUNTING 172 174 select HAVE_KERNEL_BZIP2 if !XIP_KERNEL && !EFI_ZBOOT 173 175 select HAVE_KERNEL_GZIP if !XIP_KERNEL && !EFI_ZBOOT ··· 223 225 select THREAD_INFO_IN_TASK 224 226 select TRACE_IRQFLAGS_SUPPORT 225 227 select UACCESS_MEMCPY if !MMU 226 - select VDSO_GETRANDOM if HAVE_GENERIC_VDSO 228 + select VDSO_GETRANDOM if HAVE_GENERIC_VDSO && 64BIT 227 229 select USER_STACKTRACE_SUPPORT 228 230 select ZONE_DMA32 if 64BIT 229 231
-2
arch/s390/Kconfig
··· 174 174 select GENERIC_GETTIMEOFDAY 175 175 select GENERIC_SMP_IDLE_THREAD 176 176 select GENERIC_TIME_VSYSCALL 177 - select GENERIC_VDSO_DATA_STORE 178 - select GENERIC_VDSO_TIME_NS 179 177 select GENERIC_IOREMAP if PCI 180 178 select HAVE_ALIGNED_STRUCT_PAGE 181 179 select HAVE_ARCH_AUDITSYSCALL
-3
arch/x86/Kconfig
··· 14 14 select ARCH_WANT_IPC_PARSE_VERSION 15 15 select CLKSRC_I8253 16 16 select CLONE_BACKWARDS 17 - select GENERIC_VDSO_32 18 17 select HAVE_DEBUG_STACKOVERFLOW 19 18 select KMAP_LOCAL 20 19 select MODULES_USE_ELF_REL ··· 181 182 select GENERIC_SMP_IDLE_THREAD 182 183 select GENERIC_TIME_VSYSCALL 183 184 select GENERIC_GETTIMEOFDAY 184 - select GENERIC_VDSO_DATA_STORE 185 - select GENERIC_VDSO_TIME_NS 186 185 select GENERIC_VDSO_OVERFLOW_PROTECT 187 186 select GUP_GET_PXX_LOW_HIGH if X86_PAE 188 187 select HARDIRQS_SW_RESEND
-4
include/asm-generic/vdso/vsyscall.h
··· 4 4 5 5 #ifndef __ASSEMBLY__ 6 6 7 - #ifdef CONFIG_GENERIC_VDSO_DATA_STORE 8 - 9 7 #ifndef __arch_get_vdso_u_time_data 10 8 static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_data(void) 11 9 { ··· 17 19 return &vdso_u_rng_data; 18 20 } 19 21 #endif 20 - 21 - #endif /* CONFIG_GENERIC_VDSO_DATA_STORE */ 22 22 23 23 #ifndef __arch_update_vdso_clock 24 24 static __always_inline void __arch_update_vdso_clock(struct vdso_clock *vc)
+1 -8
include/vdso/datapage.h
··· 31 31 32 32 #if defined(CONFIG_ARCH_HAS_VDSO_ARCH_DATA) 33 33 #include <asm/vdso/arch_data.h> 34 - #elif defined(CONFIG_GENERIC_VDSO_DATA_STORE) 34 + #else 35 35 struct vdso_arch_data { 36 36 /* Needed for the generic code, never actually used at runtime */ 37 37 char __unused; ··· 164 164 * With the hidden visibility, the compiler simply generates a PC-relative 165 165 * relocation, and this is what we need. 166 166 */ 167 - #ifdef CONFIG_GENERIC_VDSO_DATA_STORE 168 167 extern struct vdso_time_data vdso_u_time_data __attribute__((visibility("hidden"))); 169 168 extern struct vdso_rng_data vdso_u_rng_data __attribute__((visibility("hidden"))); 170 169 extern struct vdso_arch_data vdso_u_arch_data __attribute__((visibility("hidden"))); ··· 184 185 VDSO_NR_PAGES 185 186 }; 186 187 187 - #endif /* CONFIG_GENERIC_VDSO_DATA_STORE */ 188 - 189 188 /* 190 189 * The generic vDSO implementation requires that gettimeofday.h 191 190 * provides: ··· 193 196 * - clock_gettime_fallback(): fallback for clock_gettime. 194 197 * - clock_getres_fallback(): fallback for clock_getres. 195 198 */ 196 - #ifdef ENABLE_COMPAT_VDSO 197 - #include <asm/vdso/compat_gettimeofday.h> 198 - #else 199 199 #include <asm/vdso/gettimeofday.h> 200 - #endif /* ENABLE_COMPAT_VDSO */ 201 200 202 201 #else /* !__ASSEMBLY__ */ 203 202
+1
include/vdso/gettime.h
··· 5 5 #include <linux/types.h> 6 6 7 7 struct __kernel_timespec; 8 + struct __kernel_old_timeval; 8 9 struct timezone; 9 10 10 11 #if !defined(CONFIG_64BIT) || defined(BUILD_VDSO32_64)
+1 -1
init/Kconfig
··· 1363 1363 1364 1364 config TIME_NS 1365 1365 bool "TIME namespace" 1366 - depends on GENERIC_VDSO_TIME_NS 1366 + depends on GENERIC_GETTIMEOFDAY 1367 1367 default y 1368 1368 help 1369 1369 In this namespace boottime and monotonic clocks can be set.
+1 -1
kernel/time/Makefile
··· 26 26 ifeq ($(CONFIG_SMP),y) 27 27 obj-$(CONFIG_NO_HZ_COMMON) += timer_migration.o 28 28 endif 29 - obj-$(CONFIG_HAVE_GENERIC_VDSO) += vsyscall.o 29 + obj-$(CONFIG_GENERIC_GETTIMEOFDAY) += vsyscall.o 30 30 obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o 31 31 obj-$(CONFIG_TEST_UDELAY) += test_udelay.o 32 32 obj-$(CONFIG_TIME_NS) += namespace.o
+1 -24
lib/vdso/Kconfig
··· 12 12 Each architecture that enables this feature has to 13 13 provide the fallback implementation. 14 14 15 - config GENERIC_VDSO_32 16 - bool 17 - depends on GENERIC_GETTIMEOFDAY && !64BIT 18 - help 19 - This config option helps to avoid possible performance issues 20 - in 32 bit only architectures. 21 - 22 - config GENERIC_COMPAT_VDSO 23 - bool 24 - help 25 - This config option enables the compat VDSO layer. 26 - 27 - config GENERIC_VDSO_TIME_NS 28 - bool 29 - help 30 - Selected by architectures which support time namespaces in the 31 - VDSO 32 - 33 15 config GENERIC_VDSO_OVERFLOW_PROTECT 34 16 bool 35 17 help ··· 19 37 time getter functions for the price of an extra conditional 20 38 in the hotpath. 21 39 22 - endif 23 - 24 40 config VDSO_GETRANDOM 25 41 bool 26 42 help 27 43 Selected by architectures that support vDSO getrandom(). 28 44 29 - config GENERIC_VDSO_DATA_STORE 30 - bool 31 - help 32 - Selected by architectures that use the generic vDSO data store. 45 + endif
+1 -1
lib/vdso/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 - obj-$(CONFIG_GENERIC_VDSO_DATA_STORE) += datastore.o 3 + obj-$(CONFIG_HAVE_GENERIC_VDSO) += datastore.o
+3 -3
lib/vdso/datastore.c
··· 11 11 /* 12 12 * The vDSO data page. 13 13 */ 14 - #ifdef CONFIG_HAVE_GENERIC_VDSO 14 + #ifdef CONFIG_GENERIC_GETTIMEOFDAY 15 15 static union { 16 16 struct vdso_time_data data; 17 17 u8 page[PAGE_SIZE]; 18 18 } vdso_time_data_store __page_aligned_data; 19 19 struct vdso_time_data *vdso_k_time_data = &vdso_time_data_store.data; 20 20 static_assert(sizeof(vdso_time_data_store) == PAGE_SIZE); 21 - #endif /* CONFIG_HAVE_GENERIC_VDSO */ 21 + #endif /* CONFIG_GENERIC_GETTIMEOFDAY */ 22 22 23 23 #ifdef CONFIG_VDSO_GETRANDOM 24 24 static union { ··· 46 46 47 47 switch (vmf->pgoff) { 48 48 case VDSO_TIME_PAGE_OFFSET: 49 - if (!IS_ENABLED(CONFIG_HAVE_GENERIC_VDSO)) 49 + if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) 50 50 return VM_FAULT_SIGBUS; 51 51 pfn = __phys_to_pfn(__pa_symbol(vdso_k_time_data)); 52 52 if (timens_page) {
-27
lib/vdso/gettimeofday.c
··· 108 108 return true; 109 109 } 110 110 111 - #ifdef CONFIG_TIME_NS 112 - 113 - #ifdef CONFIG_GENERIC_VDSO_DATA_STORE 114 111 static __always_inline 115 112 const struct vdso_time_data *__arch_get_vdso_u_timens_data(const struct vdso_time_data *vd) 116 113 { 117 114 return (void *)vd + PAGE_SIZE; 118 115 } 119 - #endif /* CONFIG_GENERIC_VDSO_DATA_STORE */ 120 116 121 117 static __always_inline 122 118 bool do_hres_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns, ··· 145 149 146 150 return true; 147 151 } 148 - #else 149 - static __always_inline 150 - const struct vdso_time_data *__arch_get_vdso_u_timens_data(const struct vdso_time_data *vd) 151 - { 152 - return NULL; 153 - } 154 - 155 - static __always_inline 156 - bool do_hres_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns, 157 - clockid_t clk, struct __kernel_timespec *ts) 158 - { 159 - return false; 160 - } 161 - #endif 162 152 163 153 static __always_inline 164 154 bool do_hres(const struct vdso_time_data *vd, const struct vdso_clock *vc, ··· 186 204 return true; 187 205 } 188 206 189 - #ifdef CONFIG_TIME_NS 190 207 static __always_inline 191 208 bool do_coarse_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns, 192 209 clockid_t clk, struct __kernel_timespec *ts) ··· 214 233 215 234 return true; 216 235 } 217 - #else 218 - static __always_inline 219 - bool do_coarse_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns, 220 - clockid_t clk, struct __kernel_timespec *ts) 221 - { 222 - return false; 223 - } 224 - #endif 225 236 226 237 static __always_inline 227 238 bool do_coarse(const struct vdso_time_data *vd, const struct vdso_clock *vc,
-1
tools/testing/selftests/pidfd/config
··· 4 4 CONFIG_PID_NS=y 5 5 CONFIG_NET_NS=y 6 6 CONFIG_TIME_NS=y 7 - CONFIG_GENERIC_VDSO_TIME_NS=y 8 7 CONFIG_CGROUPS=y 9 8 CONFIG_CHECKPOINT_RESTORE=y
-1
tools/testing/selftests/vDSO/.gitignore
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 vdso_test 3 3 vdso_test_abi 4 - vdso_test_clock_getres 5 4 vdso_test_correctness 6 5 vdso_test_gettimeofday 7 6 vdso_test_getcpu
-2
tools/testing/selftests/vDSO/Makefile
··· 4 4 TEST_GEN_PROGS := vdso_test_gettimeofday 5 5 TEST_GEN_PROGS += vdso_test_getcpu 6 6 TEST_GEN_PROGS += vdso_test_abi 7 - TEST_GEN_PROGS += vdso_test_clock_getres 8 7 ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64)) 9 8 TEST_GEN_PROGS += vdso_standalone_test_x86 10 9 endif ··· 28 29 $(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c 29 30 $(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c 30 31 $(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c 31 - $(OUTPUT)/vdso_test_clock_getres: vdso_test_clock_getres.c 32 32 33 33 $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c | headers 34 34 $(OUTPUT)/vdso_standalone_test_x86: CFLAGS:=$(CFLAGS_NOLIBC) $(CFLAGS)
+3 -4
tools/testing/selftests/vDSO/vdso_call.h
··· 44 44 register long _r6 asm ("r6"); \ 45 45 register long _r7 asm ("r7"); \ 46 46 register long _r8 asm ("r8"); \ 47 - register long _rval asm ("r3"); \ 48 47 \ 49 48 LOADARGS_##nr(fn, args); \ 50 49 \ ··· 53 54 " bns+ 1f\n" \ 54 55 " neg 3, 3\n" \ 55 56 "1:" \ 56 - : "+r" (_r0), "=r" (_r3), "+r" (_r4), "+r" (_r5), \ 57 + : "+r" (_r0), "+r" (_r3), "+r" (_r4), "+r" (_r5), \ 57 58 "+r" (_r6), "+r" (_r7), "+r" (_r8) \ 58 - : "r" (_rval) \ 59 + : \ 59 60 : "r9", "r10", "r11", "r12", "cr0", "cr1", "cr5", \ 60 61 "cr6", "cr7", "xer", "lr", "ctr", "memory" \ 61 62 ); \ 62 - _rval; \ 63 + _r3; \ 63 64 }) 64 65 65 66 #else
+56 -45
tools/testing/selftests/vDSO/vdso_test_abi.c
··· 26 26 static const char *version; 27 27 static const char **name; 28 28 29 + /* The same as struct __kernel_timespec */ 30 + struct vdso_timespec64 { 31 + uint64_t tv_sec; 32 + uint64_t tv_nsec; 33 + }; 34 + 29 35 typedef long (*vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz); 30 36 typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts); 37 + typedef long (*vdso_clock_gettime64_t)(clockid_t clk_id, struct vdso_timespec64 *ts); 31 38 typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts); 32 39 typedef time_t (*vdso_time_t)(time_t *t); 33 40 34 - const char *vdso_clock_name[12] = { 35 - "CLOCK_REALTIME", 36 - "CLOCK_MONOTONIC", 37 - "CLOCK_PROCESS_CPUTIME_ID", 38 - "CLOCK_THREAD_CPUTIME_ID", 39 - "CLOCK_MONOTONIC_RAW", 40 - "CLOCK_REALTIME_COARSE", 41 - "CLOCK_MONOTONIC_COARSE", 42 - "CLOCK_BOOTTIME", 43 - "CLOCK_REALTIME_ALARM", 44 - "CLOCK_BOOTTIME_ALARM", 45 - "CLOCK_SGI_CYCLE", 46 - "CLOCK_TAI", 41 + static const char * const vdso_clock_name[] = { 42 + [CLOCK_REALTIME] = "CLOCK_REALTIME", 43 + [CLOCK_MONOTONIC] = "CLOCK_MONOTONIC", 44 + [CLOCK_PROCESS_CPUTIME_ID] = "CLOCK_PROCESS_CPUTIME_ID", 45 + [CLOCK_THREAD_CPUTIME_ID] = "CLOCK_THREAD_CPUTIME_ID", 46 + [CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW", 47 + [CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE", 48 + [CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE", 49 + [CLOCK_BOOTTIME] = "CLOCK_BOOTTIME", 50 + [CLOCK_REALTIME_ALARM] = "CLOCK_REALTIME_ALARM", 51 + [CLOCK_BOOTTIME_ALARM] = "CLOCK_BOOTTIME_ALARM", 52 + [10 /* CLOCK_SGI_CYCLE */] = "CLOCK_SGI_CYCLE", 53 + [CLOCK_TAI] = "CLOCK_TAI", 47 54 }; 48 55 49 56 static void vdso_test_gettimeofday(void) ··· 74 67 ksft_test_result_pass("%s\n", name[0]); 75 68 } else { 76 69 ksft_test_result_fail("%s\n", name[0]); 70 + } 71 + } 72 + 73 + static void vdso_test_clock_gettime64(clockid_t clk_id) 74 + { 75 + /* Find clock_gettime64. */ 76 + vdso_clock_gettime64_t vdso_clock_gettime64 = 77 + (vdso_clock_gettime64_t)vdso_sym(version, name[5]); 78 + 79 + if (!vdso_clock_gettime64) { 80 + ksft_print_msg("Couldn't find %s\n", name[5]); 81 + ksft_test_result_skip("%s %s\n", name[5], 82 + vdso_clock_name[clk_id]); 83 + return; 84 + } 85 + 86 + struct vdso_timespec64 ts; 87 + long ret = VDSO_CALL(vdso_clock_gettime64, 2, clk_id, &ts); 88 + 89 + if (ret == 0) { 90 + ksft_print_msg("The time is %lld.%06lld\n", 91 + (long long)ts.tv_sec, (long long)ts.tv_nsec); 92 + ksft_test_result_pass("%s %s\n", name[5], 93 + vdso_clock_name[clk_id]); 94 + } else { 95 + ksft_test_result_fail("%s %s\n", name[5], 96 + vdso_clock_name[clk_id]); 77 97 } 78 98 } 79 99 ··· 205 171 ksft_print_msg("clock_id: %s\n", vdso_clock_name[clock_id]); 206 172 207 173 vdso_test_clock_gettime(clock_id); 174 + vdso_test_clock_gettime64(clock_id); 208 175 209 176 vdso_test_clock_getres(clock_id); 210 177 } 211 178 212 - #define VDSO_TEST_PLAN 16 179 + #define VDSO_TEST_PLAN 29 213 180 214 181 int main(int argc, char **argv) 215 182 { 216 183 unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); 217 184 218 185 ksft_print_header(); 219 - ksft_set_plan(VDSO_TEST_PLAN); 220 186 221 - if (!sysinfo_ehdr) { 222 - ksft_print_msg("AT_SYSINFO_EHDR is not present!\n"); 223 - return KSFT_SKIP; 224 - } 187 + if (!sysinfo_ehdr) 188 + ksft_exit_skip("AT_SYSINFO_EHDR is not present!\n"); 189 + 190 + ksft_set_plan(VDSO_TEST_PLAN); 225 191 226 192 version = versions[VDSO_VERSION]; 227 193 name = (const char **)&names[VDSO_NAMES]; ··· 232 198 233 199 vdso_test_gettimeofday(); 234 200 235 - #if _POSIX_TIMERS > 0 236 - 237 - #ifdef CLOCK_REALTIME 238 201 vdso_test_clock(CLOCK_REALTIME); 239 - #endif 240 - 241 - #ifdef CLOCK_BOOTTIME 242 202 vdso_test_clock(CLOCK_BOOTTIME); 243 - #endif 244 - 245 - #ifdef CLOCK_TAI 246 203 vdso_test_clock(CLOCK_TAI); 247 - #endif 248 - 249 - #ifdef CLOCK_REALTIME_COARSE 250 204 vdso_test_clock(CLOCK_REALTIME_COARSE); 251 - #endif 252 - 253 - #ifdef CLOCK_MONOTONIC 254 205 vdso_test_clock(CLOCK_MONOTONIC); 255 - #endif 256 - 257 - #ifdef CLOCK_MONOTONIC_RAW 258 206 vdso_test_clock(CLOCK_MONOTONIC_RAW); 259 - #endif 260 - 261 - #ifdef CLOCK_MONOTONIC_COARSE 262 207 vdso_test_clock(CLOCK_MONOTONIC_COARSE); 263 - #endif 264 - 265 - #endif 208 + vdso_test_clock(CLOCK_PROCESS_CPUTIME_ID); 209 + vdso_test_clock(CLOCK_THREAD_CPUTIME_ID); 266 210 267 211 vdso_test_time(); 268 212 269 - ksft_print_cnts(); 270 - return ksft_get_fail_cnt() == 0 ? KSFT_PASS : KSFT_FAIL; 213 + ksft_finished(); 271 214 }
-123
tools/testing/selftests/vDSO/vdso_test_clock_getres.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note 2 - /* 3 - * vdso_clock_getres.c: Sample code to test clock_getres. 4 - * Copyright (c) 2019 Arm Ltd. 5 - * 6 - * Compile with: 7 - * gcc -std=gnu99 vdso_clock_getres.c 8 - * 9 - * Tested on ARM, ARM64, MIPS32, x86 (32-bit and 64-bit), 10 - * Power (32-bit and 64-bit), S390x (32-bit and 64-bit). 11 - * Might work on other architectures. 12 - */ 13 - 14 - #define _GNU_SOURCE 15 - #include <elf.h> 16 - #include <fcntl.h> 17 - #include <stdint.h> 18 - #include <stdio.h> 19 - #include <stdlib.h> 20 - #include <time.h> 21 - #include <sys/auxv.h> 22 - #include <sys/mman.h> 23 - #include <sys/time.h> 24 - #include <unistd.h> 25 - #include <sys/syscall.h> 26 - 27 - #include "../kselftest.h" 28 - 29 - static long syscall_clock_getres(clockid_t _clkid, struct timespec *_ts) 30 - { 31 - long ret; 32 - 33 - ret = syscall(SYS_clock_getres, _clkid, _ts); 34 - 35 - return ret; 36 - } 37 - 38 - const char *vdso_clock_name[12] = { 39 - "CLOCK_REALTIME", 40 - "CLOCK_MONOTONIC", 41 - "CLOCK_PROCESS_CPUTIME_ID", 42 - "CLOCK_THREAD_CPUTIME_ID", 43 - "CLOCK_MONOTONIC_RAW", 44 - "CLOCK_REALTIME_COARSE", 45 - "CLOCK_MONOTONIC_COARSE", 46 - "CLOCK_BOOTTIME", 47 - "CLOCK_REALTIME_ALARM", 48 - "CLOCK_BOOTTIME_ALARM", 49 - "CLOCK_SGI_CYCLE", 50 - "CLOCK_TAI", 51 - }; 52 - 53 - /* 54 - * This function calls clock_getres in vdso and by system call 55 - * with different values for clock_id. 56 - * 57 - * Example of output: 58 - * 59 - * clock_id: CLOCK_REALTIME [PASS] 60 - * clock_id: CLOCK_BOOTTIME [PASS] 61 - * clock_id: CLOCK_TAI [PASS] 62 - * clock_id: CLOCK_REALTIME_COARSE [PASS] 63 - * clock_id: CLOCK_MONOTONIC [PASS] 64 - * clock_id: CLOCK_MONOTONIC_RAW [PASS] 65 - * clock_id: CLOCK_MONOTONIC_COARSE [PASS] 66 - */ 67 - static inline int vdso_test_clock(unsigned int clock_id) 68 - { 69 - struct timespec x, y; 70 - 71 - printf("clock_id: %s", vdso_clock_name[clock_id]); 72 - clock_getres(clock_id, &x); 73 - syscall_clock_getres(clock_id, &y); 74 - 75 - if ((x.tv_sec != y.tv_sec) || (x.tv_nsec != y.tv_nsec)) { 76 - printf(" [FAIL]\n"); 77 - return KSFT_FAIL; 78 - } 79 - 80 - printf(" [PASS]\n"); 81 - return KSFT_PASS; 82 - } 83 - 84 - int main(int argc, char **argv) 85 - { 86 - int ret = 0; 87 - 88 - #if _POSIX_TIMERS > 0 89 - 90 - #ifdef CLOCK_REALTIME 91 - ret += vdso_test_clock(CLOCK_REALTIME); 92 - #endif 93 - 94 - #ifdef CLOCK_BOOTTIME 95 - ret += vdso_test_clock(CLOCK_BOOTTIME); 96 - #endif 97 - 98 - #ifdef CLOCK_TAI 99 - ret += vdso_test_clock(CLOCK_TAI); 100 - #endif 101 - 102 - #ifdef CLOCK_REALTIME_COARSE 103 - ret += vdso_test_clock(CLOCK_REALTIME_COARSE); 104 - #endif 105 - 106 - #ifdef CLOCK_MONOTONIC 107 - ret += vdso_test_clock(CLOCK_MONOTONIC); 108 - #endif 109 - 110 - #ifdef CLOCK_MONOTONIC_RAW 111 - ret += vdso_test_clock(CLOCK_MONOTONIC_RAW); 112 - #endif 113 - 114 - #ifdef CLOCK_MONOTONIC_COARSE 115 - ret += vdso_test_clock(CLOCK_MONOTONIC_COARSE); 116 - #endif 117 - 118 - #endif 119 - if (ret > 0) 120 - return KSFT_FAIL; 121 - 122 - return KSFT_PASS; 123 - }