Skip to content

Commit 461c966

Browse files
t-8chKAGA-KOKO
authored andcommitted
arm64: vdso: Use only one single vvar mapping
The vvar mapping is the same for all processes. Use a single mapping to simplify the logic and align it with the other architectures. In addition this will enable the move of the vvar handling into generic code. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Will Deacon <[email protected]> Acked-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 0973fed commit 461c966

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

arch/arm64/kernel/vdso.c

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ struct vdso_abi_info {
3838
const char *vdso_code_start;
3939
const char *vdso_code_end;
4040
unsigned long vdso_pages;
41-
/* Data Mapping */
42-
struct vm_special_mapping *dm;
4341
/* Code Mapping */
4442
struct vm_special_mapping *cm;
4543
};
@@ -112,6 +110,8 @@ struct vdso_data *arch_get_vdso_data(void *vvar_page)
112110
return (struct vdso_data *)(vvar_page);
113111
}
114112

113+
static const struct vm_special_mapping vvar_map;
114+
115115
/*
116116
* The vvar mapping contains data for a specific time namespace, so when a task
117117
* changes namespace we must unmap its vvar data for the old namespace.
@@ -128,12 +128,8 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
128128
mmap_read_lock(mm);
129129

130130
for_each_vma(vmi, vma) {
131-
if (vma_is_special_mapping(vma, vdso_info[VDSO_ABI_AA64].dm))
132-
zap_vma_pages(vma);
133-
#ifdef CONFIG_COMPAT_VDSO
134-
if (vma_is_special_mapping(vma, vdso_info[VDSO_ABI_AA32].dm))
131+
if (vma_is_special_mapping(vma, &vvar_map))
135132
zap_vma_pages(vma);
136-
#endif
137133
}
138134

139135
mmap_read_unlock(mm);
@@ -175,6 +171,11 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
175171
return vmf_insert_pfn(vma, vmf->address, pfn);
176172
}
177173

174+
static const struct vm_special_mapping vvar_map = {
175+
.name = "[vvar]",
176+
.fault = vvar_fault,
177+
};
178+
178179
static int __setup_additional_pages(enum vdso_abi abi,
179180
struct mm_struct *mm,
180181
struct linux_binprm *bprm,
@@ -198,7 +199,7 @@ static int __setup_additional_pages(enum vdso_abi abi,
198199

199200
ret = _install_special_mapping(mm, vdso_base, VVAR_NR_PAGES * PAGE_SIZE,
200201
VM_READ|VM_MAYREAD|VM_PFNMAP,
201-
vdso_info[abi].dm);
202+
&vvar_map);
202203
if (IS_ERR(ret))
203204
goto up_fail;
204205

@@ -228,7 +229,6 @@ static int __setup_additional_pages(enum vdso_abi abi,
228229
enum aarch32_map {
229230
AA32_MAP_VECTORS, /* kuser helpers */
230231
AA32_MAP_SIGPAGE,
231-
AA32_MAP_VVAR,
232232
AA32_MAP_VDSO,
233233
};
234234

@@ -253,10 +253,6 @@ static struct vm_special_mapping aarch32_vdso_maps[] = {
253253
.pages = &aarch32_sig_page,
254254
.mremap = aarch32_sigpage_mremap,
255255
},
256-
[AA32_MAP_VVAR] = {
257-
.name = "[vvar]",
258-
.fault = vvar_fault,
259-
},
260256
[AA32_MAP_VDSO] = {
261257
.name = "[vdso]",
262258
.mremap = vdso_mremap,
@@ -306,7 +302,6 @@ static int __init __aarch32_alloc_vdso_pages(void)
306302
if (!IS_ENABLED(CONFIG_COMPAT_VDSO))
307303
return 0;
308304

309-
vdso_info[VDSO_ABI_AA32].dm = &aarch32_vdso_maps[AA32_MAP_VVAR];
310305
vdso_info[VDSO_ABI_AA32].cm = &aarch32_vdso_maps[AA32_MAP_VDSO];
311306

312307
return __vdso_init(VDSO_ABI_AA32);
@@ -401,26 +396,14 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
401396
}
402397
#endif /* CONFIG_COMPAT */
403398

404-
enum aarch64_map {
405-
AA64_MAP_VVAR,
406-
AA64_MAP_VDSO,
407-
};
408-
409-
static struct vm_special_mapping aarch64_vdso_maps[] __ro_after_init = {
410-
[AA64_MAP_VVAR] = {
411-
.name = "[vvar]",
412-
.fault = vvar_fault,
413-
},
414-
[AA64_MAP_VDSO] = {
415-
.name = "[vdso]",
416-
.mremap = vdso_mremap,
417-
},
399+
static struct vm_special_mapping aarch64_vdso_map __ro_after_init = {
400+
.name = "[vdso]",
401+
.mremap = vdso_mremap,
418402
};
419403

420404
static int __init vdso_init(void)
421405
{
422-
vdso_info[VDSO_ABI_AA64].dm = &aarch64_vdso_maps[AA64_MAP_VVAR];
423-
vdso_info[VDSO_ABI_AA64].cm = &aarch64_vdso_maps[AA64_MAP_VDSO];
406+
vdso_info[VDSO_ABI_AA64].cm = &aarch64_vdso_map;
424407

425408
return __vdso_init(VDSO_ABI_AA64);
426409
}

0 commit comments

Comments
 (0)