diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2005-11-11 05:15:21 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-11-11 06:25:39 -0500 |
commit | a7f290dad32ee34d931561b7943c858fe2aae503 (patch) | |
tree | 850f04ed9ffba8aef6e151fa9c9e8a0c667bb795 /arch/powerpc/kernel | |
parent | 6761c4a07378e19e3710bb69cea65795774529b1 (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')
29 files changed, 2630 insertions, 114 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index c68eace12a9d..9a74b7ab03a4 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -12,11 +12,13 @@ CFLAGS_btext.o += -fPIC | |||
12 | endif | 12 | endif |
13 | 13 | ||
14 | obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ | 14 | obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ |
15 | irq.o signal_32.o pmc.o | 15 | irq.o signal_32.o pmc.o vdso.o |
16 | obj-y += vdso32/ | ||
16 | obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ | 17 | obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ |
17 | signal_64.o ptrace32.o systbl.o \ | 18 | signal_64.o ptrace32.o systbl.o \ |
18 | paca.o ioctl32.o cpu_setup_power4.o \ | 19 | paca.o ioctl32.o cpu_setup_power4.o \ |
19 | firmware.o sysfs.o udbg.o | 20 | firmware.o sysfs.o udbg.o |
21 | obj-$(CONFIG_PPC64) += vdso64/ | ||
20 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o | 22 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o |
21 | obj-$(CONFIG_POWER4) += idle_power4.o | 23 | obj-$(CONFIG_POWER4) += idle_power4.o |
22 | obj-$(CONFIG_PPC_OF) += of_device.o | 24 | obj-$(CONFIG_PPC_OF) += of_device.o |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 8793102711a8..4550eb4f4fbd 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -37,12 +37,12 @@ | |||
37 | #include <asm/cputable.h> | 37 | #include <asm/cputable.h> |
38 | #include <asm/thread_info.h> | 38 | #include <asm/thread_info.h> |
39 | #include <asm/rtas.h> | 39 | #include <asm/rtas.h> |
40 | #include <asm/vdso_datapage.h> | ||
40 | #ifdef CONFIG_PPC64 | 41 | #ifdef CONFIG_PPC64 |
41 | #include <asm/paca.h> | 42 | #include <asm/paca.h> |
42 | #include <asm/lppaca.h> | 43 | #include <asm/lppaca.h> |
43 | #include <asm/iseries/hv_lp_event.h> | 44 | #include <asm/iseries/hv_lp_event.h> |
44 | #include <asm/cache.h> | 45 | #include <asm/cache.h> |
45 | #include <asm/systemcfg.h> | ||
46 | #include <asm/compat.h> | 46 | #include <asm/compat.h> |
47 | #endif | 47 | #endif |
48 | 48 | ||
@@ -251,25 +251,42 @@ int main(void) | |||
251 | 251 | ||
252 | DEFINE(TASK_SIZE, TASK_SIZE); | 252 | DEFINE(TASK_SIZE, TASK_SIZE); |
253 | DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28); | 253 | DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28); |
254 | #else /* CONFIG_PPC64 */ | 254 | #endif /* ! CONFIG_PPC64 */ |
255 | /* systemcfg offsets for use by vdso */ | ||
256 | DEFINE(CFG_TB_ORIG_STAMP, offsetof(struct systemcfg, tb_orig_stamp)); | ||
257 | DEFINE(CFG_TB_TICKS_PER_SEC, offsetof(struct systemcfg, tb_ticks_per_sec)); | ||
258 | DEFINE(CFG_TB_TO_XS, offsetof(struct systemcfg, tb_to_xs)); | ||
259 | DEFINE(CFG_STAMP_XSEC, offsetof(struct systemcfg, stamp_xsec)); | ||
260 | DEFINE(CFG_TB_UPDATE_COUNT, offsetof(struct systemcfg, tb_update_count)); | ||
261 | DEFINE(CFG_TZ_MINUTEWEST, offsetof(struct systemcfg, tz_minuteswest)); | ||
262 | DEFINE(CFG_TZ_DSTTIME, offsetof(struct systemcfg, tz_dsttime)); | ||
263 | DEFINE(CFG_SYSCALL_MAP32, offsetof(struct systemcfg, syscall_map_32)); | ||
264 | DEFINE(CFG_SYSCALL_MAP64, offsetof(struct systemcfg, syscall_map_64)); | ||
265 | 255 | ||
266 | /* timeval/timezone offsets for use by vdso */ | 256 | /* datapage offsets for use by vdso */ |
257 | DEFINE(CFG_TB_ORIG_STAMP, offsetof(struct vdso_data, tb_orig_stamp)); | ||
258 | DEFINE(CFG_TB_TICKS_PER_SEC, offsetof(struct vdso_data, tb_ticks_per_sec)); | ||
259 | DEFINE(CFG_TB_TO_XS, offsetof(struct vdso_data, tb_to_xs)); | ||
260 | DEFINE(CFG_STAMP_XSEC, offsetof(struct vdso_data, stamp_xsec)); | ||
261 | DEFINE(CFG_TB_UPDATE_COUNT, offsetof(struct vdso_data, tb_update_count)); | ||
262 | DEFINE(CFG_TZ_MINUTEWEST, offsetof(struct vdso_data, tz_minuteswest)); | ||
263 | DEFINE(CFG_TZ_DSTTIME, offsetof(struct vdso_data, tz_dsttime)); | ||
264 | DEFINE(CFG_SYSCALL_MAP32, offsetof(struct vdso_data, syscall_map_32)); | ||
265 | DEFINE(WTOM_CLOCK_SEC, offsetof(struct vdso_data, wtom_clock_sec)); | ||
266 | DEFINE(WTOM_CLOCK_NSEC, offsetof(struct vdso_data, wtom_clock_nsec)); | ||
267 | #ifdef CONFIG_PPC64 | ||
268 | DEFINE(CFG_SYSCALL_MAP64, offsetof(struct vdso_data, syscall_map_64)); | ||
267 | DEFINE(TVAL64_TV_SEC, offsetof(struct timeval, tv_sec)); | 269 | DEFINE(TVAL64_TV_SEC, offsetof(struct timeval, tv_sec)); |
268 | DEFINE(TVAL64_TV_USEC, offsetof(struct timeval, tv_usec)); | 270 | DEFINE(TVAL64_TV_USEC, offsetof(struct timeval, tv_usec)); |
269 | DEFINE(TVAL32_TV_SEC, offsetof(struct compat_timeval, tv_sec)); | 271 | DEFINE(TVAL32_TV_SEC, offsetof(struct compat_timeval, tv_sec)); |
270 | DEFINE(TVAL32_TV_USEC, offsetof(struct compat_timeval, tv_usec)); | 272 | DEFINE(TVAL32_TV_USEC, offsetof(struct compat_timeval, tv_usec)); |
273 | DEFINE(TSPC32_TV_SEC, offsetof(struct compat_timespec, tv_sec)); | ||
274 | DEFINE(TSPC32_TV_NSEC, offsetof(struct compat_timespec, tv_nsec)); | ||
275 | #else | ||
276 | DEFINE(TVAL32_TV_SEC, offsetof(struct timeval, tv_sec)); | ||
277 | DEFINE(TVAL32_TV_USEC, offsetof(struct timeval, tv_usec)); | ||
278 | DEFINE(TSPEC32_TV_SEC, offsetof(struct timespec, tv_sec)); | ||
279 | DEFINE(TSPEC32_TV_NSEC, offsetof(struct timespec, tv_nsec)); | ||
280 | #endif | ||
281 | /* timeval/timezone offsets for use by vdso */ | ||
271 | DEFINE(TZONE_TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); | 282 | DEFINE(TZONE_TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); |
272 | DEFINE(TZONE_TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); | 283 | DEFINE(TZONE_TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); |
273 | #endif /* CONFIG_PPC64 */ | 284 | |
285 | /* Other bits used by the vdso */ | ||
286 | DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); | ||
287 | DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); | ||
288 | DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); | ||
289 | DEFINE(CLOCK_REALTIME_RES, TICK_NSEC); | ||
290 | |||
274 | return 0; | 291 | return 0; |
275 | } | 292 | } |
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 3cf2517c5f91..a7b68f911eb1 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c | |||
@@ -15,17 +15,10 @@ | |||
15 | #include <asm/processor.h> | 15 | #include <asm/processor.h> |
16 | #include <asm/ptrace.h> | 16 | #include <asm/ptrace.h> |
17 | #include <asm/page.h> | 17 | #include <asm/page.h> |
18 | #include <asm/systemcfg.h> | ||
19 | #include <asm/lppaca.h> | 18 | #include <asm/lppaca.h> |
20 | #include <asm/iseries/it_lp_queue.h> | 19 | #include <asm/iseries/it_lp_queue.h> |
21 | #include <asm/paca.h> | 20 | #include <asm/paca.h> |
22 | 21 | ||
23 | static union { | ||
24 | struct systemcfg data; | ||
25 | u8 page[PAGE_SIZE]; | ||
26 | } systemcfg_store __attribute__((__section__(".data.page.aligned"))); | ||
27 | struct systemcfg *_systemcfg = &systemcfg_store.data; | ||
28 | |||
29 | 22 | ||
30 | /* This symbol is provided by the linker - let it fill in the paca | 23 | /* This symbol is provided by the linker - let it fill in the paca |
31 | * field correctly */ | 24 | * field correctly */ |
diff --git a/arch/powerpc/kernel/proc_ppc64.c b/arch/powerpc/kernel/proc_ppc64.c index a1c19502fe8b..7ba42a405f41 100644 --- a/arch/powerpc/kernel/proc_ppc64.c +++ b/arch/powerpc/kernel/proc_ppc64.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | 25 | ||
26 | #include <asm/systemcfg.h> | 26 | #include <asm/vdso_datapage.h> |
27 | #include <asm/rtas.h> | 27 | #include <asm/rtas.h> |
28 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
29 | #include <asm/prom.h> | 29 | #include <asm/prom.h> |
@@ -72,7 +72,7 @@ static int __init proc_ppc64_init(void) | |||
72 | if (!pde) | 72 | if (!pde) |
73 | return 1; | 73 | return 1; |
74 | pde->nlink = 1; | 74 | pde->nlink = 1; |
75 | pde->data = _systemcfg; | 75 | pde->data = vdso_data; |
76 | pde->size = PAGE_SIZE; | 76 | pde->size = PAGE_SIZE; |
77 | pde->proc_fops = &page_map_fops; | 77 | pde->proc_fops = &page_map_fops; |
78 | 78 | ||
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c index ae1a36449ccd..7a95b8a28354 100644 --- a/arch/powerpc/kernel/rtas-proc.c +++ b/arch/powerpc/kernel/rtas-proc.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <asm/rtas.h> | 32 | #include <asm/rtas.h> |
33 | #include <asm/machdep.h> /* for ppc_md */ | 33 | #include <asm/machdep.h> /* for ppc_md */ |
34 | #include <asm/time.h> | 34 | #include <asm/time.h> |
35 | #include <asm/systemcfg.h> | ||
36 | 35 | ||
37 | /* Token for Sensors */ | 36 | /* Token for Sensors */ |
38 | #define KEY_SWITCH 0x0001 | 37 | #define KEY_SWITCH 0x0001 |
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index a754de63450f..33e7f2c7f194 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <asm/prom.h> | 34 | #include <asm/prom.h> |
35 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
36 | #include <asm/systemcfg.h> | 36 | #include <asm/vdso_datapage.h> |
37 | #include <asm/pgtable.h> | 37 | #include <asm/pgtable.h> |
38 | #include <asm/smp.h> | 38 | #include <asm/smp.h> |
39 | #include <asm/elf.h> | 39 | #include <asm/elf.h> |
@@ -564,7 +564,7 @@ void __init smp_setup_cpu_maps(void) | |||
564 | cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]); | 564 | cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]); |
565 | } | 565 | } |
566 | 566 | ||
567 | _systemcfg->processorCount = num_present_cpus(); | 567 | vdso_data->processorCount = num_present_cpus(); |
568 | #endif /* CONFIG_PPC64 */ | 568 | #endif /* CONFIG_PPC64 */ |
569 | } | 569 | } |
570 | #endif /* CONFIG_SMP */ | 570 | #endif /* CONFIG_SMP */ |
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 6791668213e7..fdbd9f9122f2 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -57,7 +57,6 @@ | |||
57 | #include <asm/lmb.h> | 57 | #include <asm/lmb.h> |
58 | #include <asm/iseries/it_lp_naca.h> | 58 | #include <asm/iseries/it_lp_naca.h> |
59 | #include <asm/firmware.h> | 59 | #include <asm/firmware.h> |
60 | #include <asm/systemcfg.h> | ||
61 | #include <asm/xmon.h> | 60 | #include <asm/xmon.h> |
62 | #include <asm/udbg.h> | 61 | #include <asm/udbg.h> |
63 | 62 | ||
@@ -375,9 +374,8 @@ static void __init initialize_cache_info(void) | |||
375 | DBG("Argh, can't find dcache properties ! " | 374 | DBG("Argh, can't find dcache properties ! " |
376 | "sizep: %p, lsizep: %p\n", sizep, lsizep); | 375 | "sizep: %p, lsizep: %p\n", sizep, lsizep); |
377 | 376 | ||
378 | _systemcfg->dcache_size = ppc64_caches.dsize = size; | 377 | ppc64_caches.dsize = size; |
379 | _systemcfg->dcache_line_size = | 378 | ppc64_caches.dline_size = lsize; |
380 | ppc64_caches.dline_size = lsize; | ||
381 | ppc64_caches.log_dline_size = __ilog2(lsize); | 379 | ppc64_caches.log_dline_size = __ilog2(lsize); |
382 | ppc64_caches.dlines_per_page = PAGE_SIZE / lsize; | 380 | ppc64_caches.dlines_per_page = PAGE_SIZE / lsize; |
383 | 381 | ||
@@ -393,22 +391,13 @@ static void __init initialize_cache_info(void) | |||
393 | DBG("Argh, can't find icache properties ! " | 391 | DBG("Argh, can't find icache properties ! " |
394 | "sizep: %p, lsizep: %p\n", sizep, lsizep); | 392 | "sizep: %p, lsizep: %p\n", sizep, lsizep); |
395 | 393 | ||
396 | _systemcfg->icache_size = ppc64_caches.isize = size; | 394 | ppc64_caches.isize = size; |
397 | _systemcfg->icache_line_size = | 395 | ppc64_caches.iline_size = lsize; |
398 | ppc64_caches.iline_size = lsize; | ||
399 | ppc64_caches.log_iline_size = __ilog2(lsize); | 396 | ppc64_caches.log_iline_size = __ilog2(lsize); |
400 | ppc64_caches.ilines_per_page = PAGE_SIZE / lsize; | 397 | ppc64_caches.ilines_per_page = PAGE_SIZE / lsize; |
401 | } | 398 | } |
402 | } | 399 | } |
403 | 400 | ||
404 | /* Add an eye catcher and the systemcfg layout version number */ | ||
405 | strcpy(_systemcfg->eye_catcher, "SYSTEMCFG:PPC64"); | ||
406 | _systemcfg->version.major = SYSTEMCFG_MAJOR; | ||
407 | _systemcfg->version.minor = SYSTEMCFG_MINOR; | ||
408 | _systemcfg->processor = mfspr(SPRN_PVR); | ||
409 | _systemcfg->platform = _machine; | ||
410 | _systemcfg->physicalMemorySize = lmb_phys_mem_size(); | ||
411 | |||
412 | DBG(" <- initialize_cache_info()\n"); | 401 | DBG(" <- initialize_cache_info()\n"); |
413 | } | 402 | } |
414 | 403 | ||
@@ -495,15 +484,14 @@ void __init setup_system(void) | |||
495 | 484 | ||
496 | printk("-----------------------------------------------------\n"); | 485 | printk("-----------------------------------------------------\n"); |
497 | printk("ppc64_pft_size = 0x%lx\n", ppc64_pft_size); | 486 | printk("ppc64_pft_size = 0x%lx\n", ppc64_pft_size); |
498 | printk("ppc64_interrupt_controller = 0x%ld\n", ppc64_interrupt_controller); | 487 | printk("ppc64_interrupt_controller = 0x%ld\n", |
499 | printk("systemcfg = 0x%p\n", _systemcfg); | 488 | ppc64_interrupt_controller); |
500 | printk("systemcfg->platform = 0x%x\n", _systemcfg->platform); | 489 | printk("platform = 0x%x\n", _machine); |
501 | printk("systemcfg->processorCount = 0x%lx\n", _systemcfg->processorCount); | 490 | printk("physicalMemorySize = 0x%lx\n", lmb_phys_mem_size()); |
502 | printk("systemcfg->physicalMemorySize = 0x%lx\n", _systemcfg->physicalMemorySize); | ||
503 | printk("ppc64_caches.dcache_line_size = 0x%x\n", | 491 | printk("ppc64_caches.dcache_line_size = 0x%x\n", |
504 | ppc64_caches.dline_size); | 492 | ppc64_caches.dline_size); |
505 | printk("ppc64_caches.icache_line_size = 0x%x\n", | 493 | printk("ppc64_caches.icache_line_size = 0x%x\n", |
506 | ppc64_caches.iline_size); | 494 | ppc64_caches.iline_size); |
507 | printk("htab_address = 0x%p\n", htab_address); | 495 | printk("htab_address = 0x%p\n", htab_address); |
508 | printk("htab_hash_mask = 0x%lx\n", htab_hash_mask); | 496 | printk("htab_hash_mask = 0x%lx\n", htab_hash_mask); |
509 | printk("-----------------------------------------------------\n"); | 497 | printk("-----------------------------------------------------\n"); |
@@ -568,33 +556,6 @@ static void __init emergency_stack_init(void) | |||
568 | } | 556 | } |
569 | 557 | ||
570 | /* | 558 | /* |
571 | * Called from setup_arch to initialize the bitmap of available | ||
572 | * syscalls in the systemcfg page | ||
573 | */ | ||
574 | void __init setup_syscall_map(void) | ||
575 | { | ||
576 | unsigned int i, count64 = 0, count32 = 0; | ||
577 | extern unsigned long *sys_call_table; | ||
578 | extern unsigned long sys_ni_syscall; | ||
579 | |||
580 | |||
581 | for (i = 0; i < __NR_syscalls; i++) { | ||
582 | if (sys_call_table[i*2] != sys_ni_syscall) { | ||
583 | count64++; | ||
584 | _systemcfg->syscall_map_64[i >> 5] |= | ||
585 | 0x80000000UL >> (i & 0x1f); | ||
586 | } | ||
587 | if (sys_call_table[i*2+1] != sys_ni_syscall) { | ||
588 | count32++; | ||
589 | _systemcfg->syscall_map_32[i >> 5] |= | ||
590 | 0x80000000UL >> (i & 0x1f); | ||
591 | } | ||
592 | } | ||
593 | printk(KERN_INFO "Syscall map setup, %d 32-bit and %d 64-bit syscalls\n", | ||
594 | count32, count64); | ||
595 | } | ||
596 | |||
597 | /* | ||
598 | * Called into from start_kernel, after lock_kernel has been called. | 559 | * Called into from start_kernel, after lock_kernel has been called. |
599 | * Initializes bootmem, which is unsed to manage page allocation until | 560 | * Initializes bootmem, which is unsed to manage page allocation until |
600 | * mem_init is called. | 561 | * mem_init is called. |
@@ -635,9 +596,6 @@ void __init setup_arch(char **cmdline_p) | |||
635 | do_init_bootmem(); | 596 | do_init_bootmem(); |
636 | sparse_init(); | 597 | sparse_init(); |
637 | 598 | ||
638 | /* initialize the syscall map in systemcfg */ | ||
639 | setup_syscall_map(); | ||
640 | |||
641 | #ifdef CONFIG_DUMMY_CONSOLE | 599 | #ifdef CONFIG_DUMMY_CONSOLE |
642 | conswitchp = &dummy_con; | 600 | conswitchp = &dummy_con; |
643 | #endif | 601 | #endif |
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index a7c4515f320f..8bdf95b7e420 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c | |||
@@ -43,10 +43,10 @@ | |||
43 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
44 | #include <asm/cacheflush.h> | 44 | #include <asm/cacheflush.h> |
45 | #include <asm/sigcontext.h> | 45 | #include <asm/sigcontext.h> |
46 | #include <asm/vdso.h> | ||
46 | #ifdef CONFIG_PPC64 | 47 | #ifdef CONFIG_PPC64 |
47 | #include "ppc32.h" | 48 | #include "ppc32.h" |
48 | #include <asm/unistd.h> | 49 | #include <asm/unistd.h> |
49 | #include <asm/vdso.h> | ||
50 | #else | 50 | #else |
51 | #include <asm/ucontext.h> | 51 | #include <asm/ucontext.h> |
52 | #include <asm/pgtable.h> | 52 | #include <asm/pgtable.h> |
@@ -809,14 +809,11 @@ static int handle_rt_signal(unsigned long sig, struct k_sigaction *ka, | |||
809 | 809 | ||
810 | /* Save user registers on the stack */ | 810 | /* Save user registers on the stack */ |
811 | frame = &rt_sf->uc.uc_mcontext; | 811 | frame = &rt_sf->uc.uc_mcontext; |
812 | #ifdef CONFIG_PPC64 | ||
813 | if (vdso32_rt_sigtramp && current->thread.vdso_base) { | 812 | if (vdso32_rt_sigtramp && current->thread.vdso_base) { |
814 | if (save_user_regs(regs, frame, 0)) | 813 | if (save_user_regs(regs, frame, 0)) |
815 | goto badframe; | 814 | goto badframe; |
816 | regs->link = current->thread.vdso_base + vdso32_rt_sigtramp; | 815 | regs->link = current->thread.vdso_base + vdso32_rt_sigtramp; |
817 | } else | 816 | } else { |
818 | #endif | ||
819 | { | ||
820 | if (save_user_regs(regs, frame, __NR_rt_sigreturn)) | 817 | if (save_user_regs(regs, frame, __NR_rt_sigreturn)) |
821 | goto badframe; | 818 | goto badframe; |
822 | regs->link = (unsigned long) frame->tramp; | 819 | regs->link = (unsigned long) frame->tramp; |
@@ -1090,14 +1087,11 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka, | |||
1090 | || __put_user(sig, &sc->signal)) | 1087 | || __put_user(sig, &sc->signal)) |
1091 | goto badframe; | 1088 | goto badframe; |
1092 | 1089 | ||
1093 | #ifdef CONFIG_PPC64 | ||
1094 | if (vdso32_sigtramp && current->thread.vdso_base) { | 1090 | if (vdso32_sigtramp && current->thread.vdso_base) { |
1095 | if (save_user_regs(regs, &frame->mctx, 0)) | 1091 | if (save_user_regs(regs, &frame->mctx, 0)) |
1096 | goto badframe; | 1092 | goto badframe; |
1097 | regs->link = current->thread.vdso_base + vdso32_sigtramp; | 1093 | regs->link = current->thread.vdso_base + vdso32_sigtramp; |
1098 | } else | 1094 | } else { |
1099 | #endif | ||
1100 | { | ||
1101 | if (save_user_regs(regs, &frame->mctx, __NR_sigreturn)) | 1095 | if (save_user_regs(regs, &frame->mctx, __NR_sigreturn)) |
1102 | goto badframe; | 1096 | goto badframe; |
1103 | regs->link = (unsigned long) frame->mctx.tramp; | 1097 | regs->link = (unsigned long) frame->mctx.tramp; |
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index e28a139c29d0..62dfc5b8d765 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <asm/cputable.h> | 44 | #include <asm/cputable.h> |
45 | #include <asm/system.h> | 45 | #include <asm/system.h> |
46 | #include <asm/mpic.h> | 46 | #include <asm/mpic.h> |
47 | #include <asm/systemcfg.h> | 47 | #include <asm/vdso_datapage.h> |
48 | #ifdef CONFIG_PPC64 | 48 | #ifdef CONFIG_PPC64 |
49 | #include <asm/paca.h> | 49 | #include <asm/paca.h> |
50 | #endif | 50 | #endif |
@@ -371,7 +371,7 @@ int generic_cpu_disable(void) | |||
371 | 371 | ||
372 | cpu_clear(cpu, cpu_online_map); | 372 | cpu_clear(cpu, cpu_online_map); |
373 | #ifdef CONFIG_PPC64 | 373 | #ifdef CONFIG_PPC64 |
374 | _systemcfg->processorCount--; | 374 | vdso_data->processorCount--; |
375 | fixup_irqs(cpu_online_map); | 375 | fixup_irqs(cpu_online_map); |
376 | #endif | 376 | #endif |
377 | return 0; | 377 | return 0; |
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 850af198fb5f..0f0c3a9ae2e5 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <asm/firmware.h> | 16 | #include <asm/firmware.h> |
17 | #include <asm/hvcall.h> | 17 | #include <asm/hvcall.h> |
18 | #include <asm/prom.h> | 18 | #include <asm/prom.h> |
19 | #include <asm/systemcfg.h> | ||
20 | #include <asm/paca.h> | 19 | #include <asm/paca.h> |
21 | #include <asm/lppaca.h> | 20 | #include <asm/lppaca.h> |
22 | #include <asm/machdep.h> | 21 | #include <asm/machdep.h> |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 260b6ecd26a9..070b4b458aaf 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -62,8 +62,8 @@ | |||
62 | #include <asm/irq.h> | 62 | #include <asm/irq.h> |
63 | #include <asm/div64.h> | 63 | #include <asm/div64.h> |
64 | #include <asm/smp.h> | 64 | #include <asm/smp.h> |
65 | #include <asm/vdso_datapage.h> | ||
65 | #ifdef CONFIG_PPC64 | 66 | #ifdef CONFIG_PPC64 |
66 | #include <asm/systemcfg.h> | ||
67 | #include <asm/firmware.h> | 67 | #include <asm/firmware.h> |
68 | #endif | 68 | #endif |
69 | #ifdef CONFIG_PPC_ISERIES | 69 | #ifdef CONFIG_PPC_ISERIES |
@@ -261,7 +261,6 @@ static inline void update_gtod(u64 new_tb_stamp, u64 new_stamp_xsec, | |||
261 | do_gtod.varp = temp_varp; | 261 | do_gtod.varp = temp_varp; |
262 | do_gtod.var_idx = temp_idx; | 262 | do_gtod.var_idx = temp_idx; |
263 | 263 | ||
264 | #ifdef CONFIG_PPC64 | ||
265 | /* | 264 | /* |
266 | * tb_update_count is used to allow the userspace gettimeofday code | 265 | * tb_update_count is used to allow the userspace gettimeofday code |
267 | * to assure itself that it sees a consistent view of the tb_to_xs and | 266 | * to assure itself that it sees a consistent view of the tb_to_xs and |
@@ -271,14 +270,15 @@ static inline void update_gtod(u64 new_tb_stamp, u64 new_stamp_xsec, | |||
271 | * tb_to_xs and stamp_xsec values are consistent. If not, then it | 270 | * tb_to_xs and stamp_xsec values are consistent. If not, then it |
272 | * loops back and reads them again until this criteria is met. | 271 | * loops back and reads them again until this criteria is met. |
273 | */ | 272 | */ |
274 | ++(_systemcfg->tb_update_count); | 273 | ++(vdso_data->tb_update_count); |
275 | smp_wmb(); | 274 | smp_wmb(); |
276 | _systemcfg->tb_orig_stamp = new_tb_stamp; | 275 | vdso_data->tb_orig_stamp = new_tb_stamp; |
277 | _systemcfg->stamp_xsec = new_stamp_xsec; | 276 | vdso_data->stamp_xsec = new_stamp_xsec; |
278 | _systemcfg->tb_to_xs = new_tb_to_xs; | 277 | vdso_data->tb_to_xs = new_tb_to_xs; |
278 | vdso_data->wtom_clock_sec = wall_to_monotonic.tv_sec; | ||
279 | vdso_data->wtom_clock_nsec = wall_to_monotonic.tv_nsec; | ||
279 | smp_wmb(); | 280 | smp_wmb(); |
280 | ++(_systemcfg->tb_update_count); | 281 | ++(vdso_data->tb_update_count); |
281 | #endif | ||
282 | } | 282 | } |
283 | 283 | ||
284 | /* | 284 | /* |
@@ -357,9 +357,8 @@ static void iSeries_tb_recal(void) | |||
357 | do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; | 357 | do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; |
358 | tb_to_xs = divres.result_low; | 358 | tb_to_xs = divres.result_low; |
359 | do_gtod.varp->tb_to_xs = tb_to_xs; | 359 | do_gtod.varp->tb_to_xs = tb_to_xs; |
360 | _systemcfg->tb_ticks_per_sec = | 360 | vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; |
361 | tb_ticks_per_sec; | 361 | vdso_data->tb_to_xs = tb_to_xs; |
362 | _systemcfg->tb_to_xs = tb_to_xs; | ||
363 | } | 362 | } |
364 | else { | 363 | else { |
365 | printk( "Titan recalibrate: FAILED (difference > 4 percent)\n" | 364 | printk( "Titan recalibrate: FAILED (difference > 4 percent)\n" |
@@ -561,10 +560,8 @@ int do_settimeofday(struct timespec *tv) | |||
561 | new_xsec += (u64)new_sec * XSEC_PER_SEC - tb_delta_xs; | 560 | new_xsec += (u64)new_sec * XSEC_PER_SEC - tb_delta_xs; |
562 | update_gtod(tb_last_jiffy, new_xsec, do_gtod.varp->tb_to_xs); | 561 | update_gtod(tb_last_jiffy, new_xsec, do_gtod.varp->tb_to_xs); |
563 | 562 | ||
564 | #ifdef CONFIG_PPC64 | 563 | vdso_data->tz_minuteswest = sys_tz.tz_minuteswest; |
565 | _systemcfg->tz_minuteswest = sys_tz.tz_minuteswest; | 564 | vdso_data->tz_dsttime = sys_tz.tz_dsttime; |
566 | _systemcfg->tz_dsttime = sys_tz.tz_dsttime; | ||
567 | #endif | ||
568 | 565 | ||
569 | write_sequnlock_irqrestore(&xtime_lock, flags); | 566 | write_sequnlock_irqrestore(&xtime_lock, flags); |
570 | clock_was_set(); | 567 | clock_was_set(); |
@@ -713,13 +710,12 @@ void __init time_init(void) | |||
713 | do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; | 710 | do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; |
714 | do_gtod.varp->tb_to_xs = tb_to_xs; | 711 | do_gtod.varp->tb_to_xs = tb_to_xs; |
715 | do_gtod.tb_to_us = tb_to_us; | 712 | do_gtod.tb_to_us = tb_to_us; |
716 | #ifdef CONFIG_PPC64 | 713 | |
717 | _systemcfg->tb_orig_stamp = tb_last_jiffy; | 714 | vdso_data->tb_orig_stamp = tb_last_jiffy; |
718 | _systemcfg->tb_update_count = 0; | 715 | vdso_data->tb_update_count = 0; |
719 | _systemcfg->tb_ticks_per_sec = tb_ticks_per_sec; | 716 | vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; |
720 | _systemcfg->stamp_xsec = xtime.tv_sec * XSEC_PER_SEC; | 717 | vdso_data->stamp_xsec = xtime.tv_sec * XSEC_PER_SEC; |
721 | _systemcfg->tb_to_xs = tb_to_xs; | 718 | vdso_data->tb_to_xs = tb_to_xs; |
722 | #endif | ||
723 | 719 | ||
724 | time_freq = 0; | 720 | time_freq = 0; |
725 | 721 | ||
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 2020bb7648fb..1511454c4690 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #ifdef CONFIG_PPC64 | 49 | #ifdef CONFIG_PPC64 |
50 | #include <asm/firmware.h> | 50 | #include <asm/firmware.h> |
51 | #include <asm/processor.h> | 51 | #include <asm/processor.h> |
52 | #include <asm/systemcfg.h> | ||
53 | #endif | 52 | #endif |
54 | 53 | ||
55 | #ifdef CONFIG_PPC64 /* XXX */ | 54 | #ifdef CONFIG_PPC64 /* XXX */ |
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 | |||
52 | extern char vdso32_start, vdso32_end; | ||
53 | static void *vdso32_kbase = &vdso32_start; | ||
54 | unsigned int vdso32_pages; | ||
55 | unsigned long vdso32_sigtramp; | ||
56 | unsigned long vdso32_rt_sigtramp; | ||
57 | |||
58 | #ifdef CONFIG_PPC64 | ||
59 | extern char vdso64_start, vdso64_end; | ||
60 | static void *vdso64_kbase = &vdso64_start; | ||
61 | unsigned int vdso64_pages; | ||
62 | unsigned 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 | */ | ||
70 | static union { | ||
71 | struct vdso_data data; | ||
72 | u8 page[PAGE_SIZE]; | ||
73 | } vdso_data_store __attribute__((__section__(".data.page_aligned"))); | ||
74 | struct vdso_data *vdso_data = &vdso_data_store.data; | ||
75 | |||
76 | /* Format of the patch table */ | ||
77 | struct 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 | */ | ||
89 | static 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 | */ | ||
104 | struct 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 | |||
113 | struct 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 | ||
124 | static 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 | |||
138 | static 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 | */ | ||
172 | static 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 | */ | ||
181 | static 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 | |||
213 | static 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 | */ | ||
222 | int 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 | |||
306 | static 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 | |||
329 | static 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 | */ | ||
352 | static 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 | |||
365 | static 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 | |||
397 | static 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 | |||
421 | static 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 | */ | ||
444 | static 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 | |||
462 | static 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 | |||
494 | static __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 | |||
534 | static __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 | |||
548 | static __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 | |||
579 | static __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 | |||
612 | static __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 | */ | ||
639 | static 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 | |||
663 | void __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 | |||
732 | int in_gate_area_no_task(unsigned long addr) | ||
733 | { | ||
734 | return 0; | ||
735 | } | ||
736 | |||
737 | int in_gate_area(struct task_struct *task, unsigned long addr) | ||
738 | { | ||
739 | return 0; | ||
740 | } | ||
741 | |||
742 | struct vm_area_struct *get_gate_vma(struct task_struct *tsk) | ||
743 | { | ||
744 | return NULL; | ||
745 | } | ||
746 | |||
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile new file mode 100644 index 000000000000..758331d4d1a5 --- /dev/null +++ b/arch/powerpc/kernel/vdso32/Makefile | |||
@@ -0,0 +1,40 @@ | |||
1 | |||
2 | # List of files in the vdso, has to be asm only for now | ||
3 | |||
4 | obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o | ||
5 | |||
6 | # Build rules | ||
7 | |||
8 | ifeq ($(CONFIG_PPC32),y) | ||
9 | CROSS32CC := $(CC) | ||
10 | endif | ||
11 | |||
12 | targets := $(obj-vdso32) vdso32.so | ||
13 | obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) | ||
14 | |||
15 | |||
16 | EXTRA_CFLAGS := -shared -s -fno-common -fno-builtin | ||
17 | EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso32.so.1 | ||
18 | EXTRA_AFLAGS := -D__VDSO32__ -s | ||
19 | |||
20 | obj-y += vdso32_wrapper.o | ||
21 | extra-y += vdso32.lds | ||
22 | CPPFLAGS_vdso32.lds += -P -C -U$(ARCH) | ||
23 | |||
24 | # Force dependency (incbin is bad) | ||
25 | $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so | ||
26 | |||
27 | # link rule for the .so file, .lds has to be first | ||
28 | $(obj)/vdso32.so: $(src)/vdso32.lds $(obj-vdso32) | ||
29 | $(call if_changed,vdso32ld) | ||
30 | |||
31 | # assembly rules for the .S files | ||
32 | $(obj-vdso32): %.o: %.S | ||
33 | $(call if_changed_dep,vdso32as) | ||
34 | |||
35 | # actual build commands | ||
36 | quiet_cmd_vdso32ld = VDSO32L $@ | ||
37 | cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@ | ||
38 | quiet_cmd_vdso32as = VDSO32A $@ | ||
39 | cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $< | ||
40 | |||
diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S b/arch/powerpc/kernel/vdso32/cacheflush.S new file mode 100644 index 000000000000..c8db993574ee --- /dev/null +++ b/arch/powerpc/kernel/vdso32/cacheflush.S | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * vDSO provided cache flush routines | ||
3 | * | ||
4 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), | ||
5 | * IBM Corp. | ||
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 | #include <linux/config.h> | ||
13 | #include <asm/processor.h> | ||
14 | #include <asm/ppc_asm.h> | ||
15 | #include <asm/vdso.h> | ||
16 | #include <asm/asm-offsets.h> | ||
17 | |||
18 | .text | ||
19 | |||
20 | /* | ||
21 | * Default "generic" version of __kernel_sync_dicache. | ||
22 | * | ||
23 | * void __kernel_sync_dicache(unsigned long start, unsigned long end) | ||
24 | * | ||
25 | * Flushes the data cache & invalidate the instruction cache for the | ||
26 | * provided range [start, end[ | ||
27 | * | ||
28 | * Note: all CPUs supported by this kernel have a 128 bytes cache | ||
29 | * line size so we don't have to peek that info from the datapage | ||
30 | */ | ||
31 | V_FUNCTION_BEGIN(__kernel_sync_dicache) | ||
32 | .cfi_startproc | ||
33 | li r5,127 | ||
34 | andc r6,r3,r5 /* round low to line bdy */ | ||
35 | subf r8,r6,r4 /* compute length */ | ||
36 | add r8,r8,r5 /* ensure we get enough */ | ||
37 | srwi. r8,r8,7 /* compute line count */ | ||
38 | beqlr /* nothing to do? */ | ||
39 | mtctr r8 | ||
40 | mr r3,r6 | ||
41 | 1: dcbst 0,r3 | ||
42 | addi r3,r3,128 | ||
43 | bdnz 1b | ||
44 | sync | ||
45 | mtctr r8 | ||
46 | 1: icbi 0,r6 | ||
47 | addi r6,r6,128 | ||
48 | bdnz 1b | ||
49 | isync | ||
50 | li r3,0 | ||
51 | blr | ||
52 | .cfi_endproc | ||
53 | V_FUNCTION_END(__kernel_sync_dicache) | ||
54 | |||
55 | |||
56 | /* | ||
57 | * POWER5 version of __kernel_sync_dicache | ||
58 | */ | ||
59 | V_FUNCTION_BEGIN(__kernel_sync_dicache_p5) | ||
60 | .cfi_startproc | ||
61 | sync | ||
62 | isync | ||
63 | li r3,0 | ||
64 | blr | ||
65 | .cfi_endproc | ||
66 | V_FUNCTION_END(__kernel_sync_dicache_p5) | ||
67 | |||
diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso32/datapage.S new file mode 100644 index 000000000000..a08c26e87835 --- /dev/null +++ b/arch/powerpc/kernel/vdso32/datapage.S | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Access to the shared data page by the vDSO & syscall map | ||
3 | * | ||
4 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp. | ||
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/config.h> | ||
13 | #include <asm/processor.h> | ||
14 | #include <asm/ppc_asm.h> | ||
15 | #include <asm/asm-offsets.h> | ||
16 | #include <asm/unistd.h> | ||
17 | #include <asm/vdso.h> | ||
18 | |||
19 | .text | ||
20 | V_FUNCTION_BEGIN(__get_datapage) | ||
21 | .cfi_startproc | ||
22 | /* We don't want that exposed or overridable as we want other objects | ||
23 | * to be able to bl directly to here | ||
24 | */ | ||
25 | .protected __get_datapage | ||
26 | .hidden __get_datapage | ||
27 | |||
28 | mflr r0 | ||
29 | .cfi_register lr,r0 | ||
30 | |||
31 | bcl 20,31,1f | ||
32 | .global __kernel_datapage_offset; | ||
33 | __kernel_datapage_offset: | ||
34 | .long 0 | ||
35 | 1: | ||
36 | mflr r3 | ||
37 | mtlr r0 | ||
38 | lwz r0,0(r3) | ||
39 | add r3,r0,r3 | ||
40 | blr | ||
41 | .cfi_endproc | ||
42 | V_FUNCTION_END(__get_datapage) | ||
43 | |||
44 | /* | ||
45 | * void *__kernel_get_syscall_map(unsigned int *syscall_count) ; | ||
46 | * | ||
47 | * returns a pointer to the syscall map. the map is agnostic to the | ||
48 | * size of "long", unlike kernel bitops, it stores bits from top to | ||
49 | * bottom so that memory actually contains a linear bitmap | ||
50 | * check for syscall N by testing bit (0x80000000 >> (N & 0x1f)) of | ||
51 | * 32 bits int at N >> 5. | ||
52 | */ | ||
53 | V_FUNCTION_BEGIN(__kernel_get_syscall_map) | ||
54 | .cfi_startproc | ||
55 | mflr r12 | ||
56 | .cfi_register lr,r12 | ||
57 | |||
58 | mr r4,r3 | ||
59 | bl __get_datapage@local | ||
60 | mtlr r12 | ||
61 | addi r3,r3,CFG_SYSCALL_MAP32 | ||
62 | cmpli cr0,r4,0 | ||
63 | beqlr | ||
64 | li r0,__NR_syscalls | ||
65 | stw r0,0(r4) | ||
66 | blr | ||
67 | .cfi_endproc | ||
68 | V_FUNCTION_END(__kernel_get_syscall_map) | ||
69 | |||
70 | /* | ||
71 | * void unsigned long long __kernel_get_tbfreq(void); | ||
72 | * | ||
73 | * returns the timebase frequency in HZ | ||
74 | */ | ||
75 | V_FUNCTION_BEGIN(__kernel_get_tbfreq) | ||
76 | .cfi_startproc | ||
77 | mflr r12 | ||
78 | .cfi_register lr,r12 | ||
79 | bl __get_datapage@local | ||
80 | lwz r3,CFG_TB_TICKS_PER_SEC(r3) | ||
81 | lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) | ||
82 | mtlr r12 | ||
83 | .cfi_endproc | ||
84 | V_FUNCTION_END(__kernel_get_tbfreq) | ||
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S new file mode 100644 index 000000000000..aeb5fc9b87b3 --- /dev/null +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S | |||
@@ -0,0 +1,315 @@ | |||
1 | /* | ||
2 | * Userland implementation of gettimeofday() for 32 bits processes in a | ||
3 | * ppc64 kernel for use in the vDSO | ||
4 | * | ||
5 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org, | ||
6 | * IBM Corp. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | #include <linux/config.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/ppc_asm.h> | ||
16 | #include <asm/vdso.h> | ||
17 | #include <asm/asm-offsets.h> | ||
18 | #include <asm/unistd.h> | ||
19 | |||
20 | .text | ||
21 | /* | ||
22 | * Exact prototype of gettimeofday | ||
23 | * | ||
24 | * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); | ||
25 | * | ||
26 | */ | ||
27 | V_FUNCTION_BEGIN(__kernel_gettimeofday) | ||
28 | .cfi_startproc | ||
29 | mflr r12 | ||
30 | .cfi_register lr,r12 | ||
31 | |||
32 | mr r10,r3 /* r10 saves tv */ | ||
33 | mr r11,r4 /* r11 saves tz */ | ||
34 | bl __get_datapage@local /* get data page */ | ||
35 | mr r9, r3 /* datapage ptr in r9 */ | ||
36 | bl __do_get_xsec@local /* get xsec from tb & kernel */ | ||
37 | bne- 2f /* out of line -> do syscall */ | ||
38 | |||
39 | /* seconds are xsec >> 20 */ | ||
40 | rlwinm r5,r4,12,20,31 | ||
41 | rlwimi r5,r3,12,0,19 | ||
42 | stw r5,TVAL32_TV_SEC(r10) | ||
43 | |||
44 | /* get remaining xsec and convert to usec. we scale | ||
45 | * up remaining xsec by 12 bits and get the top 32 bits | ||
46 | * of the multiplication | ||
47 | */ | ||
48 | rlwinm r5,r4,12,0,19 | ||
49 | lis r6,1000000@h | ||
50 | ori r6,r6,1000000@l | ||
51 | mulhwu r5,r5,r6 | ||
52 | stw r5,TVAL32_TV_USEC(r10) | ||
53 | |||
54 | cmpli cr0,r11,0 /* check if tz is NULL */ | ||
55 | beq 1f | ||
56 | lwz r4,CFG_TZ_MINUTEWEST(r9)/* fill tz */ | ||
57 | lwz r5,CFG_TZ_DSTTIME(r9) | ||
58 | stw r4,TZONE_TZ_MINWEST(r11) | ||
59 | stw r5,TZONE_TZ_DSTTIME(r11) | ||
60 | |||
61 | 1: mtlr r12 | ||
62 | li r3,0 | ||
63 | blr | ||
64 | |||
65 | 2: | ||
66 | mtlr r12 | ||
67 | mr r3,r10 | ||
68 | mr r4,r11 | ||
69 | li r0,__NR_gettimeofday | ||
70 | sc | ||
71 | blr | ||
72 | .cfi_endproc | ||
73 | V_FUNCTION_END(__kernel_gettimeofday) | ||
74 | |||
75 | /* | ||
76 | * Exact prototype of clock_gettime() | ||
77 | * | ||
78 | * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); | ||
79 | * | ||
80 | */ | ||
81 | V_FUNCTION_BEGIN(__kernel_clock_gettime) | ||
82 | .cfi_startproc | ||
83 | /* Check for supported clock IDs */ | ||
84 | cmpli cr0,r3,CLOCK_REALTIME | ||
85 | cmpli cr1,r3,CLOCK_MONOTONIC | ||
86 | cror cr0,cr0,cr1 | ||
87 | bne cr0,99f | ||
88 | |||
89 | mflr r12 /* r12 saves lr */ | ||
90 | .cfi_register lr,r12 | ||
91 | mr r10,r3 /* r10 saves id */ | ||
92 | mr r11,r4 /* r11 saves tp */ | ||
93 | bl __get_datapage@local /* get data page */ | ||
94 | mr r9, r3 /* datapage ptr in r9 */ | ||
95 | beq cr1,50f /* if monotonic -> jump there */ | ||
96 | |||
97 | /* | ||
98 | * CLOCK_REALTIME | ||
99 | */ | ||
100 | |||
101 | bl __do_get_xsec@local /* get xsec from tb & kernel */ | ||
102 | bne- 98f /* out of line -> do syscall */ | ||
103 | |||
104 | /* seconds are xsec >> 20 */ | ||
105 | rlwinm r5,r4,12,20,31 | ||
106 | rlwimi r5,r3,12,0,19 | ||
107 | stw r5,TSPC32_TV_SEC(r11) | ||
108 | |||
109 | /* get remaining xsec and convert to nsec. we scale | ||
110 | * up remaining xsec by 12 bits and get the top 32 bits | ||
111 | * of the multiplication, then we multiply by 1000 | ||
112 | */ | ||
113 | rlwinm r5,r4,12,0,19 | ||
114 | lis r6,1000000@h | ||
115 | ori r6,r6,1000000@l | ||
116 | mulhwu r5,r5,r6 | ||
117 | mulli r5,r5,1000 | ||
118 | stw r5,TSPC32_TV_NSEC(r11) | ||
119 | mtlr r12 | ||
120 | li r3,0 | ||
121 | blr | ||
122 | |||
123 | /* | ||
124 | * CLOCK_MONOTONIC | ||
125 | */ | ||
126 | |||
127 | 50: bl __do_get_xsec@local /* get xsec from tb & kernel */ | ||
128 | bne- 98f /* out of line -> do syscall */ | ||
129 | |||
130 | /* seconds are xsec >> 20 */ | ||
131 | rlwinm r6,r4,12,20,31 | ||
132 | rlwimi r6,r3,12,0,19 | ||
133 | |||
134 | /* get remaining xsec and convert to nsec. we scale | ||
135 | * up remaining xsec by 12 bits and get the top 32 bits | ||
136 | * of the multiplication, then we multiply by 1000 | ||
137 | */ | ||
138 | rlwinm r7,r4,12,0,19 | ||
139 | lis r5,1000000@h | ||
140 | ori r5,r5,1000000@l | ||
141 | mulhwu r7,r7,r5 | ||
142 | mulli r7,r7,1000 | ||
143 | |||
144 | /* now we must fixup using wall to monotonic. We need to snapshot | ||
145 | * that value and do the counter trick again. Fortunately, we still | ||
146 | * have the counter value in r8 that was returned by __do_get_xsec. | ||
147 | * At this point, r6,r7 contain our sec/nsec values, r3,r4 and r5 | ||
148 | * can be used | ||
149 | */ | ||
150 | |||
151 | lwz r3,WTOM_CLOCK_SEC(r9) | ||
152 | lwz r4,WTOM_CLOCK_NSEC(r9) | ||
153 | |||
154 | /* We now have our result in r3,r4. We create a fake dependency | ||
155 | * on that result and re-check the counter | ||
156 | */ | ||
157 | or r5,r4,r3 | ||
158 | xor r0,r5,r5 | ||
159 | add r9,r9,r0 | ||
160 | #ifdef CONFIG_PPC64 | ||
161 | lwz r0,(CFG_TB_UPDATE_COUNT+4)(r9) | ||
162 | #else | ||
163 | lwz r0,(CFG_TB_UPDATE_COUNT)(r9) | ||
164 | #endif | ||
165 | cmpl cr0,r8,r0 /* check if updated */ | ||
166 | bne- 50b | ||
167 | |||
168 | /* Calculate and store result. Note that this mimmics the C code, | ||
169 | * which may cause funny results if nsec goes negative... is that | ||
170 | * possible at all ? | ||
171 | */ | ||
172 | add r3,r3,r6 | ||
173 | add r4,r4,r7 | ||
174 | lis r5,NSEC_PER_SEC@h | ||
175 | ori r5,r5,NSEC_PER_SEC@l | ||
176 | cmpli cr0,r4,r5 | ||
177 | blt 1f | ||
178 | subf r4,r5,r4 | ||
179 | addi r3,r3,1 | ||
180 | 1: stw r3,TSPC32_TV_SEC(r11) | ||
181 | stw r4,TSPC32_TV_NSEC(r11) | ||
182 | |||
183 | mtlr r12 | ||
184 | li r3,0 | ||
185 | blr | ||
186 | |||
187 | /* | ||
188 | * syscall fallback | ||
189 | */ | ||
190 | 98: | ||
191 | mtlr r12 | ||
192 | mr r3,r10 | ||
193 | mr r4,r11 | ||
194 | 99: | ||
195 | li r0,__NR_clock_gettime | ||
196 | sc | ||
197 | blr | ||
198 | .cfi_endproc | ||
199 | V_FUNCTION_END(__kernel_clock_gettime) | ||
200 | |||
201 | |||
202 | /* | ||
203 | * Exact prototype of clock_getres() | ||
204 | * | ||
205 | * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); | ||
206 | * | ||
207 | */ | ||
208 | V_FUNCTION_BEGIN(__kernel_clock_getres) | ||
209 | .cfi_startproc | ||
210 | /* Check for supported clock IDs */ | ||
211 | cmpwi cr0,r3,CLOCK_REALTIME | ||
212 | cmpwi cr1,r3,CLOCK_MONOTONIC | ||
213 | cror cr0,cr0,cr1 | ||
214 | bne cr0,99f | ||
215 | |||
216 | li r3,0 | ||
217 | cmpli cr0,r4,0 | ||
218 | beqlr | ||
219 | lis r5,CLOCK_REALTIME_RES@h | ||
220 | ori r5,r5,CLOCK_REALTIME_RES@l | ||
221 | stw r3,TSPC32_TV_SEC(r4) | ||
222 | stw r5,TSPC32_TV_NSEC(r4) | ||
223 | blr | ||
224 | |||
225 | /* | ||
226 | * syscall fallback | ||
227 | */ | ||
228 | 99: | ||
229 | li r0,__NR_clock_getres | ||
230 | sc | ||
231 | blr | ||
232 | .cfi_endproc | ||
233 | V_FUNCTION_END(__kernel_clock_getres) | ||
234 | |||
235 | |||
236 | /* | ||
237 | * This is the core of gettimeofday() & friends, it returns the xsec | ||
238 | * value in r3 & r4 and expects the datapage ptr (non clobbered) | ||
239 | * in r9. clobbers r0,r4,r5,r6,r7,r8. | ||
240 | * When returning, r8 contains the counter value that can be reused | ||
241 | * by the monotonic clock implementation | ||
242 | */ | ||
243 | __do_get_xsec: | ||
244 | .cfi_startproc | ||
245 | /* Check for update count & load values. We use the low | ||
246 | * order 32 bits of the update count | ||
247 | */ | ||
248 | #ifdef CONFIG_PPC64 | ||
249 | 1: lwz r8,(CFG_TB_UPDATE_COUNT+4)(r9) | ||
250 | #else | ||
251 | 1: lwz r8,(CFG_TB_UPDATE_COUNT)(r9) | ||
252 | #endif | ||
253 | andi. r0,r8,1 /* pending update ? loop */ | ||
254 | bne- 1b | ||
255 | xor r0,r8,r8 /* create dependency */ | ||
256 | add r9,r9,r0 | ||
257 | |||
258 | /* Load orig stamp (offset to TB) */ | ||
259 | lwz r5,CFG_TB_ORIG_STAMP(r9) | ||
260 | lwz r6,(CFG_TB_ORIG_STAMP+4)(r9) | ||
261 | |||
262 | /* Get a stable TB value */ | ||
263 | 2: mftbu r3 | ||
264 | mftbl r4 | ||
265 | mftbu r0 | ||
266 | cmpl cr0,r3,r0 | ||
267 | bne- 2b | ||
268 | |||
269 | /* Substract tb orig stamp. If the high part is non-zero, we jump to | ||
270 | * the slow path which call the syscall. | ||
271 | * If it's ok, then we have our 32 bits tb_ticks value in r7 | ||
272 | */ | ||
273 | subfc r7,r6,r4 | ||
274 | subfe. r0,r5,r3 | ||
275 | bne- 3f | ||
276 | |||
277 | /* Load scale factor & do multiplication */ | ||
278 | lwz r5,CFG_TB_TO_XS(r9) /* load values */ | ||
279 | lwz r6,(CFG_TB_TO_XS+4)(r9) | ||
280 | mulhwu r4,r7,r5 | ||
281 | mulhwu r6,r7,r6 | ||
282 | mullw r0,r7,r5 | ||
283 | addc r6,r6,r0 | ||
284 | |||
285 | /* At this point, we have the scaled xsec value in r4 + XER:CA | ||
286 | * we load & add the stamp since epoch | ||
287 | */ | ||
288 | lwz r5,CFG_STAMP_XSEC(r9) | ||
289 | lwz r6,(CFG_STAMP_XSEC+4)(r9) | ||
290 | adde r4,r4,r6 | ||
291 | addze r3,r5 | ||
292 | |||
293 | /* We now have our result in r3,r4. We create a fake dependency | ||
294 | * on that result and re-check the counter | ||
295 | */ | ||
296 | or r6,r4,r3 | ||
297 | xor r0,r6,r6 | ||
298 | add r9,r9,r0 | ||
299 | #ifdef CONFIG_PPC64 | ||
300 | lwz r0,(CFG_TB_UPDATE_COUNT+4)(r9) | ||
301 | #else | ||
302 | lwz r0,(CFG_TB_UPDATE_COUNT)(r9) | ||
303 | #endif | ||
304 | cmpl cr0,r8,r0 /* check if updated */ | ||
305 | bne- 1b | ||
306 | |||
307 | /* Warning ! The caller expects CR:EQ to be set to indicate a | ||
308 | * successful calculation (so it won't fallback to the syscall | ||
309 | * method). We have overriden that CR bit in the counter check, | ||
310 | * but fortunately, the loop exit condition _is_ CR:EQ set, so | ||
311 | * we can exit safely here. If you change this code, be careful | ||
312 | * of that side effect. | ||
313 | */ | ||
314 | 3: blr | ||
315 | .cfi_endproc | ||
diff --git a/arch/powerpc/kernel/vdso32/note.S b/arch/powerpc/kernel/vdso32/note.S new file mode 100644 index 000000000000..d4b5be4f3d5f --- /dev/null +++ b/arch/powerpc/kernel/vdso32/note.S | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text. | ||
3 | * Here we can supply some information useful to userland. | ||
4 | */ | ||
5 | |||
6 | #include <linux/uts.h> | ||
7 | #include <linux/version.h> | ||
8 | |||
9 | #define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type) \ | ||
10 | .section name, flags; \ | ||
11 | .balign 4; \ | ||
12 | .long 1f - 0f; /* name length */ \ | ||
13 | .long 3f - 2f; /* data length */ \ | ||
14 | .long type; /* note type */ \ | ||
15 | 0: .asciz vendor; /* vendor name */ \ | ||
16 | 1: .balign 4; \ | ||
17 | 2: | ||
18 | |||
19 | #define ASM_ELF_NOTE_END \ | ||
20 | 3: .balign 4; /* pad out section */ \ | ||
21 | .previous | ||
22 | |||
23 | ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0) | ||
24 | .long LINUX_VERSION_CODE | ||
25 | ASM_ELF_NOTE_END | ||
diff --git a/arch/powerpc/kernel/vdso32/sigtramp.S b/arch/powerpc/kernel/vdso32/sigtramp.S new file mode 100644 index 000000000000..e04642781917 --- /dev/null +++ b/arch/powerpc/kernel/vdso32/sigtramp.S | |||
@@ -0,0 +1,300 @@ | |||
1 | /* | ||
2 | * Signal trampolines for 32 bits processes in a ppc64 kernel for | ||
3 | * use in the vDSO | ||
4 | * | ||
5 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp. | ||
6 | * Copyright (C) 2004 Alan Modra (amodra@au.ibm.com)), IBM Corp. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | #include <linux/config.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/ppc_asm.h> | ||
16 | #include <asm/unistd.h> | ||
17 | #include <asm/vdso.h> | ||
18 | |||
19 | .text | ||
20 | |||
21 | /* The nop here is a hack. The dwarf2 unwind routines subtract 1 from | ||
22 | the return address to get an address in the middle of the presumed | ||
23 | call instruction. Since we don't have a call here, we artifically | ||
24 | extend the range covered by the unwind info by adding a nop before | ||
25 | the real start. */ | ||
26 | nop | ||
27 | V_FUNCTION_BEGIN(__kernel_sigtramp32) | ||
28 | .Lsig_start = . - 4 | ||
29 | li r0,__NR_sigreturn | ||
30 | sc | ||
31 | .Lsig_end: | ||
32 | V_FUNCTION_END(__kernel_sigtramp32) | ||
33 | |||
34 | .Lsigrt_start: | ||
35 | nop | ||
36 | V_FUNCTION_BEGIN(__kernel_sigtramp_rt32) | ||
37 | li r0,__NR_rt_sigreturn | ||
38 | sc | ||
39 | .Lsigrt_end: | ||
40 | V_FUNCTION_END(__kernel_sigtramp_rt32) | ||
41 | |||
42 | .section .eh_frame,"a",@progbits | ||
43 | |||
44 | /* Register r1 can be found at offset 4 of a pt_regs structure. | ||
45 | A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */ | ||
46 | #define cfa_save \ | ||
47 | .byte 0x0f; /* DW_CFA_def_cfa_expression */ \ | ||
48 | .uleb128 9f - 1f; /* length */ \ | ||
49 | 1: \ | ||
50 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
51 | .byte 0x06; /* DW_OP_deref */ \ | ||
52 | .byte 0x23; .uleb128 RSIZE; /* DW_OP_plus_uconst */ \ | ||
53 | .byte 0x06; /* DW_OP_deref */ \ | ||
54 | 9: | ||
55 | |||
56 | /* Register REGNO can be found at offset OFS of a pt_regs structure. | ||
57 | A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */ | ||
58 | #define rsave(regno, ofs) \ | ||
59 | .byte 0x10; /* DW_CFA_expression */ \ | ||
60 | .uleb128 regno; /* regno */ \ | ||
61 | .uleb128 9f - 1f; /* length */ \ | ||
62 | 1: \ | ||
63 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
64 | .byte 0x06; /* DW_OP_deref */ \ | ||
65 | .ifne ofs; \ | ||
66 | .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \ | ||
67 | .endif; \ | ||
68 | 9: | ||
69 | |||
70 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16 | ||
71 | of the VMX reg struct. The VMX reg struct is at offset VREGS of | ||
72 | the pt_regs struct. This macro is for REGNO == 0, and contains | ||
73 | 'subroutines' that the other macros jump to. */ | ||
74 | #define vsave_msr0(regno) \ | ||
75 | .byte 0x10; /* DW_CFA_expression */ \ | ||
76 | .uleb128 regno + 77; /* regno */ \ | ||
77 | .uleb128 9f - 1f; /* length */ \ | ||
78 | 1: \ | ||
79 | .byte 0x30 + regno; /* DW_OP_lit0 */ \ | ||
80 | 2: \ | ||
81 | .byte 0x40; /* DW_OP_lit16 */ \ | ||
82 | .byte 0x1e; /* DW_OP_mul */ \ | ||
83 | 3: \ | ||
84 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
85 | .byte 0x06; /* DW_OP_deref */ \ | ||
86 | .byte 0x12; /* DW_OP_dup */ \ | ||
87 | .byte 0x23; /* DW_OP_plus_uconst */ \ | ||
88 | .uleb128 33*RSIZE; /* msr offset */ \ | ||
89 | .byte 0x06; /* DW_OP_deref */ \ | ||
90 | .byte 0x0c; .long 1 << 25; /* DW_OP_const4u */ \ | ||
91 | .byte 0x1a; /* DW_OP_and */ \ | ||
92 | .byte 0x12; /* DW_OP_dup, ret 0 if bra taken */ \ | ||
93 | .byte 0x30; /* DW_OP_lit0 */ \ | ||
94 | .byte 0x29; /* DW_OP_eq */ \ | ||
95 | .byte 0x28; .short 0x7fff; /* DW_OP_bra to end */ \ | ||
96 | .byte 0x13; /* DW_OP_drop, pop the 0 */ \ | ||
97 | .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \ | ||
98 | .byte 0x22; /* DW_OP_plus */ \ | ||
99 | .byte 0x2f; .short 0x7fff; /* DW_OP_skip to end */ \ | ||
100 | 9: | ||
101 | |||
102 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16 | ||
103 | of the VMX reg struct. REGNO is 1 thru 31. */ | ||
104 | #define vsave_msr1(regno) \ | ||
105 | .byte 0x10; /* DW_CFA_expression */ \ | ||
106 | .uleb128 regno + 77; /* regno */ \ | ||
107 | .uleb128 9f - 1f; /* length */ \ | ||
108 | 1: \ | ||
109 | .byte 0x30 + regno; /* DW_OP_lit n */ \ | ||
110 | .byte 0x2f; .short 2b - 9f; /* DW_OP_skip */ \ | ||
111 | 9: | ||
112 | |||
113 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset OFS of | ||
114 | the VMX save block. */ | ||
115 | #define vsave_msr2(regno, ofs) \ | ||
116 | .byte 0x10; /* DW_CFA_expression */ \ | ||
117 | .uleb128 regno + 77; /* regno */ \ | ||
118 | .uleb128 9f - 1f; /* length */ \ | ||
119 | 1: \ | ||
120 | .byte 0x0a; .short ofs; /* DW_OP_const2u */ \ | ||
121 | .byte 0x2f; .short 3b - 9f; /* DW_OP_skip */ \ | ||
122 | 9: | ||
123 | |||
124 | /* VMX register REGNO is at offset OFS of the VMX save area. */ | ||
125 | #define vsave(regno, ofs) \ | ||
126 | .byte 0x10; /* DW_CFA_expression */ \ | ||
127 | .uleb128 regno + 77; /* regno */ \ | ||
128 | .uleb128 9f - 1f; /* length */ \ | ||
129 | 1: \ | ||
130 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
131 | .byte 0x06; /* DW_OP_deref */ \ | ||
132 | .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \ | ||
133 | .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \ | ||
134 | 9: | ||
135 | |||
136 | /* This is where the pt_regs pointer can be found on the stack. */ | ||
137 | #define PTREGS 64+28 | ||
138 | |||
139 | /* Size of regs. */ | ||
140 | #define RSIZE 4 | ||
141 | |||
142 | /* This is the offset of the VMX regs. */ | ||
143 | #define VREGS 48*RSIZE+34*8 | ||
144 | |||
145 | /* Describe where general purpose regs are saved. */ | ||
146 | #define EH_FRAME_GEN \ | ||
147 | cfa_save; \ | ||
148 | rsave ( 0, 0*RSIZE); \ | ||
149 | rsave ( 2, 2*RSIZE); \ | ||
150 | rsave ( 3, 3*RSIZE); \ | ||
151 | rsave ( 4, 4*RSIZE); \ | ||
152 | rsave ( 5, 5*RSIZE); \ | ||
153 | rsave ( 6, 6*RSIZE); \ | ||
154 | rsave ( 7, 7*RSIZE); \ | ||
155 | rsave ( 8, 8*RSIZE); \ | ||
156 | rsave ( 9, 9*RSIZE); \ | ||
157 | rsave (10, 10*RSIZE); \ | ||
158 | rsave (11, 11*RSIZE); \ | ||
159 | rsave (12, 12*RSIZE); \ | ||
160 | rsave (13, 13*RSIZE); \ | ||
161 | rsave (14, 14*RSIZE); \ | ||
162 | rsave (15, 15*RSIZE); \ | ||
163 | rsave (16, 16*RSIZE); \ | ||
164 | rsave (17, 17*RSIZE); \ | ||
165 | rsave (18, 18*RSIZE); \ | ||
166 | rsave (19, 19*RSIZE); \ | ||
167 | rsave (20, 20*RSIZE); \ | ||
168 | rsave (21, 21*RSIZE); \ | ||
169 | rsave (22, 22*RSIZE); \ | ||
170 | rsave (23, 23*RSIZE); \ | ||
171 | rsave (24, 24*RSIZE); \ | ||
172 | rsave (25, 25*RSIZE); \ | ||
173 | rsave (26, 26*RSIZE); \ | ||
174 | rsave (27, 27*RSIZE); \ | ||
175 | rsave (28, 28*RSIZE); \ | ||
176 | rsave (29, 29*RSIZE); \ | ||
177 | rsave (30, 30*RSIZE); \ | ||
178 | rsave (31, 31*RSIZE); \ | ||
179 | rsave (67, 32*RSIZE); /* ap, used as temp for nip */ \ | ||
180 | rsave (65, 36*RSIZE); /* lr */ \ | ||
181 | rsave (70, 38*RSIZE) /* cr */ | ||
182 | |||
183 | /* Describe where the FP regs are saved. */ | ||
184 | #define EH_FRAME_FP \ | ||
185 | rsave (32, 48*RSIZE + 0*8); \ | ||
186 | rsave (33, 48*RSIZE + 1*8); \ | ||
187 | rsave (34, 48*RSIZE + 2*8); \ | ||
188 | rsave (35, 48*RSIZE + 3*8); \ | ||
189 | rsave (36, 48*RSIZE + 4*8); \ | ||
190 | rsave (37, 48*RSIZE + 5*8); \ | ||
191 | rsave (38, 48*RSIZE + 6*8); \ | ||
192 | rsave (39, 48*RSIZE + 7*8); \ | ||
193 | rsave (40, 48*RSIZE + 8*8); \ | ||
194 | rsave (41, 48*RSIZE + 9*8); \ | ||
195 | rsave (42, 48*RSIZE + 10*8); \ | ||
196 | rsave (43, 48*RSIZE + 11*8); \ | ||
197 | rsave (44, 48*RSIZE + 12*8); \ | ||
198 | rsave (45, 48*RSIZE + 13*8); \ | ||
199 | rsave (46, 48*RSIZE + 14*8); \ | ||
200 | rsave (47, 48*RSIZE + 15*8); \ | ||
201 | rsave (48, 48*RSIZE + 16*8); \ | ||
202 | rsave (49, 48*RSIZE + 17*8); \ | ||
203 | rsave (50, 48*RSIZE + 18*8); \ | ||
204 | rsave (51, 48*RSIZE + 19*8); \ | ||
205 | rsave (52, 48*RSIZE + 20*8); \ | ||
206 | rsave (53, 48*RSIZE + 21*8); \ | ||
207 | rsave (54, 48*RSIZE + 22*8); \ | ||
208 | rsave (55, 48*RSIZE + 23*8); \ | ||
209 | rsave (56, 48*RSIZE + 24*8); \ | ||
210 | rsave (57, 48*RSIZE + 25*8); \ | ||
211 | rsave (58, 48*RSIZE + 26*8); \ | ||
212 | rsave (59, 48*RSIZE + 27*8); \ | ||
213 | rsave (60, 48*RSIZE + 28*8); \ | ||
214 | rsave (61, 48*RSIZE + 29*8); \ | ||
215 | rsave (62, 48*RSIZE + 30*8); \ | ||
216 | rsave (63, 48*RSIZE + 31*8) | ||
217 | |||
218 | /* Describe where the VMX regs are saved. */ | ||
219 | #ifdef CONFIG_ALTIVEC | ||
220 | #define EH_FRAME_VMX \ | ||
221 | vsave_msr0 ( 0); \ | ||
222 | vsave_msr1 ( 1); \ | ||
223 | vsave_msr1 ( 2); \ | ||
224 | vsave_msr1 ( 3); \ | ||
225 | vsave_msr1 ( 4); \ | ||
226 | vsave_msr1 ( 5); \ | ||
227 | vsave_msr1 ( 6); \ | ||
228 | vsave_msr1 ( 7); \ | ||
229 | vsave_msr1 ( 8); \ | ||
230 | vsave_msr1 ( 9); \ | ||
231 | vsave_msr1 (10); \ | ||
232 | vsave_msr1 (11); \ | ||
233 | vsave_msr1 (12); \ | ||
234 | vsave_msr1 (13); \ | ||
235 | vsave_msr1 (14); \ | ||
236 | vsave_msr1 (15); \ | ||
237 | vsave_msr1 (16); \ | ||
238 | vsave_msr1 (17); \ | ||
239 | vsave_msr1 (18); \ | ||
240 | vsave_msr1 (19); \ | ||
241 | vsave_msr1 (20); \ | ||
242 | vsave_msr1 (21); \ | ||
243 | vsave_msr1 (22); \ | ||
244 | vsave_msr1 (23); \ | ||
245 | vsave_msr1 (24); \ | ||
246 | vsave_msr1 (25); \ | ||
247 | vsave_msr1 (26); \ | ||
248 | vsave_msr1 (27); \ | ||
249 | vsave_msr1 (28); \ | ||
250 | vsave_msr1 (29); \ | ||
251 | vsave_msr1 (30); \ | ||
252 | vsave_msr1 (31); \ | ||
253 | vsave_msr2 (33, 32*16+12); \ | ||
254 | vsave (32, 32*16) | ||
255 | #else | ||
256 | #define EH_FRAME_VMX | ||
257 | #endif | ||
258 | |||
259 | .Lcie: | ||
260 | .long .Lcie_end - .Lcie_start | ||
261 | .Lcie_start: | ||
262 | .long 0 /* CIE ID */ | ||
263 | .byte 1 /* Version number */ | ||
264 | .string "zR" /* NUL-terminated augmentation string */ | ||
265 | .uleb128 4 /* Code alignment factor */ | ||
266 | .sleb128 -4 /* Data alignment factor */ | ||
267 | .byte 67 /* Return address register column, ap */ | ||
268 | .uleb128 1 /* Augmentation value length */ | ||
269 | .byte 0x1b /* DW_EH_PE_pcrel | DW_EH_PE_sdata4. */ | ||
270 | .byte 0x0c,1,0 /* DW_CFA_def_cfa: r1 ofs 0 */ | ||
271 | .balign 4 | ||
272 | .Lcie_end: | ||
273 | |||
274 | .long .Lfde0_end - .Lfde0_start | ||
275 | .Lfde0_start: | ||
276 | .long .Lfde0_start - .Lcie /* CIE pointer. */ | ||
277 | .long .Lsig_start - . /* PC start, length */ | ||
278 | .long .Lsig_end - .Lsig_start | ||
279 | .uleb128 0 /* Augmentation */ | ||
280 | EH_FRAME_GEN | ||
281 | EH_FRAME_FP | ||
282 | EH_FRAME_VMX | ||
283 | .balign 4 | ||
284 | .Lfde0_end: | ||
285 | |||
286 | /* We have a different stack layout for rt_sigreturn. */ | ||
287 | #undef PTREGS | ||
288 | #define PTREGS 64+16+128+20+28 | ||
289 | |||
290 | .long .Lfde1_end - .Lfde1_start | ||
291 | .Lfde1_start: | ||
292 | .long .Lfde1_start - .Lcie /* CIE pointer. */ | ||
293 | .long .Lsigrt_start - . /* PC start, length */ | ||
294 | .long .Lsigrt_end - .Lsigrt_start | ||
295 | .uleb128 0 /* Augmentation */ | ||
296 | EH_FRAME_GEN | ||
297 | EH_FRAME_FP | ||
298 | EH_FRAME_VMX | ||
299 | .balign 4 | ||
300 | .Lfde1_end: | ||
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S new file mode 100644 index 000000000000..f4bad720cb0a --- /dev/null +++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S | |||
@@ -0,0 +1,117 @@ | |||
1 | |||
2 | /* | ||
3 | * This is the infamous ld script for the 32 bits vdso | ||
4 | * library | ||
5 | */ | ||
6 | #include <asm/vdso.h> | ||
7 | |||
8 | /* Default link addresses for the vDSOs */ | ||
9 | OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") | ||
10 | OUTPUT_ARCH(powerpc:common) | ||
11 | ENTRY(_start) | ||
12 | |||
13 | SECTIONS | ||
14 | { | ||
15 | . = VDSO32_LBASE + SIZEOF_HEADERS; | ||
16 | .hash : { *(.hash) } :text | ||
17 | .dynsym : { *(.dynsym) } | ||
18 | .dynstr : { *(.dynstr) } | ||
19 | .gnu.version : { *(.gnu.version) } | ||
20 | .gnu.version_d : { *(.gnu.version_d) } | ||
21 | .gnu.version_r : { *(.gnu.version_r) } | ||
22 | |||
23 | .note : { *(.note.*) } :text :note | ||
24 | |||
25 | . = ALIGN (16); | ||
26 | .text : | ||
27 | { | ||
28 | *(.text .stub .text.* .gnu.linkonce.t.*) | ||
29 | } | ||
30 | PROVIDE (__etext = .); | ||
31 | PROVIDE (_etext = .); | ||
32 | PROVIDE (etext = .); | ||
33 | |||
34 | /* Other stuff is appended to the text segment: */ | ||
35 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } | ||
36 | .rodata1 : { *(.rodata1) } | ||
37 | |||
38 | .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr | ||
39 | .eh_frame : { KEEP (*(.eh_frame)) } :text | ||
40 | .gcc_except_table : { *(.gcc_except_table) } | ||
41 | .fixup : { *(.fixup) } | ||
42 | |||
43 | .dynamic : { *(.dynamic) } :text :dynamic | ||
44 | .got : { *(.got) } | ||
45 | .plt : { *(.plt) } | ||
46 | |||
47 | _end = .; | ||
48 | __end = .; | ||
49 | PROVIDE (end = .); | ||
50 | |||
51 | |||
52 | /* Stabs debugging sections are here too | ||
53 | */ | ||
54 | .stab 0 : { *(.stab) } | ||
55 | .stabstr 0 : { *(.stabstr) } | ||
56 | .stab.excl 0 : { *(.stab.excl) } | ||
57 | .stab.exclstr 0 : { *(.stab.exclstr) } | ||
58 | .stab.index 0 : { *(.stab.index) } | ||
59 | .stab.indexstr 0 : { *(.stab.indexstr) } | ||
60 | .comment 0 : { *(.comment) } | ||
61 | .debug 0 : { *(.debug) } | ||
62 | .line 0 : { *(.line) } | ||
63 | |||
64 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | ||
65 | .debug_sfnames 0 : { *(.debug_sfnames) } | ||
66 | |||
67 | .debug_aranges 0 : { *(.debug_aranges) } | ||
68 | .debug_pubnames 0 : { *(.debug_pubnames) } | ||
69 | |||
70 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } | ||
71 | .debug_abbrev 0 : { *(.debug_abbrev) } | ||
72 | .debug_line 0 : { *(.debug_line) } | ||
73 | .debug_frame 0 : { *(.debug_frame) } | ||
74 | .debug_str 0 : { *(.debug_str) } | ||
75 | .debug_loc 0 : { *(.debug_loc) } | ||
76 | .debug_macinfo 0 : { *(.debug_macinfo) } | ||
77 | |||
78 | .debug_weaknames 0 : { *(.debug_weaknames) } | ||
79 | .debug_funcnames 0 : { *(.debug_funcnames) } | ||
80 | .debug_typenames 0 : { *(.debug_typenames) } | ||
81 | .debug_varnames 0 : { *(.debug_varnames) } | ||
82 | |||
83 | /DISCARD/ : { *(.note.GNU-stack) } | ||
84 | /DISCARD/ : { *(.data .data.* .gnu.linkonce.d.* .sdata*) } | ||
85 | /DISCARD/ : { *(.bss .sbss .dynbss .dynsbss) } | ||
86 | } | ||
87 | |||
88 | |||
89 | PHDRS | ||
90 | { | ||
91 | text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */ | ||
92 | note PT_NOTE FLAGS(4); /* PF_R */ | ||
93 | dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ | ||
94 | eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */ | ||
95 | } | ||
96 | |||
97 | |||
98 | /* | ||
99 | * This controls what symbols we export from the DSO. | ||
100 | */ | ||
101 | VERSION | ||
102 | { | ||
103 | VDSO_VERSION_STRING { | ||
104 | global: | ||
105 | __kernel_datapage_offset; /* Has to be there for the kernel to find */ | ||
106 | __kernel_get_syscall_map; | ||
107 | __kernel_gettimeofday; | ||
108 | __kernel_clock_gettime; | ||
109 | __kernel_clock_getres; | ||
110 | __kernel_get_tbfreq; | ||
111 | __kernel_sync_dicache; | ||
112 | __kernel_sync_dicache_p5; | ||
113 | __kernel_sigtramp32; | ||
114 | __kernel_sigtramp_rt32; | ||
115 | local: *; | ||
116 | }; | ||
117 | } | ||
diff --git a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S new file mode 100644 index 000000000000..556f0caa5d84 --- /dev/null +++ b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S | |||
@@ -0,0 +1,13 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <asm/page.h> | ||
3 | |||
4 | .section ".data.page_aligned" | ||
5 | |||
6 | .globl vdso32_start, vdso32_end | ||
7 | .balign PAGE_SIZE | ||
8 | vdso32_start: | ||
9 | .incbin "arch/powerpc/kernel/vdso32/vdso32.so" | ||
10 | .balign PAGE_SIZE | ||
11 | vdso32_end: | ||
12 | |||
13 | .previous | ||
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile new file mode 100644 index 000000000000..ab39988452cc --- /dev/null +++ b/arch/powerpc/kernel/vdso64/Makefile | |||
@@ -0,0 +1,35 @@ | |||
1 | # List of files in the vdso, has to be asm only for now | ||
2 | |||
3 | obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o | ||
4 | |||
5 | # Build rules | ||
6 | |||
7 | targets := $(obj-vdso64) vdso64.so | ||
8 | obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) | ||
9 | |||
10 | EXTRA_CFLAGS := -shared -s -fno-common -fno-builtin | ||
11 | EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso64.so.1 | ||
12 | EXTRA_AFLAGS := -D__VDSO64__ -s | ||
13 | |||
14 | obj-y += vdso64_wrapper.o | ||
15 | extra-y += vdso64.lds | ||
16 | CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) | ||
17 | |||
18 | # Force dependency (incbin is bad) | ||
19 | $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so | ||
20 | |||
21 | # link rule for the .so file, .lds has to be first | ||
22 | $(obj)/vdso64.so: $(src)/vdso64.lds $(obj-vdso64) | ||
23 | $(call if_changed,vdso64ld) | ||
24 | |||
25 | # assembly rules for the .S files | ||
26 | $(obj-vdso64): %.o: %.S | ||
27 | $(call if_changed_dep,vdso64as) | ||
28 | |||
29 | # actual build commands | ||
30 | quiet_cmd_vdso64ld = VDSO64L $@ | ||
31 | cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ | ||
32 | quiet_cmd_vdso64as = VDSO64A $@ | ||
33 | cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $< | ||
34 | |||
35 | |||
diff --git a/arch/powerpc/kernel/vdso64/cacheflush.S b/arch/powerpc/kernel/vdso64/cacheflush.S new file mode 100644 index 000000000000..d4a0ad28d534 --- /dev/null +++ b/arch/powerpc/kernel/vdso64/cacheflush.S | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * vDSO provided cache flush routines | ||
3 | * | ||
4 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), | ||
5 | * IBM Corp. | ||
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 | #include <linux/config.h> | ||
13 | #include <asm/processor.h> | ||
14 | #include <asm/ppc_asm.h> | ||
15 | #include <asm/vdso.h> | ||
16 | #include <asm/asm-offsets.h> | ||
17 | |||
18 | .text | ||
19 | |||
20 | /* | ||
21 | * Default "generic" version of __kernel_sync_dicache. | ||
22 | * | ||
23 | * void __kernel_sync_dicache(unsigned long start, unsigned long end) | ||
24 | * | ||
25 | * Flushes the data cache & invalidate the instruction cache for the | ||
26 | * provided range [start, end[ | ||
27 | * | ||
28 | * Note: all CPUs supported by this kernel have a 128 bytes cache | ||
29 | * line size so we don't have to peek that info from the datapage | ||
30 | */ | ||
31 | V_FUNCTION_BEGIN(__kernel_sync_dicache) | ||
32 | .cfi_startproc | ||
33 | li r5,127 | ||
34 | andc r6,r3,r5 /* round low to line bdy */ | ||
35 | subf r8,r6,r4 /* compute length */ | ||
36 | add r8,r8,r5 /* ensure we get enough */ | ||
37 | srwi. r8,r8,7 /* compute line count */ | ||
38 | beqlr /* nothing to do? */ | ||
39 | mtctr r8 | ||
40 | mr r3,r6 | ||
41 | 1: dcbst 0,r3 | ||
42 | addi r3,r3,128 | ||
43 | bdnz 1b | ||
44 | sync | ||
45 | mtctr r8 | ||
46 | 1: icbi 0,r6 | ||
47 | addi r6,r6,128 | ||
48 | bdnz 1b | ||
49 | isync | ||
50 | li r3,0 | ||
51 | blr | ||
52 | .cfi_endproc | ||
53 | V_FUNCTION_END(__kernel_sync_dicache) | ||
54 | |||
55 | |||
56 | /* | ||
57 | * POWER5 version of __kernel_sync_dicache | ||
58 | */ | ||
59 | V_FUNCTION_BEGIN(__kernel_sync_dicache_p5) | ||
60 | .cfi_startproc | ||
61 | sync | ||
62 | isync | ||
63 | li r3,0 | ||
64 | blr | ||
65 | .cfi_endproc | ||
66 | V_FUNCTION_END(__kernel_sync_dicache_p5) | ||
diff --git a/arch/powerpc/kernel/vdso64/datapage.S b/arch/powerpc/kernel/vdso64/datapage.S new file mode 100644 index 000000000000..e67eda0f8cda --- /dev/null +++ b/arch/powerpc/kernel/vdso64/datapage.S | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Access to the shared data page by the vDSO & syscall map | ||
3 | * | ||
4 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp. | ||
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/config.h> | ||
13 | #include <asm/processor.h> | ||
14 | #include <asm/ppc_asm.h> | ||
15 | #include <asm/asm-offsets.h> | ||
16 | #include <asm/unistd.h> | ||
17 | #include <asm/vdso.h> | ||
18 | |||
19 | .text | ||
20 | V_FUNCTION_BEGIN(__get_datapage) | ||
21 | .cfi_startproc | ||
22 | /* We don't want that exposed or overridable as we want other objects | ||
23 | * to be able to bl directly to here | ||
24 | */ | ||
25 | .protected __get_datapage | ||
26 | .hidden __get_datapage | ||
27 | |||
28 | mflr r0 | ||
29 | .cfi_register lr,r0 | ||
30 | |||
31 | bcl 20,31,1f | ||
32 | .global __kernel_datapage_offset; | ||
33 | __kernel_datapage_offset: | ||
34 | .long 0 | ||
35 | 1: | ||
36 | mflr r3 | ||
37 | mtlr r0 | ||
38 | lwz r0,0(r3) | ||
39 | add r3,r0,r3 | ||
40 | blr | ||
41 | .cfi_endproc | ||
42 | V_FUNCTION_END(__get_datapage) | ||
43 | |||
44 | /* | ||
45 | * void *__kernel_get_syscall_map(unsigned int *syscall_count) ; | ||
46 | * | ||
47 | * returns a pointer to the syscall map. the map is agnostic to the | ||
48 | * size of "long", unlike kernel bitops, it stores bits from top to | ||
49 | * bottom so that memory actually contains a linear bitmap | ||
50 | * check for syscall N by testing bit (0x80000000 >> (N & 0x1f)) of | ||
51 | * 32 bits int at N >> 5. | ||
52 | */ | ||
53 | V_FUNCTION_BEGIN(__kernel_get_syscall_map) | ||
54 | .cfi_startproc | ||
55 | mflr r12 | ||
56 | .cfi_register lr,r12 | ||
57 | |||
58 | mr r4,r3 | ||
59 | bl V_LOCAL_FUNC(__get_datapage) | ||
60 | mtlr r12 | ||
61 | addi r3,r3,CFG_SYSCALL_MAP64 | ||
62 | cmpli cr0,r4,0 | ||
63 | beqlr | ||
64 | li r0,__NR_syscalls | ||
65 | stw r0,0(r4) | ||
66 | blr | ||
67 | .cfi_endproc | ||
68 | V_FUNCTION_END(__kernel_get_syscall_map) | ||
69 | |||
70 | |||
71 | /* | ||
72 | * void unsigned long __kernel_get_tbfreq(void); | ||
73 | * | ||
74 | * returns the timebase frequency in HZ | ||
75 | */ | ||
76 | V_FUNCTION_BEGIN(__kernel_get_tbfreq) | ||
77 | .cfi_startproc | ||
78 | mflr r12 | ||
79 | .cfi_register lr,r12 | ||
80 | bl V_LOCAL_FUNC(__get_datapage) | ||
81 | ld r3,CFG_TB_TICKS_PER_SEC(r3) | ||
82 | mtlr r12 | ||
83 | .cfi_endproc | ||
84 | V_FUNCTION_END(__kernel_get_tbfreq) | ||
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S new file mode 100644 index 000000000000..d371c02a8c0e --- /dev/null +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | * Userland implementation of gettimeofday() for 64 bits processes in a | ||
3 | * ppc64 kernel for use in the vDSO | ||
4 | * | ||
5 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), | ||
6 | * IBM Corp. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | #include <linux/config.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/ppc_asm.h> | ||
16 | #include <asm/vdso.h> | ||
17 | #include <asm/asm-offsets.h> | ||
18 | #include <asm/unistd.h> | ||
19 | |||
20 | .text | ||
21 | /* | ||
22 | * Exact prototype of gettimeofday | ||
23 | * | ||
24 | * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); | ||
25 | * | ||
26 | */ | ||
27 | V_FUNCTION_BEGIN(__kernel_gettimeofday) | ||
28 | .cfi_startproc | ||
29 | mflr r12 | ||
30 | .cfi_register lr,r12 | ||
31 | |||
32 | mr r11,r3 /* r11 holds tv */ | ||
33 | mr r10,r4 /* r10 holds tz */ | ||
34 | bl V_LOCAL_FUNC(__get_datapage) /* get data page */ | ||
35 | bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */ | ||
36 | lis r7,15 /* r7 = 1000000 = USEC_PER_SEC */ | ||
37 | ori r7,r7,16960 | ||
38 | rldicl r5,r4,44,20 /* r5 = sec = xsec / XSEC_PER_SEC */ | ||
39 | rldicr r6,r5,20,43 /* r6 = sec * XSEC_PER_SEC */ | ||
40 | std r5,TVAL64_TV_SEC(r11) /* store sec in tv */ | ||
41 | subf r0,r6,r4 /* r0 = xsec = (xsec - r6) */ | ||
42 | mulld r0,r0,r7 /* usec = (xsec * USEC_PER_SEC) / | ||
43 | * XSEC_PER_SEC | ||
44 | */ | ||
45 | rldicl r0,r0,44,20 | ||
46 | cmpldi cr0,r10,0 /* check if tz is NULL */ | ||
47 | std r0,TVAL64_TV_USEC(r11) /* store usec in tv */ | ||
48 | beq 1f | ||
49 | lwz r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */ | ||
50 | lwz r5,CFG_TZ_DSTTIME(r3) | ||
51 | stw r4,TZONE_TZ_MINWEST(r10) | ||
52 | stw r5,TZONE_TZ_DSTTIME(r10) | ||
53 | 1: mtlr r12 | ||
54 | li r3,0 /* always success */ | ||
55 | blr | ||
56 | .cfi_endproc | ||
57 | V_FUNCTION_END(__kernel_gettimeofday) | ||
58 | |||
59 | |||
60 | /* | ||
61 | * Exact prototype of clock_gettime() | ||
62 | * | ||
63 | * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); | ||
64 | * | ||
65 | */ | ||
66 | V_FUNCTION_BEGIN(__kernel_clock_gettime) | ||
67 | .cfi_startproc | ||
68 | /* Check for supported clock IDs */ | ||
69 | cmpwi cr0,r3,CLOCK_REALTIME | ||
70 | cmpwi cr1,r3,CLOCK_MONOTONIC | ||
71 | cror cr0,cr0,cr1 | ||
72 | bne cr0,99f | ||
73 | |||
74 | mflr r12 /* r12 saves lr */ | ||
75 | .cfi_register lr,r12 | ||
76 | mr r10,r3 /* r10 saves id */ | ||
77 | mr r11,r4 /* r11 saves tp */ | ||
78 | bl V_LOCAL_FUNC(__get_datapage) /* get data page */ | ||
79 | beq cr1,50f /* if monotonic -> jump there */ | ||
80 | |||
81 | /* | ||
82 | * CLOCK_REALTIME | ||
83 | */ | ||
84 | |||
85 | bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */ | ||
86 | |||
87 | lis r7,0x3b9a /* r7 = 1000000000 = NSEC_PER_SEC */ | ||
88 | ori r7,r7,0xca00 | ||
89 | rldicl r5,r4,44,20 /* r5 = sec = xsec / XSEC_PER_SEC */ | ||
90 | rldicr r6,r5,20,43 /* r6 = sec * XSEC_PER_SEC */ | ||
91 | std r5,TSPC64_TV_SEC(r11) /* store sec in tv */ | ||
92 | subf r0,r6,r4 /* r0 = xsec = (xsec - r6) */ | ||
93 | mulld r0,r0,r7 /* nsec = (xsec * NSEC_PER_SEC) / | ||
94 | * XSEC_PER_SEC | ||
95 | */ | ||
96 | rldicl r0,r0,44,20 | ||
97 | std r0,TSPC64_TV_NSEC(r11) /* store nsec in tp */ | ||
98 | |||
99 | mtlr r12 | ||
100 | li r3,0 | ||
101 | blr | ||
102 | |||
103 | /* | ||
104 | * CLOCK_MONOTONIC | ||
105 | */ | ||
106 | |||
107 | 50: bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */ | ||
108 | |||
109 | lis r7,0x3b9a /* r7 = 1000000000 = NSEC_PER_SEC */ | ||
110 | ori r7,r7,0xca00 | ||
111 | rldicl r5,r4,44,20 /* r5 = sec = xsec / XSEC_PER_SEC */ | ||
112 | rldicr r6,r5,20,43 /* r6 = sec * XSEC_PER_SEC */ | ||
113 | subf r0,r6,r4 /* r0 = xsec = (xsec - r6) */ | ||
114 | mulld r0,r0,r7 /* nsec = (xsec * NSEC_PER_SEC) / | ||
115 | * XSEC_PER_SEC | ||
116 | */ | ||
117 | rldicl r6,r0,44,20 | ||
118 | |||
119 | /* now we must fixup using wall to monotonic. We need to snapshot | ||
120 | * that value and do the counter trick again. Fortunately, we still | ||
121 | * have the counter value in r8 that was returned by __do_get_xsec. | ||
122 | * At this point, r5,r6 contain our sec/nsec values. | ||
123 | * can be used | ||
124 | */ | ||
125 | |||
126 | lwz r4,WTOM_CLOCK_SEC(r9) | ||
127 | lwz r7,WTOM_CLOCK_NSEC(r9) | ||
128 | |||
129 | /* We now have our result in r4,r7. We create a fake dependency | ||
130 | * on that result and re-check the counter | ||
131 | */ | ||
132 | or r9,r4,r7 | ||
133 | xor r0,r9,r9 | ||
134 | add r3,r3,r0 | ||
135 | ld r0,CFG_TB_UPDATE_COUNT(r3) | ||
136 | cmpld cr0,r0,r8 /* check if updated */ | ||
137 | bne- 50b | ||
138 | |||
139 | /* Calculate and store result. Note that this mimmics the C code, | ||
140 | * which may cause funny results if nsec goes negative... is that | ||
141 | * possible at all ? | ||
142 | */ | ||
143 | add r4,r4,r5 | ||
144 | add r7,r7,r6 | ||
145 | lis r9,NSEC_PER_SEC@h | ||
146 | ori r9,r9,NSEC_PER_SEC@l | ||
147 | cmpli cr0,r7,r9 | ||
148 | blt 1f | ||
149 | subf r7,r9,r7 | ||
150 | addi r4,r4,1 | ||
151 | 1: std r4,TSPC64_TV_SEC(r11) | ||
152 | std r7,TSPC64_TV_NSEC(r11) | ||
153 | |||
154 | mtlr r12 | ||
155 | li r3,0 | ||
156 | blr | ||
157 | |||
158 | /* | ||
159 | * syscall fallback | ||
160 | */ | ||
161 | 98: | ||
162 | mtlr r12 | ||
163 | mr r3,r10 | ||
164 | mr r4,r11 | ||
165 | 99: | ||
166 | li r0,__NR_clock_gettime | ||
167 | sc | ||
168 | blr | ||
169 | .cfi_endproc | ||
170 | V_FUNCTION_END(__kernel_clock_gettime) | ||
171 | |||
172 | |||
173 | /* | ||
174 | * Exact prototype of clock_getres() | ||
175 | * | ||
176 | * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); | ||
177 | * | ||
178 | */ | ||
179 | V_FUNCTION_BEGIN(__kernel_clock_getres) | ||
180 | .cfi_startproc | ||
181 | /* Check for supported clock IDs */ | ||
182 | cmpwi cr0,r3,CLOCK_REALTIME | ||
183 | cmpwi cr1,r3,CLOCK_MONOTONIC | ||
184 | cror cr0,cr0,cr1 | ||
185 | bne cr0,99f | ||
186 | |||
187 | li r3,0 | ||
188 | cmpli cr0,r4,0 | ||
189 | beqlr | ||
190 | lis r5,CLOCK_REALTIME_RES@h | ||
191 | ori r5,r5,CLOCK_REALTIME_RES@l | ||
192 | std r3,TSPC64_TV_SEC(r4) | ||
193 | std r5,TSPC64_TV_NSEC(r4) | ||
194 | blr | ||
195 | |||
196 | /* | ||
197 | * syscall fallback | ||
198 | */ | ||
199 | 99: | ||
200 | li r0,__NR_clock_getres | ||
201 | sc | ||
202 | blr | ||
203 | .cfi_endproc | ||
204 | V_FUNCTION_END(__kernel_clock_getres) | ||
205 | |||
206 | |||
207 | /* | ||
208 | * This is the core of gettimeofday(), it returns the xsec | ||
209 | * value in r4 and expects the datapage ptr (non clobbered) | ||
210 | * in r3. clobbers r0,r4,r5,r6,r7,r8 | ||
211 | * When returning, r8 contains the counter value that can be reused | ||
212 | */ | ||
213 | V_FUNCTION_BEGIN(__do_get_xsec) | ||
214 | .cfi_startproc | ||
215 | /* check for update count & load values */ | ||
216 | 1: ld r8,CFG_TB_UPDATE_COUNT(r3) | ||
217 | andi. r0,r4,1 /* pending update ? loop */ | ||
218 | bne- 1b | ||
219 | xor r0,r4,r4 /* create dependency */ | ||
220 | add r3,r3,r0 | ||
221 | |||
222 | /* Get TB & offset it */ | ||
223 | mftb r7 | ||
224 | ld r9,CFG_TB_ORIG_STAMP(r3) | ||
225 | subf r7,r9,r7 | ||
226 | |||
227 | /* Scale result */ | ||
228 | ld r5,CFG_TB_TO_XS(r3) | ||
229 | mulhdu r7,r7,r5 | ||
230 | |||
231 | /* Add stamp since epoch */ | ||
232 | ld r6,CFG_STAMP_XSEC(r3) | ||
233 | add r4,r6,r7 | ||
234 | |||
235 | xor r0,r4,r4 | ||
236 | add r3,r3,r0 | ||
237 | ld r0,CFG_TB_UPDATE_COUNT(r3) | ||
238 | cmpld cr0,r0,r8 /* check if updated */ | ||
239 | bne- 1b | ||
240 | blr | ||
241 | .cfi_endproc | ||
242 | V_FUNCTION_END(__do_get_xsec) | ||
diff --git a/arch/powerpc/kernel/vdso64/note.S b/arch/powerpc/kernel/vdso64/note.S new file mode 100644 index 000000000000..dc2a509f7e8a --- /dev/null +++ b/arch/powerpc/kernel/vdso64/note.S | |||
@@ -0,0 +1 @@ | |||
#include "../vdso32/note.S" | |||
diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S b/arch/powerpc/kernel/vdso64/sigtramp.S new file mode 100644 index 000000000000..31b604ab56de --- /dev/null +++ b/arch/powerpc/kernel/vdso64/sigtramp.S | |||
@@ -0,0 +1,295 @@ | |||
1 | /* | ||
2 | * Signal trampoline for 64 bits processes in a ppc64 kernel for | ||
3 | * use in the vDSO | ||
4 | * | ||
5 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp. | ||
6 | * Copyright (C) 2004 Alan Modra (amodra@au.ibm.com)), IBM Corp. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | #include <linux/config.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/ppc_asm.h> | ||
16 | #include <asm/unistd.h> | ||
17 | #include <asm/vdso.h> | ||
18 | #include <asm/ptrace.h> /* XXX for __SIGNAL_FRAMESIZE */ | ||
19 | |||
20 | .text | ||
21 | |||
22 | /* The nop here is a hack. The dwarf2 unwind routines subtract 1 from | ||
23 | the return address to get an address in the middle of the presumed | ||
24 | call instruction. Since we don't have a call here, we artifically | ||
25 | extend the range covered by the unwind info by padding before the | ||
26 | real start. */ | ||
27 | nop | ||
28 | .balign 8 | ||
29 | V_FUNCTION_BEGIN(__kernel_sigtramp_rt64) | ||
30 | .Lsigrt_start = . - 4 | ||
31 | addi r1, r1, __SIGNAL_FRAMESIZE | ||
32 | li r0,__NR_rt_sigreturn | ||
33 | sc | ||
34 | .Lsigrt_end: | ||
35 | V_FUNCTION_END(__kernel_sigtramp_rt64) | ||
36 | /* The ".balign 8" above and the following zeros mimic the old stack | ||
37 | trampoline layout. The last magic value is the ucontext pointer, | ||
38 | chosen in such a way that older libgcc unwind code returns a zero | ||
39 | for a sigcontext pointer. */ | ||
40 | .long 0,0,0 | ||
41 | .quad 0,-21*8 | ||
42 | |||
43 | /* Register r1 can be found at offset 8 of a pt_regs structure. | ||
44 | A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */ | ||
45 | #define cfa_save \ | ||
46 | .byte 0x0f; /* DW_CFA_def_cfa_expression */ \ | ||
47 | .uleb128 9f - 1f; /* length */ \ | ||
48 | 1: \ | ||
49 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
50 | .byte 0x06; /* DW_OP_deref */ \ | ||
51 | .byte 0x23; .uleb128 RSIZE; /* DW_OP_plus_uconst */ \ | ||
52 | .byte 0x06; /* DW_OP_deref */ \ | ||
53 | 9: | ||
54 | |||
55 | /* Register REGNO can be found at offset OFS of a pt_regs structure. | ||
56 | A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */ | ||
57 | #define rsave(regno, ofs) \ | ||
58 | .byte 0x10; /* DW_CFA_expression */ \ | ||
59 | .uleb128 regno; /* regno */ \ | ||
60 | .uleb128 9f - 1f; /* length */ \ | ||
61 | 1: \ | ||
62 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
63 | .byte 0x06; /* DW_OP_deref */ \ | ||
64 | .ifne ofs; \ | ||
65 | .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \ | ||
66 | .endif; \ | ||
67 | 9: | ||
68 | |||
69 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16 | ||
70 | of the VMX reg struct. A pointer to the VMX reg struct is at VREGS in | ||
71 | the pt_regs struct. This macro is for REGNO == 0, and contains | ||
72 | 'subroutines' that the other macros jump to. */ | ||
73 | #define vsave_msr0(regno) \ | ||
74 | .byte 0x10; /* DW_CFA_expression */ \ | ||
75 | .uleb128 regno + 77; /* regno */ \ | ||
76 | .uleb128 9f - 1f; /* length */ \ | ||
77 | 1: \ | ||
78 | .byte 0x30 + regno; /* DW_OP_lit0 */ \ | ||
79 | 2: \ | ||
80 | .byte 0x40; /* DW_OP_lit16 */ \ | ||
81 | .byte 0x1e; /* DW_OP_mul */ \ | ||
82 | 3: \ | ||
83 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
84 | .byte 0x06; /* DW_OP_deref */ \ | ||
85 | .byte 0x12; /* DW_OP_dup */ \ | ||
86 | .byte 0x23; /* DW_OP_plus_uconst */ \ | ||
87 | .uleb128 33*RSIZE; /* msr offset */ \ | ||
88 | .byte 0x06; /* DW_OP_deref */ \ | ||
89 | .byte 0x0c; .long 1 << 25; /* DW_OP_const4u */ \ | ||
90 | .byte 0x1a; /* DW_OP_and */ \ | ||
91 | .byte 0x12; /* DW_OP_dup, ret 0 if bra taken */ \ | ||
92 | .byte 0x30; /* DW_OP_lit0 */ \ | ||
93 | .byte 0x29; /* DW_OP_eq */ \ | ||
94 | .byte 0x28; .short 0x7fff; /* DW_OP_bra to end */ \ | ||
95 | .byte 0x13; /* DW_OP_drop, pop the 0 */ \ | ||
96 | .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \ | ||
97 | .byte 0x06; /* DW_OP_deref */ \ | ||
98 | .byte 0x22; /* DW_OP_plus */ \ | ||
99 | .byte 0x2f; .short 0x7fff; /* DW_OP_skip to end */ \ | ||
100 | 9: | ||
101 | |||
102 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16 | ||
103 | of the VMX reg struct. REGNO is 1 thru 31. */ | ||
104 | #define vsave_msr1(regno) \ | ||
105 | .byte 0x10; /* DW_CFA_expression */ \ | ||
106 | .uleb128 regno + 77; /* regno */ \ | ||
107 | .uleb128 9f - 1f; /* length */ \ | ||
108 | 1: \ | ||
109 | .byte 0x30 + regno; /* DW_OP_lit n */ \ | ||
110 | .byte 0x2f; .short 2b - 9f; /* DW_OP_skip */ \ | ||
111 | 9: | ||
112 | |||
113 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset OFS of | ||
114 | the VMX save block. */ | ||
115 | #define vsave_msr2(regno, ofs) \ | ||
116 | .byte 0x10; /* DW_CFA_expression */ \ | ||
117 | .uleb128 regno + 77; /* regno */ \ | ||
118 | .uleb128 9f - 1f; /* length */ \ | ||
119 | 1: \ | ||
120 | .byte 0x0a; .short ofs; /* DW_OP_const2u */ \ | ||
121 | .byte 0x2f; .short 3b - 9f; /* DW_OP_skip */ \ | ||
122 | 9: | ||
123 | |||
124 | /* VMX register REGNO is at offset OFS of the VMX save area. */ | ||
125 | #define vsave(regno, ofs) \ | ||
126 | .byte 0x10; /* DW_CFA_expression */ \ | ||
127 | .uleb128 regno + 77; /* regno */ \ | ||
128 | .uleb128 9f - 1f; /* length */ \ | ||
129 | 1: \ | ||
130 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
131 | .byte 0x06; /* DW_OP_deref */ \ | ||
132 | .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \ | ||
133 | .byte 0x06; /* DW_OP_deref */ \ | ||
134 | .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \ | ||
135 | 9: | ||
136 | |||
137 | /* This is where the pt_regs pointer can be found on the stack. */ | ||
138 | #define PTREGS 128+168+56 | ||
139 | |||
140 | /* Size of regs. */ | ||
141 | #define RSIZE 8 | ||
142 | |||
143 | /* This is the offset of the VMX reg pointer. */ | ||
144 | #define VREGS 48*RSIZE+33*8 | ||
145 | |||
146 | /* Describe where general purpose regs are saved. */ | ||
147 | #define EH_FRAME_GEN \ | ||
148 | cfa_save; \ | ||
149 | rsave ( 0, 0*RSIZE); \ | ||
150 | rsave ( 2, 2*RSIZE); \ | ||
151 | rsave ( 3, 3*RSIZE); \ | ||
152 | rsave ( 4, 4*RSIZE); \ | ||
153 | rsave ( 5, 5*RSIZE); \ | ||
154 | rsave ( 6, 6*RSIZE); \ | ||
155 | rsave ( 7, 7*RSIZE); \ | ||
156 | rsave ( 8, 8*RSIZE); \ | ||
157 | rsave ( 9, 9*RSIZE); \ | ||
158 | rsave (10, 10*RSIZE); \ | ||
159 | rsave (11, 11*RSIZE); \ | ||
160 | rsave (12, 12*RSIZE); \ | ||
161 | rsave (13, 13*RSIZE); \ | ||
162 | rsave (14, 14*RSIZE); \ | ||
163 | rsave (15, 15*RSIZE); \ | ||
164 | rsave (16, 16*RSIZE); \ | ||
165 | rsave (17, 17*RSIZE); \ | ||
166 | rsave (18, 18*RSIZE); \ | ||
167 | rsave (19, 19*RSIZE); \ | ||
168 | rsave (20, 20*RSIZE); \ | ||
169 | rsave (21, 21*RSIZE); \ | ||
170 | rsave (22, 22*RSIZE); \ | ||
171 | rsave (23, 23*RSIZE); \ | ||
172 | rsave (24, 24*RSIZE); \ | ||
173 | rsave (25, 25*RSIZE); \ | ||
174 | rsave (26, 26*RSIZE); \ | ||
175 | rsave (27, 27*RSIZE); \ | ||
176 | rsave (28, 28*RSIZE); \ | ||
177 | rsave (29, 29*RSIZE); \ | ||
178 | rsave (30, 30*RSIZE); \ | ||
179 | rsave (31, 31*RSIZE); \ | ||
180 | rsave (67, 32*RSIZE); /* ap, used as temp for nip */ \ | ||
181 | rsave (65, 36*RSIZE); /* lr */ \ | ||
182 | rsave (70, 38*RSIZE) /* cr */ | ||
183 | |||
184 | /* Describe where the FP regs are saved. */ | ||
185 | #define EH_FRAME_FP \ | ||
186 | rsave (32, 48*RSIZE + 0*8); \ | ||
187 | rsave (33, 48*RSIZE + 1*8); \ | ||
188 | rsave (34, 48*RSIZE + 2*8); \ | ||
189 | rsave (35, 48*RSIZE + 3*8); \ | ||
190 | rsave (36, 48*RSIZE + 4*8); \ | ||
191 | rsave (37, 48*RSIZE + 5*8); \ | ||
192 | rsave (38, 48*RSIZE + 6*8); \ | ||
193 | rsave (39, 48*RSIZE + 7*8); \ | ||
194 | rsave (40, 48*RSIZE + 8*8); \ | ||
195 | rsave (41, 48*RSIZE + 9*8); \ | ||
196 | rsave (42, 48*RSIZE + 10*8); \ | ||
197 | rsave (43, 48*RSIZE + 11*8); \ | ||
198 | rsave (44, 48*RSIZE + 12*8); \ | ||
199 | rsave (45, 48*RSIZE + 13*8); \ | ||
200 | rsave (46, 48*RSIZE + 14*8); \ | ||
201 | rsave (47, 48*RSIZE + 15*8); \ | ||
202 | rsave (48, 48*RSIZE + 16*8); \ | ||
203 | rsave (49, 48*RSIZE + 17*8); \ | ||
204 | rsave (50, 48*RSIZE + 18*8); \ | ||
205 | rsave (51, 48*RSIZE + 19*8); \ | ||
206 | rsave (52, 48*RSIZE + 20*8); \ | ||
207 | rsave (53, 48*RSIZE + 21*8); \ | ||
208 | rsave (54, 48*RSIZE + 22*8); \ | ||
209 | rsave (55, 48*RSIZE + 23*8); \ | ||
210 | rsave (56, 48*RSIZE + 24*8); \ | ||
211 | rsave (57, 48*RSIZE + 25*8); \ | ||
212 | rsave (58, 48*RSIZE + 26*8); \ | ||
213 | rsave (59, 48*RSIZE + 27*8); \ | ||
214 | rsave (60, 48*RSIZE + 28*8); \ | ||
215 | rsave (61, 48*RSIZE + 29*8); \ | ||
216 | rsave (62, 48*RSIZE + 30*8); \ | ||
217 | rsave (63, 48*RSIZE + 31*8) | ||
218 | |||
219 | /* Describe where the VMX regs are saved. */ | ||
220 | #ifdef CONFIG_ALTIVEC | ||
221 | #define EH_FRAME_VMX \ | ||
222 | vsave_msr0 ( 0); \ | ||
223 | vsave_msr1 ( 1); \ | ||
224 | vsave_msr1 ( 2); \ | ||
225 | vsave_msr1 ( 3); \ | ||
226 | vsave_msr1 ( 4); \ | ||
227 | vsave_msr1 ( 5); \ | ||
228 | vsave_msr1 ( 6); \ | ||
229 | vsave_msr1 ( 7); \ | ||
230 | vsave_msr1 ( 8); \ | ||
231 | vsave_msr1 ( 9); \ | ||
232 | vsave_msr1 (10); \ | ||
233 | vsave_msr1 (11); \ | ||
234 | vsave_msr1 (12); \ | ||
235 | vsave_msr1 (13); \ | ||
236 | vsave_msr1 (14); \ | ||
237 | vsave_msr1 (15); \ | ||
238 | vsave_msr1 (16); \ | ||
239 | vsave_msr1 (17); \ | ||
240 | vsave_msr1 (18); \ | ||
241 | vsave_msr1 (19); \ | ||
242 | vsave_msr1 (20); \ | ||
243 | vsave_msr1 (21); \ | ||
244 | vsave_msr1 (22); \ | ||
245 | vsave_msr1 (23); \ | ||
246 | vsave_msr1 (24); \ | ||
247 | vsave_msr1 (25); \ | ||
248 | vsave_msr1 (26); \ | ||
249 | vsave_msr1 (27); \ | ||
250 | vsave_msr1 (28); \ | ||
251 | vsave_msr1 (29); \ | ||
252 | vsave_msr1 (30); \ | ||
253 | vsave_msr1 (31); \ | ||
254 | vsave_msr2 (33, 32*16+12); \ | ||
255 | vsave (32, 33*16) | ||
256 | #else | ||
257 | #define EH_FRAME_VMX | ||
258 | #endif | ||
259 | |||
260 | .section .eh_frame,"a",@progbits | ||
261 | .Lcie: | ||
262 | .long .Lcie_end - .Lcie_start | ||
263 | .Lcie_start: | ||
264 | .long 0 /* CIE ID */ | ||
265 | .byte 1 /* Version number */ | ||
266 | .string "zR" /* NUL-terminated augmentation string */ | ||
267 | .uleb128 4 /* Code alignment factor */ | ||
268 | .sleb128 -8 /* Data alignment factor */ | ||
269 | .byte 67 /* Return address register column, ap */ | ||
270 | .uleb128 1 /* Augmentation value length */ | ||
271 | .byte 0x14 /* DW_EH_PE_pcrel | DW_EH_PE_udata8. */ | ||
272 | .byte 0x0c,1,0 /* DW_CFA_def_cfa: r1 ofs 0 */ | ||
273 | .balign 8 | ||
274 | .Lcie_end: | ||
275 | |||
276 | .long .Lfde0_end - .Lfde0_start | ||
277 | .Lfde0_start: | ||
278 | .long .Lfde0_start - .Lcie /* CIE pointer. */ | ||
279 | .quad .Lsigrt_start - . /* PC start, length */ | ||
280 | .quad .Lsigrt_end - .Lsigrt_start | ||
281 | .uleb128 0 /* Augmentation */ | ||
282 | EH_FRAME_GEN | ||
283 | EH_FRAME_FP | ||
284 | EH_FRAME_VMX | ||
285 | # Do we really need to describe the frame at this point? ie. will | ||
286 | # we ever have some call chain that returns somewhere past the addi? | ||
287 | # I don't think so, since gcc doesn't support async signals. | ||
288 | # .byte 0x41 /* DW_CFA_advance_loc 1*4 */ | ||
289 | #undef PTREGS | ||
290 | #define PTREGS 168+56 | ||
291 | # EH_FRAME_GEN | ||
292 | # EH_FRAME_FP | ||
293 | # EH_FRAME_VMX | ||
294 | .balign 8 | ||
295 | .Lfde0_end: | ||
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S new file mode 100644 index 000000000000..4bdf224464ab --- /dev/null +++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * This is the infamous ld script for the 64 bits vdso | ||
3 | * library | ||
4 | */ | ||
5 | #include <asm/vdso.h> | ||
6 | |||
7 | OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") | ||
8 | OUTPUT_ARCH(powerpc:common64) | ||
9 | ENTRY(_start) | ||
10 | |||
11 | SECTIONS | ||
12 | { | ||
13 | . = VDSO64_LBASE + SIZEOF_HEADERS; | ||
14 | .hash : { *(.hash) } :text | ||
15 | .dynsym : { *(.dynsym) } | ||
16 | .dynstr : { *(.dynstr) } | ||
17 | .gnu.version : { *(.gnu.version) } | ||
18 | .gnu.version_d : { *(.gnu.version_d) } | ||
19 | .gnu.version_r : { *(.gnu.version_r) } | ||
20 | |||
21 | .note : { *(.note.*) } :text :note | ||
22 | |||
23 | . = ALIGN (16); | ||
24 | .text : | ||
25 | { | ||
26 | *(.text .stub .text.* .gnu.linkonce.t.*) | ||
27 | *(.sfpr .glink) | ||
28 | } :text | ||
29 | PROVIDE (__etext = .); | ||
30 | PROVIDE (_etext = .); | ||
31 | PROVIDE (etext = .); | ||
32 | |||
33 | /* Other stuff is appended to the text segment: */ | ||
34 | .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } | ||
35 | .rodata1 : { *(.rodata1) } | ||
36 | .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr | ||
37 | .eh_frame : { KEEP (*(.eh_frame)) } :text | ||
38 | .gcc_except_table : { *(.gcc_except_table) } | ||
39 | |||
40 | .opd ALIGN(8) : { KEEP (*(.opd)) } | ||
41 | .got ALIGN(8) : { *(.got .toc) } | ||
42 | .rela.dyn ALIGN(8) : { *(.rela.dyn) } | ||
43 | |||
44 | .dynamic : { *(.dynamic) } :text :dynamic | ||
45 | |||
46 | _end = .; | ||
47 | PROVIDE (end = .); | ||
48 | |||
49 | /* Stabs debugging sections are here too | ||
50 | */ | ||
51 | .stab 0 : { *(.stab) } | ||
52 | .stabstr 0 : { *(.stabstr) } | ||
53 | .stab.excl 0 : { *(.stab.excl) } | ||
54 | .stab.exclstr 0 : { *(.stab.exclstr) } | ||
55 | .stab.index 0 : { *(.stab.index) } | ||
56 | .stab.indexstr 0 : { *(.stab.indexstr) } | ||
57 | .comment 0 : { *(.comment) } | ||
58 | /* DWARF debug sectio/ns. | ||
59 | Symbols in the DWARF debugging sections are relative to the beginning | ||
60 | of the section so we begin them at 0. */ | ||
61 | /* DWARF 1 */ | ||
62 | .debug 0 : { *(.debug) } | ||
63 | .line 0 : { *(.line) } | ||
64 | /* GNU DWARF 1 extensions */ | ||
65 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | ||
66 | .debug_sfnames 0 : { *(.debug_sfnames) } | ||
67 | /* DWARF 1.1 and DWARF 2 */ | ||
68 | .debug_aranges 0 : { *(.debug_aranges) } | ||
69 | .debug_pubnames 0 : { *(.debug_pubnames) } | ||
70 | /* DWARF 2 */ | ||
71 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } | ||
72 | .debug_abbrev 0 : { *(.debug_abbrev) } | ||
73 | .debug_line 0 : { *(.debug_line) } | ||
74 | .debug_frame 0 : { *(.debug_frame) } | ||
75 | .debug_str 0 : { *(.debug_str) } | ||
76 | .debug_loc 0 : { *(.debug_loc) } | ||
77 | .debug_macinfo 0 : { *(.debug_macinfo) } | ||
78 | /* SGI/MIPS DWARF 2 extensions */ | ||
79 | .debug_weaknames 0 : { *(.debug_weaknames) } | ||
80 | .debug_funcnames 0 : { *(.debug_funcnames) } | ||
81 | .debug_typenames 0 : { *(.debug_typenames) } | ||
82 | .debug_varnames 0 : { *(.debug_varnames) } | ||
83 | |||
84 | /DISCARD/ : { *(.note.GNU-stack) } | ||
85 | /DISCARD/ : { *(.branch_lt) } | ||
86 | /DISCARD/ : { *(.data .data.* .gnu.linkonce.d.*) } | ||
87 | /DISCARD/ : { *(.bss .sbss .dynbss .dynsbss) } | ||
88 | } | ||
89 | |||
90 | PHDRS | ||
91 | { | ||
92 | text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */ | ||
93 | note PT_NOTE FLAGS(4); /* PF_R */ | ||
94 | dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ | ||
95 | eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */ | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * This controls what symbols we export from the DSO. | ||
100 | */ | ||
101 | VERSION | ||
102 | { | ||
103 | VDSO_VERSION_STRING { | ||
104 | global: | ||
105 | __kernel_datapage_offset; /* Has to be there for the kernel to find */ | ||
106 | __kernel_get_syscall_map; | ||
107 | __kernel_gettimeofday; | ||
108 | __kernel_clock_gettime; | ||
109 | __kernel_clock_getres; | ||
110 | __kernel_get_tbfreq; | ||
111 | __kernel_sync_dicache; | ||
112 | __kernel_sync_dicache_p5; | ||
113 | __kernel_sigtramp_rt64; | ||
114 | local: *; | ||
115 | }; | ||
116 | } | ||
diff --git a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S new file mode 100644 index 000000000000..0529cb9e3b97 --- /dev/null +++ b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S | |||
@@ -0,0 +1,13 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <asm/page.h> | ||
3 | |||
4 | .section ".data.page_aligned" | ||
5 | |||
6 | .globl vdso64_start, vdso64_end | ||
7 | .balign PAGE_SIZE | ||
8 | vdso64_start: | ||
9 | .incbin "arch/powerpc/kernel/vdso64/vdso64.so" | ||
10 | .balign PAGE_SIZE | ||
11 | vdso64_end: | ||
12 | |||
13 | .previous | ||