powerpc/vdso: Remove unused debug code
[deliverable/linux.git] / arch / powerpc / kernel / vdso.c
1
2 /*
3 * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
4 * <benh@kernel.crashing.org>
5 *
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.
10 */
11
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/memblock.h>
24
25 #include <asm/pgtable.h>
26 #include <asm/processor.h>
27 #include <asm/mmu.h>
28 #include <asm/mmu_context.h>
29 #include <asm/prom.h>
30 #include <asm/machdep.h>
31 #include <asm/cputable.h>
32 #include <asm/sections.h>
33 #include <asm/firmware.h>
34 #include <asm/vdso.h>
35 #include <asm/vdso_datapage.h>
36 #include <asm/setup.h>
37
38 #undef DEBUG
39
40 #ifdef DEBUG
41 #define DBG(fmt...) printk(fmt)
42 #else
43 #define DBG(fmt...)
44 #endif
45
46 /* Max supported size for symbol names */
47 #define MAX_SYMNAME 64
48
49 /* The alignment of the vDSO */
50 #define VDSO_ALIGNMENT (1 << 16)
51
52 extern char vdso32_start, vdso32_end;
53 static void *vdso32_kbase = &vdso32_start;
54 static unsigned int vdso32_pages;
55 static struct page **vdso32_pagelist;
56 unsigned long vdso32_sigtramp;
57 unsigned long vdso32_rt_sigtramp;
58
59 #ifdef CONFIG_PPC64
60 extern char vdso64_start, vdso64_end;
61 static void *vdso64_kbase = &vdso64_start;
62 static unsigned int vdso64_pages;
63 static struct page **vdso64_pagelist;
64 unsigned long vdso64_rt_sigtramp;
65 #endif /* CONFIG_PPC64 */
66
67 static int vdso_ready;
68
69 /*
70 * The vdso data page (aka. systemcfg for old ppc64 fans) is here.
71 * Once the early boot kernel code no longer needs to muck around
72 * with it, it will become dynamically allocated
73 */
74 static union {
75 struct vdso_data data;
76 u8 page[PAGE_SIZE];
77 } vdso_data_store __page_aligned_data;
78 struct vdso_data *vdso_data = &vdso_data_store.data;
79
80 /* Format of the patch table */
81 struct vdso_patch_def
82 {
83 unsigned long ftr_mask, ftr_value;
84 const char *gen_name;
85 const char *fix_name;
86 };
87
88 /* Table of functions to patch based on the CPU type/revision
89 *
90 * Currently, we only change sync_dicache to do nothing on processors
91 * with a coherent icache
92 */
93 static struct vdso_patch_def vdso_patches[] = {
94 {
95 CPU_FTR_COHERENT_ICACHE, CPU_FTR_COHERENT_ICACHE,
96 "__kernel_sync_dicache", "__kernel_sync_dicache_p5"
97 },
98 {
99 CPU_FTR_USE_TB, 0,
100 "__kernel_gettimeofday", NULL
101 },
102 {
103 CPU_FTR_USE_TB, 0,
104 "__kernel_clock_gettime", NULL
105 },
106 {
107 CPU_FTR_USE_TB, 0,
108 "__kernel_clock_getres", NULL
109 },
110 {
111 CPU_FTR_USE_TB, 0,
112 "__kernel_get_tbfreq", NULL
113 },
114 {
115 CPU_FTR_USE_TB, 0,
116 "__kernel_time", NULL
117 },
118 };
119
120 /*
121 * Some infos carried around for each of them during parsing at
122 * boot time.
123 */
124 struct lib32_elfinfo
125 {
126 Elf32_Ehdr *hdr; /* ptr to ELF */
127 Elf32_Sym *dynsym; /* ptr to .dynsym section */
128 unsigned long dynsymsize; /* size of .dynsym section */
129 char *dynstr; /* ptr to .dynstr section */
130 unsigned long text; /* offset of .text section in .so */
131 };
132
133 struct lib64_elfinfo
134 {
135 Elf64_Ehdr *hdr;
136 Elf64_Sym *dynsym;
137 unsigned long dynsymsize;
138 char *dynstr;
139 unsigned long text;
140 };
141
142
143 /*
144 * This is called from binfmt_elf, we create the special vma for the
145 * vDSO and insert it into the mm struct tree
146 */
147 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
148 {
149 struct mm_struct *mm = current->mm;
150 struct page **vdso_pagelist;
151 unsigned long vdso_pages;
152 unsigned long vdso_base;
153 int rc;
154
155 if (!vdso_ready)
156 return 0;
157
158 #ifdef CONFIG_PPC64
159 if (is_32bit_task()) {
160 vdso_pagelist = vdso32_pagelist;
161 vdso_pages = vdso32_pages;
162 vdso_base = VDSO32_MBASE;
163 } else {
164 vdso_pagelist = vdso64_pagelist;
165 vdso_pages = vdso64_pages;
166 /*
167 * On 64bit we don't have a preferred map address. This
168 * allows get_unmapped_area to find an area near other mmaps
169 * and most likely share a SLB entry.
170 */
171 vdso_base = 0;
172 }
173 #else
174 vdso_pagelist = vdso32_pagelist;
175 vdso_pages = vdso32_pages;
176 vdso_base = VDSO32_MBASE;
177 #endif
178
179 current->mm->context.vdso_base = 0;
180
181 /* vDSO has a problem and was disabled, just don't "enable" it for the
182 * process
183 */
184 if (vdso_pages == 0)
185 return 0;
186 /* Add a page to the vdso size for the data page */
187 vdso_pages ++;
188
189 /*
190 * pick a base address for the vDSO in process space. We try to put it
191 * at vdso_base which is the "natural" base for it, but we might fail
192 * and end up putting it elsewhere.
193 * Add enough to the size so that the result can be aligned.
194 */
195 down_write(&mm->mmap_sem);
196 vdso_base = get_unmapped_area(NULL, vdso_base,
197 (vdso_pages << PAGE_SHIFT) +
198 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
199 0, 0);
200 if (IS_ERR_VALUE(vdso_base)) {
201 rc = vdso_base;
202 goto fail_mmapsem;
203 }
204
205 /* Add required alignment. */
206 vdso_base = ALIGN(vdso_base, VDSO_ALIGNMENT);
207
208 /*
209 * Put vDSO base into mm struct. We need to do this before calling
210 * install_special_mapping or the perf counter mmap tracking code
211 * will fail to recognise it as a vDSO (since arch_vma_name fails).
212 */
213 current->mm->context.vdso_base = vdso_base;
214
215 /*
216 * our vma flags don't have VM_WRITE so by default, the process isn't
217 * allowed to write those pages.
218 * gdb can break that with ptrace interface, and thus trigger COW on
219 * those pages but it's then your responsibility to never do that on
220 * the "data" page of the vDSO or you'll stop getting kernel updates
221 * and your nice userland gettimeofday will be totally dead.
222 * It's fine to use that for setting breakpoints in the vDSO code
223 * pages though.
224 */
225 rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
226 VM_READ|VM_EXEC|
227 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
228 vdso_pagelist);
229 if (rc) {
230 current->mm->context.vdso_base = 0;
231 goto fail_mmapsem;
232 }
233
234 up_write(&mm->mmap_sem);
235 return 0;
236
237 fail_mmapsem:
238 up_write(&mm->mmap_sem);
239 return rc;
240 }
241
242 const char *arch_vma_name(struct vm_area_struct *vma)
243 {
244 if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso_base)
245 return "[vdso]";
246 return NULL;
247 }
248
249
250
251 static void * __init find_section32(Elf32_Ehdr *ehdr, const char *secname,
252 unsigned long *size)
253 {
254 Elf32_Shdr *sechdrs;
255 unsigned int i;
256 char *secnames;
257
258 /* Grab section headers and strings so we can tell who is who */
259 sechdrs = (void *)ehdr + ehdr->e_shoff;
260 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;
261
262 /* Find the section they want */
263 for (i = 1; i < ehdr->e_shnum; i++) {
264 if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
265 if (size)
266 *size = sechdrs[i].sh_size;
267 return (void *)ehdr + sechdrs[i].sh_offset;
268 }
269 }
270 *size = 0;
271 return NULL;
272 }
273
274 static Elf32_Sym * __init find_symbol32(struct lib32_elfinfo *lib,
275 const char *symname)
276 {
277 unsigned int i;
278 char name[MAX_SYMNAME], *c;
279
280 for (i = 0; i < (lib->dynsymsize / sizeof(Elf32_Sym)); i++) {
281 if (lib->dynsym[i].st_name == 0)
282 continue;
283 strlcpy(name, lib->dynstr + lib->dynsym[i].st_name,
284 MAX_SYMNAME);
285 c = strchr(name, '@');
286 if (c)
287 *c = 0;
288 if (strcmp(symname, name) == 0)
289 return &lib->dynsym[i];
290 }
291 return NULL;
292 }
293
294 /* Note that we assume the section is .text and the symbol is relative to
295 * the library base
296 */
297 static unsigned long __init find_function32(struct lib32_elfinfo *lib,
298 const char *symname)
299 {
300 Elf32_Sym *sym = find_symbol32(lib, symname);
301
302 if (sym == NULL) {
303 printk(KERN_WARNING "vDSO32: function %s not found !\n",
304 symname);
305 return 0;
306 }
307 return sym->st_value - VDSO32_LBASE;
308 }
309
310 static int __init vdso_do_func_patch32(struct lib32_elfinfo *v32,
311 struct lib64_elfinfo *v64,
312 const char *orig, const char *fix)
313 {
314 Elf32_Sym *sym32_gen, *sym32_fix;
315
316 sym32_gen = find_symbol32(v32, orig);
317 if (sym32_gen == NULL) {
318 printk(KERN_ERR "vDSO32: Can't find symbol %s !\n", orig);
319 return -1;
320 }
321 if (fix == NULL) {
322 sym32_gen->st_name = 0;
323 return 0;
324 }
325 sym32_fix = find_symbol32(v32, fix);
326 if (sym32_fix == NULL) {
327 printk(KERN_ERR "vDSO32: Can't find symbol %s !\n", fix);
328 return -1;
329 }
330 sym32_gen->st_value = sym32_fix->st_value;
331 sym32_gen->st_size = sym32_fix->st_size;
332 sym32_gen->st_info = sym32_fix->st_info;
333 sym32_gen->st_other = sym32_fix->st_other;
334 sym32_gen->st_shndx = sym32_fix->st_shndx;
335
336 return 0;
337 }
338
339
340 #ifdef CONFIG_PPC64
341
342 static void * __init find_section64(Elf64_Ehdr *ehdr, const char *secname,
343 unsigned long *size)
344 {
345 Elf64_Shdr *sechdrs;
346 unsigned int i;
347 char *secnames;
348
349 /* Grab section headers and strings so we can tell who is who */
350 sechdrs = (void *)ehdr + ehdr->e_shoff;
351 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;
352
353 /* Find the section they want */
354 for (i = 1; i < ehdr->e_shnum; i++) {
355 if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
356 if (size)
357 *size = sechdrs[i].sh_size;
358 return (void *)ehdr + sechdrs[i].sh_offset;
359 }
360 }
361 if (size)
362 *size = 0;
363 return NULL;
364 }
365
366 static Elf64_Sym * __init find_symbol64(struct lib64_elfinfo *lib,
367 const char *symname)
368 {
369 unsigned int i;
370 char name[MAX_SYMNAME], *c;
371
372 for (i = 0; i < (lib->dynsymsize / sizeof(Elf64_Sym)); i++) {
373 if (lib->dynsym[i].st_name == 0)
374 continue;
375 strlcpy(name, lib->dynstr + lib->dynsym[i].st_name,
376 MAX_SYMNAME);
377 c = strchr(name, '@');
378 if (c)
379 *c = 0;
380 if (strcmp(symname, name) == 0)
381 return &lib->dynsym[i];
382 }
383 return NULL;
384 }
385
386 /* Note that we assume the section is .text and the symbol is relative to
387 * the library base
388 */
389 static unsigned long __init find_function64(struct lib64_elfinfo *lib,
390 const char *symname)
391 {
392 Elf64_Sym *sym = find_symbol64(lib, symname);
393
394 if (sym == NULL) {
395 printk(KERN_WARNING "vDSO64: function %s not found !\n",
396 symname);
397 return 0;
398 }
399 #ifdef VDS64_HAS_DESCRIPTORS
400 return *((u64 *)(vdso64_kbase + sym->st_value - VDSO64_LBASE)) -
401 VDSO64_LBASE;
402 #else
403 return sym->st_value - VDSO64_LBASE;
404 #endif
405 }
406
407 static int __init vdso_do_func_patch64(struct lib32_elfinfo *v32,
408 struct lib64_elfinfo *v64,
409 const char *orig, const char *fix)
410 {
411 Elf64_Sym *sym64_gen, *sym64_fix;
412
413 sym64_gen = find_symbol64(v64, orig);
414 if (sym64_gen == NULL) {
415 printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", orig);
416 return -1;
417 }
418 if (fix == NULL) {
419 sym64_gen->st_name = 0;
420 return 0;
421 }
422 sym64_fix = find_symbol64(v64, fix);
423 if (sym64_fix == NULL) {
424 printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", fix);
425 return -1;
426 }
427 sym64_gen->st_value = sym64_fix->st_value;
428 sym64_gen->st_size = sym64_fix->st_size;
429 sym64_gen->st_info = sym64_fix->st_info;
430 sym64_gen->st_other = sym64_fix->st_other;
431 sym64_gen->st_shndx = sym64_fix->st_shndx;
432
433 return 0;
434 }
435
436 #endif /* CONFIG_PPC64 */
437
438
439 static __init int vdso_do_find_sections(struct lib32_elfinfo *v32,
440 struct lib64_elfinfo *v64)
441 {
442 void *sect;
443
444 /*
445 * Locate symbol tables & text section
446 */
447
448 v32->dynsym = find_section32(v32->hdr, ".dynsym", &v32->dynsymsize);
449 v32->dynstr = find_section32(v32->hdr, ".dynstr", NULL);
450 if (v32->dynsym == NULL || v32->dynstr == NULL) {
451 printk(KERN_ERR "vDSO32: required symbol section not found\n");
452 return -1;
453 }
454 sect = find_section32(v32->hdr, ".text", NULL);
455 if (sect == NULL) {
456 printk(KERN_ERR "vDSO32: the .text section was not found\n");
457 return -1;
458 }
459 v32->text = sect - vdso32_kbase;
460
461 #ifdef CONFIG_PPC64
462 v64->dynsym = find_section64(v64->hdr, ".dynsym", &v64->dynsymsize);
463 v64->dynstr = find_section64(v64->hdr, ".dynstr", NULL);
464 if (v64->dynsym == NULL || v64->dynstr == NULL) {
465 printk(KERN_ERR "vDSO64: required symbol section not found\n");
466 return -1;
467 }
468 sect = find_section64(v64->hdr, ".text", NULL);
469 if (sect == NULL) {
470 printk(KERN_ERR "vDSO64: the .text section was not found\n");
471 return -1;
472 }
473 v64->text = sect - vdso64_kbase;
474 #endif /* CONFIG_PPC64 */
475
476 return 0;
477 }
478
479 static __init void vdso_setup_trampolines(struct lib32_elfinfo *v32,
480 struct lib64_elfinfo *v64)
481 {
482 /*
483 * Find signal trampolines
484 */
485
486 #ifdef CONFIG_PPC64
487 vdso64_rt_sigtramp = find_function64(v64, "__kernel_sigtramp_rt64");
488 #endif
489 vdso32_sigtramp = find_function32(v32, "__kernel_sigtramp32");
490 vdso32_rt_sigtramp = find_function32(v32, "__kernel_sigtramp_rt32");
491 }
492
493 static __init int vdso_fixup_datapage(struct lib32_elfinfo *v32,
494 struct lib64_elfinfo *v64)
495 {
496 Elf32_Sym *sym32;
497 #ifdef CONFIG_PPC64
498 Elf64_Sym *sym64;
499
500 sym64 = find_symbol64(v64, "__kernel_datapage_offset");
501 if (sym64 == NULL) {
502 printk(KERN_ERR "vDSO64: Can't find symbol "
503 "__kernel_datapage_offset !\n");
504 return -1;
505 }
506 *((int *)(vdso64_kbase + sym64->st_value - VDSO64_LBASE)) =
507 (vdso64_pages << PAGE_SHIFT) -
508 (sym64->st_value - VDSO64_LBASE);
509 #endif /* CONFIG_PPC64 */
510
511 sym32 = find_symbol32(v32, "__kernel_datapage_offset");
512 if (sym32 == NULL) {
513 printk(KERN_ERR "vDSO32: Can't find symbol "
514 "__kernel_datapage_offset !\n");
515 return -1;
516 }
517 *((int *)(vdso32_kbase + (sym32->st_value - VDSO32_LBASE))) =
518 (vdso32_pages << PAGE_SHIFT) -
519 (sym32->st_value - VDSO32_LBASE);
520
521 return 0;
522 }
523
524
525 static __init int vdso_fixup_features(struct lib32_elfinfo *v32,
526 struct lib64_elfinfo *v64)
527 {
528 void *start32;
529 unsigned long size32;
530
531 #ifdef CONFIG_PPC64
532 void *start64;
533 unsigned long size64;
534
535 start64 = find_section64(v64->hdr, "__ftr_fixup", &size64);
536 if (start64)
537 do_feature_fixups(cur_cpu_spec->cpu_features,
538 start64, start64 + size64);
539
540 start64 = find_section64(v64->hdr, "__mmu_ftr_fixup", &size64);
541 if (start64)
542 do_feature_fixups(cur_cpu_spec->mmu_features,
543 start64, start64 + size64);
544
545 start64 = find_section64(v64->hdr, "__fw_ftr_fixup", &size64);
546 if (start64)
547 do_feature_fixups(powerpc_firmware_features,
548 start64, start64 + size64);
549
550 start64 = find_section64(v64->hdr, "__lwsync_fixup", &size64);
551 if (start64)
552 do_lwsync_fixups(cur_cpu_spec->cpu_features,
553 start64, start64 + size64);
554 #endif /* CONFIG_PPC64 */
555
556 start32 = find_section32(v32->hdr, "__ftr_fixup", &size32);
557 if (start32)
558 do_feature_fixups(cur_cpu_spec->cpu_features,
559 start32, start32 + size32);
560
561 start32 = find_section32(v32->hdr, "__mmu_ftr_fixup", &size32);
562 if (start32)
563 do_feature_fixups(cur_cpu_spec->mmu_features,
564 start32, start32 + size32);
565
566 #ifdef CONFIG_PPC64
567 start32 = find_section32(v32->hdr, "__fw_ftr_fixup", &size32);
568 if (start32)
569 do_feature_fixups(powerpc_firmware_features,
570 start32, start32 + size32);
571 #endif /* CONFIG_PPC64 */
572
573 start32 = find_section32(v32->hdr, "__lwsync_fixup", &size32);
574 if (start32)
575 do_lwsync_fixups(cur_cpu_spec->cpu_features,
576 start32, start32 + size32);
577
578 return 0;
579 }
580
581 static __init int vdso_fixup_alt_funcs(struct lib32_elfinfo *v32,
582 struct lib64_elfinfo *v64)
583 {
584 int i;
585
586 for (i = 0; i < ARRAY_SIZE(vdso_patches); i++) {
587 struct vdso_patch_def *patch = &vdso_patches[i];
588 int match = (cur_cpu_spec->cpu_features & patch->ftr_mask)
589 == patch->ftr_value;
590 if (!match)
591 continue;
592
593 DBG("replacing %s with %s...\n", patch->gen_name,
594 patch->fix_name ? "NONE" : patch->fix_name);
595
596 /*
597 * Patch the 32 bits and 64 bits symbols. Note that we do not
598 * patch the "." symbol on 64 bits.
599 * It would be easy to do, but doesn't seem to be necessary,
600 * patching the OPD symbol is enough.
601 */
602 vdso_do_func_patch32(v32, v64, patch->gen_name,
603 patch->fix_name);
604 #ifdef CONFIG_PPC64
605 vdso_do_func_patch64(v32, v64, patch->gen_name,
606 patch->fix_name);
607 #endif /* CONFIG_PPC64 */
608 }
609
610 return 0;
611 }
612
613
614 static __init int vdso_setup(void)
615 {
616 struct lib32_elfinfo v32;
617 struct lib64_elfinfo v64;
618
619 v32.hdr = vdso32_kbase;
620 #ifdef CONFIG_PPC64
621 v64.hdr = vdso64_kbase;
622 #endif
623 if (vdso_do_find_sections(&v32, &v64))
624 return -1;
625
626 if (vdso_fixup_datapage(&v32, &v64))
627 return -1;
628
629 if (vdso_fixup_features(&v32, &v64))
630 return -1;
631
632 if (vdso_fixup_alt_funcs(&v32, &v64))
633 return -1;
634
635 vdso_setup_trampolines(&v32, &v64);
636
637 return 0;
638 }
639
640 /*
641 * Called from setup_arch to initialize the bitmap of available
642 * syscalls in the systemcfg page
643 */
644 static void __init vdso_setup_syscall_map(void)
645 {
646 unsigned int i;
647 extern unsigned long *sys_call_table;
648 extern unsigned long sys_ni_syscall;
649
650
651 for (i = 0; i < __NR_syscalls; i++) {
652 #ifdef CONFIG_PPC64
653 if (sys_call_table[i*2] != sys_ni_syscall)
654 vdso_data->syscall_map_64[i >> 5] |=
655 0x80000000UL >> (i & 0x1f);
656 if (sys_call_table[i*2+1] != sys_ni_syscall)
657 vdso_data->syscall_map_32[i >> 5] |=
658 0x80000000UL >> (i & 0x1f);
659 #else /* CONFIG_PPC64 */
660 if (sys_call_table[i] != sys_ni_syscall)
661 vdso_data->syscall_map_32[i >> 5] |=
662 0x80000000UL >> (i & 0x1f);
663 #endif /* CONFIG_PPC64 */
664 }
665 }
666
667 #ifdef CONFIG_PPC64
668 int vdso_getcpu_init(void)
669 {
670 unsigned long cpu, node, val;
671
672 /*
673 * SPRG_VDSO contains the CPU in the bottom 16 bits and the NUMA node
674 * in the next 16 bits. The VDSO uses this to implement getcpu().
675 */
676 cpu = get_cpu();
677 WARN_ON_ONCE(cpu > 0xffff);
678
679 node = cpu_to_node(cpu);
680 WARN_ON_ONCE(node > 0xffff);
681
682 val = (cpu & 0xfff) | ((node & 0xffff) << 16);
683 mtspr(SPRN_SPRG_VDSO_WRITE, val);
684 get_paca()->sprg_vdso = val;
685
686 put_cpu();
687
688 return 0;
689 }
690 /* We need to call this before SMP init */
691 early_initcall(vdso_getcpu_init);
692 #endif
693
694 static int __init vdso_init(void)
695 {
696 int i;
697
698 #ifdef CONFIG_PPC64
699 /*
700 * Fill up the "systemcfg" stuff for backward compatibility
701 */
702 strcpy((char *)vdso_data->eye_catcher, "SYSTEMCFG:PPC64");
703 vdso_data->version.major = SYSTEMCFG_MAJOR;
704 vdso_data->version.minor = SYSTEMCFG_MINOR;
705 vdso_data->processor = mfspr(SPRN_PVR);
706 /*
707 * Fake the old platform number for pSeries and add
708 * in LPAR bit if necessary
709 */
710 vdso_data->platform = 0x100;
711 if (firmware_has_feature(FW_FEATURE_LPAR))
712 vdso_data->platform |= 1;
713 vdso_data->physicalMemorySize = memblock_phys_mem_size();
714 vdso_data->dcache_size = ppc64_caches.dsize;
715 vdso_data->dcache_line_size = ppc64_caches.dline_size;
716 vdso_data->icache_size = ppc64_caches.isize;
717 vdso_data->icache_line_size = ppc64_caches.iline_size;
718
719 /* XXXOJN: Blocks should be added to ppc64_caches and used instead */
720 vdso_data->dcache_block_size = ppc64_caches.dline_size;
721 vdso_data->icache_block_size = ppc64_caches.iline_size;
722 vdso_data->dcache_log_block_size = ppc64_caches.log_dline_size;
723 vdso_data->icache_log_block_size = ppc64_caches.log_iline_size;
724
725 /*
726 * Calculate the size of the 64 bits vDSO
727 */
728 vdso64_pages = (&vdso64_end - &vdso64_start) >> PAGE_SHIFT;
729 DBG("vdso64_kbase: %p, 0x%x pages\n", vdso64_kbase, vdso64_pages);
730 #else
731 vdso_data->dcache_block_size = L1_CACHE_BYTES;
732 vdso_data->dcache_log_block_size = L1_CACHE_SHIFT;
733 vdso_data->icache_block_size = L1_CACHE_BYTES;
734 vdso_data->icache_log_block_size = L1_CACHE_SHIFT;
735 #endif /* CONFIG_PPC64 */
736
737
738 /*
739 * Calculate the size of the 32 bits vDSO
740 */
741 vdso32_pages = (&vdso32_end - &vdso32_start) >> PAGE_SHIFT;
742 DBG("vdso32_kbase: %p, 0x%x pages\n", vdso32_kbase, vdso32_pages);
743
744
745 /*
746 * Setup the syscall map in the vDOS
747 */
748 vdso_setup_syscall_map();
749
750 /*
751 * Initialize the vDSO images in memory, that is do necessary
752 * fixups of vDSO symbols, locate trampolines, etc...
753 */
754 if (vdso_setup()) {
755 printk(KERN_ERR "vDSO setup failure, not enabled !\n");
756 vdso32_pages = 0;
757 #ifdef CONFIG_PPC64
758 vdso64_pages = 0;
759 #endif
760 return 0;
761 }
762
763 /* Make sure pages are in the correct state */
764 vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2),
765 GFP_KERNEL);
766 BUG_ON(vdso32_pagelist == NULL);
767 for (i = 0; i < vdso32_pages; i++) {
768 struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);
769 ClearPageReserved(pg);
770 get_page(pg);
771 vdso32_pagelist[i] = pg;
772 }
773 vdso32_pagelist[i++] = virt_to_page(vdso_data);
774 vdso32_pagelist[i] = NULL;
775
776 #ifdef CONFIG_PPC64
777 vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2),
778 GFP_KERNEL);
779 BUG_ON(vdso64_pagelist == NULL);
780 for (i = 0; i < vdso64_pages; i++) {
781 struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);
782 ClearPageReserved(pg);
783 get_page(pg);
784 vdso64_pagelist[i] = pg;
785 }
786 vdso64_pagelist[i++] = virt_to_page(vdso_data);
787 vdso64_pagelist[i] = NULL;
788 #endif /* CONFIG_PPC64 */
789
790 get_page(virt_to_page(vdso_data));
791
792 smp_wmb();
793 vdso_ready = 1;
794
795 return 0;
796 }
797 arch_initcall(vdso_init);
This page took 0.072823 seconds and 5 git commands to generate.