aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/vdso.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2005-11-11 05:15:21 -0500
committerPaul Mackerras <paulus@samba.org>2005-11-11 06:25:39 -0500
commita7f290dad32ee34d931561b7943c858fe2aae503 (patch)
tree850f04ed9ffba8aef6e151fa9c9e8a0c667bb795 /arch/powerpc/kernel/vdso.c
parent6761c4a07378e19e3710bb69cea65795774529b1 (diff)
[PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel
This patch moves the vdso's to arch/powerpc, adds support for the 32 bits vdso to the 32 bits kernel, rename systemcfg (finally !), and adds some new (still untested) routines to both vdso's: clock_gettime() with support for CLOCK_REALTIME and CLOCK_MONOTONIC, clock_getres() (same clocks) and get_tbfreq() for glibc to retreive the timebase frequency. Tom,Steve: The implementation of get_tbfreq() I've done for 32 bits returns a long long (r3, r4) not a long. This is such that if we ever add support for >4Ghz timebases on ppc32, the userland interface won't have to change. I have tested gettimeofday() using some glibc patches in both ppc32 and ppc64 kernels using 32 bits userland (I haven't had a chance to test a 64 bits userland yet, but the implementation didn't change and was tested earlier). I haven't tested yet the new functions. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/vdso.c')
-rw-r--r--arch/powerpc/kernel/vdso.c746
1 files changed, 746 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
new file mode 100644
index 000000000000..0d4d8bec0df4
--- /dev/null
+++ b/arch/powerpc/kernel/vdso.c
@@ -0,0 +1,746 @@
1/*
2 * linux/arch/ppc64/kernel/vdso.c
3 *
4 * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/module.h>
15#include <linux/errno.h>
16#include <linux/sched.h>
17#include <linux/kernel.h>
18#include <linux/mm.h>
19#include <linux/smp.h>
20#include <linux/smp_lock.h>
21#include <linux/stddef.h>
22#include <linux/unistd.h>
23#include <linux/slab.h>
24#include <linux/user.h>
25#include <linux/elf.h>
26#include <linux/security.h>
27#include <linux/bootmem.h>
28
29#include <asm/pgtable.h>
30#include <asm/system.h>
31#include <asm/processor.h>
32#include <asm/mmu.h>
33#include <asm/mmu_context.h>
34#include <asm/lmb.h>
35#include <asm/machdep.h>
36#include <asm/cputable.h>
37#include <asm/sections.h>
38#include <asm/vdso.h>
39#include <asm/vdso_datapage.h>
40
41#undef DEBUG
42
43#ifdef DEBUG
44#define DBG(fmt...) printk(fmt)
45#else
46#define DBG(fmt...)
47#endif
48
49/* Max supported size for symbol names */
50#define MAX_SYMNAME 64
51
52extern char vdso32_start, vdso32_end;
53static void *vdso32_kbase = &vdso32_start;
54unsigned int vdso32_pages;
55unsigned long vdso32_sigtramp;
56unsigned long vdso32_rt_sigtramp;
57
58#ifdef CONFIG_PPC64
59extern char vdso64_start, vdso64_end;
60static void *vdso64_kbase = &vdso64_start;
61unsigned int vdso64_pages;
62unsigned long vdso64_rt_sigtramp;
63#endif /* CONFIG_PPC64 */
64
65/*
66 * The vdso data page (aka. systemcfg for old ppc64 fans) is here.
67 * Once the early boot kernel code no longer needs to muck around
68 * with it, it will become dynamically allocated
69 */
70static union {
71 struct vdso_data data;
72 u8 page[PAGE_SIZE];
73} vdso_data_store __attribute__((__section__(".data.page_aligned")));
74struct vdso_data *vdso_data = &vdso_data_store.data;
75
76/* Format of the patch table */
77struct vdso_patch_def
78{
79 unsigned long ftr_mask, ftr_value;
80 const char *gen_name;
81 const char *fix_name;
82};
83
84/* Table of functions to patch based on the CPU type/revision
85 *
86 * Currently, we only change sync_dicache to do nothing on processors
87 * with a coherent icache
88 */
89static struct vdso_patch_def vdso_patches[] = {
90 {
91 CPU_FTR_COHERENT_ICACHE, CPU_FTR_COHERENT_ICACHE,
92 "__kernel_sync_dicache", "__kernel_sync_dicache_p5"
93 },
94 {
95 CPU_FTR_USE_TB, 0,
96 "__kernel_gettimeofday", NULL
97 },
98};
99
100/*
101 * Some infos carried around for each of them during parsing at
102 * boot time.
103 */
104struct lib32_elfinfo
105{
106 Elf32_Ehdr *hdr; /* ptr to ELF */
107 Elf32_Sym *dynsym; /* ptr to .dynsym section */
108 unsigned long dynsymsize; /* size of .dynsym section */
109 char *dynstr; /* ptr to .dynstr section */
110 unsigned long text; /* offset of .text section in .so */
111};
112
113struct lib64_elfinfo
114{
115 Elf64_Ehdr *hdr;
116 Elf64_Sym *dynsym;
117 unsigned long dynsymsize;
118 char *dynstr;
119 unsigned long text;
120};
121
122
123#ifdef __DEBUG
124static void dump_one_vdso_page(struct page *pg, struct page *upg)
125{
126 printk("kpg: %p (c:%d,f:%08lx)", __va(page_to_pfn(pg) << PAGE_SHIFT),
127 page_count(pg),
128 pg->flags);
129 if (upg/* && pg != upg*/) {
130 printk(" upg: %p (c:%d,f:%08lx)", __va(page_to_pfn(upg)
131 << PAGE_SHIFT),
132 page_count(upg),
133 upg->flags);
134 }
135 printk("\n");
136}
137
138static void dump_vdso_pages(struct vm_area_struct * vma)
139{
140 int i;
141
142 if (!vma || test_thread_flag(TIF_32BIT)) {
143 printk("vDSO32 @ %016lx:\n", (unsigned long)vdso32_kbase);
144 for (i=0; i<vdso32_pages; i++) {
145 struct page *pg = virt_to_page(vdso32_kbase +
146 i*PAGE_SIZE);
147 struct page *upg = (vma && vma->vm_mm) ?
148 follow_page(vma->vm_mm, vma->vm_start +
149 i*PAGE_SIZE, 0)
150 : NULL;
151 dump_one_vdso_page(pg, upg);
152 }
153 }
154 if (!vma || !test_thread_flag(TIF_32BIT)) {
155 printk("vDSO64 @ %016lx:\n", (unsigned long)vdso64_kbase);
156 for (i=0; i<vdso64_pages; i++) {
157 struct page *pg = virt_to_page(vdso64_kbase +
158 i*PAGE_SIZE);
159 struct page *upg = (vma && vma->vm_mm) ?
160 follow_page(vma->vm_mm, vma->vm_start +
161 i*PAGE_SIZE, 0)
162 : NULL;
163 dump_one_vdso_page(pg, upg);
164 }
165 }
166}
167#endif /* DEBUG */
168
169/*
170 * Keep a dummy vma_close for now, it will prevent VMA merging.
171 */
172static void vdso_vma_close(struct vm_area_struct * vma)
173{
174}
175
176/*
177 * Our nopage() function, maps in the actual vDSO kernel pages, they will
178 * be mapped read-only by do_no_page(), and eventually COW'ed, either
179 * right away for an initial write access, or by do_wp_page().
180 */
181static struct page * vdso_vma_nopage(struct vm_area_struct * vma,
182 unsigned long address, int *type)
183{
184 unsigned long offset = address - vma->vm_start;
185 struct page *pg;
186#ifdef CONFIG_PPC64
187 void *vbase = test_thread_flag(TIF_32BIT) ?
188 vdso32_kbase : vdso64_kbase;
189#else
190 void *vbase = vdso32_kbase;
191#endif
192
193 DBG("vdso_vma_nopage(current: %s, address: %016lx, off: %lx)\n",
194 current->comm, address, offset);
195
196 if (address < vma->vm_start || address > vma->vm_end)
197 return NOPAGE_SIGBUS;
198
199 /*
200 * Last page is systemcfg.
201 */
202 if ((vma->vm_end - address) <= PAGE_SIZE)
203 pg = virt_to_page(vdso_data);
204 else
205 pg = virt_to_page(vbase + offset);
206
207 get_page(pg);
208 DBG(" ->page count: %d\n", page_count(pg));
209
210 return pg;
211}
212
213static struct vm_operations_struct vdso_vmops = {
214 .close = vdso_vma_close,
215 .nopage = vdso_vma_nopage,
216};
217
218/*
219 * This is called from binfmt_elf, we create the special vma for the
220 * vDSO and insert it into the mm struct tree
221 */
222int arch_setup_additional_pages(struct linux_binprm *bprm,
223 int executable_stack)
224{
225 struct mm_struct *mm = current->mm;
226 struct vm_area_struct *vma;
227 unsigned long vdso_pages;
228 unsigned long vdso_base;
229
230#ifdef CONFIG_PPC64
231 if (test_thread_flag(TIF_32BIT)) {
232 vdso_pages = vdso32_pages;
233 vdso_base = VDSO32_MBASE;
234 } else {
235 vdso_pages = vdso64_pages;
236 vdso_base = VDSO64_MBASE;
237 }
238#else
239 vdso_pages = vdso32_pages;
240 vdso_base = VDSO32_MBASE;
241#endif
242
243 current->thread.vdso_base = 0;
244
245 /* vDSO has a problem and was disabled, just don't "enable" it for the
246 * process
247 */
248 if (vdso_pages == 0)
249 return 0;
250
251 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
252 if (vma == NULL)
253 return -ENOMEM;
254
255 memset(vma, 0, sizeof(*vma));
256
257 /* Add a page to the vdso size for the data page */
258 vdso_pages ++;
259
260 /*
261 * pick a base address for the vDSO in process space. We try to put it
262 * at vdso_base which is the "natural" base for it, but we might fail
263 * and end up putting it elsewhere.
264 */
265 vdso_base = get_unmapped_area(NULL, vdso_base,
266 vdso_pages << PAGE_SHIFT, 0, 0);
267 if (vdso_base & ~PAGE_MASK) {
268 kmem_cache_free(vm_area_cachep, vma);
269 return (int)vdso_base;
270 }
271
272 current->thread.vdso_base = vdso_base;
273
274 vma->vm_mm = mm;
275 vma->vm_start = current->thread.vdso_base;
276 vma->vm_end = vma->vm_start + (vdso_pages << PAGE_SHIFT);
277
278 /*
279 * our vma flags don't have VM_WRITE so by default, the process isn't
280 * allowed to write those pages.
281 * gdb can break that with ptrace interface, and thus trigger COW on
282 * those pages but it's then your responsibility to never do that on
283 * the "data" page of the vDSO or you'll stop getting kernel updates
284 * and your nice userland gettimeofday will be totally dead.
285 * It's fine to use that for setting breakpoints in the vDSO code
286 * pages though
287 */
288 vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE |
289 VM_MAYEXEC | VM_RESERVED;
290 vma->vm_flags |= mm->def_flags;
291 vma->vm_page_prot = protection_map[vma->vm_flags & 0x7];
292 vma->vm_ops = &vdso_vmops;
293
294 down_write(&mm->mmap_sem);
295 if (insert_vm_struct(mm, vma)) {
296 up_write(&mm->mmap_sem);
297 kmem_cache_free(vm_area_cachep, vma);
298 return -ENOMEM;
299 }
300 mm->total_vm += (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
301 up_write(&mm->mmap_sem);
302
303 return 0;
304}
305
306static void * __init find_section32(Elf32_Ehdr *ehdr, const char *secname,
307 unsigned long *size)
308{
309 Elf32_Shdr *sechdrs;
310 unsigned int i;
311 char *secnames;
312
313 /* Grab section headers and strings so we can tell who is who */
314 sechdrs = (void *)ehdr + ehdr->e_shoff;
315 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;
316
317 /* Find the section they want */
318 for (i = 1; i < ehdr->e_shnum; i++) {
319 if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
320 if (size)
321 *size = sechdrs[i].sh_size;
322 return (void *)ehdr + sechdrs[i].sh_offset;
323 }
324 }
325 *size = 0;
326 return NULL;
327}
328
329static Elf32_Sym * __init find_symbol32(struct lib32_elfinfo *lib,
330 const char *symname)
331{
332 unsigned int i;
333 char name[MAX_SYMNAME], *c;
334
335 for (i = 0; i < (lib->dynsymsize / sizeof(Elf32_Sym)); i++) {
336 if (lib->dynsym[i].st_name == 0)
337 continue;
338 strlcpy(name, lib->dynstr + lib->dynsym[i].st_name,
339 MAX_SYMNAME);
340 c = strchr(name, '@');
341 if (c)
342 *c = 0;
343 if (strcmp(symname, name) == 0)
344 return &lib->dynsym[i];
345 }
346 return NULL;
347}
348
349/* Note that we assume the section is .text and the symbol is relative to
350 * the library base
351 */
352static unsigned long __init find_function32(struct lib32_elfinfo *lib,
353 const char *symname)
354{
355 Elf32_Sym *sym = find_symbol32(lib, symname);
356
357 if (sym == NULL) {
358 printk(KERN_WARNING "vDSO32: function %s not found !\n",
359 symname);
360 return 0;
361 }
362 return sym->st_value - VDSO32_LBASE;
363}
364
365static int vdso_do_func_patch32(struct lib32_elfinfo *v32,
366 struct lib64_elfinfo *v64,
367 const char *orig, const char *fix)
368{
369 Elf32_Sym *sym32_gen, *sym32_fix;
370
371 sym32_gen = find_symbol32(v32, orig);
372 if (sym32_gen == NULL) {
373 printk(KERN_ERR "vDSO32: Can't find symbol %s !\n", orig);
374 return -1;
375 }
376 if (fix == NULL) {
377 sym32_gen->st_name = 0;
378 return 0;
379 }
380 sym32_fix = find_symbol32(v32, fix);
381 if (sym32_fix == NULL) {
382 printk(KERN_ERR "vDSO32: Can't find symbol %s !\n", fix);
383 return -1;
384 }
385 sym32_gen->st_value = sym32_fix->st_value;
386 sym32_gen->st_size = sym32_fix->st_size;
387 sym32_gen->st_info = sym32_fix->st_info;
388 sym32_gen->st_other = sym32_fix->st_other;
389 sym32_gen->st_shndx = sym32_fix->st_shndx;
390
391 return 0;
392}
393
394
395#ifdef CONFIG_PPC64
396
397static void * __init find_section64(Elf64_Ehdr *ehdr, const char *secname,
398 unsigned long *size)
399{
400 Elf64_Shdr *sechdrs;
401 unsigned int i;
402 char *secnames;
403
404 /* Grab section headers and strings so we can tell who is who */
405 sechdrs = (void *)ehdr + ehdr->e_shoff;
406 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset;
407
408 /* Find the section they want */
409 for (i = 1; i < ehdr->e_shnum; i++) {
410 if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
411 if (size)
412 *size = sechdrs[i].sh_size;
413 return (void *)ehdr + sechdrs[i].sh_offset;
414 }
415 }
416 if (size)
417 *size = 0;
418 return NULL;
419}
420
421static Elf64_Sym * __init find_symbol64(struct lib64_elfinfo *lib,
422 const char *symname)
423{
424 unsigned int i;
425 char name[MAX_SYMNAME], *c;
426
427 for (i = 0; i < (lib->dynsymsize / sizeof(Elf64_Sym)); i++) {
428 if (lib->dynsym[i].st_name == 0)
429 continue;
430 strlcpy(name, lib->dynstr + lib->dynsym[i].st_name,
431 MAX_SYMNAME);
432 c = strchr(name, '@');
433 if (c)
434 *c = 0;
435 if (strcmp(symname, name) == 0)
436 return &lib->dynsym[i];
437 }
438 return NULL;
439}
440
441/* Note that we assume the section is .text and the symbol is relative to
442 * the library base
443 */
444static unsigned long __init find_function64(struct lib64_elfinfo *lib,
445 const char *symname)
446{
447 Elf64_Sym *sym = find_symbol64(lib, symname);
448
449 if (sym == NULL) {
450 printk(KERN_WARNING "vDSO64: function %s not found !\n",
451 symname);
452 return 0;
453 }
454#ifdef VDS64_HAS_DESCRIPTORS
455 return *((u64 *)(vdso64_kbase + sym->st_value - VDSO64_LBASE)) -
456 VDSO64_LBASE;
457#else
458 return sym->st_value - VDSO64_LBASE;
459#endif
460}
461
462static int vdso_do_func_patch64(struct lib32_elfinfo *v32,
463 struct lib64_elfinfo *v64,
464 const char *orig, const char *fix)
465{
466 Elf64_Sym *sym64_gen, *sym64_fix;
467
468 sym64_gen = find_symbol64(v64, orig);
469 if (sym64_gen == NULL) {
470 printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", orig);
471 return -1;
472 }
473 if (fix == NULL) {
474 sym64_gen->st_name = 0;
475 return 0;
476 }
477 sym64_fix = find_symbol64(v64, fix);
478 if (sym64_fix == NULL) {
479 printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", fix);
480 return -1;
481 }
482 sym64_gen->st_value = sym64_fix->st_value;
483 sym64_gen->st_size = sym64_fix->st_size;
484 sym64_gen->st_info = sym64_fix->st_info;
485 sym64_gen->st_other = sym64_fix->st_other;
486 sym64_gen->st_shndx = sym64_fix->st_shndx;
487
488 return 0;
489}
490
491#endif /* CONFIG_PPC64 */
492
493
494static __init int vdso_do_find_sections(struct lib32_elfinfo *v32,
495 struct lib64_elfinfo *v64)
496{
497 void *sect;
498
499 /*
500 * Locate symbol tables & text section
501 */
502
503 v32->dynsym = find_section32(v32->hdr, ".dynsym", &v32->dynsymsize);
504 v32->dynstr = find_section32(v32->hdr, ".dynstr", NULL);
505 if (v32->dynsym == NULL || v32->dynstr == NULL) {
506 printk(KERN_ERR "vDSO32: required symbol section not found\n");
507 return -1;
508 }
509 sect = find_section32(v32->hdr, ".text", NULL);
510 if (sect == NULL) {
511 printk(KERN_ERR "vDSO32: the .text section was not found\n");
512 return -1;
513 }
514 v32->text = sect - vdso32_kbase;
515
516#ifdef CONFIG_PPC64
517 v64->dynsym = find_section64(v64->hdr, ".dynsym", &v64->dynsymsize);
518 v64->dynstr = find_section64(v64->hdr, ".dynstr", NULL);
519 if (v64->dynsym == NULL || v64->dynstr == NULL) {
520 printk(KERN_ERR "vDSO64: required symbol section not found\n");
521 return -1;
522 }
523 sect = find_section64(v64->hdr, ".text", NULL);
524 if (sect == NULL) {
525 printk(KERN_ERR "vDSO64: the .text section was not found\n");
526 return -1;
527 }
528 v64->text = sect - vdso64_kbase;
529#endif /* CONFIG_PPC64 */
530
531 return 0;
532}
533
534static __init void vdso_setup_trampolines(struct lib32_elfinfo *v32,
535 struct lib64_elfinfo *v64)
536{
537 /*
538 * Find signal trampolines
539 */
540
541#ifdef CONFIG_PPC64
542 vdso64_rt_sigtramp = find_function64(v64, "__kernel_sigtramp_rt64");
543#endif
544 vdso32_sigtramp = find_function32(v32, "__kernel_sigtramp32");
545 vdso32_rt_sigtramp = find_function32(v32, "__kernel_sigtramp_rt32");
546}
547
548static __init int vdso_fixup_datapage(struct lib32_elfinfo *v32,
549 struct lib64_elfinfo *v64)
550{
551 Elf32_Sym *sym32;
552#ifdef CONFIG_PPC64
553 Elf64_Sym *sym64;
554
555 sym64 = find_symbol64(v64, "__kernel_datapage_offset");
556 if (sym64 == NULL) {
557 printk(KERN_ERR "vDSO64: Can't find symbol "
558 "__kernel_datapage_offset !\n");
559 return -1;
560 }
561 *((int *)(vdso64_kbase + sym64->st_value - VDSO64_LBASE)) =
562 (vdso64_pages << PAGE_SHIFT) -
563 (sym64->st_value - VDSO64_LBASE);
564#endif /* CONFIG_PPC64 */
565
566 sym32 = find_symbol32(v32, "__kernel_datapage_offset");
567 if (sym32 == NULL) {
568 printk(KERN_ERR "vDSO32: Can't find symbol "
569 "__kernel_datapage_offset !\n");
570 return -1;
571 }
572 *((int *)(vdso32_kbase + (sym32->st_value - VDSO32_LBASE))) =
573 (vdso32_pages << PAGE_SHIFT) -
574 (sym32->st_value - VDSO32_LBASE);
575
576 return 0;
577}
578
579static __init int vdso_fixup_alt_funcs(struct lib32_elfinfo *v32,
580 struct lib64_elfinfo *v64)
581{
582 int i;
583
584 for (i = 0; i < ARRAY_SIZE(vdso_patches); i++) {
585 struct vdso_patch_def *patch = &vdso_patches[i];
586 int match = (cur_cpu_spec->cpu_features & patch->ftr_mask)
587 == patch->ftr_value;
588 if (!match)
589 continue;
590
591 DBG("replacing %s with %s...\n", patch->gen_name,
592 patch->fix_name ? "NONE" : patch->fix_name);
593
594 /*
595 * Patch the 32 bits and 64 bits symbols. Note that we do not
596 * patch the "." symbol on 64 bits.
597 * It would be easy to do, but doesn't seem to be necessary,
598 * patching the OPD symbol is enough.
599 */
600 vdso_do_func_patch32(v32, v64, patch->gen_name,
601 patch->fix_name);
602#ifdef CONFIG_PPC64
603 vdso_do_func_patch64(v32, v64, patch->gen_name,
604 patch->fix_name);
605#endif /* CONFIG_PPC64 */
606 }
607
608 return 0;
609}
610
611
612static __init int vdso_setup(void)
613{
614 struct lib32_elfinfo v32;
615 struct lib64_elfinfo v64;
616
617 v32.hdr = vdso32_kbase;
618#ifdef CONFIG_PPC64
619 v64.hdr = vdso64_kbase;
620#endif
621 if (vdso_do_find_sections(&v32, &v64))
622 return -1;
623
624 if (vdso_fixup_datapage(&v32, &v64))
625 return -1;
626
627 if (vdso_fixup_alt_funcs(&v32, &v64))
628 return -1;
629
630 vdso_setup_trampolines(&v32, &v64);
631
632 return 0;
633}
634
635/*
636 * Called from setup_arch to initialize the bitmap of available
637 * syscalls in the systemcfg page
638 */
639static void __init vdso_setup_syscall_map(void)
640{
641 unsigned int i;
642 extern unsigned long *sys_call_table;
643 extern unsigned long sys_ni_syscall;
644
645
646 for (i = 0; i < __NR_syscalls; i++) {
647#ifdef CONFIG_PPC64
648 if (sys_call_table[i*2] != sys_ni_syscall)
649 vdso_data->syscall_map_64[i >> 5] |=
650 0x80000000UL >> (i & 0x1f);
651 if (sys_call_table[i*2+1] != sys_ni_syscall)
652 vdso_data->syscall_map_32[i >> 5] |=
653 0x80000000UL >> (i & 0x1f);
654#else /* CONFIG_PPC64 */
655 if (sys_call_table[i] != sys_ni_syscall)
656 vdso_data->syscall_map_32[i >> 5] |=
657 0x80000000UL >> (i & 0x1f);
658#endif /* CONFIG_PPC64 */
659 }
660}
661
662
663void __init vdso_init(void)
664{
665 int i;
666
667#ifdef CONFIG_PPC64
668 /*
669 * Fill up the "systemcfg" stuff for backward compatiblity
670 */
671 strcpy(vdso_data->eye_catcher, "SYSTEMCFG:PPC64");
672 vdso_data->version.major = SYSTEMCFG_MAJOR;
673 vdso_data->version.minor = SYSTEMCFG_MINOR;
674 vdso_data->processor = mfspr(SPRN_PVR);
675 vdso_data->platform = _machine;
676 vdso_data->physicalMemorySize = lmb_phys_mem_size();
677 vdso_data->dcache_size = ppc64_caches.dsize;
678 vdso_data->dcache_line_size = ppc64_caches.dline_size;
679 vdso_data->icache_size = ppc64_caches.isize;
680 vdso_data->icache_line_size = ppc64_caches.iline_size;
681
682 /*
683 * Calculate the size of the 64 bits vDSO
684 */
685 vdso64_pages = (&vdso64_end - &vdso64_start) >> PAGE_SHIFT;
686 DBG("vdso64_kbase: %p, 0x%x pages\n", vdso64_kbase, vdso64_pages);
687#endif /* CONFIG_PPC64 */
688
689
690 /*
691 * Calculate the size of the 32 bits vDSO
692 */
693 vdso32_pages = (&vdso32_end - &vdso32_start) >> PAGE_SHIFT;
694 DBG("vdso32_kbase: %p, 0x%x pages\n", vdso32_kbase, vdso32_pages);
695
696
697 /*
698 * Setup the syscall map in the vDOS
699 */
700 vdso_setup_syscall_map();
701 /*
702 * Initialize the vDSO images in memory, that is do necessary
703 * fixups of vDSO symbols, locate trampolines, etc...
704 */
705 if (vdso_setup()) {
706 printk(KERN_ERR "vDSO setup failure, not enabled !\n");
707 vdso32_pages = 0;
708#ifdef CONFIG_PPC64
709 vdso64_pages = 0;
710#endif
711 return;
712 }
713
714 /* Make sure pages are in the correct state */
715 for (i = 0; i < vdso32_pages; i++) {
716 struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);
717 ClearPageReserved(pg);
718 get_page(pg);
719
720 }
721#ifdef CONFIG_PPC64
722 for (i = 0; i < vdso64_pages; i++) {
723 struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);
724 ClearPageReserved(pg);
725 get_page(pg);
726 }
727#endif /* CONFIG_PPC64 */
728
729 get_page(virt_to_page(vdso_data));
730}
731
732int in_gate_area_no_task(unsigned long addr)
733{
734 return 0;
735}
736
737int in_gate_area(struct task_struct *task, unsigned long addr)
738{
739 return 0;
740}
741
742struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
743{
744 return NULL;
745}
746