Skip to content

Commit 317a76a

Browse files
committed
Merge tag 'timers-vdso-2025-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull VDSO infrastructure updates from Thomas Gleixner: - Consolidate the VDSO storage The VDSO data storage and data layout has been largely architecture specific for historical reasons. That increases the maintenance effort and causes inconsistencies over and over. There is no real technical reason for architecture specific layouts and implementations. The architecture specific details can easily be integrated into a generic layout, which also reduces the amount of duplicated code for managing the mappings. Convert all architectures over to a unified layout and common mapping infrastructure. This splits the VDSO data layout into subsystem specific blocks, timekeeping, random and architecture parts, which provides a better structure and allows to improve and update the functionalities without conflict and interaction. - Rework the timekeeping data storage The current implementation is designed for exposing system timekeeping accessors, which was good enough at the time when it was designed. PTP and Time Sensitive Networking (TSN) change that as there are requirements to expose independent PTP clocks, which are not related to system timekeeping. Replace the monolithic data storage by a structured layout, which allows to add support for independent PTP clocks on top while reusing both the data structures and the time accessor implementations. * tag 'timers-vdso-2025-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (55 commits) sparc/vdso: Always reject undefined references during linking x86/vdso: Always reject undefined references during linking vdso: Rework struct vdso_time_data and introduce struct vdso_clock vdso: Move architecture related data before basetime data powerpc/vdso: Prepare introduction of struct vdso_clock arm64/vdso: Prepare introduction of struct vdso_clock x86/vdso: Prepare introduction of struct vdso_clock time/namespace: Prepare introduction of struct vdso_clock vdso/namespace: Rename timens_setup_vdso_data() to reflect new vdso_clock struct vdso/vsyscall: Prepare introduction of struct vdso_clock vdso/gettimeofday: Prepare helper functions for introduction of struct vdso_clock vdso/gettimeofday: Prepare do_coarse_timens() for introduction of struct vdso_clock vdso/gettimeofday: Prepare do_coarse() for introduction of struct vdso_clock vdso/gettimeofday: Prepare do_hres_timens() for introduction of struct vdso_clock vdso/gettimeofday: Prepare do_hres() for introduction of struct vdso_clock vdso/gettimeofday: Prepare introduction of struct vdso_clock vdso/helpers: Prepare introduction of struct vdso_clock vdso/datapage: Define vdso_clock to prepare for multiple PTP clocks vdso: Make vdso_time_data cacheline aligned arm64: Make asm/cache.h compatible with vDSO ...
2 parents a50b4fe + 6522629 commit 317a76a

File tree

125 files changed

+1397
-1573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1397
-1573
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9792,6 +9792,7 @@ F: include/asm-generic/vdso/vsyscall.h
97929792
F: include/vdso/
97939793
F: kernel/time/vsyscall.c
97949794
F: lib/vdso/
9795+
F: tools/testing/selftests/vDSO/
97959796

97969797
GENWQE (IBM Generic Workqueue Card)
97979798
M: Frank Haverkamp <haver@linux.ibm.com>

arch/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,10 @@ config HAVE_SPARSE_SYSCALL_NR
15841584
entries at 4000, 5000 and 6000 locations. This option turns on syscall
15851585
related optimizations for a given architecture.
15861586

1587+
config ARCH_HAS_VDSO_ARCH_DATA
1588+
depends on GENERIC_VDSO_DATA_STORE
1589+
bool
1590+
15871591
config ARCH_HAS_VDSO_TIME_DATA
15881592
bool
15891593

arch/arm/include/asm/vdso.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#ifdef __KERNEL__
66

7+
#define __VDSO_PAGES 4
8+
79
#ifndef __ASSEMBLY__
810

911
struct mm_struct;

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static inline bool arm_vdso_hres_capable(void)
112112
#define __arch_vdso_hres_capable arm_vdso_hres_capable
113113

114114
static __always_inline u64 __arch_get_hw_counter(int clock_mode,
115-
const struct vdso_data *vd)
115+
const struct vdso_time_data *vd)
116116
{
117117
#ifdef CONFIG_ARM_ARCH_TIMER
118118
u64 cycle_now;
@@ -135,11 +135,6 @@ static __always_inline u64 __arch_get_hw_counter(int clock_mode,
135135
#endif
136136
}
137137

138-
static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
139-
{
140-
return _vdso_data;
141-
}
142-
143138
#endif /* !__ASSEMBLY__ */
144139

145140
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */

arch/arm/include/asm/vdso/vsyscall.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,14 @@
77
#include <vdso/datapage.h>
88
#include <asm/cacheflush.h>
99

10-
extern struct vdso_data *vdso_data;
1110
extern bool cntvct_ok;
1211

1312
static __always_inline
14-
struct vdso_data *__arm_get_k_vdso_data(void)
15-
{
16-
return vdso_data;
17-
}
18-
#define __arch_get_k_vdso_data __arm_get_k_vdso_data
19-
20-
static __always_inline
21-
void __arm_sync_vdso_data(struct vdso_data *vdata)
13+
void __arch_sync_vdso_time_data(struct vdso_time_data *vdata)
2214
{
2315
flush_dcache_page(virt_to_page(vdata));
2416
}
25-
#define __arch_sync_vdso_data __arm_sync_vdso_data
17+
#define __arch_sync_vdso_time_data __arch_sync_vdso_time_data
2618

2719
/* The asm-generic header needs to be included after the definitions above */
2820
#include <asm-generic/vdso/vsyscall.h>

arch/arm/kernel/asm-offsets.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ int main(void)
153153
DEFINE(CACHE_WRITEBACK_ORDER, __CACHE_WRITEBACK_ORDER);
154154
DEFINE(CACHE_WRITEBACK_GRANULE, __CACHE_WRITEBACK_GRANULE);
155155
BLANK();
156-
#ifdef CONFIG_VDSO
157-
DEFINE(VDSO_DATA_SIZE, sizeof(union vdso_data_store));
158-
#endif
159-
BLANK();
160156
#ifdef CONFIG_ARM_MPU
161157
DEFINE(MPU_RNG_INFO_RNGS, offsetof(struct mpu_rgn_info, rgns));
162158
DEFINE(MPU_RNG_INFO_USED, offsetof(struct mpu_rgn_info, used));

arch/arm/kernel/vdso.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/cache.h>
10+
#include <linux/vdso_datastore.h>
1011
#include <linux/elf.h>
1112
#include <linux/err.h>
1213
#include <linux/kernel.h>
@@ -33,15 +34,6 @@ extern char vdso_start[], vdso_end[];
3334
/* Total number of pages needed for the data and text portions of the VDSO. */
3435
unsigned int vdso_total_pages __ro_after_init;
3536

36-
static union vdso_data_store vdso_data_store __page_aligned_data;
37-
struct vdso_data *vdso_data = vdso_data_store.data;
38-
39-
static struct page *vdso_data_page __ro_after_init;
40-
static const struct vm_special_mapping vdso_data_mapping = {
41-
.name = "[vvar]",
42-
.pages = &vdso_data_page,
43-
};
44-
4537
static int vdso_mremap(const struct vm_special_mapping *sm,
4638
struct vm_area_struct *new_vma)
4739
{
@@ -192,9 +184,6 @@ static int __init vdso_init(void)
192184
if (vdso_text_pagelist == NULL)
193185
return -ENOMEM;
194186

195-
/* Grab the VDSO data page. */
196-
vdso_data_page = virt_to_page(vdso_data);
197-
198187
/* Grab the VDSO text pages. */
199188
for (i = 0; i < text_pages; i++) {
200189
struct page *page;
@@ -205,7 +194,7 @@ static int __init vdso_init(void)
205194

206195
vdso_text_mapping.pages = vdso_text_pagelist;
207196

208-
vdso_total_pages = 1; /* for the data/vvar page */
197+
vdso_total_pages = VDSO_NR_PAGES; /* for the data/vvar pages */
209198
vdso_total_pages += text_pages;
210199

211200
cntvct_ok = cntvct_functional();
@@ -216,16 +205,7 @@ static int __init vdso_init(void)
216205
}
217206
arch_initcall(vdso_init);
218207

219-
static int install_vvar(struct mm_struct *mm, unsigned long addr)
220-
{
221-
struct vm_area_struct *vma;
222-
223-
vma = _install_special_mapping(mm, addr, PAGE_SIZE,
224-
VM_READ | VM_MAYREAD,
225-
&vdso_data_mapping);
226-
227-
return PTR_ERR_OR_ZERO(vma);
228-
}
208+
static_assert(__VDSO_PAGES == VDSO_NR_PAGES);
229209

230210
/* assumes mmap_lock is write-locked */
231211
void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
@@ -238,12 +218,12 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
238218
if (vdso_text_pagelist == NULL)
239219
return;
240220

241-
if (install_vvar(mm, addr))
221+
if (IS_ERR(vdso_install_vvar_mapping(mm, addr)))
242222
return;
243223

244-
/* Account for vvar page. */
245-
addr += PAGE_SIZE;
246-
len = (vdso_total_pages - 1) << PAGE_SHIFT;
224+
/* Account for vvar pages. */
225+
addr += VDSO_NR_PAGES * PAGE_SIZE;
226+
len = (vdso_total_pages - VDSO_NR_PAGES) << PAGE_SHIFT;
247227

248228
vma = _install_special_mapping(mm, addr, len,
249229
VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,

arch/arm/mm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ config VDSO
928928
select GENERIC_TIME_VSYSCALL
929929
select GENERIC_VDSO_32
930930
select GENERIC_GETTIMEOFDAY
931+
select GENERIC_VDSO_DATA_STORE
931932
help
932933
Place in the process address space an ELF shared object
933934
providing fast implementations of gettimeofday and

arch/arm/vdso/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

33
# Include the generic Makefile to check the built vdso.
4-
include $(srctree)/lib/vdso/Makefile
4+
include $(srctree)/lib/vdso/Makefile.include
55

66
hostprogs := vdsomunge
77

arch/arm/vdso/vdso.lds.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
*/
1212

1313
#include <linux/const.h>
14-
#include <asm/asm-offsets.h>
1514
#include <asm/page.h>
1615
#include <asm/vdso.h>
16+
#include <vdso/datapage.h>
1717

1818
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
1919
OUTPUT_ARCH(arm)
2020

2121
SECTIONS
2222
{
23-
PROVIDE(_vdso_data = . - VDSO_DATA_SIZE);
23+
VDSO_VVAR_SYMS
2424

2525
. = SIZEOF_HEADERS;
2626

0 commit comments

Comments
 (0)