Skip to content

Commit 7175126

Browse files
t-8chKAGA-KOKO
authored andcommitted
x86/vdso: Allocate vvar page from C code
Allocate the vvar page through the standard union vdso_data_store and remove the custom linker script logic. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 7821571 commit 7175126

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

arch/x86/entry/vdso/vma.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,19 @@
2020
#include <asm/vgtod.h>
2121
#include <asm/proto.h>
2222
#include <asm/vdso.h>
23-
#include <asm/vvar.h>
2423
#include <asm/tlb.h>
2524
#include <asm/page.h>
2625
#include <asm/desc.h>
2726
#include <asm/cpufeature.h>
2827
#include <clocksource/hyperv_timer.h>
2928

30-
#undef _ASM_X86_VVAR_H
31-
#define EMIT_VVAR(name, offset) \
32-
const size_t name ## _offset = offset;
33-
#include <asm/vvar.h>
34-
3529
struct vdso_data *arch_get_vdso_data(void *vvar_page)
3630
{
37-
return (struct vdso_data *)(vvar_page + _vdso_data_offset);
31+
return (struct vdso_data *)vvar_page;
3832
}
39-
#undef EMIT_VVAR
4033

41-
DEFINE_VVAR(struct vdso_data, _vdso_data);
34+
static union vdso_data_store vdso_data_store __page_aligned_data;
35+
struct vdso_data *vdso_data = vdso_data_store.data;
4236

4337
unsigned int vclocks_used __read_mostly;
4438

@@ -153,7 +147,7 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
153147
if (sym_offset == image->sym_vvar_page) {
154148
struct page *timens_page = find_timens_vvar_page(vma);
155149

156-
pfn = __pa_symbol(&__vvar_page) >> PAGE_SHIFT;
150+
pfn = __pa_symbol(vdso_data) >> PAGE_SHIFT;
157151

158152
/*
159153
* If a task belongs to a time namespace then a namespace
@@ -200,7 +194,7 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
200194
if (!timens_page)
201195
return VM_FAULT_SIGBUS;
202196

203-
pfn = __pa_symbol(&__vvar_page) >> PAGE_SHIFT;
197+
pfn = __pa_symbol(vdso_data) >> PAGE_SHIFT;
204198
return vmf_insert_pfn(vma, vmf->address, pfn);
205199
}
206200

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88
#include <asm/vgtod.h>
99
#include <asm/vvar.h>
1010

11+
extern struct vdso_data *vdso_data;
12+
1113
/*
1214
* Update the vDSO data page to keep in sync with kernel timekeeping.
1315
*/
1416
static __always_inline
1517
struct vdso_data *__x86_get_k_vdso_data(void)
1618
{
17-
return _vdso_data;
19+
return vdso_data;
1820
}
1921
#define __arch_get_k_vdso_data __x86_get_k_vdso_data
2022

2123
static __always_inline
2224
struct vdso_rng_data *__x86_get_k_vdso_rng_data(void)
2325
{
24-
return (void *)&__vvar_page + __VDSO_RND_DATA_OFFSET;
26+
return (void *)vdso_data + __VDSO_RND_DATA_OFFSET;
2527
}
2628
#define __arch_get_k_vdso_rng_data __x86_get_k_vdso_rng_data
2729

arch/x86/kernel/vmlinux.lds.S

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,6 @@ SECTIONS
193193

194194
ORC_UNWIND_TABLE
195195

196-
. = ALIGN(PAGE_SIZE);
197-
__vvar_page = .;
198-
199-
.vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
200-
/* work around gold bug 13023 */
201-
__vvar_beginning_hack = .;
202-
203-
/* Place all vvars at the offsets in asm/vvar.h. */
204-
#define EMIT_VVAR(name, offset) \
205-
. = __vvar_beginning_hack + offset; \
206-
*(.vvar_ ## name)
207-
#include <asm/vvar.h>
208-
#undef EMIT_VVAR
209-
210-
/*
211-
* Pad the rest of the page with zeros. Otherwise the loader
212-
* can leave garbage here.
213-
*/
214-
. = __vvar_beginning_hack + PAGE_SIZE;
215-
} :data
216-
217-
. = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
218-
219196
/* Init code and data - will be freed after init */
220197
. = ALIGN(PAGE_SIZE);
221198
.init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {

arch/x86/tools/relocs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
8989
"init_per_cpu__.*|"
9090
"__end_rodata_hpage_align|"
9191
#endif
92-
"__vvar_page|"
9392
"_end)$"
9493
};
9594

0 commit comments

Comments
 (0)