Skip to content

Commit 1d09094

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: vdso: use consistent 'map' nomenclature
The current code doesn't use a consistent naming scheme for structures, enums, or variables, making it harder than necessary to determine the relationship between these. Let's make this easier by consistently using 'map' nomenclature for mappings created in userspace, minimizing redundant comments, and using designated array initializers to tie indices to their respective elements. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent d3418f3 commit 1d09094

File tree

1 file changed

+26
-38
lines changed

1 file changed

+26
-38
lines changed

arch/arm64/kernel/vdso.c

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -182,45 +182,36 @@ static int aarch32_vdso_mremap(const struct vm_special_mapping *sm,
182182
}
183183
#endif /* CONFIG_COMPAT_VDSO */
184184

185-
/*
186-
* aarch32_vdso_pages:
187-
* 0 - kuser helpers
188-
* 1 - sigreturn code
189-
* or (CONFIG_COMPAT_VDSO):
190-
* 0 - kuser helpers
191-
* 1 - vdso data
192-
* 2 - vdso code
193-
*/
194-
#define C_VECTORS 0
185+
enum aarch32_map {
186+
AA32_MAP_VECTORS, /* kuser helpers */
195187
#ifdef CONFIG_COMPAT_VDSO
196-
#define C_VVAR 1
197-
#define C_VDSO 2
198-
#define C_PAGES (C_VDSO + 1)
188+
AA32_MAP_VVAR,
189+
AA32_MAP_VDSO,
199190
#else
200-
#define C_SIGPAGE 1
201-
#define C_PAGES (C_SIGPAGE + 1)
202-
#endif /* CONFIG_COMPAT_VDSO */
191+
AA32_MAP_SIGPAGE
192+
#endif
193+
};
203194

204195
static struct page *aarch32_vectors_page __ro_after_init;
205196
#ifndef CONFIG_COMPAT_VDSO
206197
static struct page *aarch32_sig_page __ro_after_init;
207198
#endif
208199

209-
static struct vm_special_mapping aarch32_vdso_spec[C_PAGES] = {
210-
{
200+
static struct vm_special_mapping aarch32_vdso_maps[] = {
201+
[AA32_MAP_VECTORS] = {
211202
.name = "[vectors]", /* ABI */
212203
.pages = &aarch32_vectors_page,
213204
},
214205
#ifdef CONFIG_COMPAT_VDSO
215-
{
206+
[AA32_MAP_VVAR] = {
216207
.name = "[vvar]",
217208
},
218-
{
209+
[AA32_MAP_VDSO] = {
219210
.name = "[vdso]",
220211
.mremap = aarch32_vdso_mremap,
221212
},
222213
#else
223-
{
214+
[AA32_MAP_SIGPAGE] = {
224215
.name = "[sigpage]", /* ABI */
225216
.pages = &aarch32_sig_page,
226217
},
@@ -252,8 +243,8 @@ static int __aarch32_alloc_vdso_pages(void)
252243
{
253244
int ret;
254245

255-
vdso_info[VDSO_ABI_AA32].dm = &aarch32_vdso_spec[C_VVAR];
256-
vdso_info[VDSO_ABI_AA32].cm = &aarch32_vdso_spec[C_VDSO];
246+
vdso_info[VDSO_ABI_AA32].dm = &aarch32_vdso_maps[AA32_MAP_VVAR];
247+
vdso_info[VDSO_ABI_AA32].cm = &aarch32_vdso_maps[AA32_MAP_VDSO];
257248

258249
ret = __vdso_init(VDSO_ABI_AA32);
259250
if (ret)
@@ -305,7 +296,7 @@ static int aarch32_kuser_helpers_setup(struct mm_struct *mm)
305296
ret = _install_special_mapping(mm, AARCH32_VECTORS_BASE, PAGE_SIZE,
306297
VM_READ | VM_EXEC |
307298
VM_MAYREAD | VM_MAYEXEC,
308-
&aarch32_vdso_spec[C_VECTORS]);
299+
&aarch32_vdso_maps[AA32_MAP_VECTORS]);
309300

310301
return PTR_ERR_OR_ZERO(ret);
311302
}
@@ -329,7 +320,7 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm)
329320
ret = _install_special_mapping(mm, addr, PAGE_SIZE,
330321
VM_READ | VM_EXEC | VM_MAYREAD |
331322
VM_MAYWRITE | VM_MAYEXEC,
332-
&aarch32_vdso_spec[C_SIGPAGE]);
323+
&aarch32_vdso_maps[AA32_MAP_SIGPAGE]);
333324
if (IS_ERR(ret))
334325
goto out;
335326

@@ -373,28 +364,25 @@ static int vdso_mremap(const struct vm_special_mapping *sm,
373364
return __vdso_remap(VDSO_ABI_AA64, sm, new_vma);
374365
}
375366

376-
/*
377-
* aarch64_vdso_pages:
378-
* 0 - vvar
379-
* 1 - vdso
380-
*/
381-
#define A_VVAR 0
382-
#define A_VDSO 1
383-
#define A_PAGES (A_VDSO + 1)
384-
static struct vm_special_mapping vdso_spec[A_PAGES] __ro_after_init = {
385-
{
367+
enum aarch64_map {
368+
AA64_MAP_VVAR,
369+
AA64_MAP_VDSO,
370+
};
371+
372+
static struct vm_special_mapping aarch64_vdso_maps[] __ro_after_init = {
373+
[AA64_MAP_VVAR] = {
386374
.name = "[vvar]",
387375
},
388-
{
376+
[AA64_MAP_VDSO] = {
389377
.name = "[vdso]",
390378
.mremap = vdso_mremap,
391379
},
392380
};
393381

394382
static int __init vdso_init(void)
395383
{
396-
vdso_info[VDSO_ABI_AA64].dm = &vdso_spec[A_VVAR];
397-
vdso_info[VDSO_ABI_AA64].cm = &vdso_spec[A_VDSO];
384+
vdso_info[VDSO_ABI_AA64].dm = &aarch64_vdso_maps[AA64_MAP_VVAR];
385+
vdso_info[VDSO_ABI_AA64].cm = &aarch64_vdso_maps[AA64_MAP_VDSO];
398386

399387
return __vdso_init(VDSO_ABI_AA64);
400388
}

0 commit comments

Comments
 (0)