diff options
author | Nathan Lynch <nathan_lynch@mentor.com> | 2014-02-11 17:28:42 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2014-02-26 06:16:30 -0500 |
commit | 16fb1a9bec6126162560f159df449e4781560807 (patch) | |
tree | 4fd6e83caddba1b10a6d012b41c30d1365817795 /arch/arm64/kernel/vdso.c | |
parent | bb10eb7b4d176f408d45fb492df28bed2981a1f3 (diff) |
arm64: vdso: clean up vdso_pagelist initialization
Remove some unnecessary bits that were apparently carried over from
another architecture's implementation:
- No need to get_page() the vdso text/data - these are part of the
kernel image.
- No need for ClearPageReserved on the vdso text.
- No need to vmap the first text page to check the ELF header - this
can be done through &vdso_start.
Also some minor cleanup:
- Use kcalloc for vdso_pagelist array allocation.
- Don't print on allocation failure, slab/slub will do that for us.
Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel/vdso.c')
-rw-r--r-- | arch/arm64/kernel/vdso.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index a7149cae1615..50384fec56c4 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c | |||
@@ -106,49 +106,31 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) | |||
106 | 106 | ||
107 | static int __init vdso_init(void) | 107 | static int __init vdso_init(void) |
108 | { | 108 | { |
109 | struct page *pg; | 109 | int i; |
110 | char *vbase; | 110 | |
111 | int i, ret = 0; | 111 | if (memcmp(&vdso_start, "\177ELF", 4)) { |
112 | pr_err("vDSO is not a valid ELF object!\n"); | ||
113 | return -EINVAL; | ||
114 | } | ||
112 | 115 | ||
113 | vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; | 116 | vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; |
114 | pr_info("vdso: %ld pages (%ld code, %ld data) at base %p\n", | 117 | pr_info("vdso: %ld pages (%ld code, %ld data) at base %p\n", |
115 | vdso_pages + 1, vdso_pages, 1L, &vdso_start); | 118 | vdso_pages + 1, vdso_pages, 1L, &vdso_start); |
116 | 119 | ||
117 | /* Allocate the vDSO pagelist, plus a page for the data. */ | 120 | /* Allocate the vDSO pagelist, plus a page for the data. */ |
118 | vdso_pagelist = kzalloc(sizeof(struct page *) * (vdso_pages + 1), | 121 | vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *), |
119 | GFP_KERNEL); | 122 | GFP_KERNEL); |
120 | if (vdso_pagelist == NULL) { | 123 | if (vdso_pagelist == NULL) |
121 | pr_err("Failed to allocate vDSO pagelist!\n"); | ||
122 | return -ENOMEM; | 124 | return -ENOMEM; |
123 | } | ||
124 | 125 | ||
125 | /* Grab the vDSO code pages. */ | 126 | /* Grab the vDSO code pages. */ |
126 | for (i = 0; i < vdso_pages; i++) { | 127 | for (i = 0; i < vdso_pages; i++) |
127 | pg = virt_to_page(&vdso_start + i*PAGE_SIZE); | 128 | vdso_pagelist[i] = virt_to_page(&vdso_start + i * PAGE_SIZE); |
128 | ClearPageReserved(pg); | ||
129 | get_page(pg); | ||
130 | vdso_pagelist[i] = pg; | ||
131 | } | ||
132 | |||
133 | /* Sanity check the shared object header. */ | ||
134 | vbase = vmap(vdso_pagelist, 1, 0, PAGE_KERNEL); | ||
135 | if (vbase == NULL) { | ||
136 | pr_err("Failed to map vDSO pagelist!\n"); | ||
137 | return -ENOMEM; | ||
138 | } else if (memcmp(vbase, "\177ELF", 4)) { | ||
139 | pr_err("vDSO is not a valid ELF object!\n"); | ||
140 | ret = -EINVAL; | ||
141 | goto unmap; | ||
142 | } | ||
143 | 129 | ||
144 | /* Grab the vDSO data page. */ | 130 | /* Grab the vDSO data page. */ |
145 | pg = virt_to_page(vdso_data); | 131 | vdso_pagelist[i] = virt_to_page(vdso_data); |
146 | get_page(pg); | ||
147 | vdso_pagelist[i] = pg; | ||
148 | 132 | ||
149 | unmap: | 133 | return 0; |
150 | vunmap(vbase); | ||
151 | return ret; | ||
152 | } | 134 | } |
153 | arch_initcall(vdso_init); | 135 | arch_initcall(vdso_init); |
154 | 136 | ||