12 #include <linux/module.h>
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
18 #include <linux/stddef.h>
20 #include <linux/slab.h>
22 #include <linux/elf.h>
26 #include <asm/asm-offsets.h>
27 #include <asm/pgtable.h>
28 #include <asm/processor.h>
30 #include <asm/mmu_context.h>
31 #include <asm/sections.h>
35 #if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
38 static unsigned int vdso32_pages;
39 static struct page **vdso32_pagelist;
43 extern char vdso64_start, vdso64_end;
44 static void *vdso64_kbase = &vdso64_start;
45 static unsigned int vdso64_pages;
46 static struct page **vdso64_pagelist;
55 static int __init vdso_setup(
char *
s)
63 else if (
strncmp(s,
"off", 4) == 0)
85 static void vdso_init_data(
struct vdso_data *vd)
95 #define SEGMENT_ORDER 2
97 int vdso_alloc_per_cpu(
struct _lowcore *lowcore)
99 unsigned long segment_table, page_table, page_frame;
111 if (!segment_table || !page_table || !page_frame)
117 256*
sizeof(
unsigned long));
120 *(
unsigned long *) page_table =
_PAGE_RO + page_frame;
122 psal = (
u32 *) (page_table + 256*
sizeof(
unsigned long));
125 for (i = 4; i < 32; i += 4)
126 psal[i] = 0x80000000;
129 psal[0] = 0x20000000;
131 *(
unsigned long *) (aste + 2) = segment_table +
145 void vdso_free_per_cpu(
struct _lowcore *lowcore)
147 unsigned long segment_table, page_table, page_frame;
155 segment_table = *(
unsigned long *)(aste + 2) &
PAGE_MASK;
156 page_table = *(
unsigned long *) segment_table;
157 page_frame = *(
unsigned long *) page_table;
164 static void vdso_init_cr5(
void)
182 struct page **vdso_pagelist;
184 unsigned long vdso_base;
196 vdso_pagelist = vdso64_pagelist;
197 vdso_pages = vdso64_pages;
200 vdso_pagelist = vdso32_pagelist;
201 vdso_pages = vdso32_pages;
205 vdso_pagelist = vdso32_pagelist;
206 vdso_pages = vdso32_pages;
216 current->mm->context.vdso_base = 0;
235 current->mm->context.vdso_base = vdso_base;
249 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
252 current->mm->context.vdso_base = 0;
265 static int __init vdso_init(
void)
271 vdso_init_data(vdso_data);
272 #if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
278 vdso32_pagelist = kzalloc(
sizeof(
struct page *) * (vdso32_pages + 1),
281 for (i = 0; i < vdso32_pages - 1; i++) {
283 ClearPageReserved(pg);
285 vdso32_pagelist[
i] =
pg;
287 vdso32_pagelist[vdso32_pages - 1] =
virt_to_page(vdso_data);
288 vdso32_pagelist[vdso32_pages] =
NULL;
293 vdso64_pages = ((&vdso64_end - &vdso64_start
297 vdso64_pagelist = kzalloc(
sizeof(
struct page *) * (vdso64_pages + 1),
300 for (i = 0; i < vdso64_pages - 1; i++) {
302 ClearPageReserved(pg);
304 vdso64_pagelist[
i] =
pg;
306 vdso64_pagelist[vdso64_pages - 1] =
virt_to_page(vdso_data);
307 vdso64_pagelist[vdso64_pages] =
NULL;