Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / powerpc / kernel / vdso.c
blob7d14bb697d407fc93fa6fd8d2411f61c08adbcf2
2 /*
3 * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
4 * <benh@kernel.crashing.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
15 #include <linux/mm.h>
16 #include <linux/smp.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/slab.h>
20 #include <linux/user.h>
21 #include <linux/elf.h>
22 #include <linux/security.h>
23 #include <linux/bootmem.h>
24 #include <linux/memblock.h>
26 #include <asm/pgtable.h>
27 #include <asm/system.h>
28 #include <asm/processor.h>
29 #include <asm/mmu.h>
30 #include <asm/mmu_context.h>
31 #include <asm/prom.h>
32 #include <asm/machdep.h>
33 #include <asm/cputable.h>
34 #include <asm/sections.h>
35 #include <asm/firmware.h>
36 #include <asm/vdso.h>
37 #include <asm/vdso_datapage.h>
39 #include "setup.h"
41 #undef DEBUG
43 #ifdef DEBUG
44 #define DBG(fmt...) printk(fmt)
45 #else
46 #define DBG(fmt...)
47 #endif
49 /* Max supported size for symbol names */
50 #define MAX_SYMNAME 64
52 /* The alignment of the vDSO */
53 #define VDSO_ALIGNMENT (1 << 16)
55 extern char vdso32_start, vdso32_end;
56 static void *vdso32_kbase = &vdso32_start;
57 static unsigned int vdso32_pages;
58 static struct page **vdso32_pagelist;
59 unsigned long vdso32_sigtramp;
60 unsigned long vdso32_rt_sigtramp;
62 #ifdef CONFIG_PPC64
63 extern char vdso64_start, vdso64_end;
64 static void *vdso64_kbase = &vdso64_start;
65 static unsigned int vdso64_pages;
66 static struct page **vdso64_pagelist;
67 unsigned long vdso64_rt_sigtramp;
68 #endif /* CONFIG_PPC64 */
70 static int vdso_ready;
73 * The vdso data page (aka. systemcfg for old ppc64 fans) is here.
74 * Once the early boot kernel code no longer needs to muck around
75 * with it, it will become dynamically allocated
77 static union {
78 struct vdso_data data;
79 u8 page[PAGE_SIZE];
80 } vdso_data_store __page_aligned_data;
81 struct vdso_data *vdso_data = &vdso_data_store.data;
83 /* Format of the patch table */
84 struct vdso_patch_def
86 unsigned long ftr_mask, ftr_value;
87 const char *gen_name;
88 const char *fix_name;
91 /* Table of functions to patch based on the CPU type/revision
93 * Currently, we only change sync_dicache to do nothing on processors
94 * with a coherent icache
96 static struct vdso_patch_def vdso_patches[] = {
98 CPU_FTR_COHERENT_ICACHE, CPU_FTR_COHERENT_ICACHE,
99 "__kernel_sync_dicache", "__kernel_sync_dicache_p5"
102 CPU_FTR_USE_TB, 0,
103 "__kernel_gettimeofday", NULL
106 CPU_FTR_USE_TB, 0,
107 "__kernel_clock_gettime", NULL
110 CPU_FTR_USE_TB, 0,
111 "__kernel_clock_getres", NULL
114 CPU_FTR_USE_TB, 0,
115 "__kernel_get_tbfreq", NULL
120 * Some infos carried around for each of them during parsing at
121 * boot time.
123 struct lib32_elfinfo
125 Elf32_Ehdr *hdr; /* ptr to ELF */
126 Elf32_Sym *dynsym; /* ptr to .dynsym section */
127 unsigned long dynsymsize; /* size of .dynsym section */
128 char *dynstr; /* ptr to .dynstr section */
129 unsigned long text; /* offset of .text section in .so */
132 struct lib64_elfinfo
134 Elf64_Ehdr *hdr;
135 Elf64_Sym *dynsym;
136 unsigned long dynsymsize;
137 char *dynstr;
138 unsigned long text;
142 #ifdef __DEBUG
143 static void dump_one_vdso_page(struct page *pg, struct page *upg)
145 printk("kpg: %p (c:%d,f:%08lx)", __va(page_to_pfn(pg) << PAGE_SHIFT),
146 page_count(pg),
147 pg->flags);
148 if (upg && !IS_ERR(upg) /* && pg != upg*/) {
149 printk(" upg: %p (c:%d,f:%08lx)", __va(page_to_pfn(upg)
150 << PAGE_SHIFT),
151 page_count(upg),
152 upg->flags);
154 printk("\n");
157 static void dump_vdso_pages(struct vm_area_struct * vma)
159 int i;
161 if (!vma || is_32bit_task()) {
162 printk("vDSO32 @ %016lx:\n", (unsigned long)vdso32_kbase);
163 for (i=0; i<vdso32_pages; i++) {
164 struct page *pg = virt_to_page(vdso32_kbase +
165 i*PAGE_SIZE);
166 struct page *upg = (vma && vma->vm_mm) ?
167 follow_page(vma, vma->vm_start + i*PAGE_SIZE, 0)
168 : NULL;
169 dump_one_vdso_page(pg, upg);
172 if (!vma || !is_32bit_task()) {
173 printk("vDSO64 @ %016lx:\n", (unsigned long)vdso64_kbase);
174 for (i=0; i<vdso64_pages; i++) {
175 struct page *pg = virt_to_page(vdso64_kbase +
176 i*PAGE_SIZE);
177 struct page *upg = (vma && vma->vm_mm) ?
178 follow_page(vma, vma->vm_start + i*PAGE_SIZE, 0)
179 : NULL;
180 dump_one_vdso_page(pg, upg);
184 #endif /* DEBUG */
187 * This is called from binfmt_elf, we create the special vma for the
188 * vDSO and insert it into the mm struct tree
190 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
192 struct mm_struct *mm = current->mm;
193 struct page **vdso_pagelist;
194 unsigned long vdso_pages;
195 unsigned long vdso_base;
196 int rc;
198 if (!vdso_ready)
199 return 0;
201 #ifdef CONFIG_PPC64
202 if (is_32bit_task()) {
203 vdso_pagelist = vdso32_pagelist;
204 vdso_pages = vdso32_pages;
205 vdso_base = VDSO32_MBASE;
206 } else {
207 vdso_pagelist = vdso64_pagelist;
208 vdso_pages = vdso64_pages;
210 * On 64bit we don't have a preferred map address. This
211 * allows get_unmapped_area to find an area near other mmaps
212 * and most likely share a SLB entry.
214 vdso_base = 0;
216 #else
217 vdso_pagelist = vdso32_pagelist;
218 vdso_pages = vdso32_pages;
219 vdso_base = VDSO32_MBASE;
220 #endif
222 current->mm->context.vdso_base = 0;
224 /* vDSO has a problem and was disabled, just don't "enable" it for the
225 * process
227 if (vdso_pages == 0)
228 return 0;
229 /* Add a page to the vdso size for the data page */
230 vdso_pages ++;
233 * pick a base address for the vDSO in process space. We try to put it
234 * at vdso_base which is the "natural" base for it, but we might fail
235 * and end up putting it elsewhere.
236 * Add enough to the size so that the result can be aligned.
238 down_write(&mm->mmap_sem);
239 vdso_base = get_unmapped_area(NULL, vdso_base,
240 (vdso_pages << PAGE_SHIFT) +
241 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
242 0, 0);
243 if (IS_ERR_VALUE(vdso_base)) {
244 rc = vdso_base;
245 goto fail_mmapsem;
248 /* Add required alignment. */
249 vdso_base = ALIGN(vdso_base, VDSO_ALIGNMENT);
252 * Put vDSO base into mm struct. We need to do this before calling
253 * install_special_mapping or the perf counter mmap tracking code
254 * will fail to recognise it as a vDSO (since arch_vma_name fails).
256 current->mm->context.vdso_base = vdso_base;
259 * our vma flags don't have VM_WRITE so by default, the process isn't
260 * allowed to write those pages.
261 * gdb can break that with ptrace interface, and thus trigger COW on
262 * those pages but it's then your responsibility to never do that on
263 * the "data" page of the vDSO or you'll stop getting kernel updates
264 * and your nice userland gettimeofday will be totally dead.
265 * It's fine to use that for setting breakpoints in the vDSO code
266 * pages though
268 * Make sure the vDSO gets into every core dump.
269 * Dumping its contents makes post-mortem fully interpretable later
270 * without matching up the same kernel and hardware config to see
271 * what PC values meant.
273 rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
274 VM_READ|VM_EXEC|
275 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
276 VM_ALWAYSDUMP,
277 vdso_pagelist);
278 if (rc) {
279 current->mm->context.vdso_base = 0;
280 goto fail_mmapsem;
283 up_write(&mm->mmap_sem);
284 return 0;
286 fail_mmapsem:
287 up_write(&mm->mmap_sem);
288 return rc;
291 const char *arch_vma_name(struct vm_area_struct *vma)
293 if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso_base)
294 return "[vdso]";
295 return NULL;
300 static void * __init find_section32(Elf32_Ehdr *ehdr, const char *secname,
301 unsigned long *size)
303 Elf32_Shdr *sechdrs;
304 unsigned int i;
305 char *secnames;
307 /* Grab section headers and strings so we can tell who is who */
308 sechdrs = (void *)ehdr + ehdr->e_shoff;
309 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;
311 /* Find the section they want */
312 for (i = 1; i < ehdr->e_shnum; i++) {
313 if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
314 if (size)
315 *size = sechdrs[i].sh_size;
316 return (void *)ehdr + sechdrs[i].sh_offset;
319 *size = 0;
320 return NULL;
323 static Elf32_Sym * __init find_symbol32(struct lib32_elfinfo *lib,
324 const char *symname)
326 unsigned int i;
327 char name[MAX_SYMNAME], *c;
329 for (i = 0; i < (lib->dynsymsize / sizeof(Elf32_Sym)); i++) {
330 if (lib->dynsym[i].st_name == 0)
331 continue;
332 strlcpy(name, lib->dynstr + lib->dynsym[i].st_name,
333 MAX_SYMNAME);
334 c = strchr(name, '@');
335 if (c)
336 *c = 0;
337 if (strcmp(symname, name) == 0)
338 return &lib->dynsym[i];
340 return NULL;
343 /* Note that we assume the section is .text and the symbol is relative to
344 * the library base
346 static unsigned long __init find_function32(struct lib32_elfinfo *lib,
347 const char *symname)
349 Elf32_Sym *sym = find_symbol32(lib, symname);
351 if (sym == NULL) {
352 printk(KERN_WARNING "vDSO32: function %s not found !\n",
353 symname);
354 return 0;
356 return sym->st_value - VDSO32_LBASE;
359 static int __init vdso_do_func_patch32(struct lib32_elfinfo *v32,
360 struct lib64_elfinfo *v64,
361 const char *orig, const char *fix)
363 Elf32_Sym *sym32_gen, *sym32_fix;
365 sym32_gen = find_symbol32(v32, orig);
366 if (sym32_gen == NULL) {
367 printk(KERN_ERR "vDSO32: Can't find symbol %s !\n", orig);
368 return -1;
370 if (fix == NULL) {
371 sym32_gen->st_name = 0;
372 return 0;
374 sym32_fix = find_symbol32(v32, fix);
375 if (sym32_fix == NULL) {
376 printk(KERN_ERR "vDSO32: Can't find symbol %s !\n", fix);
377 return -1;
379 sym32_gen->st_value = sym32_fix->st_value;
380 sym32_gen->st_size = sym32_fix->st_size;
381 sym32_gen->st_info = sym32_fix->st_info;
382 sym32_gen->st_other = sym32_fix->st_other;
383 sym32_gen->st_shndx = sym32_fix->st_shndx;
385 return 0;
389 #ifdef CONFIG_PPC64
391 static void * __init find_section64(Elf64_Ehdr *ehdr, const char *secname,
392 unsigned long *size)
394 Elf64_Shdr *sechdrs;
395 unsigned int i;
396 char *secnames;
398 /* Grab section headers and strings so we can tell who is who */
399 sechdrs = (void *)ehdr + ehdr->e_shoff;
400 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;
402 /* Find the section they want */
403 for (i = 1; i < ehdr->e_shnum; i++) {
404 if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
405 if (size)
406 *size = sechdrs[i].sh_size;
407 return (void *)ehdr + sechdrs[i].sh_offset;
410 if (size)
411 *size = 0;
412 return NULL;
415 static Elf64_Sym * __init find_symbol64(struct lib64_elfinfo *lib,
416 const char *symname)
418 unsigned int i;
419 char name[MAX_SYMNAME], *c;
421 for (i = 0; i < (lib->dynsymsize / sizeof(Elf64_Sym)); i++) {
422 if (lib->dynsym[i].st_name == 0)
423 continue;
424 strlcpy(name, lib->dynstr + lib->dynsym[i].st_name,
425 MAX_SYMNAME);
426 c = strchr(name, '@');
427 if (c)
428 *c = 0;
429 if (strcmp(symname, name) == 0)
430 return &lib->dynsym[i];
432 return NULL;
435 /* Note that we assume the section is .text and the symbol is relative to
436 * the library base
438 static unsigned long __init find_function64(struct lib64_elfinfo *lib,
439 const char *symname)
441 Elf64_Sym *sym = find_symbol64(lib, symname);
443 if (sym == NULL) {
444 printk(KERN_WARNING "vDSO64: function %s not found !\n",
445 symname);
446 return 0;
448 #ifdef VDS64_HAS_DESCRIPTORS
449 return *((u64 *)(vdso64_kbase + sym->st_value - VDSO64_LBASE)) -
450 VDSO64_LBASE;
451 #else
452 return sym->st_value - VDSO64_LBASE;
453 #endif
456 static int __init vdso_do_func_patch64(struct lib32_elfinfo *v32,
457 struct lib64_elfinfo *v64,
458 const char *orig, const char *fix)
460 Elf64_Sym *sym64_gen, *sym64_fix;
462 sym64_gen = find_symbol64(v64, orig);
463 if (sym64_gen == NULL) {
464 printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", orig);
465 return -1;
467 if (fix == NULL) {
468 sym64_gen->st_name = 0;
469 return 0;
471 sym64_fix = find_symbol64(v64, fix);
472 if (sym64_fix == NULL) {
473 printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", fix);
474 return -1;
476 sym64_gen->st_value = sym64_fix->st_value;
477 sym64_gen->st_size = sym64_fix->st_size;
478 sym64_gen->st_info = sym64_fix->st_info;
479 sym64_gen->st_other = sym64_fix->st_other;
480 sym64_gen->st_shndx = sym64_fix->st_shndx;
482 return 0;
485 #endif /* CONFIG_PPC64 */
488 static __init int vdso_do_find_sections(struct lib32_elfinfo *v32,
489 struct lib64_elfinfo *v64)
491 void *sect;
494 * Locate symbol tables & text section
497 v32->dynsym = find_section32(v32->hdr, ".dynsym", &v32->dynsymsize);
498 v32->dynstr = find_section32(v32->hdr, ".dynstr", NULL);
499 if (v32->dynsym == NULL || v32->dynstr == NULL) {
500 printk(KERN_ERR "vDSO32: required symbol section not found\n");
501 return -1;
503 sect = find_section32(v32->hdr, ".text", NULL);
504 if (sect == NULL) {
505 printk(KERN_ERR "vDSO32: the .text section was not found\n");
506 return -1;
508 v32->text = sect - vdso32_kbase;
510 #ifdef CONFIG_PPC64
511 v64->dynsym = find_section64(v64->hdr, ".dynsym", &v64->dynsymsize);
512 v64->dynstr = find_section64(v64->hdr, ".dynstr", NULL);
513 if (v64->dynsym == NULL || v64->dynstr == NULL) {
514 printk(KERN_ERR "vDSO64: required symbol section not found\n");
515 return -1;
517 sect = find_section64(v64->hdr, ".text", NULL);
518 if (sect == NULL) {
519 printk(KERN_ERR "vDSO64: the .text section was not found\n");
520 return -1;
522 v64->text = sect - vdso64_kbase;
523 #endif /* CONFIG_PPC64 */
525 return 0;
528 static __init void vdso_setup_trampolines(struct lib32_elfinfo *v32,
529 struct lib64_elfinfo *v64)
532 * Find signal trampolines
535 #ifdef CONFIG_PPC64
536 vdso64_rt_sigtramp = find_function64(v64, "__kernel_sigtramp_rt64");
537 #endif
538 vdso32_sigtramp = find_function32(v32, "__kernel_sigtramp32");
539 vdso32_rt_sigtramp = find_function32(v32, "__kernel_sigtramp_rt32");
542 static __init int vdso_fixup_datapage(struct lib32_elfinfo *v32,
543 struct lib64_elfinfo *v64)
545 Elf32_Sym *sym32;
546 #ifdef CONFIG_PPC64
547 Elf64_Sym *sym64;
549 sym64 = find_symbol64(v64, "__kernel_datapage_offset");
550 if (sym64 == NULL) {
551 printk(KERN_ERR "vDSO64: Can't find symbol "
552 "__kernel_datapage_offset !\n");
553 return -1;
555 *((int *)(vdso64_kbase + sym64->st_value - VDSO64_LBASE)) =
556 (vdso64_pages << PAGE_SHIFT) -
557 (sym64->st_value - VDSO64_LBASE);
558 #endif /* CONFIG_PPC64 */
560 sym32 = find_symbol32(v32, "__kernel_datapage_offset");
561 if (sym32 == NULL) {
562 printk(KERN_ERR "vDSO32: Can't find symbol "
563 "__kernel_datapage_offset !\n");
564 return -1;
566 *((int *)(vdso32_kbase + (sym32->st_value - VDSO32_LBASE))) =
567 (vdso32_pages << PAGE_SHIFT) -
568 (sym32->st_value - VDSO32_LBASE);
570 return 0;
574 static __init int vdso_fixup_features(struct lib32_elfinfo *v32,
575 struct lib64_elfinfo *v64)
577 void *start32;
578 unsigned long size32;
580 #ifdef CONFIG_PPC64
581 void *start64;
582 unsigned long size64;
584 start64 = find_section64(v64->hdr, "__ftr_fixup", &size64);
585 if (start64)
586 do_feature_fixups(cur_cpu_spec->cpu_features,
587 start64, start64 + size64);
589 start64 = find_section64(v64->hdr, "__mmu_ftr_fixup", &size64);
590 if (start64)
591 do_feature_fixups(cur_cpu_spec->mmu_features,
592 start64, start64 + size64);
594 start64 = find_section64(v64->hdr, "__fw_ftr_fixup", &size64);
595 if (start64)
596 do_feature_fixups(powerpc_firmware_features,
597 start64, start64 + size64);
599 start64 = find_section64(v64->hdr, "__lwsync_fixup", &size64);
600 if (start64)
601 do_lwsync_fixups(cur_cpu_spec->cpu_features,
602 start64, start64 + size64);
603 #endif /* CONFIG_PPC64 */
605 start32 = find_section32(v32->hdr, "__ftr_fixup", &size32);
606 if (start32)
607 do_feature_fixups(cur_cpu_spec->cpu_features,
608 start32, start32 + size32);
610 start32 = find_section32(v32->hdr, "__mmu_ftr_fixup", &size32);
611 if (start32)
612 do_feature_fixups(cur_cpu_spec->mmu_features,
613 start32, start32 + size32);
615 #ifdef CONFIG_PPC64
616 start32 = find_section32(v32->hdr, "__fw_ftr_fixup", &size32);
617 if (start32)
618 do_feature_fixups(powerpc_firmware_features,
619 start32, start32 + size32);
620 #endif /* CONFIG_PPC64 */
622 start32 = find_section32(v32->hdr, "__lwsync_fixup", &size32);
623 if (start32)
624 do_lwsync_fixups(cur_cpu_spec->cpu_features,
625 start32, start32 + size32);
627 return 0;
630 static __init int vdso_fixup_alt_funcs(struct lib32_elfinfo *v32,
631 struct lib64_elfinfo *v64)
633 int i;
635 for (i = 0; i < ARRAY_SIZE(vdso_patches); i++) {
636 struct vdso_patch_def *patch = &vdso_patches[i];
637 int match = (cur_cpu_spec->cpu_features & patch->ftr_mask)
638 == patch->ftr_value;
639 if (!match)
640 continue;
642 DBG("replacing %s with %s...\n", patch->gen_name,
643 patch->fix_name ? "NONE" : patch->fix_name);
646 * Patch the 32 bits and 64 bits symbols. Note that we do not
647 * patch the "." symbol on 64 bits.
648 * It would be easy to do, but doesn't seem to be necessary,
649 * patching the OPD symbol is enough.
651 vdso_do_func_patch32(v32, v64, patch->gen_name,
652 patch->fix_name);
653 #ifdef CONFIG_PPC64
654 vdso_do_func_patch64(v32, v64, patch->gen_name,
655 patch->fix_name);
656 #endif /* CONFIG_PPC64 */
659 return 0;
663 static __init int vdso_setup(void)
665 struct lib32_elfinfo v32;
666 struct lib64_elfinfo v64;
668 v32.hdr = vdso32_kbase;
669 #ifdef CONFIG_PPC64
670 v64.hdr = vdso64_kbase;
671 #endif
672 if (vdso_do_find_sections(&v32, &v64))
673 return -1;
675 if (vdso_fixup_datapage(&v32, &v64))
676 return -1;
678 if (vdso_fixup_features(&v32, &v64))
679 return -1;
681 if (vdso_fixup_alt_funcs(&v32, &v64))
682 return -1;
684 vdso_setup_trampolines(&v32, &v64);
686 return 0;
690 * Called from setup_arch to initialize the bitmap of available
691 * syscalls in the systemcfg page
693 static void __init vdso_setup_syscall_map(void)
695 unsigned int i;
696 extern unsigned long *sys_call_table;
697 extern unsigned long sys_ni_syscall;
700 for (i = 0; i < __NR_syscalls; i++) {
701 #ifdef CONFIG_PPC64
702 if (sys_call_table[i*2] != sys_ni_syscall)
703 vdso_data->syscall_map_64[i >> 5] |=
704 0x80000000UL >> (i & 0x1f);
705 if (sys_call_table[i*2+1] != sys_ni_syscall)
706 vdso_data->syscall_map_32[i >> 5] |=
707 0x80000000UL >> (i & 0x1f);
708 #else /* CONFIG_PPC64 */
709 if (sys_call_table[i] != sys_ni_syscall)
710 vdso_data->syscall_map_32[i >> 5] |=
711 0x80000000UL >> (i & 0x1f);
712 #endif /* CONFIG_PPC64 */
717 static int __init vdso_init(void)
719 int i;
721 #ifdef CONFIG_PPC64
723 * Fill up the "systemcfg" stuff for backward compatibility
725 strcpy((char *)vdso_data->eye_catcher, "SYSTEMCFG:PPC64");
726 vdso_data->version.major = SYSTEMCFG_MAJOR;
727 vdso_data->version.minor = SYSTEMCFG_MINOR;
728 vdso_data->processor = mfspr(SPRN_PVR);
730 * Fake the old platform number for pSeries and iSeries and add
731 * in LPAR bit if necessary
733 vdso_data->platform = machine_is(iseries) ? 0x200 : 0x100;
734 if (firmware_has_feature(FW_FEATURE_LPAR))
735 vdso_data->platform |= 1;
736 vdso_data->physicalMemorySize = memblock_phys_mem_size();
737 vdso_data->dcache_size = ppc64_caches.dsize;
738 vdso_data->dcache_line_size = ppc64_caches.dline_size;
739 vdso_data->icache_size = ppc64_caches.isize;
740 vdso_data->icache_line_size = ppc64_caches.iline_size;
742 /* XXXOJN: Blocks should be added to ppc64_caches and used instead */
743 vdso_data->dcache_block_size = ppc64_caches.dline_size;
744 vdso_data->icache_block_size = ppc64_caches.iline_size;
745 vdso_data->dcache_log_block_size = ppc64_caches.log_dline_size;
746 vdso_data->icache_log_block_size = ppc64_caches.log_iline_size;
749 * Calculate the size of the 64 bits vDSO
751 vdso64_pages = (&vdso64_end - &vdso64_start) >> PAGE_SHIFT;
752 DBG("vdso64_kbase: %p, 0x%x pages\n", vdso64_kbase, vdso64_pages);
753 #else
754 vdso_data->dcache_block_size = L1_CACHE_BYTES;
755 vdso_data->dcache_log_block_size = L1_CACHE_SHIFT;
756 vdso_data->icache_block_size = L1_CACHE_BYTES;
757 vdso_data->icache_log_block_size = L1_CACHE_SHIFT;
758 #endif /* CONFIG_PPC64 */
762 * Calculate the size of the 32 bits vDSO
764 vdso32_pages = (&vdso32_end - &vdso32_start) >> PAGE_SHIFT;
765 DBG("vdso32_kbase: %p, 0x%x pages\n", vdso32_kbase, vdso32_pages);
769 * Setup the syscall map in the vDOS
771 vdso_setup_syscall_map();
774 * Initialize the vDSO images in memory, that is do necessary
775 * fixups of vDSO symbols, locate trampolines, etc...
777 if (vdso_setup()) {
778 printk(KERN_ERR "vDSO setup failure, not enabled !\n");
779 vdso32_pages = 0;
780 #ifdef CONFIG_PPC64
781 vdso64_pages = 0;
782 #endif
783 return 0;
786 /* Make sure pages are in the correct state */
787 vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2),
788 GFP_KERNEL);
789 BUG_ON(vdso32_pagelist == NULL);
790 for (i = 0; i < vdso32_pages; i++) {
791 struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);
792 ClearPageReserved(pg);
793 get_page(pg);
794 vdso32_pagelist[i] = pg;
796 vdso32_pagelist[i++] = virt_to_page(vdso_data);
797 vdso32_pagelist[i] = NULL;
799 #ifdef CONFIG_PPC64
800 vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2),
801 GFP_KERNEL);
802 BUG_ON(vdso64_pagelist == NULL);
803 for (i = 0; i < vdso64_pages; i++) {
804 struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);
805 ClearPageReserved(pg);
806 get_page(pg);
807 vdso64_pagelist[i] = pg;
809 vdso64_pagelist[i++] = virt_to_page(vdso_data);
810 vdso64_pagelist[i] = NULL;
811 #endif /* CONFIG_PPC64 */
813 get_page(virt_to_page(vdso_data));
815 smp_wmb();
816 vdso_ready = 1;
818 return 0;
820 arch_initcall(vdso_init);
822 int in_gate_area_no_mm(unsigned long addr)
824 return 0;
827 int in_gate_area(struct mm_struct *mm, unsigned long addr)
829 return 0;
832 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
834 return NULL;