diff options
Diffstat (limited to 'arch/sparc/kernel')
43 files changed, 1145 insertions, 502 deletions
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index b90b4a1d070..cb85458f89d 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile | |||
@@ -32,6 +32,7 @@ obj-$(CONFIG_SPARC32) += sun4m_irq.o sun4c_irq.o sun4d_irq.o | |||
32 | 32 | ||
33 | obj-y += process_$(BITS).o | 33 | obj-y += process_$(BITS).o |
34 | obj-y += signal_$(BITS).o | 34 | obj-y += signal_$(BITS).o |
35 | obj-y += sigutil_$(BITS).o | ||
35 | obj-$(CONFIG_SPARC32) += ioport.o | 36 | obj-$(CONFIG_SPARC32) += ioport.o |
36 | obj-y += setup_$(BITS).o | 37 | obj-y += setup_$(BITS).o |
37 | obj-y += idprom.o | 38 | obj-y += idprom.o |
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c index 138dbbc8dc8..ba9b1cec4e6 100644 --- a/arch/sparc/kernel/cpu.c +++ b/arch/sparc/kernel/cpu.c | |||
@@ -396,6 +396,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused) | |||
396 | , cpu_data(0).clock_tick | 396 | , cpu_data(0).clock_tick |
397 | #endif | 397 | #endif |
398 | ); | 398 | ); |
399 | cpucap_info(m); | ||
399 | #ifdef CONFIG_SMP | 400 | #ifdef CONFIG_SMP |
400 | smp_bogo(m); | 401 | smp_bogo(m); |
401 | #endif | 402 | #endif |
@@ -474,11 +475,30 @@ static void __init sun4v_cpu_probe(void) | |||
474 | sparc_pmu_type = "niagara2"; | 475 | sparc_pmu_type = "niagara2"; |
475 | break; | 476 | break; |
476 | 477 | ||
478 | case SUN4V_CHIP_NIAGARA3: | ||
479 | sparc_cpu_type = "UltraSparc T3 (Niagara3)"; | ||
480 | sparc_fpu_type = "UltraSparc T3 integrated FPU"; | ||
481 | sparc_pmu_type = "niagara3"; | ||
482 | break; | ||
483 | |||
484 | case SUN4V_CHIP_NIAGARA4: | ||
485 | sparc_cpu_type = "UltraSparc T4 (Niagara4)"; | ||
486 | sparc_fpu_type = "UltraSparc T4 integrated FPU"; | ||
487 | sparc_pmu_type = "niagara4"; | ||
488 | break; | ||
489 | |||
490 | case SUN4V_CHIP_NIAGARA5: | ||
491 | sparc_cpu_type = "UltraSparc T5 (Niagara5)"; | ||
492 | sparc_fpu_type = "UltraSparc T5 integrated FPU"; | ||
493 | sparc_pmu_type = "niagara5"; | ||
494 | break; | ||
495 | |||
477 | default: | 496 | default: |
478 | printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n", | 497 | printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n", |
479 | prom_cpu_compatible); | 498 | prom_cpu_compatible); |
480 | sparc_cpu_type = "Unknown SUN4V CPU"; | 499 | sparc_cpu_type = "Unknown SUN4V CPU"; |
481 | sparc_fpu_type = "Unknown SUN4V FPU"; | 500 | sparc_fpu_type = "Unknown SUN4V FPU"; |
501 | sparc_pmu_type = "Unknown SUN4V PMU"; | ||
482 | break; | 502 | break; |
483 | } | 503 | } |
484 | } | 504 | } |
diff --git a/arch/sparc/kernel/cpumap.c b/arch/sparc/kernel/cpumap.c index d91fd782743..9323eafccb9 100644 --- a/arch/sparc/kernel/cpumap.c +++ b/arch/sparc/kernel/cpumap.c | |||
@@ -324,6 +324,9 @@ static int iterate_cpu(struct cpuinfo_tree *t, unsigned int root_index) | |||
324 | switch (sun4v_chip_type) { | 324 | switch (sun4v_chip_type) { |
325 | case SUN4V_CHIP_NIAGARA1: | 325 | case SUN4V_CHIP_NIAGARA1: |
326 | case SUN4V_CHIP_NIAGARA2: | 326 | case SUN4V_CHIP_NIAGARA2: |
327 | case SUN4V_CHIP_NIAGARA3: | ||
328 | case SUN4V_CHIP_NIAGARA4: | ||
329 | case SUN4V_CHIP_NIAGARA5: | ||
327 | rover_inc_table = niagara_iterate_method; | 330 | rover_inc_table = niagara_iterate_method; |
328 | break; | 331 | break; |
329 | default: | 332 | default: |
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c index dd1342c0a3b..7429b47c3ac 100644 --- a/arch/sparc/kernel/ds.c +++ b/arch/sparc/kernel/ds.c | |||
@@ -15,12 +15,15 @@ | |||
15 | #include <linux/reboot.h> | 15 | #include <linux/reboot.h> |
16 | #include <linux/cpu.h> | 16 | #include <linux/cpu.h> |
17 | 17 | ||
18 | #include <asm/hypervisor.h> | ||
18 | #include <asm/ldc.h> | 19 | #include <asm/ldc.h> |
19 | #include <asm/vio.h> | 20 | #include <asm/vio.h> |
20 | #include <asm/mdesc.h> | 21 | #include <asm/mdesc.h> |
21 | #include <asm/head.h> | 22 | #include <asm/head.h> |
22 | #include <asm/irq.h> | 23 | #include <asm/irq.h> |
23 | 24 | ||
25 | #include "kernel.h" | ||
26 | |||
24 | #define DRV_MODULE_NAME "ds" | 27 | #define DRV_MODULE_NAME "ds" |
25 | #define PFX DRV_MODULE_NAME ": " | 28 | #define PFX DRV_MODULE_NAME ": " |
26 | #define DRV_MODULE_VERSION "1.0" | 29 | #define DRV_MODULE_VERSION "1.0" |
@@ -828,18 +831,32 @@ void ldom_set_var(const char *var, const char *value) | |||
828 | } | 831 | } |
829 | } | 832 | } |
830 | 833 | ||
834 | static char full_boot_str[256] __attribute__((aligned(32))); | ||
835 | static int reboot_data_supported; | ||
836 | |||
831 | void ldom_reboot(const char *boot_command) | 837 | void ldom_reboot(const char *boot_command) |
832 | { | 838 | { |
833 | /* Don't bother with any of this if the boot_command | 839 | /* Don't bother with any of this if the boot_command |
834 | * is empty. | 840 | * is empty. |
835 | */ | 841 | */ |
836 | if (boot_command && strlen(boot_command)) { | 842 | if (boot_command && strlen(boot_command)) { |
837 | char full_boot_str[256]; | 843 | unsigned long len; |
838 | 844 | ||
839 | strcpy(full_boot_str, "boot "); | 845 | strcpy(full_boot_str, "boot "); |
840 | strcpy(full_boot_str + strlen("boot "), boot_command); | 846 | strcpy(full_boot_str + strlen("boot "), boot_command); |
847 | len = strlen(full_boot_str); | ||
841 | 848 | ||
842 | ldom_set_var("reboot-command", full_boot_str); | 849 | if (reboot_data_supported) { |
850 | unsigned long ra = kimage_addr_to_ra(full_boot_str); | ||
851 | unsigned long hv_ret; | ||
852 | |||
853 | hv_ret = sun4v_reboot_data_set(ra, len); | ||
854 | if (hv_ret != HV_EOK) | ||
855 | pr_err("SUN4V: Unable to set reboot data " | ||
856 | "hv_ret=%lu\n", hv_ret); | ||
857 | } else { | ||
858 | ldom_set_var("reboot-command", full_boot_str); | ||
859 | } | ||
843 | } | 860 | } |
844 | sun4v_mach_sir(); | 861 | sun4v_mach_sir(); |
845 | } | 862 | } |
@@ -1237,6 +1254,16 @@ static struct vio_driver ds_driver = { | |||
1237 | 1254 | ||
1238 | static int __init ds_init(void) | 1255 | static int __init ds_init(void) |
1239 | { | 1256 | { |
1257 | unsigned long hv_ret, major, minor; | ||
1258 | |||
1259 | if (tlb_type == hypervisor) { | ||
1260 | hv_ret = sun4v_get_version(HV_GRP_REBOOT_DATA, &major, &minor); | ||
1261 | if (hv_ret == HV_EOK) { | ||
1262 | pr_info("SUN4V: Reboot data supported (maj=%lu,min=%lu).\n", | ||
1263 | major, minor); | ||
1264 | reboot_data_supported = 1; | ||
1265 | } | ||
1266 | } | ||
1240 | kthread_run(ds_thread, NULL, "kldomd"); | 1267 | kthread_run(ds_thread, NULL, "kldomd"); |
1241 | 1268 | ||
1242 | return vio_register_driver(&ds_driver); | 1269 | return vio_register_driver(&ds_driver); |
diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h index d1f1361c416..0c218e4c088 100644 --- a/arch/sparc/kernel/entry.h +++ b/arch/sparc/kernel/entry.h | |||
@@ -42,7 +42,28 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr, | |||
42 | extern void fpload(unsigned long *fpregs, unsigned long *fsr); | 42 | extern void fpload(unsigned long *fpregs, unsigned long *fsr); |
43 | 43 | ||
44 | #else /* CONFIG_SPARC32 */ | 44 | #else /* CONFIG_SPARC32 */ |
45 | |||
46 | #include <asm/trap_block.h> | ||
47 | |||
48 | struct popc_3insn_patch_entry { | ||
49 | unsigned int addr; | ||
50 | unsigned int insns[3]; | ||
51 | }; | ||
52 | extern struct popc_3insn_patch_entry __popc_3insn_patch, | ||
53 | __popc_3insn_patch_end; | ||
54 | |||
55 | struct popc_6insn_patch_entry { | ||
56 | unsigned int addr; | ||
57 | unsigned int insns[6]; | ||
58 | }; | ||
59 | extern struct popc_6insn_patch_entry __popc_6insn_patch, | ||
60 | __popc_6insn_patch_end; | ||
61 | |||
45 | extern void __init per_cpu_patch(void); | 62 | extern void __init per_cpu_patch(void); |
63 | extern void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *, | ||
64 | struct sun4v_1insn_patch_entry *); | ||
65 | extern void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *, | ||
66 | struct sun4v_2insn_patch_entry *); | ||
46 | extern void __init sun4v_patch(void); | 67 | extern void __init sun4v_patch(void); |
47 | extern void __init boot_cpu_id_too_large(int cpu); | 68 | extern void __init boot_cpu_id_too_large(int cpu); |
48 | extern unsigned int dcache_parity_tl1_occurred; | 69 | extern unsigned int dcache_parity_tl1_occurred; |
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S index aa594c792d1..0d810c2f1d0 100644 --- a/arch/sparc/kernel/head_64.S +++ b/arch/sparc/kernel/head_64.S | |||
@@ -132,6 +132,8 @@ prom_sun4v_name: | |||
132 | .asciz "sun4v" | 132 | .asciz "sun4v" |
133 | prom_niagara_prefix: | 133 | prom_niagara_prefix: |
134 | .asciz "SUNW,UltraSPARC-T" | 134 | .asciz "SUNW,UltraSPARC-T" |
135 | prom_sparc_prefix: | ||
136 | .asciz "SPARC-" | ||
135 | .align 4 | 137 | .align 4 |
136 | prom_root_compatible: | 138 | prom_root_compatible: |
137 | .skip 64 | 139 | .skip 64 |
@@ -382,6 +384,22 @@ sun4v_chip_type: | |||
382 | 90: ldub [%g7], %g2 | 384 | 90: ldub [%g7], %g2 |
383 | ldub [%g1], %g4 | 385 | ldub [%g1], %g4 |
384 | cmp %g2, %g4 | 386 | cmp %g2, %g4 |
387 | bne,pn %icc, 89f | ||
388 | add %g7, 1, %g7 | ||
389 | subcc %g3, 1, %g3 | ||
390 | bne,pt %xcc, 90b | ||
391 | add %g1, 1, %g1 | ||
392 | ba,pt %xcc, 91f | ||
393 | nop | ||
394 | |||
395 | 89: sethi %hi(prom_cpu_compatible), %g1 | ||
396 | or %g1, %lo(prom_cpu_compatible), %g1 | ||
397 | sethi %hi(prom_sparc_prefix), %g7 | ||
398 | or %g7, %lo(prom_sparc_prefix), %g7 | ||
399 | mov 6, %g3 | ||
400 | 90: ldub [%g7], %g2 | ||
401 | ldub [%g1], %g4 | ||
402 | cmp %g2, %g4 | ||
385 | bne,pn %icc, 4f | 403 | bne,pn %icc, 4f |
386 | add %g7, 1, %g7 | 404 | add %g7, 1, %g7 |
387 | subcc %g3, 1, %g3 | 405 | subcc %g3, 1, %g3 |
@@ -390,6 +408,28 @@ sun4v_chip_type: | |||
390 | 408 | ||
391 | sethi %hi(prom_cpu_compatible), %g1 | 409 | sethi %hi(prom_cpu_compatible), %g1 |
392 | or %g1, %lo(prom_cpu_compatible), %g1 | 410 | or %g1, %lo(prom_cpu_compatible), %g1 |
411 | ldub [%g1 + 6], %g2 | ||
412 | cmp %g2, 'T' | ||
413 | be,pt %xcc, 70f | ||
414 | cmp %g2, 'M' | ||
415 | bne,pn %xcc, 4f | ||
416 | nop | ||
417 | |||
418 | 70: ldub [%g1 + 7], %g2 | ||
419 | cmp %g2, '3' | ||
420 | be,pt %xcc, 5f | ||
421 | mov SUN4V_CHIP_NIAGARA3, %g4 | ||
422 | cmp %g2, '4' | ||
423 | be,pt %xcc, 5f | ||
424 | mov SUN4V_CHIP_NIAGARA4, %g4 | ||
425 | cmp %g2, '5' | ||
426 | be,pt %xcc, 5f | ||
427 | mov SUN4V_CHIP_NIAGARA5, %g4 | ||
428 | ba,pt %xcc, 4f | ||
429 | nop | ||
430 | |||
431 | 91: sethi %hi(prom_cpu_compatible), %g1 | ||
432 | or %g1, %lo(prom_cpu_compatible), %g1 | ||
393 | ldub [%g1 + 17], %g2 | 433 | ldub [%g1 + 17], %g2 |
394 | cmp %g2, '1' | 434 | cmp %g2, '1' |
395 | be,pt %xcc, 5f | 435 | be,pt %xcc, 5f |
@@ -397,6 +437,7 @@ sun4v_chip_type: | |||
397 | cmp %g2, '2' | 437 | cmp %g2, '2' |
398 | be,pt %xcc, 5f | 438 | be,pt %xcc, 5f |
399 | mov SUN4V_CHIP_NIAGARA2, %g4 | 439 | mov SUN4V_CHIP_NIAGARA2, %g4 |
440 | |||
400 | 4: | 441 | 4: |
401 | mov SUN4V_CHIP_UNKNOWN, %g4 | 442 | mov SUN4V_CHIP_UNKNOWN, %g4 |
402 | 5: sethi %hi(sun4v_chip_type), %g2 | 443 | 5: sethi %hi(sun4v_chip_type), %g2 |
@@ -514,6 +555,15 @@ niagara_tlb_fixup: | |||
514 | cmp %g1, SUN4V_CHIP_NIAGARA2 | 555 | cmp %g1, SUN4V_CHIP_NIAGARA2 |
515 | be,pt %xcc, niagara2_patch | 556 | be,pt %xcc, niagara2_patch |
516 | nop | 557 | nop |
558 | cmp %g1, SUN4V_CHIP_NIAGARA3 | ||
559 | be,pt %xcc, niagara2_patch | ||
560 | nop | ||
561 | cmp %g1, SUN4V_CHIP_NIAGARA4 | ||
562 | be,pt %xcc, niagara2_patch | ||
563 | nop | ||
564 | cmp %g1, SUN4V_CHIP_NIAGARA5 | ||
565 | be,pt %xcc, niagara2_patch | ||
566 | nop | ||
517 | 567 | ||
518 | call generic_patch_copyops | 568 | call generic_patch_copyops |
519 | nop | 569 | nop |
@@ -528,7 +578,7 @@ niagara2_patch: | |||
528 | nop | 578 | nop |
529 | call niagara_patch_bzero | 579 | call niagara_patch_bzero |
530 | nop | 580 | nop |
531 | call niagara2_patch_pageops | 581 | call niagara_patch_pageops |
532 | nop | 582 | nop |
533 | 583 | ||
534 | ba,a,pt %xcc, 80f | 584 | ba,a,pt %xcc, 80f |
diff --git a/arch/sparc/kernel/hvapi.c b/arch/sparc/kernel/hvapi.c index 7c60afb835b..c2d055d8ba9 100644 --- a/arch/sparc/kernel/hvapi.c +++ b/arch/sparc/kernel/hvapi.c | |||
@@ -28,16 +28,23 @@ static struct api_info api_table[] = { | |||
28 | { .group = HV_GRP_CORE, .flags = FLAG_PRE_API }, | 28 | { .group = HV_GRP_CORE, .flags = FLAG_PRE_API }, |
29 | { .group = HV_GRP_INTR, }, | 29 | { .group = HV_GRP_INTR, }, |
30 | { .group = HV_GRP_SOFT_STATE, }, | 30 | { .group = HV_GRP_SOFT_STATE, }, |
31 | { .group = HV_GRP_TM, }, | ||
31 | { .group = HV_GRP_PCI, .flags = FLAG_PRE_API }, | 32 | { .group = HV_GRP_PCI, .flags = FLAG_PRE_API }, |
32 | { .group = HV_GRP_LDOM, }, | 33 | { .group = HV_GRP_LDOM, }, |
33 | { .group = HV_GRP_SVC_CHAN, .flags = FLAG_PRE_API }, | 34 | { .group = HV_GRP_SVC_CHAN, .flags = FLAG_PRE_API }, |
34 | { .group = HV_GRP_NCS, .flags = FLAG_PRE_API }, | 35 | { .group = HV_GRP_NCS, .flags = FLAG_PRE_API }, |
35 | { .group = HV_GRP_RNG, }, | 36 | { .group = HV_GRP_RNG, }, |
37 | { .group = HV_GRP_PBOOT, }, | ||
38 | { .group = HV_GRP_TPM, }, | ||
39 | { .group = HV_GRP_SDIO, }, | ||
40 | { .group = HV_GRP_SDIO_ERR, }, | ||
41 | { .group = HV_GRP_REBOOT_DATA, }, | ||
36 | { .group = HV_GRP_NIAG_PERF, .flags = FLAG_PRE_API }, | 42 | { .group = HV_GRP_NIAG_PERF, .flags = FLAG_PRE_API }, |
37 | { .group = HV_GRP_FIRE_PERF, }, | 43 | { .group = HV_GRP_FIRE_PERF, }, |
38 | { .group = HV_GRP_N2_CPU, }, | 44 | { .group = HV_GRP_N2_CPU, }, |
39 | { .group = HV_GRP_NIU, }, | 45 | { .group = HV_GRP_NIU, }, |
40 | { .group = HV_GRP_VF_CPU, }, | 46 | { .group = HV_GRP_VF_CPU, }, |
47 | { .group = HV_GRP_KT_CPU, }, | ||
41 | { .group = HV_GRP_DIAG, .flags = FLAG_PRE_API }, | 48 | { .group = HV_GRP_DIAG, .flags = FLAG_PRE_API }, |
42 | }; | 49 | }; |
43 | 50 | ||
diff --git a/arch/sparc/kernel/hvcalls.S b/arch/sparc/kernel/hvcalls.S index 8a5f35ffb15..58d60de4d65 100644 --- a/arch/sparc/kernel/hvcalls.S +++ b/arch/sparc/kernel/hvcalls.S | |||
@@ -798,3 +798,10 @@ ENTRY(sun4v_niagara2_setperf) | |||
798 | retl | 798 | retl |
799 | nop | 799 | nop |
800 | ENDPROC(sun4v_niagara2_setperf) | 800 | ENDPROC(sun4v_niagara2_setperf) |
801 | |||
802 | ENTRY(sun4v_reboot_data_set) | ||
803 | mov HV_FAST_REBOOT_DATA_SET, %o5 | ||
804 | ta HV_FAST_TRAP | ||
805 | retl | ||
806 | nop | ||
807 | ENDPROC(sun4v_reboot_data_set) | ||
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 1c9c80a1a86..d0479e2163f 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
@@ -65,9 +65,6 @@ static inline void dma_make_coherent(unsigned long pa, unsigned long len) | |||
65 | } | 65 | } |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | static struct resource *_sparc_find_resource(struct resource *r, | ||
69 | unsigned long); | ||
70 | |||
71 | static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz); | 68 | static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz); |
72 | static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys, | 69 | static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys, |
73 | unsigned long size, char *name); | 70 | unsigned long size, char *name); |
@@ -143,7 +140,11 @@ void iounmap(volatile void __iomem *virtual) | |||
143 | unsigned long vaddr = (unsigned long) virtual & PAGE_MASK; | 140 | unsigned long vaddr = (unsigned long) virtual & PAGE_MASK; |
144 | struct resource *res; | 141 | struct resource *res; |
145 | 142 | ||
146 | if ((res = _sparc_find_resource(&sparc_iomap, vaddr)) == NULL) { | 143 | /* |
144 | * XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case. | ||
145 | * This probably warrants some sort of hashing. | ||
146 | */ | ||
147 | if ((res = lookup_resource(&sparc_iomap, vaddr)) == NULL) { | ||
147 | printk("free_io/iounmap: cannot free %lx\n", vaddr); | 148 | printk("free_io/iounmap: cannot free %lx\n", vaddr); |
148 | return; | 149 | return; |
149 | } | 150 | } |
@@ -228,7 +229,7 @@ _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz) | |||
228 | } | 229 | } |
229 | 230 | ||
230 | pa &= PAGE_MASK; | 231 | pa &= PAGE_MASK; |
231 | sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1); | 232 | sparc_mapiorange(bus, pa, res->start, resource_size(res)); |
232 | 233 | ||
233 | return (void __iomem *)(unsigned long)(res->start + offset); | 234 | return (void __iomem *)(unsigned long)(res->start + offset); |
234 | } | 235 | } |
@@ -240,7 +241,7 @@ static void _sparc_free_io(struct resource *res) | |||
240 | { | 241 | { |
241 | unsigned long plen; | 242 | unsigned long plen; |
242 | 243 | ||
243 | plen = res->end - res->start + 1; | 244 | plen = resource_size(res); |
244 | BUG_ON((plen & (PAGE_SIZE-1)) != 0); | 245 | BUG_ON((plen & (PAGE_SIZE-1)) != 0); |
245 | sparc_unmapiorange(res->start, plen); | 246 | sparc_unmapiorange(res->start, plen); |
246 | release_resource(res); | 247 | release_resource(res); |
@@ -319,7 +320,7 @@ static void sbus_free_coherent(struct device *dev, size_t n, void *p, | |||
319 | struct resource *res; | 320 | struct resource *res; |
320 | struct page *pgv; | 321 | struct page *pgv; |
321 | 322 | ||
322 | if ((res = _sparc_find_resource(&_sparc_dvma, | 323 | if ((res = lookup_resource(&_sparc_dvma, |
323 | (unsigned long)p)) == NULL) { | 324 | (unsigned long)p)) == NULL) { |
324 | printk("sbus_free_consistent: cannot free %p\n", p); | 325 | printk("sbus_free_consistent: cannot free %p\n", p); |
325 | return; | 326 | return; |
@@ -331,9 +332,9 @@ static void sbus_free_coherent(struct device *dev, size_t n, void *p, | |||
331 | } | 332 | } |
332 | 333 | ||
333 | n = PAGE_ALIGN(n); | 334 | n = PAGE_ALIGN(n); |
334 | if ((res->end-res->start)+1 != n) { | 335 | if (resource_size(res) != n) { |
335 | printk("sbus_free_consistent: region 0x%lx asked 0x%zx\n", | 336 | printk("sbus_free_consistent: region 0x%lx asked 0x%zx\n", |
336 | (long)((res->end-res->start)+1), n); | 337 | (long)resource_size(res), n); |
337 | return; | 338 | return; |
338 | } | 339 | } |
339 | 340 | ||
@@ -492,7 +493,7 @@ static void pci32_free_coherent(struct device *dev, size_t n, void *p, | |||
492 | { | 493 | { |
493 | struct resource *res; | 494 | struct resource *res; |
494 | 495 | ||
495 | if ((res = _sparc_find_resource(&_sparc_dvma, | 496 | if ((res = lookup_resource(&_sparc_dvma, |
496 | (unsigned long)p)) == NULL) { | 497 | (unsigned long)p)) == NULL) { |
497 | printk("pci_free_consistent: cannot free %p\n", p); | 498 | printk("pci_free_consistent: cannot free %p\n", p); |
498 | return; | 499 | return; |
@@ -504,9 +505,9 @@ static void pci32_free_coherent(struct device *dev, size_t n, void *p, | |||
504 | } | 505 | } |
505 | 506 | ||
506 | n = PAGE_ALIGN(n); | 507 | n = PAGE_ALIGN(n); |
507 | if ((res->end-res->start)+1 != n) { | 508 | if (resource_size(res) != n) { |
508 | printk("pci_free_consistent: region 0x%lx asked 0x%lx\n", | 509 | printk("pci_free_consistent: region 0x%lx asked 0x%lx\n", |
509 | (long)((res->end-res->start)+1), (long)n); | 510 | (long)resource_size(res), (long)n); |
510 | return; | 511 | return; |
511 | } | 512 | } |
512 | 513 | ||
@@ -715,25 +716,6 @@ static const struct file_operations sparc_io_proc_fops = { | |||
715 | }; | 716 | }; |
716 | #endif /* CONFIG_PROC_FS */ | 717 | #endif /* CONFIG_PROC_FS */ |
717 | 718 | ||
718 | /* | ||
719 | * This is a version of find_resource and it belongs to kernel/resource.c. | ||
720 | * Until we have agreement with Linus and Martin, it lingers here. | ||
721 | * | ||
722 | * XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case. | ||
723 | * This probably warrants some sort of hashing. | ||
724 | */ | ||
725 | static struct resource *_sparc_find_resource(struct resource *root, | ||
726 | unsigned long hit) | ||
727 | { | ||
728 | struct resource *tmp; | ||
729 | |||
730 | for (tmp = root->child; tmp != 0; tmp = tmp->sibling) { | ||
731 | if (tmp->start <= hit && tmp->end >= hit) | ||
732 | return tmp; | ||
733 | } | ||
734 | return NULL; | ||
735 | } | ||
736 | |||
737 | static void register_proc_sparc_ioport(void) | 719 | static void register_proc_sparc_ioport(void) |
738 | { | 720 | { |
739 | #ifdef CONFIG_PROC_FS | 721 | #ifdef CONFIG_PROC_FS |
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h index 100b9c204e7..42851122bbd 100644 --- a/arch/sparc/kernel/irq.h +++ b/arch/sparc/kernel/irq.h | |||
@@ -88,7 +88,7 @@ BTFIXUPDEF_CALL(void, set_irq_udt, int) | |||
88 | #define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu) | 88 | #define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu) |
89 | 89 | ||
90 | /* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */ | 90 | /* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */ |
91 | #define SUN4D_IPI_IRQ 14 | 91 | #define SUN4D_IPI_IRQ 13 |
92 | 92 | ||
93 | extern void sun4d_ipi_interrupt(void); | 93 | extern void sun4d_ipi_interrupt(void); |
94 | 94 | ||
diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index 4e78862d12f..0dd8422a469 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | #include <asm/ptrace.h> | 27 | #include <asm/ptrace.h> |
28 | #include <asm/processor.h> | 28 | #include <asm/processor.h> |
29 | #include <asm/atomic.h> | 29 | #include <linux/atomic.h> |
30 | #include <asm/system.h> | 30 | #include <asm/system.h> |
31 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
32 | #include <asm/io.h> | 32 | #include <asm/io.h> |
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h index 6f6544cfa0e..fd6c36b1df7 100644 --- a/arch/sparc/kernel/kernel.h +++ b/arch/sparc/kernel/kernel.h | |||
@@ -4,12 +4,27 @@ | |||
4 | #include <linux/interrupt.h> | 4 | #include <linux/interrupt.h> |
5 | 5 | ||
6 | #include <asm/traps.h> | 6 | #include <asm/traps.h> |
7 | #include <asm/head.h> | ||
8 | #include <asm/io.h> | ||
7 | 9 | ||
8 | /* cpu.c */ | 10 | /* cpu.c */ |
9 | extern const char *sparc_pmu_type; | 11 | extern const char *sparc_pmu_type; |
10 | extern unsigned int fsr_storage; | 12 | extern unsigned int fsr_storage; |
11 | extern int ncpus_probed; | 13 | extern int ncpus_probed; |
12 | 14 | ||
15 | #ifdef CONFIG_SPARC64 | ||
16 | /* setup_64.c */ | ||
17 | struct seq_file; | ||
18 | extern void cpucap_info(struct seq_file *); | ||
19 | |||
20 | static inline unsigned long kimage_addr_to_ra(const char *p) | ||
21 | { | ||
22 | unsigned long val = (unsigned long) p; | ||
23 | |||
24 | return kern_base + (val - KERNBASE); | ||
25 | } | ||
26 | #endif | ||
27 | |||
13 | #ifdef CONFIG_SPARC32 | 28 | #ifdef CONFIG_SPARC32 |
14 | /* cpu.c */ | 29 | /* cpu.c */ |
15 | extern void cpu_probe(void); | 30 | extern void cpu_probe(void); |
diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S index 1d361477d7d..79f31036484 100644 --- a/arch/sparc/kernel/ktlb.S +++ b/arch/sparc/kernel/ktlb.S | |||
@@ -47,16 +47,16 @@ kvmap_itlb_tsb_miss: | |||
47 | kvmap_itlb_vmalloc_addr: | 47 | kvmap_itlb_vmalloc_addr: |
48 | KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath) | 48 | KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath) |
49 | 49 | ||
50 | KTSB_LOCK_TAG(%g1, %g2, %g7) | 50 | TSB_LOCK_TAG(%g1, %g2, %g7) |
51 | 51 | ||
52 | /* Load and check PTE. */ | 52 | /* Load and check PTE. */ |
53 | ldxa [%g5] ASI_PHYS_USE_EC, %g5 | 53 | ldxa [%g5] ASI_PHYS_USE_EC, %g5 |
54 | mov 1, %g7 | 54 | mov 1, %g7 |
55 | sllx %g7, TSB_TAG_INVALID_BIT, %g7 | 55 | sllx %g7, TSB_TAG_INVALID_BIT, %g7 |
56 | brgez,a,pn %g5, kvmap_itlb_longpath | 56 | brgez,a,pn %g5, kvmap_itlb_longpath |
57 | KTSB_STORE(%g1, %g7) | 57 | TSB_STORE(%g1, %g7) |
58 | 58 | ||
59 | KTSB_WRITE(%g1, %g5, %g6) | 59 | TSB_WRITE(%g1, %g5, %g6) |
60 | 60 | ||
61 | /* fallthrough to TLB load */ | 61 | /* fallthrough to TLB load */ |
62 | 62 | ||
@@ -102,9 +102,9 @@ kvmap_itlb_longpath: | |||
102 | kvmap_itlb_obp: | 102 | kvmap_itlb_obp: |
103 | OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_itlb_longpath) | 103 | OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_itlb_longpath) |
104 | 104 | ||
105 | KTSB_LOCK_TAG(%g1, %g2, %g7) | 105 | TSB_LOCK_TAG(%g1, %g2, %g7) |
106 | 106 | ||
107 | KTSB_WRITE(%g1, %g5, %g6) | 107 | TSB_WRITE(%g1, %g5, %g6) |
108 | 108 | ||
109 | ba,pt %xcc, kvmap_itlb_load | 109 | ba,pt %xcc, kvmap_itlb_load |
110 | nop | 110 | nop |
@@ -112,17 +112,17 @@ kvmap_itlb_obp: | |||
112 | kvmap_dtlb_obp: | 112 | kvmap_dtlb_obp: |
113 | OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_dtlb_longpath) | 113 | OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_dtlb_longpath) |
114 | 114 | ||
115 | KTSB_LOCK_TAG(%g1, %g2, %g7) | 115 | TSB_LOCK_TAG(%g1, %g2, %g7) |
116 | 116 | ||
117 | KTSB_WRITE(%g1, %g5, %g6) | 117 | TSB_WRITE(%g1, %g5, %g6) |
118 | 118 | ||
119 | ba,pt %xcc, kvmap_dtlb_load | 119 | ba,pt %xcc, kvmap_dtlb_load |
120 | nop | 120 | nop |
121 | 121 | ||
122 | .align 32 | 122 | .align 32 |
123 | kvmap_dtlb_tsb4m_load: | 123 | kvmap_dtlb_tsb4m_load: |
124 | KTSB_LOCK_TAG(%g1, %g2, %g7) | 124 | TSB_LOCK_TAG(%g1, %g2, %g7) |
125 | KTSB_WRITE(%g1, %g5, %g6) | 125 | TSB_WRITE(%g1, %g5, %g6) |
126 | ba,pt %xcc, kvmap_dtlb_load | 126 | ba,pt %xcc, kvmap_dtlb_load |
127 | nop | 127 | nop |
128 | 128 | ||
@@ -222,16 +222,16 @@ kvmap_linear_patch: | |||
222 | kvmap_dtlb_vmalloc_addr: | 222 | kvmap_dtlb_vmalloc_addr: |
223 | KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath) | 223 | KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath) |
224 | 224 | ||
225 | KTSB_LOCK_TAG(%g1, %g2, %g7) | 225 | TSB_LOCK_TAG(%g1, %g2, %g7) |
226 | 226 | ||
227 | /* Load and check PTE. */ | 227 | /* Load and check PTE. */ |
228 | ldxa [%g5] ASI_PHYS_USE_EC, %g5 | 228 | ldxa [%g5] ASI_PHYS_USE_EC, %g5 |
229 | mov 1, %g7 | 229 | mov 1, %g7 |
230 | sllx %g7, TSB_TAG_INVALID_BIT, %g7 | 230 | sllx %g7, TSB_TAG_INVALID_BIT, %g7 |
231 | brgez,a,pn %g5, kvmap_dtlb_longpath | 231 | brgez,a,pn %g5, kvmap_dtlb_longpath |
232 | KTSB_STORE(%g1, %g7) | 232 | TSB_STORE(%g1, %g7) |
233 | 233 | ||
234 | KTSB_WRITE(%g1, %g5, %g6) | 234 | TSB_WRITE(%g1, %g5, %g6) |
235 | 235 | ||
236 | /* fallthrough to TLB load */ | 236 | /* fallthrough to TLB load */ |
237 | 237 | ||
diff --git a/arch/sparc/kernel/leon_pci_grpci2.c b/arch/sparc/kernel/leon_pci_grpci2.c index 44dc093ee33..fad1bd07cb5 100644 --- a/arch/sparc/kernel/leon_pci_grpci2.c +++ b/arch/sparc/kernel/leon_pci_grpci2.c | |||
@@ -215,7 +215,7 @@ struct grpci2_priv { | |||
215 | DEFINE_SPINLOCK(grpci2_dev_lock); | 215 | DEFINE_SPINLOCK(grpci2_dev_lock); |
216 | struct grpci2_priv *grpci2priv; | 216 | struct grpci2_priv *grpci2priv; |
217 | 217 | ||
218 | int grpci2_map_irq(struct pci_dev *dev, u8 slot, u8 pin) | 218 | int grpci2_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
219 | { | 219 | { |
220 | struct grpci2_priv *priv = dev->bus->sysdata; | 220 | struct grpci2_priv *priv = dev->bus->sysdata; |
221 | int irq_group; | 221 | int irq_group; |
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c index fe8fb44c609..1210fde1874 100644 --- a/arch/sparc/kernel/leon_smp.c +++ b/arch/sparc/kernel/leon_smp.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <asm/tlbflush.h> | 28 | #include <asm/tlbflush.h> |
29 | 29 | ||
30 | #include <asm/ptrace.h> | 30 | #include <asm/ptrace.h> |
31 | #include <asm/atomic.h> | 31 | #include <linux/atomic.h> |
32 | #include <asm/irq_regs.h> | 32 | #include <asm/irq_regs.h> |
33 | #include <asm/traps.h> | 33 | #include <asm/traps.h> |
34 | 34 | ||
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c index 42f28c7420e..acaebb63c4f 100644 --- a/arch/sparc/kernel/mdesc.c +++ b/arch/sparc/kernel/mdesc.c | |||
@@ -508,6 +508,8 @@ const char *mdesc_node_name(struct mdesc_handle *hp, u64 node) | |||
508 | } | 508 | } |
509 | EXPORT_SYMBOL(mdesc_node_name); | 509 | EXPORT_SYMBOL(mdesc_node_name); |
510 | 510 | ||
511 | static u64 max_cpus = 64; | ||
512 | |||
511 | static void __init report_platform_properties(void) | 513 | static void __init report_platform_properties(void) |
512 | { | 514 | { |
513 | struct mdesc_handle *hp = mdesc_grab(); | 515 | struct mdesc_handle *hp = mdesc_grab(); |
@@ -543,8 +545,10 @@ static void __init report_platform_properties(void) | |||
543 | if (v) | 545 | if (v) |
544 | printk("PLATFORM: watchdog-max-timeout [%llu ms]\n", *v); | 546 | printk("PLATFORM: watchdog-max-timeout [%llu ms]\n", *v); |
545 | v = mdesc_get_property(hp, pn, "max-cpus", NULL); | 547 | v = mdesc_get_property(hp, pn, "max-cpus", NULL); |
546 | if (v) | 548 | if (v) { |
547 | printk("PLATFORM: max-cpus [%llu]\n", *v); | 549 | max_cpus = *v; |
550 | printk("PLATFORM: max-cpus [%llu]\n", max_cpus); | ||
551 | } | ||
548 | 552 | ||
549 | #ifdef CONFIG_SMP | 553 | #ifdef CONFIG_SMP |
550 | { | 554 | { |
@@ -715,7 +719,7 @@ static void __cpuinit set_proc_ids(struct mdesc_handle *hp) | |||
715 | } | 719 | } |
716 | 720 | ||
717 | static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask, | 721 | static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask, |
718 | unsigned char def) | 722 | unsigned long def, unsigned long max) |
719 | { | 723 | { |
720 | u64 val; | 724 | u64 val; |
721 | 725 | ||
@@ -726,6 +730,9 @@ static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask, | |||
726 | if (!val || val >= 64) | 730 | if (!val || val >= 64) |
727 | goto use_default; | 731 | goto use_default; |
728 | 732 | ||
733 | if (val > max) | ||
734 | val = max; | ||
735 | |||
729 | *mask = ((1U << val) * 64U) - 1U; | 736 | *mask = ((1U << val) * 64U) - 1U; |
730 | return; | 737 | return; |
731 | 738 | ||
@@ -736,19 +743,28 @@ use_default: | |||
736 | static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp, | 743 | static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp, |
737 | struct trap_per_cpu *tb) | 744 | struct trap_per_cpu *tb) |
738 | { | 745 | { |
746 | static int printed; | ||
739 | const u64 *val; | 747 | const u64 *val; |
740 | 748 | ||
741 | val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL); | 749 | val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL); |
742 | get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7); | 750 | get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7, ilog2(max_cpus * 2)); |
743 | 751 | ||
744 | val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL); | 752 | val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL); |
745 | get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7); | 753 | get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7, 8); |
746 | 754 | ||
747 | val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL); | 755 | val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL); |
748 | get_one_mondo_bits(val, &tb->resum_qmask, 6); | 756 | get_one_mondo_bits(val, &tb->resum_qmask, 6, 7); |
749 | 757 | ||
750 | val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL); | 758 | val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL); |
751 | get_one_mondo_bits(val, &tb->nonresum_qmask, 2); | 759 | get_one_mondo_bits(val, &tb->nonresum_qmask, 2, 2); |
760 | if (!printed++) { | ||
761 | pr_info("SUN4V: Mondo queue sizes " | ||
762 | "[cpu(%u) dev(%u) r(%u) nr(%u)]\n", | ||
763 | tb->cpu_mondo_qmask + 1, | ||
764 | tb->dev_mondo_qmask + 1, | ||
765 | tb->resum_qmask + 1, | ||
766 | tb->nonresum_qmask + 1); | ||
767 | } | ||
752 | } | 768 | } |
753 | 769 | ||
754 | static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask) | 770 | static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask) |
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c index 99ba5baa949..e5519870c3d 100644 --- a/arch/sparc/kernel/module.c +++ b/arch/sparc/kernel/module.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
18 | #include <asm/spitfire.h> | 18 | #include <asm/spitfire.h> |
19 | 19 | ||
20 | #include "entry.h" | ||
21 | |||
20 | #ifdef CONFIG_SPARC64 | 22 | #ifdef CONFIG_SPARC64 |
21 | 23 | ||
22 | #include <linux/jump_label.h> | 24 | #include <linux/jump_label.h> |
@@ -68,12 +70,6 @@ void *module_alloc(unsigned long size) | |||
68 | return ret; | 70 | return ret; |
69 | } | 71 | } |
70 | 72 | ||
71 | /* Free memory returned from module_core_alloc/module_init_alloc */ | ||
72 | void module_free(struct module *mod, void *module_region) | ||
73 | { | ||
74 | vfree(module_region); | ||
75 | } | ||
76 | |||
77 | /* Make generic code ignore STT_REGISTER dummy undefined symbols. */ | 73 | /* Make generic code ignore STT_REGISTER dummy undefined symbols. */ |
78 | int module_frob_arch_sections(Elf_Ehdr *hdr, | 74 | int module_frob_arch_sections(Elf_Ehdr *hdr, |
79 | Elf_Shdr *sechdrs, | 75 | Elf_Shdr *sechdrs, |
@@ -107,17 +103,6 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, | |||
107 | return 0; | 103 | return 0; |
108 | } | 104 | } |
109 | 105 | ||
110 | int apply_relocate(Elf_Shdr *sechdrs, | ||
111 | const char *strtab, | ||
112 | unsigned int symindex, | ||
113 | unsigned int relsec, | ||
114 | struct module *me) | ||
115 | { | ||
116 | printk(KERN_ERR "module %s: non-ADD RELOCATION unsupported\n", | ||
117 | me->name); | ||
118 | return -ENOEXEC; | ||
119 | } | ||
120 | |||
121 | int apply_relocate_add(Elf_Shdr *sechdrs, | 106 | int apply_relocate_add(Elf_Shdr *sechdrs, |
122 | const char *strtab, | 107 | const char *strtab, |
123 | unsigned int symindex, | 108 | unsigned int symindex, |
@@ -220,6 +205,29 @@ int apply_relocate_add(Elf_Shdr *sechdrs, | |||
220 | } | 205 | } |
221 | 206 | ||
222 | #ifdef CONFIG_SPARC64 | 207 | #ifdef CONFIG_SPARC64 |
208 | static void do_patch_sections(const Elf_Ehdr *hdr, | ||
209 | const Elf_Shdr *sechdrs) | ||
210 | { | ||
211 | const Elf_Shdr *s, *sun4v_1insn = NULL, *sun4v_2insn = NULL; | ||
212 | char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | ||
213 | |||
214 | for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { | ||
215 | if (!strcmp(".sun4v_1insn_patch", secstrings + s->sh_name)) | ||
216 | sun4v_1insn = s; | ||
217 | if (!strcmp(".sun4v_2insn_patch", secstrings + s->sh_name)) | ||
218 | sun4v_2insn = s; | ||
219 | } | ||
220 | |||
221 | if (sun4v_1insn && tlb_type == hypervisor) { | ||
222 | void *p = (void *) sun4v_1insn->sh_addr; | ||
223 | sun4v_patch_1insn_range(p, p + sun4v_1insn->sh_size); | ||
224 | } | ||
225 | if (sun4v_2insn && tlb_type == hypervisor) { | ||
226 | void *p = (void *) sun4v_2insn->sh_addr; | ||
227 | sun4v_patch_2insn_range(p, p + sun4v_2insn->sh_size); | ||
228 | } | ||
229 | } | ||
230 | |||
223 | int module_finalize(const Elf_Ehdr *hdr, | 231 | int module_finalize(const Elf_Ehdr *hdr, |
224 | const Elf_Shdr *sechdrs, | 232 | const Elf_Shdr *sechdrs, |
225 | struct module *me) | 233 | struct module *me) |
@@ -227,6 +235,8 @@ int module_finalize(const Elf_Ehdr *hdr, | |||
227 | /* make jump label nops */ | 235 | /* make jump label nops */ |
228 | jump_label_apply_nops(me); | 236 | jump_label_apply_nops(me); |
229 | 237 | ||
238 | do_patch_sections(hdr, sechdrs); | ||
239 | |||
230 | /* Cheetah's I-cache is fully coherent. */ | 240 | /* Cheetah's I-cache is fully coherent. */ |
231 | if (tlb_type == spitfire) { | 241 | if (tlb_type == spitfire) { |
232 | unsigned long va; | 242 | unsigned long va; |
@@ -239,15 +249,4 @@ int module_finalize(const Elf_Ehdr *hdr, | |||
239 | 249 | ||
240 | return 0; | 250 | return 0; |
241 | } | 251 | } |
242 | #else | ||
243 | int module_finalize(const Elf_Ehdr *hdr, | ||
244 | const Elf_Shdr *sechdrs, | ||
245 | struct module *me) | ||
246 | { | ||
247 | return 0; | ||
248 | } | ||
249 | #endif /* CONFIG_SPARC64 */ | 252 | #endif /* CONFIG_SPARC64 */ |
250 | |||
251 | void module_arch_cleanup(struct module *mod) | ||
252 | { | ||
253 | } | ||
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 713dc91020a..8aa0d440858 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -230,7 +230,8 @@ static void pci_parse_of_addrs(struct platform_device *op, | |||
230 | res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2]; | 230 | res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2]; |
231 | } else if (i == dev->rom_base_reg) { | 231 | } else if (i == dev->rom_base_reg) { |
232 | res = &dev->resource[PCI_ROM_RESOURCE]; | 232 | res = &dev->resource[PCI_ROM_RESOURCE]; |
233 | flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE; | 233 | flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE |
234 | | IORESOURCE_SIZEALIGN; | ||
234 | } else { | 235 | } else { |
235 | printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i); | 236 | printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i); |
236 | continue; | 237 | continue; |
@@ -284,7 +285,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, | |||
284 | dev->sysdata = node; | 285 | dev->sysdata = node; |
285 | dev->dev.parent = bus->bridge; | 286 | dev->dev.parent = bus->bridge; |
286 | dev->dev.bus = &pci_bus_type; | 287 | dev->dev.bus = &pci_bus_type; |
287 | dev->dev.of_node = node; | 288 | dev->dev.of_node = of_node_get(node); |
288 | dev->devfn = devfn; | 289 | dev->devfn = devfn; |
289 | dev->multifunction = 0; /* maybe a lie? */ | 290 | dev->multifunction = 0; /* maybe a lie? */ |
290 | set_pcie_port_type(dev); | 291 | set_pcie_port_type(dev); |
@@ -820,11 +821,9 @@ static int __pci_mmap_make_offset_bus(struct pci_dev *pdev, struct vm_area_struc | |||
820 | unsigned long space_size, user_offset, user_size; | 821 | unsigned long space_size, user_offset, user_size; |
821 | 822 | ||
822 | if (mmap_state == pci_mmap_io) { | 823 | if (mmap_state == pci_mmap_io) { |
823 | space_size = (pbm->io_space.end - | 824 | space_size = resource_size(&pbm->io_space); |
824 | pbm->io_space.start) + 1; | ||
825 | } else { | 825 | } else { |
826 | space_size = (pbm->mem_space.end - | 826 | space_size = resource_size(&pbm->mem_space); |
827 | pbm->mem_space.start) + 1; | ||
828 | } | 827 | } |
829 | 828 | ||
830 | /* Make sure the request is in range. */ | 829 | /* Make sure the request is in range. */ |
@@ -1021,12 +1020,6 @@ void arch_teardown_msi_irq(unsigned int irq) | |||
1021 | } | 1020 | } |
1022 | #endif /* !(CONFIG_PCI_MSI) */ | 1021 | #endif /* !(CONFIG_PCI_MSI) */ |
1023 | 1022 | ||
1024 | struct device_node *pci_device_to_OF_node(struct pci_dev *pdev) | ||
1025 | { | ||
1026 | return pdev->dev.of_node; | ||
1027 | } | ||
1028 | EXPORT_SYMBOL(pci_device_to_OF_node); | ||
1029 | |||
1030 | static void ali_sound_dma_hack(struct pci_dev *pdev, int set_bit) | 1023 | static void ali_sound_dma_hack(struct pci_dev *pdev, int set_bit) |
1031 | { | 1024 | { |
1032 | struct pci_dev *ali_isa_bridge; | 1025 | struct pci_dev *ali_isa_bridge; |
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index b01a06e9ae4..9e73c4a37ae 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
@@ -848,10 +848,10 @@ static int pci_sun4v_msiq_build_irq(struct pci_pbm_info *pbm, | |||
848 | if (!irq) | 848 | if (!irq) |
849 | return -ENOMEM; | 849 | return -ENOMEM; |
850 | 850 | ||
851 | if (pci_sun4v_msiq_setstate(pbm->devhandle, msiqid, HV_MSIQSTATE_IDLE)) | ||
852 | return -EINVAL; | ||
853 | if (pci_sun4v_msiq_setvalid(pbm->devhandle, msiqid, HV_MSIQ_VALID)) | 851 | if (pci_sun4v_msiq_setvalid(pbm->devhandle, msiqid, HV_MSIQ_VALID)) |
854 | return -EINVAL; | 852 | return -EINVAL; |
853 | if (pci_sun4v_msiq_setstate(pbm->devhandle, msiqid, HV_MSIQSTATE_IDLE)) | ||
854 | return -EINVAL; | ||
855 | 855 | ||
856 | return irq; | 856 | return irq; |
857 | } | 857 | } |
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index 948601a066f..1aaf8c180be 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c | |||
@@ -352,8 +352,8 @@ int __init pcic_probe(void) | |||
352 | strcpy(pbm->prom_name, namebuf); | 352 | strcpy(pbm->prom_name, namebuf); |
353 | 353 | ||
354 | { | 354 | { |
355 | extern volatile int t_nmi[1]; | 355 | extern volatile int t_nmi[4]; |
356 | extern int pcic_nmi_trap_patch[1]; | 356 | extern int pcic_nmi_trap_patch[4]; |
357 | 357 | ||
358 | t_nmi[0] = pcic_nmi_trap_patch[0]; | 358 | t_nmi[0] = pcic_nmi_trap_patch[0]; |
359 | t_nmi[1] = pcic_nmi_trap_patch[1]; | 359 | t_nmi[1] = pcic_nmi_trap_patch[1]; |
@@ -885,14 +885,6 @@ int pcibios_assign_resource(struct pci_dev *pdev, int resource) | |||
885 | return -ENXIO; | 885 | return -ENXIO; |
886 | } | 886 | } |
887 | 887 | ||
888 | struct device_node *pci_device_to_OF_node(struct pci_dev *pdev) | ||
889 | { | ||
890 | struct pcidev_cookie *pc = pdev->sysdata; | ||
891 | |||
892 | return pc->prom_node; | ||
893 | } | ||
894 | EXPORT_SYMBOL(pci_device_to_OF_node); | ||
895 | |||
896 | /* | 888 | /* |
897 | * This probably belongs here rather than ioport.c because | 889 | * This probably belongs here rather than ioport.c because |
898 | * we do not want this crud linked into SBus kernels. | 890 | * we do not want this crud linked into SBus kernels. |
diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c index 8ac23e66008..343b0f9e2e7 100644 --- a/arch/sparc/kernel/pcr.c +++ b/arch/sparc/kernel/pcr.c | |||
@@ -80,8 +80,11 @@ static void n2_pcr_write(u64 val) | |||
80 | { | 80 | { |
81 | unsigned long ret; | 81 | unsigned long ret; |
82 | 82 | ||
83 | ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val); | 83 | if (val & PCR_N2_HTRACE) { |
84 | if (ret != HV_EOK) | 84 | ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val); |
85 | if (ret != HV_EOK) | ||
86 | write_pcr(val); | ||
87 | } else | ||
85 | write_pcr(val); | 88 | write_pcr(val); |
86 | } | 89 | } |
87 | 90 | ||
@@ -106,6 +109,10 @@ static int __init register_perf_hsvc(void) | |||
106 | perf_hsvc_group = HV_GRP_N2_CPU; | 109 | perf_hsvc_group = HV_GRP_N2_CPU; |
107 | break; | 110 | break; |
108 | 111 | ||
112 | case SUN4V_CHIP_NIAGARA3: | ||
113 | perf_hsvc_group = HV_GRP_KT_CPU; | ||
114 | break; | ||
115 | |||
109 | default: | 116 | default: |
110 | return -ENODEV; | 117 | return -ENODEV; |
111 | } | 118 | } |
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c index 2cb0e1c001e..614da624330 100644 --- a/arch/sparc/kernel/perf_event.c +++ b/arch/sparc/kernel/perf_event.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <asm/stacktrace.h> | 22 | #include <asm/stacktrace.h> |
23 | #include <asm/cpudata.h> | 23 | #include <asm/cpudata.h> |
24 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
25 | #include <asm/atomic.h> | 25 | #include <linux/atomic.h> |
26 | #include <asm/nmi.h> | 26 | #include <asm/nmi.h> |
27 | #include <asm/pcr.h> | 27 | #include <asm/pcr.h> |
28 | 28 | ||
@@ -246,6 +246,20 @@ static const cache_map_t ultra3_cache_map = { | |||
246 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | 246 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, |
247 | }, | 247 | }, |
248 | }, | 248 | }, |
249 | [C(NODE)] = { | ||
250 | [C(OP_READ)] = { | ||
251 | [C(RESULT_ACCESS)] = { CACHE_OP_UNSUPPORTED }, | ||
252 | [C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
253 | }, | ||
254 | [ C(OP_WRITE) ] = { | ||
255 | [ C(RESULT_ACCESS) ] = { CACHE_OP_UNSUPPORTED }, | ||
256 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
257 | }, | ||
258 | [ C(OP_PREFETCH) ] = { | ||
259 | [ C(RESULT_ACCESS) ] = { CACHE_OP_UNSUPPORTED }, | ||
260 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
261 | }, | ||
262 | }, | ||
249 | }; | 263 | }; |
250 | 264 | ||
251 | static const struct sparc_pmu ultra3_pmu = { | 265 | static const struct sparc_pmu ultra3_pmu = { |
@@ -361,6 +375,20 @@ static const cache_map_t niagara1_cache_map = { | |||
361 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | 375 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, |
362 | }, | 376 | }, |
363 | }, | 377 | }, |
378 | [C(NODE)] = { | ||
379 | [C(OP_READ)] = { | ||
380 | [C(RESULT_ACCESS)] = { CACHE_OP_UNSUPPORTED }, | ||
381 | [C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
382 | }, | ||
383 | [ C(OP_WRITE) ] = { | ||
384 | [ C(RESULT_ACCESS) ] = { CACHE_OP_UNSUPPORTED }, | ||
385 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
386 | }, | ||
387 | [ C(OP_PREFETCH) ] = { | ||
388 | [ C(RESULT_ACCESS) ] = { CACHE_OP_UNSUPPORTED }, | ||
389 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
390 | }, | ||
391 | }, | ||
364 | }; | 392 | }; |
365 | 393 | ||
366 | static const struct sparc_pmu niagara1_pmu = { | 394 | static const struct sparc_pmu niagara1_pmu = { |
@@ -473,6 +501,20 @@ static const cache_map_t niagara2_cache_map = { | |||
473 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | 501 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, |
474 | }, | 502 | }, |
475 | }, | 503 | }, |
504 | [C(NODE)] = { | ||
505 | [C(OP_READ)] = { | ||
506 | [C(RESULT_ACCESS)] = { CACHE_OP_UNSUPPORTED }, | ||
507 | [C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
508 | }, | ||
509 | [ C(OP_WRITE) ] = { | ||
510 | [ C(RESULT_ACCESS) ] = { CACHE_OP_UNSUPPORTED }, | ||
511 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
512 | }, | ||
513 | [ C(OP_PREFETCH) ] = { | ||
514 | [ C(RESULT_ACCESS) ] = { CACHE_OP_UNSUPPORTED }, | ||
515 | [ C(RESULT_MISS) ] = { CACHE_OP_UNSUPPORTED }, | ||
516 | }, | ||
517 | }, | ||
476 | }; | 518 | }; |
477 | 519 | ||
478 | static const struct sparc_pmu niagara2_pmu = { | 520 | static const struct sparc_pmu niagara2_pmu = { |
@@ -1277,7 +1319,7 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self, | |||
1277 | if (!sparc_perf_event_set_period(event, hwc, idx)) | 1319 | if (!sparc_perf_event_set_period(event, hwc, idx)) |
1278 | continue; | 1320 | continue; |
1279 | 1321 | ||
1280 | if (perf_event_overflow(event, 1, &data, regs)) | 1322 | if (perf_event_overflow(event, &data, regs)) |
1281 | sparc_pmu_stop(event, 0); | 1323 | sparc_pmu_stop(event, 0); |
1282 | } | 1324 | } |
1283 | 1325 | ||
@@ -1301,7 +1343,8 @@ static bool __init supported_pmu(void) | |||
1301 | sparc_pmu = &niagara1_pmu; | 1343 | sparc_pmu = &niagara1_pmu; |
1302 | return true; | 1344 | return true; |
1303 | } | 1345 | } |
1304 | if (!strcmp(sparc_pmu_type, "niagara2")) { | 1346 | if (!strcmp(sparc_pmu_type, "niagara2") || |
1347 | !strcmp(sparc_pmu_type, "niagara3")) { | ||
1305 | sparc_pmu = &niagara2_pmu; | 1348 | sparc_pmu = &niagara2_pmu; |
1306 | return true; | 1349 | return true; |
1307 | } | 1350 | } |
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c index c8cc461ff75..f793742eec2 100644 --- a/arch/sparc/kernel/process_32.c +++ b/arch/sparc/kernel/process_32.c | |||
@@ -380,8 +380,7 @@ void flush_thread(void) | |||
380 | #endif | 380 | #endif |
381 | } | 381 | } |
382 | 382 | ||
383 | /* Now, this task is no longer a kernel thread. */ | 383 | /* This task is no longer a kernel thread. */ |
384 | current->thread.current_ds = USER_DS; | ||
385 | if (current->thread.flags & SPARC_FLAG_KTHREAD) { | 384 | if (current->thread.flags & SPARC_FLAG_KTHREAD) { |
386 | current->thread.flags &= ~SPARC_FLAG_KTHREAD; | 385 | current->thread.flags &= ~SPARC_FLAG_KTHREAD; |
387 | 386 | ||
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c index c158a95ec66..d959cd0a4aa 100644 --- a/arch/sparc/kernel/process_64.c +++ b/arch/sparc/kernel/process_64.c | |||
@@ -368,9 +368,6 @@ void flush_thread(void) | |||
368 | 368 | ||
369 | /* Clear FPU register state. */ | 369 | /* Clear FPU register state. */ |
370 | t->fpsaved[0] = 0; | 370 | t->fpsaved[0] = 0; |
371 | |||
372 | if (get_thread_current_ds() != ASI_AIUS) | ||
373 | set_fs(USER_DS); | ||
374 | } | 371 | } |
375 | 372 | ||
376 | /* It's a bit more tricky when 64-bit tasks are involved... */ | 373 | /* It's a bit more tricky when 64-bit tasks are involved... */ |
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c index d26e1f6c717..3e3e2914c70 100644 --- a/arch/sparc/kernel/setup_32.c +++ b/arch/sparc/kernel/setup_32.c | |||
@@ -137,7 +137,7 @@ static void __init process_switch(char c) | |||
137 | prom_halt(); | 137 | prom_halt(); |
138 | break; | 138 | break; |
139 | case 'p': | 139 | case 'p': |
140 | /* Just ignore, this behavior is now the default. */ | 140 | prom_early_console.flags &= ~CON_BOOT; |
141 | break; | 141 | break; |
142 | default: | 142 | default: |
143 | printk("Unknown boot switch (-%c)\n", c); | 143 | printk("Unknown boot switch (-%c)\n", c); |
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c index c4dd0999da8..a854a1c240f 100644 --- a/arch/sparc/kernel/setup_64.c +++ b/arch/sparc/kernel/setup_64.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/cpu.h> | 30 | #include <linux/cpu.h> |
31 | #include <linux/initrd.h> | 31 | #include <linux/initrd.h> |
32 | #include <linux/module.h> | ||
32 | 33 | ||
33 | #include <asm/system.h> | 34 | #include <asm/system.h> |
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
@@ -46,6 +47,8 @@ | |||
46 | #include <asm/mmu.h> | 47 | #include <asm/mmu.h> |
47 | #include <asm/ns87303.h> | 48 | #include <asm/ns87303.h> |
48 | #include <asm/btext.h> | 49 | #include <asm/btext.h> |
50 | #include <asm/elf.h> | ||
51 | #include <asm/mdesc.h> | ||
49 | 52 | ||
50 | #ifdef CONFIG_IP_PNP | 53 | #ifdef CONFIG_IP_PNP |
51 | #include <net/ipconfig.h> | 54 | #include <net/ipconfig.h> |
@@ -103,7 +106,7 @@ static void __init process_switch(char c) | |||
103 | prom_halt(); | 106 | prom_halt(); |
104 | break; | 107 | break; |
105 | case 'p': | 108 | case 'p': |
106 | /* Just ignore, this behavior is now the default. */ | 109 | prom_early_console.flags &= ~CON_BOOT; |
107 | break; | 110 | break; |
108 | case 'P': | 111 | case 'P': |
109 | /* Force UltraSPARC-III P-Cache on. */ | 112 | /* Force UltraSPARC-III P-Cache on. */ |
@@ -231,44 +234,88 @@ void __init per_cpu_patch(void) | |||
231 | } | 234 | } |
232 | } | 235 | } |
233 | 236 | ||
234 | void __init sun4v_patch(void) | 237 | void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *start, |
238 | struct sun4v_1insn_patch_entry *end) | ||
235 | { | 239 | { |
236 | extern void sun4v_hvapi_init(void); | 240 | while (start < end) { |
237 | struct sun4v_1insn_patch_entry *p1; | 241 | unsigned long addr = start->addr; |
238 | struct sun4v_2insn_patch_entry *p2; | ||
239 | |||
240 | if (tlb_type != hypervisor) | ||
241 | return; | ||
242 | 242 | ||
243 | p1 = &__sun4v_1insn_patch; | 243 | *(unsigned int *) (addr + 0) = start->insn; |
244 | while (p1 < &__sun4v_1insn_patch_end) { | ||
245 | unsigned long addr = p1->addr; | ||
246 | |||
247 | *(unsigned int *) (addr + 0) = p1->insn; | ||
248 | wmb(); | 244 | wmb(); |
249 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); | 245 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
250 | 246 | ||
251 | p1++; | 247 | start++; |
252 | } | 248 | } |
249 | } | ||
253 | 250 | ||
254 | p2 = &__sun4v_2insn_patch; | 251 | void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *start, |
255 | while (p2 < &__sun4v_2insn_patch_end) { | 252 | struct sun4v_2insn_patch_entry *end) |
256 | unsigned long addr = p2->addr; | 253 | { |
254 | while (start < end) { | ||
255 | unsigned long addr = start->addr; | ||
257 | 256 | ||
258 | *(unsigned int *) (addr + 0) = p2->insns[0]; | 257 | *(unsigned int *) (addr + 0) = start->insns[0]; |
259 | wmb(); | 258 | wmb(); |
260 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); | 259 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
261 | 260 | ||
262 | *(unsigned int *) (addr + 4) = p2->insns[1]; | 261 | *(unsigned int *) (addr + 4) = start->insns[1]; |
263 | wmb(); | 262 | wmb(); |
264 | __asm__ __volatile__("flush %0" : : "r" (addr + 4)); | 263 | __asm__ __volatile__("flush %0" : : "r" (addr + 4)); |
265 | 264 | ||
266 | p2++; | 265 | start++; |
267 | } | 266 | } |
267 | } | ||
268 | |||
269 | void __init sun4v_patch(void) | ||
270 | { | ||
271 | extern void sun4v_hvapi_init(void); | ||
272 | |||
273 | if (tlb_type != hypervisor) | ||
274 | return; | ||
275 | |||
276 | sun4v_patch_1insn_range(&__sun4v_1insn_patch, | ||
277 | &__sun4v_1insn_patch_end); | ||
278 | |||
279 | sun4v_patch_2insn_range(&__sun4v_2insn_patch, | ||
280 | &__sun4v_2insn_patch_end); | ||
268 | 281 | ||
269 | sun4v_hvapi_init(); | 282 | sun4v_hvapi_init(); |
270 | } | 283 | } |
271 | 284 | ||
285 | static void __init popc_patch(void) | ||
286 | { | ||
287 | struct popc_3insn_patch_entry *p3; | ||
288 | struct popc_6insn_patch_entry *p6; | ||
289 | |||
290 | p3 = &__popc_3insn_patch; | ||
291 | while (p3 < &__popc_3insn_patch_end) { | ||
292 | unsigned long i, addr = p3->addr; | ||
293 | |||
294 | for (i = 0; i < 3; i++) { | ||
295 | *(unsigned int *) (addr + (i * 4)) = p3->insns[i]; | ||
296 | wmb(); | ||
297 | __asm__ __volatile__("flush %0" | ||
298 | : : "r" (addr + (i * 4))); | ||
299 | } | ||
300 | |||
301 | p3++; | ||
302 | } | ||
303 | |||
304 | p6 = &__popc_6insn_patch; | ||
305 | while (p6 < &__popc_6insn_patch_end) { | ||
306 | unsigned long i, addr = p6->addr; | ||
307 | |||
308 | for (i = 0; i < 6; i++) { | ||
309 | *(unsigned int *) (addr + (i * 4)) = p6->insns[i]; | ||
310 | wmb(); | ||
311 | __asm__ __volatile__("flush %0" | ||
312 | : : "r" (addr + (i * 4))); | ||
313 | } | ||
314 | |||
315 | p6++; | ||
316 | } | ||
317 | } | ||
318 | |||
272 | #ifdef CONFIG_SMP | 319 | #ifdef CONFIG_SMP |
273 | void __init boot_cpu_id_too_large(int cpu) | 320 | void __init boot_cpu_id_too_large(int cpu) |
274 | { | 321 | { |
@@ -278,6 +325,168 @@ void __init boot_cpu_id_too_large(int cpu) | |||
278 | } | 325 | } |
279 | #endif | 326 | #endif |
280 | 327 | ||
328 | /* On Ultra, we support all of the v8 capabilities. */ | ||
329 | unsigned long sparc64_elf_hwcap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | | ||
330 | HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | | ||
331 | HWCAP_SPARC_V9); | ||
332 | EXPORT_SYMBOL(sparc64_elf_hwcap); | ||
333 | |||
334 | static const char *hwcaps[] = { | ||
335 | "flush", "stbar", "swap", "muldiv", "v9", | ||
336 | "ultra3", "blkinit", "n2", | ||
337 | |||
338 | /* These strings are as they appear in the machine description | ||
339 | * 'hwcap-list' property for cpu nodes. | ||
340 | */ | ||
341 | "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2", | ||
342 | "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau", | ||
343 | "ima", "cspare", | ||
344 | }; | ||
345 | |||
346 | void cpucap_info(struct seq_file *m) | ||
347 | { | ||
348 | unsigned long caps = sparc64_elf_hwcap; | ||
349 | int i, printed = 0; | ||
350 | |||
351 | seq_puts(m, "cpucaps\t\t: "); | ||
352 | for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { | ||
353 | unsigned long bit = 1UL << i; | ||
354 | if (caps & bit) { | ||
355 | seq_printf(m, "%s%s", | ||
356 | printed ? "," : "", hwcaps[i]); | ||
357 | printed++; | ||
358 | } | ||
359 | } | ||
360 | seq_putc(m, '\n'); | ||
361 | } | ||
362 | |||
363 | static void __init report_hwcaps(unsigned long caps) | ||
364 | { | ||
365 | int i, printed = 0; | ||
366 | |||
367 | printk(KERN_INFO "CPU CAPS: ["); | ||
368 | for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { | ||
369 | unsigned long bit = 1UL << i; | ||
370 | if (caps & bit) { | ||
371 | printk(KERN_CONT "%s%s", | ||
372 | printed ? "," : "", hwcaps[i]); | ||
373 | if (++printed == 8) { | ||
374 | printk(KERN_CONT "]\n"); | ||
375 | printk(KERN_INFO "CPU CAPS: ["); | ||
376 | printed = 0; | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | printk(KERN_CONT "]\n"); | ||
381 | } | ||
382 | |||
383 | static unsigned long __init mdesc_cpu_hwcap_list(void) | ||
384 | { | ||
385 | struct mdesc_handle *hp; | ||
386 | unsigned long caps = 0; | ||
387 | const char *prop; | ||
388 | int len; | ||
389 | u64 pn; | ||
390 | |||
391 | hp = mdesc_grab(); | ||
392 | if (!hp) | ||
393 | return 0; | ||
394 | |||
395 | pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "cpu"); | ||
396 | if (pn == MDESC_NODE_NULL) | ||
397 | goto out; | ||
398 | |||
399 | prop = mdesc_get_property(hp, pn, "hwcap-list", &len); | ||
400 | if (!prop) | ||
401 | goto out; | ||
402 | |||
403 | while (len) { | ||
404 | int i, plen; | ||
405 | |||
406 | for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { | ||
407 | unsigned long bit = 1UL << i; | ||
408 | |||
409 | if (!strcmp(prop, hwcaps[i])) { | ||
410 | caps |= bit; | ||
411 | break; | ||
412 | } | ||
413 | } | ||
414 | |||
415 | plen = strlen(prop) + 1; | ||
416 | prop += plen; | ||
417 | len -= plen; | ||
418 | } | ||
419 | |||
420 | out: | ||
421 | mdesc_release(hp); | ||
422 | return caps; | ||
423 | } | ||
424 | |||
425 | /* This yields a mask that user programs can use to figure out what | ||
426 | * instruction set this cpu supports. | ||
427 | */ | ||
428 | static void __init init_sparc64_elf_hwcap(void) | ||
429 | { | ||
430 | unsigned long cap = sparc64_elf_hwcap; | ||
431 | unsigned long mdesc_caps; | ||
432 | |||
433 | if (tlb_type == cheetah || tlb_type == cheetah_plus) | ||
434 | cap |= HWCAP_SPARC_ULTRA3; | ||
435 | else if (tlb_type == hypervisor) { | ||
436 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || | ||
437 | sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || | ||
438 | sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || | ||
439 | sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || | ||
440 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5) | ||
441 | cap |= HWCAP_SPARC_BLKINIT; | ||
442 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || | ||
443 | sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || | ||
444 | sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || | ||
445 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5) | ||
446 | cap |= HWCAP_SPARC_N2; | ||
447 | } | ||
448 | |||
449 | cap |= (AV_SPARC_MUL32 | AV_SPARC_DIV32 | AV_SPARC_V8PLUS); | ||
450 | |||
451 | mdesc_caps = mdesc_cpu_hwcap_list(); | ||
452 | if (!mdesc_caps) { | ||
453 | if (tlb_type == spitfire) | ||
454 | cap |= AV_SPARC_VIS; | ||
455 | if (tlb_type == cheetah || tlb_type == cheetah_plus) | ||
456 | cap |= AV_SPARC_VIS | AV_SPARC_VIS2; | ||
457 | if (tlb_type == cheetah_plus) { | ||
458 | unsigned long impl, ver; | ||
459 | |||
460 | __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver)); | ||
461 | impl = ((ver >> 32) & 0xffff); | ||
462 | if (impl == PANTHER_IMPL) | ||
463 | cap |= AV_SPARC_POPC; | ||
464 | } | ||
465 | if (tlb_type == hypervisor) { | ||
466 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1) | ||
467 | cap |= AV_SPARC_ASI_BLK_INIT; | ||
468 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || | ||
469 | sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || | ||
470 | sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || | ||
471 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5) | ||
472 | cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 | | ||
473 | AV_SPARC_ASI_BLK_INIT | | ||
474 | AV_SPARC_POPC); | ||
475 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || | ||
476 | sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || | ||
477 | sun4v_chip_type == SUN4V_CHIP_NIAGARA5) | ||
478 | cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC | | ||
479 | AV_SPARC_FMAF); | ||
480 | } | ||
481 | } | ||
482 | sparc64_elf_hwcap = cap | mdesc_caps; | ||
483 | |||
484 | report_hwcaps(sparc64_elf_hwcap); | ||
485 | |||
486 | if (sparc64_elf_hwcap & AV_SPARC_POPC) | ||
487 | popc_patch(); | ||
488 | } | ||
489 | |||
281 | void __init setup_arch(char **cmdline_p) | 490 | void __init setup_arch(char **cmdline_p) |
282 | { | 491 | { |
283 | /* Initialize PROM console and command line. */ | 492 | /* Initialize PROM console and command line. */ |
@@ -337,6 +546,7 @@ void __init setup_arch(char **cmdline_p) | |||
337 | init_cur_cpu_trap(current_thread_info()); | 546 | init_cur_cpu_trap(current_thread_info()); |
338 | 547 | ||
339 | paging_init(); | 548 | paging_init(); |
549 | init_sparc64_elf_hwcap(); | ||
340 | } | 550 | } |
341 | 551 | ||
342 | extern int stop_a_enabled; | 552 | extern int stop_a_enabled; |
diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c index 75fad425e24..023b8860dc9 100644 --- a/arch/sparc/kernel/signal32.c +++ b/arch/sparc/kernel/signal32.c | |||
@@ -29,6 +29,8 @@ | |||
29 | #include <asm/visasm.h> | 29 | #include <asm/visasm.h> |
30 | #include <asm/compat_signal.h> | 30 | #include <asm/compat_signal.h> |
31 | 31 | ||
32 | #include "sigutil.h" | ||
33 | |||
32 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 34 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
33 | 35 | ||
34 | /* This magic should be in g_upper[0] for all upper parts | 36 | /* This magic should be in g_upper[0] for all upper parts |
@@ -44,14 +46,14 @@ typedef struct { | |||
44 | struct signal_frame32 { | 46 | struct signal_frame32 { |
45 | struct sparc_stackf32 ss; | 47 | struct sparc_stackf32 ss; |
46 | __siginfo32_t info; | 48 | __siginfo32_t info; |
47 | /* __siginfo_fpu32_t * */ u32 fpu_save; | 49 | /* __siginfo_fpu_t * */ u32 fpu_save; |
48 | unsigned int insns[2]; | 50 | unsigned int insns[2]; |
49 | unsigned int extramask[_COMPAT_NSIG_WORDS - 1]; | 51 | unsigned int extramask[_COMPAT_NSIG_WORDS - 1]; |
50 | unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */ | 52 | unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */ |
51 | /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */ | 53 | /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */ |
52 | siginfo_extra_v8plus_t v8plus; | 54 | siginfo_extra_v8plus_t v8plus; |
53 | __siginfo_fpu_t fpu_state; | 55 | /* __siginfo_rwin_t * */u32 rwin_save; |
54 | }; | 56 | } __attribute__((aligned(8))); |
55 | 57 | ||
56 | typedef struct compat_siginfo{ | 58 | typedef struct compat_siginfo{ |
57 | int si_signo; | 59 | int si_signo; |
@@ -110,18 +112,14 @@ struct rt_signal_frame32 { | |||
110 | compat_siginfo_t info; | 112 | compat_siginfo_t info; |
111 | struct pt_regs32 regs; | 113 | struct pt_regs32 regs; |
112 | compat_sigset_t mask; | 114 | compat_sigset_t mask; |
113 | /* __siginfo_fpu32_t * */ u32 fpu_save; | 115 | /* __siginfo_fpu_t * */ u32 fpu_save; |
114 | unsigned int insns[2]; | 116 | unsigned int insns[2]; |
115 | stack_t32 stack; | 117 | stack_t32 stack; |
116 | unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */ | 118 | unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */ |
117 | /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */ | 119 | /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */ |
118 | siginfo_extra_v8plus_t v8plus; | 120 | siginfo_extra_v8plus_t v8plus; |
119 | __siginfo_fpu_t fpu_state; | 121 | /* __siginfo_rwin_t * */u32 rwin_save; |
120 | }; | 122 | } __attribute__((aligned(8))); |
121 | |||
122 | /* Align macros */ | ||
123 | #define SF_ALIGNEDSZ (((sizeof(struct signal_frame32) + 15) & (~15))) | ||
124 | #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 15) & (~15))) | ||
125 | 123 | ||
126 | int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) | 124 | int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) |
127 | { | 125 | { |
@@ -192,30 +190,13 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) | |||
192 | return 0; | 190 | return 0; |
193 | } | 191 | } |
194 | 192 | ||
195 | static int restore_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
196 | { | ||
197 | unsigned long *fpregs = current_thread_info()->fpregs; | ||
198 | unsigned long fprs; | ||
199 | int err; | ||
200 | |||
201 | err = __get_user(fprs, &fpu->si_fprs); | ||
202 | fprs_write(0); | ||
203 | regs->tstate &= ~TSTATE_PEF; | ||
204 | if (fprs & FPRS_DL) | ||
205 | err |= copy_from_user(fpregs, &fpu->si_float_regs[0], (sizeof(unsigned int) * 32)); | ||
206 | if (fprs & FPRS_DU) | ||
207 | err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], (sizeof(unsigned int) * 32)); | ||
208 | err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr); | ||
209 | err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr); | ||
210 | current_thread_info()->fpsaved[0] |= fprs; | ||
211 | return err; | ||
212 | } | ||
213 | |||
214 | void do_sigreturn32(struct pt_regs *regs) | 193 | void do_sigreturn32(struct pt_regs *regs) |
215 | { | 194 | { |
216 | struct signal_frame32 __user *sf; | 195 | struct signal_frame32 __user *sf; |
196 | compat_uptr_t fpu_save; | ||
197 | compat_uptr_t rwin_save; | ||
217 | unsigned int psr; | 198 | unsigned int psr; |
218 | unsigned pc, npc, fpu_save; | 199 | unsigned pc, npc; |
219 | sigset_t set; | 200 | sigset_t set; |
220 | unsigned seta[_COMPAT_NSIG_WORDS]; | 201 | unsigned seta[_COMPAT_NSIG_WORDS]; |
221 | int err, i; | 202 | int err, i; |
@@ -273,8 +254,13 @@ void do_sigreturn32(struct pt_regs *regs) | |||
273 | pt_regs_clear_syscall(regs); | 254 | pt_regs_clear_syscall(regs); |
274 | 255 | ||
275 | err |= __get_user(fpu_save, &sf->fpu_save); | 256 | err |= __get_user(fpu_save, &sf->fpu_save); |
276 | if (fpu_save) | 257 | if (!err && fpu_save) |
277 | err |= restore_fpu_state32(regs, &sf->fpu_state); | 258 | err |= restore_fpu_state(regs, compat_ptr(fpu_save)); |
259 | err |= __get_user(rwin_save, &sf->rwin_save); | ||
260 | if (!err && rwin_save) { | ||
261 | if (restore_rwin_state(compat_ptr(rwin_save))) | ||
262 | goto segv; | ||
263 | } | ||
278 | err |= __get_user(seta[0], &sf->info.si_mask); | 264 | err |= __get_user(seta[0], &sf->info.si_mask); |
279 | err |= copy_from_user(seta+1, &sf->extramask, | 265 | err |= copy_from_user(seta+1, &sf->extramask, |
280 | (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); | 266 | (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); |
@@ -287,10 +273,7 @@ void do_sigreturn32(struct pt_regs *regs) | |||
287 | case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32); | 273 | case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32); |
288 | } | 274 | } |
289 | sigdelsetmask(&set, ~_BLOCKABLE); | 275 | sigdelsetmask(&set, ~_BLOCKABLE); |
290 | spin_lock_irq(¤t->sighand->siglock); | 276 | set_current_blocked(&set); |
291 | current->blocked = set; | ||
292 | recalc_sigpending(); | ||
293 | spin_unlock_irq(¤t->sighand->siglock); | ||
294 | return; | 277 | return; |
295 | 278 | ||
296 | segv: | 279 | segv: |
@@ -300,7 +283,9 @@ segv: | |||
300 | asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) | 283 | asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) |
301 | { | 284 | { |
302 | struct rt_signal_frame32 __user *sf; | 285 | struct rt_signal_frame32 __user *sf; |
303 | unsigned int psr, pc, npc, fpu_save, u_ss_sp; | 286 | unsigned int psr, pc, npc, u_ss_sp; |
287 | compat_uptr_t fpu_save; | ||
288 | compat_uptr_t rwin_save; | ||
304 | mm_segment_t old_fs; | 289 | mm_segment_t old_fs; |
305 | sigset_t set; | 290 | sigset_t set; |
306 | compat_sigset_t seta; | 291 | compat_sigset_t seta; |
@@ -359,8 +344,8 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) | |||
359 | pt_regs_clear_syscall(regs); | 344 | pt_regs_clear_syscall(regs); |
360 | 345 | ||
361 | err |= __get_user(fpu_save, &sf->fpu_save); | 346 | err |= __get_user(fpu_save, &sf->fpu_save); |
362 | if (fpu_save) | 347 | if (!err && fpu_save) |
363 | err |= restore_fpu_state32(regs, &sf->fpu_state); | 348 | err |= restore_fpu_state(regs, compat_ptr(fpu_save)); |
364 | err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t)); | 349 | err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t)); |
365 | err |= __get_user(u_ss_sp, &sf->stack.ss_sp); | 350 | err |= __get_user(u_ss_sp, &sf->stack.ss_sp); |
366 | st.ss_sp = compat_ptr(u_ss_sp); | 351 | st.ss_sp = compat_ptr(u_ss_sp); |
@@ -376,6 +361,12 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) | |||
376 | do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf); | 361 | do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf); |
377 | set_fs(old_fs); | 362 | set_fs(old_fs); |
378 | 363 | ||
364 | err |= __get_user(rwin_save, &sf->rwin_save); | ||
365 | if (!err && rwin_save) { | ||
366 | if (restore_rwin_state(compat_ptr(rwin_save))) | ||
367 | goto segv; | ||
368 | } | ||
369 | |||
379 | switch (_NSIG_WORDS) { | 370 | switch (_NSIG_WORDS) { |
380 | case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32); | 371 | case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32); |
381 | case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32); | 372 | case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32); |
@@ -383,10 +374,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) | |||
383 | case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32); | 374 | case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32); |
384 | } | 375 | } |
385 | sigdelsetmask(&set, ~_BLOCKABLE); | 376 | sigdelsetmask(&set, ~_BLOCKABLE); |
386 | spin_lock_irq(¤t->sighand->siglock); | 377 | set_current_blocked(&set); |
387 | current->blocked = set; | ||
388 | recalc_sigpending(); | ||
389 | spin_unlock_irq(¤t->sighand->siglock); | ||
390 | return; | 378 | return; |
391 | segv: | 379 | segv: |
392 | force_sig(SIGSEGV, current); | 380 | force_sig(SIGSEGV, current); |
@@ -433,26 +421,6 @@ static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, uns | |||
433 | return (void __user *) sp; | 421 | return (void __user *) sp; |
434 | } | 422 | } |
435 | 423 | ||
436 | static int save_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
437 | { | ||
438 | unsigned long *fpregs = current_thread_info()->fpregs; | ||
439 | unsigned long fprs; | ||
440 | int err = 0; | ||
441 | |||
442 | fprs = current_thread_info()->fpsaved[0]; | ||
443 | if (fprs & FPRS_DL) | ||
444 | err |= copy_to_user(&fpu->si_float_regs[0], fpregs, | ||
445 | (sizeof(unsigned int) * 32)); | ||
446 | if (fprs & FPRS_DU) | ||
447 | err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16, | ||
448 | (sizeof(unsigned int) * 32)); | ||
449 | err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr); | ||
450 | err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr); | ||
451 | err |= __put_user(fprs, &fpu->si_fprs); | ||
452 | |||
453 | return err; | ||
454 | } | ||
455 | |||
456 | /* The I-cache flush instruction only works in the primary ASI, which | 424 | /* The I-cache flush instruction only works in the primary ASI, which |
457 | * right now is the nucleus, aka. kernel space. | 425 | * right now is the nucleus, aka. kernel space. |
458 | * | 426 | * |
@@ -515,18 +483,23 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
515 | int signo, sigset_t *oldset) | 483 | int signo, sigset_t *oldset) |
516 | { | 484 | { |
517 | struct signal_frame32 __user *sf; | 485 | struct signal_frame32 __user *sf; |
486 | int i, err, wsaved; | ||
487 | void __user *tail; | ||
518 | int sigframe_size; | 488 | int sigframe_size; |
519 | u32 psr; | 489 | u32 psr; |
520 | int i, err; | ||
521 | unsigned int seta[_COMPAT_NSIG_WORDS]; | 490 | unsigned int seta[_COMPAT_NSIG_WORDS]; |
522 | 491 | ||
523 | /* 1. Make sure everything is clean */ | 492 | /* 1. Make sure everything is clean */ |
524 | synchronize_user_stack(); | 493 | synchronize_user_stack(); |
525 | save_and_clear_fpu(); | 494 | save_and_clear_fpu(); |
526 | 495 | ||
527 | sigframe_size = SF_ALIGNEDSZ; | 496 | wsaved = get_thread_wsaved(); |
528 | if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) | 497 | |
529 | sigframe_size -= sizeof(__siginfo_fpu_t); | 498 | sigframe_size = sizeof(*sf); |
499 | if (current_thread_info()->fpsaved[0] & FPRS_FEF) | ||
500 | sigframe_size += sizeof(__siginfo_fpu_t); | ||
501 | if (wsaved) | ||
502 | sigframe_size += sizeof(__siginfo_rwin_t); | ||
530 | 503 | ||
531 | sf = (struct signal_frame32 __user *) | 504 | sf = (struct signal_frame32 __user *) |
532 | get_sigframe(&ka->sa, regs, sigframe_size); | 505 | get_sigframe(&ka->sa, regs, sigframe_size); |
@@ -534,8 +507,7 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
534 | if (invalid_frame_pointer(sf, sigframe_size)) | 507 | if (invalid_frame_pointer(sf, sigframe_size)) |
535 | goto sigill; | 508 | goto sigill; |
536 | 509 | ||
537 | if (get_thread_wsaved() != 0) | 510 | tail = (sf + 1); |
538 | goto sigill; | ||
539 | 511 | ||
540 | /* 2. Save the current process state */ | 512 | /* 2. Save the current process state */ |
541 | if (test_thread_flag(TIF_32BIT)) { | 513 | if (test_thread_flag(TIF_32BIT)) { |
@@ -560,11 +532,22 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
560 | &sf->v8plus.asi); | 532 | &sf->v8plus.asi); |
561 | 533 | ||
562 | if (psr & PSR_EF) { | 534 | if (psr & PSR_EF) { |
563 | err |= save_fpu_state32(regs, &sf->fpu_state); | 535 | __siginfo_fpu_t __user *fp = tail; |
564 | err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save); | 536 | tail += sizeof(*fp); |
537 | err |= save_fpu_state(regs, fp); | ||
538 | err |= __put_user((u64)fp, &sf->fpu_save); | ||
565 | } else { | 539 | } else { |
566 | err |= __put_user(0, &sf->fpu_save); | 540 | err |= __put_user(0, &sf->fpu_save); |
567 | } | 541 | } |
542 | if (wsaved) { | ||
543 | __siginfo_rwin_t __user *rwp = tail; | ||
544 | tail += sizeof(*rwp); | ||
545 | err |= save_rwin_state(wsaved, rwp); | ||
546 | err |= __put_user((u64)rwp, &sf->rwin_save); | ||
547 | set_thread_wsaved(0); | ||
548 | } else { | ||
549 | err |= __put_user(0, &sf->rwin_save); | ||
550 | } | ||
568 | 551 | ||
569 | switch (_NSIG_WORDS) { | 552 | switch (_NSIG_WORDS) { |
570 | case 4: seta[7] = (oldset->sig[3] >> 32); | 553 | case 4: seta[7] = (oldset->sig[3] >> 32); |
@@ -580,10 +563,21 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
580 | err |= __copy_to_user(sf->extramask, seta + 1, | 563 | err |= __copy_to_user(sf->extramask, seta + 1, |
581 | (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); | 564 | (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); |
582 | 565 | ||
583 | err |= copy_in_user((u32 __user *)sf, | 566 | if (!wsaved) { |
584 | (u32 __user *)(regs->u_regs[UREG_FP]), | 567 | err |= copy_in_user((u32 __user *)sf, |
585 | sizeof(struct reg_window32)); | 568 | (u32 __user *)(regs->u_regs[UREG_FP]), |
586 | 569 | sizeof(struct reg_window32)); | |
570 | } else { | ||
571 | struct reg_window *rp; | ||
572 | |||
573 | rp = ¤t_thread_info()->reg_window[wsaved - 1]; | ||
574 | for (i = 0; i < 8; i++) | ||
575 | err |= __put_user(rp->locals[i], &sf->ss.locals[i]); | ||
576 | for (i = 0; i < 6; i++) | ||
577 | err |= __put_user(rp->ins[i], &sf->ss.ins[i]); | ||
578 | err |= __put_user(rp->ins[6], &sf->ss.fp); | ||
579 | err |= __put_user(rp->ins[7], &sf->ss.callers_pc); | ||
580 | } | ||
587 | if (err) | 581 | if (err) |
588 | goto sigsegv; | 582 | goto sigsegv; |
589 | 583 | ||
@@ -613,7 +607,6 @@ static int setup_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
613 | err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/ | 607 | err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/ |
614 | if (err) | 608 | if (err) |
615 | goto sigsegv; | 609 | goto sigsegv; |
616 | |||
617 | flush_signal_insns(address); | 610 | flush_signal_insns(address); |
618 | } | 611 | } |
619 | return 0; | 612 | return 0; |
@@ -632,18 +625,23 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
632 | siginfo_t *info) | 625 | siginfo_t *info) |
633 | { | 626 | { |
634 | struct rt_signal_frame32 __user *sf; | 627 | struct rt_signal_frame32 __user *sf; |
628 | int i, err, wsaved; | ||
629 | void __user *tail; | ||
635 | int sigframe_size; | 630 | int sigframe_size; |
636 | u32 psr; | 631 | u32 psr; |
637 | int i, err; | ||
638 | compat_sigset_t seta; | 632 | compat_sigset_t seta; |
639 | 633 | ||
640 | /* 1. Make sure everything is clean */ | 634 | /* 1. Make sure everything is clean */ |
641 | synchronize_user_stack(); | 635 | synchronize_user_stack(); |
642 | save_and_clear_fpu(); | 636 | save_and_clear_fpu(); |
643 | 637 | ||
644 | sigframe_size = RT_ALIGNEDSZ; | 638 | wsaved = get_thread_wsaved(); |
645 | if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) | 639 | |
646 | sigframe_size -= sizeof(__siginfo_fpu_t); | 640 | sigframe_size = sizeof(*sf); |
641 | if (current_thread_info()->fpsaved[0] & FPRS_FEF) | ||
642 | sigframe_size += sizeof(__siginfo_fpu_t); | ||
643 | if (wsaved) | ||
644 | sigframe_size += sizeof(__siginfo_rwin_t); | ||
647 | 645 | ||
648 | sf = (struct rt_signal_frame32 __user *) | 646 | sf = (struct rt_signal_frame32 __user *) |
649 | get_sigframe(&ka->sa, regs, sigframe_size); | 647 | get_sigframe(&ka->sa, regs, sigframe_size); |
@@ -651,8 +649,7 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
651 | if (invalid_frame_pointer(sf, sigframe_size)) | 649 | if (invalid_frame_pointer(sf, sigframe_size)) |
652 | goto sigill; | 650 | goto sigill; |
653 | 651 | ||
654 | if (get_thread_wsaved() != 0) | 652 | tail = (sf + 1); |
655 | goto sigill; | ||
656 | 653 | ||
657 | /* 2. Save the current process state */ | 654 | /* 2. Save the current process state */ |
658 | if (test_thread_flag(TIF_32BIT)) { | 655 | if (test_thread_flag(TIF_32BIT)) { |
@@ -677,11 +674,22 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
677 | &sf->v8plus.asi); | 674 | &sf->v8plus.asi); |
678 | 675 | ||
679 | if (psr & PSR_EF) { | 676 | if (psr & PSR_EF) { |
680 | err |= save_fpu_state32(regs, &sf->fpu_state); | 677 | __siginfo_fpu_t __user *fp = tail; |
681 | err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save); | 678 | tail += sizeof(*fp); |
679 | err |= save_fpu_state(regs, fp); | ||
680 | err |= __put_user((u64)fp, &sf->fpu_save); | ||
682 | } else { | 681 | } else { |
683 | err |= __put_user(0, &sf->fpu_save); | 682 | err |= __put_user(0, &sf->fpu_save); |
684 | } | 683 | } |
684 | if (wsaved) { | ||
685 | __siginfo_rwin_t __user *rwp = tail; | ||
686 | tail += sizeof(*rwp); | ||
687 | err |= save_rwin_state(wsaved, rwp); | ||
688 | err |= __put_user((u64)rwp, &sf->rwin_save); | ||
689 | set_thread_wsaved(0); | ||
690 | } else { | ||
691 | err |= __put_user(0, &sf->rwin_save); | ||
692 | } | ||
685 | 693 | ||
686 | /* Update the siginfo structure. */ | 694 | /* Update the siginfo structure. */ |
687 | err |= copy_siginfo_to_user32(&sf->info, info); | 695 | err |= copy_siginfo_to_user32(&sf->info, info); |
@@ -703,9 +711,21 @@ static int setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs, | |||
703 | } | 711 | } |
704 | err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t)); | 712 | err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t)); |
705 | 713 | ||
706 | err |= copy_in_user((u32 __user *)sf, | 714 | if (!wsaved) { |
707 | (u32 __user *)(regs->u_regs[UREG_FP]), | 715 | err |= copy_in_user((u32 __user *)sf, |
708 | sizeof(struct reg_window32)); | 716 | (u32 __user *)(regs->u_regs[UREG_FP]), |
717 | sizeof(struct reg_window32)); | ||
718 | } else { | ||
719 | struct reg_window *rp; | ||
720 | |||
721 | rp = ¤t_thread_info()->reg_window[wsaved - 1]; | ||
722 | for (i = 0; i < 8; i++) | ||
723 | err |= __put_user(rp->locals[i], &sf->ss.locals[i]); | ||
724 | for (i = 0; i < 6; i++) | ||
725 | err |= __put_user(rp->ins[i], &sf->ss.ins[i]); | ||
726 | err |= __put_user(rp->ins[6], &sf->ss.fp); | ||
727 | err |= __put_user(rp->ins[7], &sf->ss.callers_pc); | ||
728 | } | ||
709 | if (err) | 729 | if (err) |
710 | goto sigsegv; | 730 | goto sigsegv; |
711 | 731 | ||
@@ -756,6 +776,7 @@ static inline int handle_signal32(unsigned long signr, struct k_sigaction *ka, | |||
756 | siginfo_t *info, | 776 | siginfo_t *info, |
757 | sigset_t *oldset, struct pt_regs *regs) | 777 | sigset_t *oldset, struct pt_regs *regs) |
758 | { | 778 | { |
779 | sigset_t blocked; | ||
759 | int err; | 780 | int err; |
760 | 781 | ||
761 | if (ka->sa.sa_flags & SA_SIGINFO) | 782 | if (ka->sa.sa_flags & SA_SIGINFO) |
@@ -766,12 +787,10 @@ static inline int handle_signal32(unsigned long signr, struct k_sigaction *ka, | |||
766 | if (err) | 787 | if (err) |
767 | return err; | 788 | return err; |
768 | 789 | ||
769 | spin_lock_irq(¤t->sighand->siglock); | 790 | sigorsets(&blocked, ¤t->blocked, &ka->sa.sa_mask); |
770 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | ||
771 | if (!(ka->sa.sa_flags & SA_NOMASK)) | 791 | if (!(ka->sa.sa_flags & SA_NOMASK)) |
772 | sigaddset(¤t->blocked,signr); | 792 | sigaddset(&blocked, signr); |
773 | recalc_sigpending(); | 793 | set_current_blocked(&blocked); |
774 | spin_unlock_irq(¤t->sighand->siglock); | ||
775 | 794 | ||
776 | tracehook_signal_handler(signr, info, ka, regs, 0); | 795 | tracehook_signal_handler(signr, info, ka, regs, 0); |
777 | 796 | ||
@@ -803,21 +822,23 @@ static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs | |||
803 | * want to handle. Thus you cannot kill init even with a SIGKILL even by | 822 | * want to handle. Thus you cannot kill init even with a SIGKILL even by |
804 | * mistake. | 823 | * mistake. |
805 | */ | 824 | */ |
806 | void do_signal32(sigset_t *oldset, struct pt_regs * regs, | 825 | void do_signal32(sigset_t *oldset, struct pt_regs * regs) |
807 | int restart_syscall, unsigned long orig_i0) | ||
808 | { | 826 | { |
809 | struct k_sigaction ka; | 827 | struct k_sigaction ka; |
828 | unsigned long orig_i0; | ||
829 | int restart_syscall; | ||
810 | siginfo_t info; | 830 | siginfo_t info; |
811 | int signr; | 831 | int signr; |
812 | 832 | ||
813 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 833 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
814 | 834 | ||
815 | /* If the debugger messes with the program counter, it clears | 835 | restart_syscall = 0; |
816 | * the "in syscall" bit, directing us to not perform a syscall | 836 | orig_i0 = 0; |
817 | * restart. | 837 | if (pt_regs_is_syscall(regs) && |
818 | */ | 838 | (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) { |
819 | if (restart_syscall && !pt_regs_is_syscall(regs)) | 839 | restart_syscall = 1; |
820 | restart_syscall = 0; | 840 | orig_i0 = regs->u_regs[UREG_G6]; |
841 | } | ||
821 | 842 | ||
822 | if (signr > 0) { | 843 | if (signr > 0) { |
823 | if (restart_syscall) | 844 | if (restart_syscall) |
@@ -855,7 +876,7 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs, | |||
855 | */ | 876 | */ |
856 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { | 877 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { |
857 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | 878 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; |
858 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | 879 | set_current_blocked(¤t->saved_sigmask); |
859 | } | 880 | } |
860 | } | 881 | } |
861 | 882 | ||
diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c index 5e5c5fd0378..d54c6e53aba 100644 --- a/arch/sparc/kernel/signal_32.c +++ b/arch/sparc/kernel/signal_32.c | |||
@@ -26,6 +26,8 @@ | |||
26 | #include <asm/pgtable.h> | 26 | #include <asm/pgtable.h> |
27 | #include <asm/cacheflush.h> /* flush_sig_insns */ | 27 | #include <asm/cacheflush.h> /* flush_sig_insns */ |
28 | 28 | ||
29 | #include "sigutil.h" | ||
30 | |||
29 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 31 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
30 | 32 | ||
31 | extern void fpsave(unsigned long *fpregs, unsigned long *fsr, | 33 | extern void fpsave(unsigned long *fpregs, unsigned long *fsr, |
@@ -39,8 +41,8 @@ struct signal_frame { | |||
39 | unsigned long insns[2] __attribute__ ((aligned (8))); | 41 | unsigned long insns[2] __attribute__ ((aligned (8))); |
40 | unsigned int extramask[_NSIG_WORDS - 1]; | 42 | unsigned int extramask[_NSIG_WORDS - 1]; |
41 | unsigned int extra_size; /* Should be 0 */ | 43 | unsigned int extra_size; /* Should be 0 */ |
42 | __siginfo_fpu_t fpu_state; | 44 | __siginfo_rwin_t __user *rwin_save; |
43 | }; | 45 | } __attribute__((aligned(8))); |
44 | 46 | ||
45 | struct rt_signal_frame { | 47 | struct rt_signal_frame { |
46 | struct sparc_stackf ss; | 48 | struct sparc_stackf ss; |
@@ -51,8 +53,8 @@ struct rt_signal_frame { | |||
51 | unsigned int insns[2]; | 53 | unsigned int insns[2]; |
52 | stack_t stack; | 54 | stack_t stack; |
53 | unsigned int extra_size; /* Should be 0 */ | 55 | unsigned int extra_size; /* Should be 0 */ |
54 | __siginfo_fpu_t fpu_state; | 56 | __siginfo_rwin_t __user *rwin_save; |
55 | }; | 57 | } __attribute__((aligned(8))); |
56 | 58 | ||
57 | /* Align macros */ | 59 | /* Align macros */ |
58 | #define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7))) | 60 | #define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7))) |
@@ -60,12 +62,13 @@ struct rt_signal_frame { | |||
60 | 62 | ||
61 | static int _sigpause_common(old_sigset_t set) | 63 | static int _sigpause_common(old_sigset_t set) |
62 | { | 64 | { |
63 | set &= _BLOCKABLE; | 65 | sigset_t blocked; |
64 | spin_lock_irq(¤t->sighand->siglock); | 66 | |
65 | current->saved_sigmask = current->blocked; | 67 | current->saved_sigmask = current->blocked; |
66 | siginitset(¤t->blocked, set); | 68 | |
67 | recalc_sigpending(); | 69 | set &= _BLOCKABLE; |
68 | spin_unlock_irq(¤t->sighand->siglock); | 70 | siginitset(&blocked, set); |
71 | set_current_blocked(&blocked); | ||
69 | 72 | ||
70 | current->state = TASK_INTERRUPTIBLE; | 73 | current->state = TASK_INTERRUPTIBLE; |
71 | schedule(); | 74 | schedule(); |
@@ -79,43 +82,13 @@ asmlinkage int sys_sigsuspend(old_sigset_t set) | |||
79 | return _sigpause_common(set); | 82 | return _sigpause_common(set); |
80 | } | 83 | } |
81 | 84 | ||
82 | static inline int | ||
83 | restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
84 | { | ||
85 | int err; | ||
86 | #ifdef CONFIG_SMP | ||
87 | if (test_tsk_thread_flag(current, TIF_USEDFPU)) | ||
88 | regs->psr &= ~PSR_EF; | ||
89 | #else | ||
90 | if (current == last_task_used_math) { | ||
91 | last_task_used_math = NULL; | ||
92 | regs->psr &= ~PSR_EF; | ||
93 | } | ||
94 | #endif | ||
95 | set_used_math(); | ||
96 | clear_tsk_thread_flag(current, TIF_USEDFPU); | ||
97 | |||
98 | if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu))) | ||
99 | return -EFAULT; | ||
100 | |||
101 | err = __copy_from_user(¤t->thread.float_regs[0], &fpu->si_float_regs[0], | ||
102 | (sizeof(unsigned long) * 32)); | ||
103 | err |= __get_user(current->thread.fsr, &fpu->si_fsr); | ||
104 | err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth); | ||
105 | if (current->thread.fpqdepth != 0) | ||
106 | err |= __copy_from_user(¤t->thread.fpqueue[0], | ||
107 | &fpu->si_fpqueue[0], | ||
108 | ((sizeof(unsigned long) + | ||
109 | (sizeof(unsigned long *)))*16)); | ||
110 | return err; | ||
111 | } | ||
112 | |||
113 | asmlinkage void do_sigreturn(struct pt_regs *regs) | 85 | asmlinkage void do_sigreturn(struct pt_regs *regs) |
114 | { | 86 | { |
115 | struct signal_frame __user *sf; | 87 | struct signal_frame __user *sf; |
116 | unsigned long up_psr, pc, npc; | 88 | unsigned long up_psr, pc, npc; |
117 | sigset_t set; | 89 | sigset_t set; |
118 | __siginfo_fpu_t __user *fpu_save; | 90 | __siginfo_fpu_t __user *fpu_save; |
91 | __siginfo_rwin_t __user *rwin_save; | ||
119 | int err; | 92 | int err; |
120 | 93 | ||
121 | /* Always make any pending restarted system calls return -EINTR */ | 94 | /* Always make any pending restarted system calls return -EINTR */ |
@@ -150,9 +123,11 @@ asmlinkage void do_sigreturn(struct pt_regs *regs) | |||
150 | pt_regs_clear_syscall(regs); | 123 | pt_regs_clear_syscall(regs); |
151 | 124 | ||
152 | err |= __get_user(fpu_save, &sf->fpu_save); | 125 | err |= __get_user(fpu_save, &sf->fpu_save); |
153 | |||
154 | if (fpu_save) | 126 | if (fpu_save) |
155 | err |= restore_fpu_state(regs, fpu_save); | 127 | err |= restore_fpu_state(regs, fpu_save); |
128 | err |= __get_user(rwin_save, &sf->rwin_save); | ||
129 | if (rwin_save) | ||
130 | err |= restore_rwin_state(rwin_save); | ||
156 | 131 | ||
157 | /* This is pretty much atomic, no amount locking would prevent | 132 | /* This is pretty much atomic, no amount locking would prevent |
158 | * the races which exist anyways. | 133 | * the races which exist anyways. |
@@ -165,10 +140,7 @@ asmlinkage void do_sigreturn(struct pt_regs *regs) | |||
165 | goto segv_and_exit; | 140 | goto segv_and_exit; |
166 | 141 | ||
167 | sigdelsetmask(&set, ~_BLOCKABLE); | 142 | sigdelsetmask(&set, ~_BLOCKABLE); |
168 | spin_lock_irq(¤t->sighand->siglock); | 143 | set_current_blocked(&set); |
169 | current->blocked = set; | ||
170 | recalc_sigpending(); | ||
171 | spin_unlock_irq(¤t->sighand->siglock); | ||
172 | return; | 144 | return; |
173 | 145 | ||
174 | segv_and_exit: | 146 | segv_and_exit: |
@@ -180,6 +152,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) | |||
180 | struct rt_signal_frame __user *sf; | 152 | struct rt_signal_frame __user *sf; |
181 | unsigned int psr, pc, npc; | 153 | unsigned int psr, pc, npc; |
182 | __siginfo_fpu_t __user *fpu_save; | 154 | __siginfo_fpu_t __user *fpu_save; |
155 | __siginfo_rwin_t __user *rwin_save; | ||
183 | mm_segment_t old_fs; | 156 | mm_segment_t old_fs; |
184 | sigset_t set; | 157 | sigset_t set; |
185 | stack_t st; | 158 | stack_t st; |
@@ -207,8 +180,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) | |||
207 | pt_regs_clear_syscall(regs); | 180 | pt_regs_clear_syscall(regs); |
208 | 181 | ||
209 | err |= __get_user(fpu_save, &sf->fpu_save); | 182 | err |= __get_user(fpu_save, &sf->fpu_save); |
210 | 183 | if (!err && fpu_save) | |
211 | if (fpu_save) | ||
212 | err |= restore_fpu_state(regs, fpu_save); | 184 | err |= restore_fpu_state(regs, fpu_save); |
213 | err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); | 185 | err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); |
214 | 186 | ||
@@ -228,11 +200,14 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) | |||
228 | do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf); | 200 | do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf); |
229 | set_fs(old_fs); | 201 | set_fs(old_fs); |
230 | 202 | ||
203 | err |= __get_user(rwin_save, &sf->rwin_save); | ||
204 | if (!err && rwin_save) { | ||
205 | if (restore_rwin_state(rwin_save)) | ||
206 | goto segv; | ||
207 | } | ||
208 | |||
231 | sigdelsetmask(&set, ~_BLOCKABLE); | 209 | sigdelsetmask(&set, ~_BLOCKABLE); |
232 | spin_lock_irq(¤t->sighand->siglock); | 210 | set_current_blocked(&set); |
233 | current->blocked = set; | ||
234 | recalc_sigpending(); | ||
235 | spin_unlock_irq(¤t->sighand->siglock); | ||
236 | return; | 211 | return; |
237 | segv: | 212 | segv: |
238 | force_sig(SIGSEGV, current); | 213 | force_sig(SIGSEGV, current); |
@@ -280,53 +255,23 @@ static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *re | |||
280 | return (void __user *) sp; | 255 | return (void __user *) sp; |
281 | } | 256 | } |
282 | 257 | ||
283 | static inline int | ||
284 | save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
285 | { | ||
286 | int err = 0; | ||
287 | #ifdef CONFIG_SMP | ||
288 | if (test_tsk_thread_flag(current, TIF_USEDFPU)) { | ||
289 | put_psr(get_psr() | PSR_EF); | ||
290 | fpsave(¤t->thread.float_regs[0], ¤t->thread.fsr, | ||
291 | ¤t->thread.fpqueue[0], ¤t->thread.fpqdepth); | ||
292 | regs->psr &= ~(PSR_EF); | ||
293 | clear_tsk_thread_flag(current, TIF_USEDFPU); | ||
294 | } | ||
295 | #else | ||
296 | if (current == last_task_used_math) { | ||
297 | put_psr(get_psr() | PSR_EF); | ||
298 | fpsave(¤t->thread.float_regs[0], ¤t->thread.fsr, | ||
299 | ¤t->thread.fpqueue[0], ¤t->thread.fpqdepth); | ||
300 | last_task_used_math = NULL; | ||
301 | regs->psr &= ~(PSR_EF); | ||
302 | } | ||
303 | #endif | ||
304 | err |= __copy_to_user(&fpu->si_float_regs[0], | ||
305 | ¤t->thread.float_regs[0], | ||
306 | (sizeof(unsigned long) * 32)); | ||
307 | err |= __put_user(current->thread.fsr, &fpu->si_fsr); | ||
308 | err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth); | ||
309 | if (current->thread.fpqdepth != 0) | ||
310 | err |= __copy_to_user(&fpu->si_fpqueue[0], | ||
311 | ¤t->thread.fpqueue[0], | ||
312 | ((sizeof(unsigned long) + | ||
313 | (sizeof(unsigned long *)))*16)); | ||
314 | clear_used_math(); | ||
315 | return err; | ||
316 | } | ||
317 | |||
318 | static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs, | 258 | static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs, |
319 | int signo, sigset_t *oldset) | 259 | int signo, sigset_t *oldset) |
320 | { | 260 | { |
321 | struct signal_frame __user *sf; | 261 | struct signal_frame __user *sf; |
322 | int sigframe_size, err; | 262 | int sigframe_size, err, wsaved; |
263 | void __user *tail; | ||
323 | 264 | ||
324 | /* 1. Make sure everything is clean */ | 265 | /* 1. Make sure everything is clean */ |
325 | synchronize_user_stack(); | 266 | synchronize_user_stack(); |
326 | 267 | ||
327 | sigframe_size = SF_ALIGNEDSZ; | 268 | wsaved = current_thread_info()->w_saved; |
328 | if (!used_math()) | 269 | |
329 | sigframe_size -= sizeof(__siginfo_fpu_t); | 270 | sigframe_size = sizeof(*sf); |
271 | if (used_math()) | ||
272 | sigframe_size += sizeof(__siginfo_fpu_t); | ||
273 | if (wsaved) | ||
274 | sigframe_size += sizeof(__siginfo_rwin_t); | ||
330 | 275 | ||
331 | sf = (struct signal_frame __user *) | 276 | sf = (struct signal_frame __user *) |
332 | get_sigframe(&ka->sa, regs, sigframe_size); | 277 | get_sigframe(&ka->sa, regs, sigframe_size); |
@@ -334,8 +279,7 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
334 | if (invalid_frame_pointer(sf, sigframe_size)) | 279 | if (invalid_frame_pointer(sf, sigframe_size)) |
335 | goto sigill_and_return; | 280 | goto sigill_and_return; |
336 | 281 | ||
337 | if (current_thread_info()->w_saved != 0) | 282 | tail = sf + 1; |
338 | goto sigill_and_return; | ||
339 | 283 | ||
340 | /* 2. Save the current process state */ | 284 | /* 2. Save the current process state */ |
341 | err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs)); | 285 | err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs)); |
@@ -343,17 +287,34 @@ static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
343 | err |= __put_user(0, &sf->extra_size); | 287 | err |= __put_user(0, &sf->extra_size); |
344 | 288 | ||
345 | if (used_math()) { | 289 | if (used_math()) { |
346 | err |= save_fpu_state(regs, &sf->fpu_state); | 290 | __siginfo_fpu_t __user *fp = tail; |
347 | err |= __put_user(&sf->fpu_state, &sf->fpu_save); | 291 | tail += sizeof(*fp); |
292 | err |= save_fpu_state(regs, fp); | ||
293 | err |= __put_user(fp, &sf->fpu_save); | ||
348 | } else { | 294 | } else { |
349 | err |= __put_user(0, &sf->fpu_save); | 295 | err |= __put_user(0, &sf->fpu_save); |
350 | } | 296 | } |
297 | if (wsaved) { | ||
298 | __siginfo_rwin_t __user *rwp = tail; | ||
299 | tail += sizeof(*rwp); | ||
300 | err |= save_rwin_state(wsaved, rwp); | ||
301 | err |= __put_user(rwp, &sf->rwin_save); | ||
302 | } else { | ||
303 | err |= __put_user(0, &sf->rwin_save); | ||
304 | } | ||
351 | 305 | ||
352 | err |= __put_user(oldset->sig[0], &sf->info.si_mask); | 306 | err |= __put_user(oldset->sig[0], &sf->info.si_mask); |
353 | err |= __copy_to_user(sf->extramask, &oldset->sig[1], | 307 | err |= __copy_to_user(sf->extramask, &oldset->sig[1], |
354 | (_NSIG_WORDS - 1) * sizeof(unsigned int)); | 308 | (_NSIG_WORDS - 1) * sizeof(unsigned int)); |
355 | err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], | 309 | if (!wsaved) { |
356 | sizeof(struct reg_window32)); | 310 | err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], |
311 | sizeof(struct reg_window32)); | ||
312 | } else { | ||
313 | struct reg_window32 *rp; | ||
314 | |||
315 | rp = ¤t_thread_info()->reg_window[wsaved - 1]; | ||
316 | err |= __copy_to_user(sf, rp, sizeof(struct reg_window32)); | ||
317 | } | ||
357 | if (err) | 318 | if (err) |
358 | goto sigsegv; | 319 | goto sigsegv; |
359 | 320 | ||
@@ -399,21 +360,24 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
399 | int signo, sigset_t *oldset, siginfo_t *info) | 360 | int signo, sigset_t *oldset, siginfo_t *info) |
400 | { | 361 | { |
401 | struct rt_signal_frame __user *sf; | 362 | struct rt_signal_frame __user *sf; |
402 | int sigframe_size; | 363 | int sigframe_size, wsaved; |
364 | void __user *tail; | ||
403 | unsigned int psr; | 365 | unsigned int psr; |
404 | int err; | 366 | int err; |
405 | 367 | ||
406 | synchronize_user_stack(); | 368 | synchronize_user_stack(); |
407 | sigframe_size = RT_ALIGNEDSZ; | 369 | wsaved = current_thread_info()->w_saved; |
408 | if (!used_math()) | 370 | sigframe_size = sizeof(*sf); |
409 | sigframe_size -= sizeof(__siginfo_fpu_t); | 371 | if (used_math()) |
372 | sigframe_size += sizeof(__siginfo_fpu_t); | ||
373 | if (wsaved) | ||
374 | sigframe_size += sizeof(__siginfo_rwin_t); | ||
410 | sf = (struct rt_signal_frame __user *) | 375 | sf = (struct rt_signal_frame __user *) |
411 | get_sigframe(&ka->sa, regs, sigframe_size); | 376 | get_sigframe(&ka->sa, regs, sigframe_size); |
412 | if (invalid_frame_pointer(sf, sigframe_size)) | 377 | if (invalid_frame_pointer(sf, sigframe_size)) |
413 | goto sigill; | 378 | goto sigill; |
414 | if (current_thread_info()->w_saved != 0) | ||
415 | goto sigill; | ||
416 | 379 | ||
380 | tail = sf + 1; | ||
417 | err = __put_user(regs->pc, &sf->regs.pc); | 381 | err = __put_user(regs->pc, &sf->regs.pc); |
418 | err |= __put_user(regs->npc, &sf->regs.npc); | 382 | err |= __put_user(regs->npc, &sf->regs.npc); |
419 | err |= __put_user(regs->y, &sf->regs.y); | 383 | err |= __put_user(regs->y, &sf->regs.y); |
@@ -425,11 +389,21 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
425 | err |= __put_user(0, &sf->extra_size); | 389 | err |= __put_user(0, &sf->extra_size); |
426 | 390 | ||
427 | if (psr & PSR_EF) { | 391 | if (psr & PSR_EF) { |
428 | err |= save_fpu_state(regs, &sf->fpu_state); | 392 | __siginfo_fpu_t *fp = tail; |
429 | err |= __put_user(&sf->fpu_state, &sf->fpu_save); | 393 | tail += sizeof(*fp); |
394 | err |= save_fpu_state(regs, fp); | ||
395 | err |= __put_user(fp, &sf->fpu_save); | ||
430 | } else { | 396 | } else { |
431 | err |= __put_user(0, &sf->fpu_save); | 397 | err |= __put_user(0, &sf->fpu_save); |
432 | } | 398 | } |
399 | if (wsaved) { | ||
400 | __siginfo_rwin_t *rwp = tail; | ||
401 | tail += sizeof(*rwp); | ||
402 | err |= save_rwin_state(wsaved, rwp); | ||
403 | err |= __put_user(rwp, &sf->rwin_save); | ||
404 | } else { | ||
405 | err |= __put_user(0, &sf->rwin_save); | ||
406 | } | ||
433 | err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t)); | 407 | err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t)); |
434 | 408 | ||
435 | /* Setup sigaltstack */ | 409 | /* Setup sigaltstack */ |
@@ -437,8 +411,15 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
437 | err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags); | 411 | err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags); |
438 | err |= __put_user(current->sas_ss_size, &sf->stack.ss_size); | 412 | err |= __put_user(current->sas_ss_size, &sf->stack.ss_size); |
439 | 413 | ||
440 | err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], | 414 | if (!wsaved) { |
441 | sizeof(struct reg_window32)); | 415 | err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], |
416 | sizeof(struct reg_window32)); | ||
417 | } else { | ||
418 | struct reg_window32 *rp; | ||
419 | |||
420 | rp = ¤t_thread_info()->reg_window[wsaved - 1]; | ||
421 | err |= __copy_to_user(sf, rp, sizeof(struct reg_window32)); | ||
422 | } | ||
442 | 423 | ||
443 | err |= copy_siginfo_to_user(&sf->info, info); | 424 | err |= copy_siginfo_to_user(&sf->info, info); |
444 | 425 | ||
@@ -484,6 +465,7 @@ static inline int | |||
484 | handle_signal(unsigned long signr, struct k_sigaction *ka, | 465 | handle_signal(unsigned long signr, struct k_sigaction *ka, |
485 | siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) | 466 | siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) |
486 | { | 467 | { |
468 | sigset_t blocked; | ||
487 | int err; | 469 | int err; |
488 | 470 | ||
489 | if (ka->sa.sa_flags & SA_SIGINFO) | 471 | if (ka->sa.sa_flags & SA_SIGINFO) |
@@ -494,12 +476,10 @@ handle_signal(unsigned long signr, struct k_sigaction *ka, | |||
494 | if (err) | 476 | if (err) |
495 | return err; | 477 | return err; |
496 | 478 | ||
497 | spin_lock_irq(¤t->sighand->siglock); | 479 | sigorsets(&blocked, ¤t->blocked, &ka->sa.sa_mask); |
498 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | ||
499 | if (!(ka->sa.sa_flags & SA_NOMASK)) | 480 | if (!(ka->sa.sa_flags & SA_NOMASK)) |
500 | sigaddset(¤t->blocked, signr); | 481 | sigaddset(&blocked, signr); |
501 | recalc_sigpending(); | 482 | set_current_blocked(&blocked); |
502 | spin_unlock_irq(¤t->sighand->siglock); | ||
503 | 483 | ||
504 | tracehook_signal_handler(signr, info, ka, regs, 0); | 484 | tracehook_signal_handler(signr, info, ka, regs, 0); |
505 | 485 | ||
@@ -539,10 +519,26 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
539 | siginfo_t info; | 519 | siginfo_t info; |
540 | int signr; | 520 | int signr; |
541 | 521 | ||
522 | /* It's a lot of work and synchronization to add a new ptrace | ||
523 | * register for GDB to save and restore in order to get | ||
524 | * orig_i0 correct for syscall restarts when debugging. | ||
525 | * | ||
526 | * Although it should be the case that most of the global | ||
527 | * registers are volatile across a system call, glibc already | ||
528 | * depends upon that fact that we preserve them. So we can't | ||
529 | * just use any global register to save away the orig_i0 value. | ||
530 | * | ||
531 | * In particular %g2, %g3, %g4, and %g5 are all assumed to be | ||
532 | * preserved across a system call trap by various pieces of | ||
533 | * code in glibc. | ||
534 | * | ||
535 | * %g7 is used as the "thread register". %g6 is not used in | ||
536 | * any fixed manner. %g6 is used as a scratch register and | ||
537 | * a compiler temporary, but it's value is never used across | ||
538 | * a system call. Therefore %g6 is usable for orig_i0 storage. | ||
539 | */ | ||
542 | if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C)) | 540 | if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C)) |
543 | restart_syscall = 1; | 541 | regs->u_regs[UREG_G6] = orig_i0; |
544 | else | ||
545 | restart_syscall = 0; | ||
546 | 542 | ||
547 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | 543 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
548 | oldset = ¤t->saved_sigmask; | 544 | oldset = ¤t->saved_sigmask; |
@@ -555,8 +551,12 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
555 | * the software "in syscall" bit, directing us to not perform | 551 | * the software "in syscall" bit, directing us to not perform |
556 | * a syscall restart. | 552 | * a syscall restart. |
557 | */ | 553 | */ |
558 | if (restart_syscall && !pt_regs_is_syscall(regs)) | 554 | restart_syscall = 0; |
559 | restart_syscall = 0; | 555 | if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C)) { |
556 | restart_syscall = 1; | ||
557 | orig_i0 = regs->u_regs[UREG_G6]; | ||
558 | } | ||
559 | |||
560 | 560 | ||
561 | if (signr > 0) { | 561 | if (signr > 0) { |
562 | if (restart_syscall) | 562 | if (restart_syscall) |
@@ -595,7 +595,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
595 | */ | 595 | */ |
596 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) { | 596 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) { |
597 | clear_thread_flag(TIF_RESTORE_SIGMASK); | 597 | clear_thread_flag(TIF_RESTORE_SIGMASK); |
598 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | 598 | set_current_blocked(¤t->saved_sigmask); |
599 | } | 599 | } |
600 | } | 600 | } |
601 | 601 | ||
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c index 006fe451588..f0836cd0e2f 100644 --- a/arch/sparc/kernel/signal_64.c +++ b/arch/sparc/kernel/signal_64.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include "entry.h" | 35 | #include "entry.h" |
36 | #include "systbls.h" | 36 | #include "systbls.h" |
37 | #include "sigutil.h" | ||
37 | 38 | ||
38 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 39 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
39 | 40 | ||
@@ -69,10 +70,7 @@ asmlinkage void sparc64_set_context(struct pt_regs *regs) | |||
69 | goto do_sigsegv; | 70 | goto do_sigsegv; |
70 | } | 71 | } |
71 | sigdelsetmask(&set, ~_BLOCKABLE); | 72 | sigdelsetmask(&set, ~_BLOCKABLE); |
72 | spin_lock_irq(¤t->sighand->siglock); | 73 | set_current_blocked(&set); |
73 | current->blocked = set; | ||
74 | recalc_sigpending(); | ||
75 | spin_unlock_irq(¤t->sighand->siglock); | ||
76 | } | 74 | } |
77 | if (test_thread_flag(TIF_32BIT)) { | 75 | if (test_thread_flag(TIF_32BIT)) { |
78 | pc &= 0xffffffff; | 76 | pc &= 0xffffffff; |
@@ -236,17 +234,18 @@ struct rt_signal_frame { | |||
236 | __siginfo_fpu_t __user *fpu_save; | 234 | __siginfo_fpu_t __user *fpu_save; |
237 | stack_t stack; | 235 | stack_t stack; |
238 | sigset_t mask; | 236 | sigset_t mask; |
239 | __siginfo_fpu_t fpu_state; | 237 | __siginfo_rwin_t *rwin_save; |
240 | }; | 238 | }; |
241 | 239 | ||
242 | static long _sigpause_common(old_sigset_t set) | 240 | static long _sigpause_common(old_sigset_t set) |
243 | { | 241 | { |
244 | set &= _BLOCKABLE; | 242 | sigset_t blocked; |
245 | spin_lock_irq(¤t->sighand->siglock); | 243 | |
246 | current->saved_sigmask = current->blocked; | 244 | current->saved_sigmask = current->blocked; |
247 | siginitset(¤t->blocked, set); | 245 | |
248 | recalc_sigpending(); | 246 | set &= _BLOCKABLE; |
249 | spin_unlock_irq(¤t->sighand->siglock); | 247 | siginitset(&blocked, set); |
248 | set_current_blocked(&blocked); | ||
250 | 249 | ||
251 | current->state = TASK_INTERRUPTIBLE; | 250 | current->state = TASK_INTERRUPTIBLE; |
252 | schedule(); | 251 | schedule(); |
@@ -266,33 +265,12 @@ asmlinkage long sys_sigsuspend(old_sigset_t set) | |||
266 | return _sigpause_common(set); | 265 | return _sigpause_common(set); |
267 | } | 266 | } |
268 | 267 | ||
269 | static inline int | ||
270 | restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
271 | { | ||
272 | unsigned long *fpregs = current_thread_info()->fpregs; | ||
273 | unsigned long fprs; | ||
274 | int err; | ||
275 | |||
276 | err = __get_user(fprs, &fpu->si_fprs); | ||
277 | fprs_write(0); | ||
278 | regs->tstate &= ~TSTATE_PEF; | ||
279 | if (fprs & FPRS_DL) | ||
280 | err |= copy_from_user(fpregs, &fpu->si_float_regs[0], | ||
281 | (sizeof(unsigned int) * 32)); | ||
282 | if (fprs & FPRS_DU) | ||
283 | err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], | ||
284 | (sizeof(unsigned int) * 32)); | ||
285 | err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr); | ||
286 | err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr); | ||
287 | current_thread_info()->fpsaved[0] |= fprs; | ||
288 | return err; | ||
289 | } | ||
290 | |||
291 | void do_rt_sigreturn(struct pt_regs *regs) | 268 | void do_rt_sigreturn(struct pt_regs *regs) |
292 | { | 269 | { |
293 | struct rt_signal_frame __user *sf; | 270 | struct rt_signal_frame __user *sf; |
294 | unsigned long tpc, tnpc, tstate; | 271 | unsigned long tpc, tnpc, tstate; |
295 | __siginfo_fpu_t __user *fpu_save; | 272 | __siginfo_fpu_t __user *fpu_save; |
273 | __siginfo_rwin_t __user *rwin_save; | ||
296 | sigset_t set; | 274 | sigset_t set; |
297 | int err; | 275 | int err; |
298 | 276 | ||
@@ -325,8 +303,8 @@ void do_rt_sigreturn(struct pt_regs *regs) | |||
325 | regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC)); | 303 | regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC)); |
326 | 304 | ||
327 | err |= __get_user(fpu_save, &sf->fpu_save); | 305 | err |= __get_user(fpu_save, &sf->fpu_save); |
328 | if (fpu_save) | 306 | if (!err && fpu_save) |
329 | err |= restore_fpu_state(regs, &sf->fpu_state); | 307 | err |= restore_fpu_state(regs, fpu_save); |
330 | 308 | ||
331 | err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); | 309 | err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); |
332 | err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf); | 310 | err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf); |
@@ -334,6 +312,12 @@ void do_rt_sigreturn(struct pt_regs *regs) | |||
334 | if (err) | 312 | if (err) |
335 | goto segv; | 313 | goto segv; |
336 | 314 | ||
315 | err |= __get_user(rwin_save, &sf->rwin_save); | ||
316 | if (!err && rwin_save) { | ||
317 | if (restore_rwin_state(rwin_save)) | ||
318 | goto segv; | ||
319 | } | ||
320 | |||
337 | regs->tpc = tpc; | 321 | regs->tpc = tpc; |
338 | regs->tnpc = tnpc; | 322 | regs->tnpc = tnpc; |
339 | 323 | ||
@@ -341,44 +325,20 @@ void do_rt_sigreturn(struct pt_regs *regs) | |||
341 | pt_regs_clear_syscall(regs); | 325 | pt_regs_clear_syscall(regs); |
342 | 326 | ||
343 | sigdelsetmask(&set, ~_BLOCKABLE); | 327 | sigdelsetmask(&set, ~_BLOCKABLE); |
344 | spin_lock_irq(¤t->sighand->siglock); | 328 | set_current_blocked(&set); |
345 | current->blocked = set; | ||
346 | recalc_sigpending(); | ||
347 | spin_unlock_irq(¤t->sighand->siglock); | ||
348 | return; | 329 | return; |
349 | segv: | 330 | segv: |
350 | force_sig(SIGSEGV, current); | 331 | force_sig(SIGSEGV, current); |
351 | } | 332 | } |
352 | 333 | ||
353 | /* Checks if the fp is valid */ | 334 | /* Checks if the fp is valid */ |
354 | static int invalid_frame_pointer(void __user *fp, int fplen) | 335 | static int invalid_frame_pointer(void __user *fp) |
355 | { | 336 | { |
356 | if (((unsigned long) fp) & 15) | 337 | if (((unsigned long) fp) & 15) |
357 | return 1; | 338 | return 1; |
358 | return 0; | 339 | return 0; |
359 | } | 340 | } |
360 | 341 | ||
361 | static inline int | ||
362 | save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
363 | { | ||
364 | unsigned long *fpregs = current_thread_info()->fpregs; | ||
365 | unsigned long fprs; | ||
366 | int err = 0; | ||
367 | |||
368 | fprs = current_thread_info()->fpsaved[0]; | ||
369 | if (fprs & FPRS_DL) | ||
370 | err |= copy_to_user(&fpu->si_float_regs[0], fpregs, | ||
371 | (sizeof(unsigned int) * 32)); | ||
372 | if (fprs & FPRS_DU) | ||
373 | err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16, | ||
374 | (sizeof(unsigned int) * 32)); | ||
375 | err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr); | ||
376 | err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr); | ||
377 | err |= __put_user(fprs, &fpu->si_fprs); | ||
378 | |||
379 | return err; | ||
380 | } | ||
381 | |||
382 | static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize) | 342 | static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize) |
383 | { | 343 | { |
384 | unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS; | 344 | unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS; |
@@ -414,34 +374,48 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
414 | int signo, sigset_t *oldset, siginfo_t *info) | 374 | int signo, sigset_t *oldset, siginfo_t *info) |
415 | { | 375 | { |
416 | struct rt_signal_frame __user *sf; | 376 | struct rt_signal_frame __user *sf; |
417 | int sigframe_size, err; | 377 | int wsaved, err, sf_size; |
378 | void __user *tail; | ||
418 | 379 | ||
419 | /* 1. Make sure everything is clean */ | 380 | /* 1. Make sure everything is clean */ |
420 | synchronize_user_stack(); | 381 | synchronize_user_stack(); |
421 | save_and_clear_fpu(); | 382 | save_and_clear_fpu(); |
422 | 383 | ||
423 | sigframe_size = sizeof(struct rt_signal_frame); | 384 | wsaved = get_thread_wsaved(); |
424 | if (!(current_thread_info()->fpsaved[0] & FPRS_FEF)) | ||
425 | sigframe_size -= sizeof(__siginfo_fpu_t); | ||
426 | 385 | ||
386 | sf_size = sizeof(struct rt_signal_frame); | ||
387 | if (current_thread_info()->fpsaved[0] & FPRS_FEF) | ||
388 | sf_size += sizeof(__siginfo_fpu_t); | ||
389 | if (wsaved) | ||
390 | sf_size += sizeof(__siginfo_rwin_t); | ||
427 | sf = (struct rt_signal_frame __user *) | 391 | sf = (struct rt_signal_frame __user *) |
428 | get_sigframe(ka, regs, sigframe_size); | 392 | get_sigframe(ka, regs, sf_size); |
429 | |||
430 | if (invalid_frame_pointer (sf, sigframe_size)) | ||
431 | goto sigill; | ||
432 | 393 | ||
433 | if (get_thread_wsaved() != 0) | 394 | if (invalid_frame_pointer (sf)) |
434 | goto sigill; | 395 | goto sigill; |
435 | 396 | ||
397 | tail = (sf + 1); | ||
398 | |||
436 | /* 2. Save the current process state */ | 399 | /* 2. Save the current process state */ |
437 | err = copy_to_user(&sf->regs, regs, sizeof (*regs)); | 400 | err = copy_to_user(&sf->regs, regs, sizeof (*regs)); |
438 | 401 | ||
439 | if (current_thread_info()->fpsaved[0] & FPRS_FEF) { | 402 | if (current_thread_info()->fpsaved[0] & FPRS_FEF) { |
440 | err |= save_fpu_state(regs, &sf->fpu_state); | 403 | __siginfo_fpu_t __user *fpu_save = tail; |
441 | err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save); | 404 | tail += sizeof(__siginfo_fpu_t); |
405 | err |= save_fpu_state(regs, fpu_save); | ||
406 | err |= __put_user((u64)fpu_save, &sf->fpu_save); | ||
442 | } else { | 407 | } else { |
443 | err |= __put_user(0, &sf->fpu_save); | 408 | err |= __put_user(0, &sf->fpu_save); |
444 | } | 409 | } |
410 | if (wsaved) { | ||
411 | __siginfo_rwin_t __user *rwin_save = tail; | ||
412 | tail += sizeof(__siginfo_rwin_t); | ||
413 | err |= save_rwin_state(wsaved, rwin_save); | ||
414 | err |= __put_user((u64)rwin_save, &sf->rwin_save); | ||
415 | set_thread_wsaved(0); | ||
416 | } else { | ||
417 | err |= __put_user(0, &sf->rwin_save); | ||
418 | } | ||
445 | 419 | ||
446 | /* Setup sigaltstack */ | 420 | /* Setup sigaltstack */ |
447 | err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp); | 421 | err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp); |
@@ -450,10 +424,17 @@ setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, | |||
450 | 424 | ||
451 | err |= copy_to_user(&sf->mask, oldset, sizeof(sigset_t)); | 425 | err |= copy_to_user(&sf->mask, oldset, sizeof(sigset_t)); |
452 | 426 | ||
453 | err |= copy_in_user((u64 __user *)sf, | 427 | if (!wsaved) { |
454 | (u64 __user *)(regs->u_regs[UREG_FP]+STACK_BIAS), | 428 | err |= copy_in_user((u64 __user *)sf, |
455 | sizeof(struct reg_window)); | 429 | (u64 __user *)(regs->u_regs[UREG_FP] + |
430 | STACK_BIAS), | ||
431 | sizeof(struct reg_window)); | ||
432 | } else { | ||
433 | struct reg_window *rp; | ||
456 | 434 | ||
435 | rp = ¤t_thread_info()->reg_window[wsaved - 1]; | ||
436 | err |= copy_to_user(sf, rp, sizeof(struct reg_window)); | ||
437 | } | ||
457 | if (info) | 438 | if (info) |
458 | err |= copy_siginfo_to_user(&sf->info, info); | 439 | err |= copy_siginfo_to_user(&sf->info, info); |
459 | else { | 440 | else { |
@@ -498,18 +479,17 @@ static inline int handle_signal(unsigned long signr, struct k_sigaction *ka, | |||
498 | siginfo_t *info, | 479 | siginfo_t *info, |
499 | sigset_t *oldset, struct pt_regs *regs) | 480 | sigset_t *oldset, struct pt_regs *regs) |
500 | { | 481 | { |
482 | sigset_t blocked; | ||
501 | int err; | 483 | int err; |
502 | 484 | ||
503 | err = setup_rt_frame(ka, regs, signr, oldset, | 485 | err = setup_rt_frame(ka, regs, signr, oldset, |
504 | (ka->sa.sa_flags & SA_SIGINFO) ? info : NULL); | 486 | (ka->sa.sa_flags & SA_SIGINFO) ? info : NULL); |
505 | if (err) | 487 | if (err) |
506 | return err; | 488 | return err; |
507 | spin_lock_irq(¤t->sighand->siglock); | 489 | sigorsets(&blocked, ¤t->blocked, &ka->sa.sa_mask); |
508 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | ||
509 | if (!(ka->sa.sa_flags & SA_NOMASK)) | 490 | if (!(ka->sa.sa_flags & SA_NOMASK)) |
510 | sigaddset(¤t->blocked,signr); | 491 | sigaddset(&blocked, signr); |
511 | recalc_sigpending(); | 492 | set_current_blocked(&blocked); |
512 | spin_unlock_irq(¤t->sighand->siglock); | ||
513 | 493 | ||
514 | tracehook_signal_handler(signr, info, ka, regs, 0); | 494 | tracehook_signal_handler(signr, info, ka, regs, 0); |
515 | 495 | ||
@@ -549,11 +529,27 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
549 | siginfo_t info; | 529 | siginfo_t info; |
550 | int signr; | 530 | int signr; |
551 | 531 | ||
532 | /* It's a lot of work and synchronization to add a new ptrace | ||
533 | * register for GDB to save and restore in order to get | ||
534 | * orig_i0 correct for syscall restarts when debugging. | ||
535 | * | ||
536 | * Although it should be the case that most of the global | ||
537 | * registers are volatile across a system call, glibc already | ||
538 | * depends upon that fact that we preserve them. So we can't | ||
539 | * just use any global register to save away the orig_i0 value. | ||
540 | * | ||
541 | * In particular %g2, %g3, %g4, and %g5 are all assumed to be | ||
542 | * preserved across a system call trap by various pieces of | ||
543 | * code in glibc. | ||
544 | * | ||
545 | * %g7 is used as the "thread register". %g6 is not used in | ||
546 | * any fixed manner. %g6 is used as a scratch register and | ||
547 | * a compiler temporary, but it's value is never used across | ||
548 | * a system call. Therefore %g6 is usable for orig_i0 storage. | ||
549 | */ | ||
552 | if (pt_regs_is_syscall(regs) && | 550 | if (pt_regs_is_syscall(regs) && |
553 | (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) { | 551 | (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) |
554 | restart_syscall = 1; | 552 | regs->u_regs[UREG_G6] = orig_i0; |
555 | } else | ||
556 | restart_syscall = 0; | ||
557 | 553 | ||
558 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) | 554 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) |
559 | oldset = ¤t->saved_sigmask; | 555 | oldset = ¤t->saved_sigmask; |
@@ -562,22 +558,20 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
562 | 558 | ||
563 | #ifdef CONFIG_COMPAT | 559 | #ifdef CONFIG_COMPAT |
564 | if (test_thread_flag(TIF_32BIT)) { | 560 | if (test_thread_flag(TIF_32BIT)) { |
565 | extern void do_signal32(sigset_t *, struct pt_regs *, | 561 | extern void do_signal32(sigset_t *, struct pt_regs *); |
566 | int restart_syscall, | 562 | do_signal32(oldset, regs); |
567 | unsigned long orig_i0); | ||
568 | do_signal32(oldset, regs, restart_syscall, orig_i0); | ||
569 | return; | 563 | return; |
570 | } | 564 | } |
571 | #endif | 565 | #endif |
572 | 566 | ||
573 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 567 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
574 | 568 | ||
575 | /* If the debugger messes with the program counter, it clears | 569 | restart_syscall = 0; |
576 | * the software "in syscall" bit, directing us to not perform | 570 | if (pt_regs_is_syscall(regs) && |
577 | * a syscall restart. | 571 | (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) { |
578 | */ | 572 | restart_syscall = 1; |
579 | if (restart_syscall && !pt_regs_is_syscall(regs)) | 573 | orig_i0 = regs->u_regs[UREG_G6]; |
580 | restart_syscall = 0; | 574 | } |
581 | 575 | ||
582 | if (signr > 0) { | 576 | if (signr > 0) { |
583 | if (restart_syscall) | 577 | if (restart_syscall) |
@@ -615,7 +609,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) | |||
615 | */ | 609 | */ |
616 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { | 610 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { |
617 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | 611 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; |
618 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | 612 | set_current_blocked(¤t->saved_sigmask); |
619 | } | 613 | } |
620 | } | 614 | } |
621 | 615 | ||
diff --git a/arch/sparc/kernel/sigutil.h b/arch/sparc/kernel/sigutil.h new file mode 100644 index 00000000000..d223aa432bb --- /dev/null +++ b/arch/sparc/kernel/sigutil.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _SIGUTIL_H | ||
2 | #define _SIGUTIL_H | ||
3 | |||
4 | int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu); | ||
5 | int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu); | ||
6 | int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin); | ||
7 | int restore_rwin_state(__siginfo_rwin_t __user *rp); | ||
8 | |||
9 | #endif /* _SIGUTIL_H */ | ||
diff --git a/arch/sparc/kernel/sigutil_32.c b/arch/sparc/kernel/sigutil_32.c new file mode 100644 index 00000000000..35c7897b009 --- /dev/null +++ b/arch/sparc/kernel/sigutil_32.c | |||
@@ -0,0 +1,120 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/types.h> | ||
3 | #include <linux/thread_info.h> | ||
4 | #include <linux/uaccess.h> | ||
5 | #include <linux/sched.h> | ||
6 | |||
7 | #include <asm/sigcontext.h> | ||
8 | #include <asm/fpumacro.h> | ||
9 | #include <asm/ptrace.h> | ||
10 | |||
11 | #include "sigutil.h" | ||
12 | |||
13 | int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
14 | { | ||
15 | int err = 0; | ||
16 | #ifdef CONFIG_SMP | ||
17 | if (test_tsk_thread_flag(current, TIF_USEDFPU)) { | ||
18 | put_psr(get_psr() | PSR_EF); | ||
19 | fpsave(¤t->thread.float_regs[0], ¤t->thread.fsr, | ||
20 | ¤t->thread.fpqueue[0], ¤t->thread.fpqdepth); | ||
21 | regs->psr &= ~(PSR_EF); | ||
22 | clear_tsk_thread_flag(current, TIF_USEDFPU); | ||
23 | } | ||
24 | #else | ||
25 | if (current == last_task_used_math) { | ||
26 | put_psr(get_psr() | PSR_EF); | ||
27 | fpsave(¤t->thread.float_regs[0], ¤t->thread.fsr, | ||
28 | ¤t->thread.fpqueue[0], ¤t->thread.fpqdepth); | ||
29 | last_task_used_math = NULL; | ||
30 | regs->psr &= ~(PSR_EF); | ||
31 | } | ||
32 | #endif | ||
33 | err |= __copy_to_user(&fpu->si_float_regs[0], | ||
34 | ¤t->thread.float_regs[0], | ||
35 | (sizeof(unsigned long) * 32)); | ||
36 | err |= __put_user(current->thread.fsr, &fpu->si_fsr); | ||
37 | err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth); | ||
38 | if (current->thread.fpqdepth != 0) | ||
39 | err |= __copy_to_user(&fpu->si_fpqueue[0], | ||
40 | ¤t->thread.fpqueue[0], | ||
41 | ((sizeof(unsigned long) + | ||
42 | (sizeof(unsigned long *)))*16)); | ||
43 | clear_used_math(); | ||
44 | return err; | ||
45 | } | ||
46 | |||
47 | int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
48 | { | ||
49 | int err; | ||
50 | #ifdef CONFIG_SMP | ||
51 | if (test_tsk_thread_flag(current, TIF_USEDFPU)) | ||
52 | regs->psr &= ~PSR_EF; | ||
53 | #else | ||
54 | if (current == last_task_used_math) { | ||
55 | last_task_used_math = NULL; | ||
56 | regs->psr &= ~PSR_EF; | ||
57 | } | ||
58 | #endif | ||
59 | set_used_math(); | ||
60 | clear_tsk_thread_flag(current, TIF_USEDFPU); | ||
61 | |||
62 | if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu))) | ||
63 | return -EFAULT; | ||
64 | |||
65 | err = __copy_from_user(¤t->thread.float_regs[0], &fpu->si_float_regs[0], | ||
66 | (sizeof(unsigned long) * 32)); | ||
67 | err |= __get_user(current->thread.fsr, &fpu->si_fsr); | ||
68 | err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth); | ||
69 | if (current->thread.fpqdepth != 0) | ||
70 | err |= __copy_from_user(¤t->thread.fpqueue[0], | ||
71 | &fpu->si_fpqueue[0], | ||
72 | ((sizeof(unsigned long) + | ||
73 | (sizeof(unsigned long *)))*16)); | ||
74 | return err; | ||
75 | } | ||
76 | |||
77 | int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin) | ||
78 | { | ||
79 | int i, err = __put_user(wsaved, &rwin->wsaved); | ||
80 | |||
81 | for (i = 0; i < wsaved; i++) { | ||
82 | struct reg_window32 *rp; | ||
83 | unsigned long fp; | ||
84 | |||
85 | rp = ¤t_thread_info()->reg_window[i]; | ||
86 | fp = current_thread_info()->rwbuf_stkptrs[i]; | ||
87 | err |= copy_to_user(&rwin->reg_window[i], rp, | ||
88 | sizeof(struct reg_window32)); | ||
89 | err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]); | ||
90 | } | ||
91 | return err; | ||
92 | } | ||
93 | |||
94 | int restore_rwin_state(__siginfo_rwin_t __user *rp) | ||
95 | { | ||
96 | struct thread_info *t = current_thread_info(); | ||
97 | int i, wsaved, err; | ||
98 | |||
99 | __get_user(wsaved, &rp->wsaved); | ||
100 | if (wsaved > NSWINS) | ||
101 | return -EFAULT; | ||
102 | |||
103 | err = 0; | ||
104 | for (i = 0; i < wsaved; i++) { | ||
105 | err |= copy_from_user(&t->reg_window[i], | ||
106 | &rp->reg_window[i], | ||
107 | sizeof(struct reg_window32)); | ||
108 | err |= __get_user(t->rwbuf_stkptrs[i], | ||
109 | &rp->rwbuf_stkptrs[i]); | ||
110 | } | ||
111 | if (err) | ||
112 | return err; | ||
113 | |||
114 | t->w_saved = wsaved; | ||
115 | synchronize_user_stack(); | ||
116 | if (t->w_saved) | ||
117 | return -EFAULT; | ||
118 | return 0; | ||
119 | |||
120 | } | ||
diff --git a/arch/sparc/kernel/sigutil_64.c b/arch/sparc/kernel/sigutil_64.c new file mode 100644 index 00000000000..e7dc508c38e --- /dev/null +++ b/arch/sparc/kernel/sigutil_64.c | |||
@@ -0,0 +1,93 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/types.h> | ||
3 | #include <linux/thread_info.h> | ||
4 | #include <linux/uaccess.h> | ||
5 | |||
6 | #include <asm/sigcontext.h> | ||
7 | #include <asm/fpumacro.h> | ||
8 | #include <asm/ptrace.h> | ||
9 | |||
10 | #include "sigutil.h" | ||
11 | |||
12 | int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
13 | { | ||
14 | unsigned long *fpregs = current_thread_info()->fpregs; | ||
15 | unsigned long fprs; | ||
16 | int err = 0; | ||
17 | |||
18 | fprs = current_thread_info()->fpsaved[0]; | ||
19 | if (fprs & FPRS_DL) | ||
20 | err |= copy_to_user(&fpu->si_float_regs[0], fpregs, | ||
21 | (sizeof(unsigned int) * 32)); | ||
22 | if (fprs & FPRS_DU) | ||
23 | err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16, | ||
24 | (sizeof(unsigned int) * 32)); | ||
25 | err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr); | ||
26 | err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr); | ||
27 | err |= __put_user(fprs, &fpu->si_fprs); | ||
28 | |||
29 | return err; | ||
30 | } | ||
31 | |||
32 | int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) | ||
33 | { | ||
34 | unsigned long *fpregs = current_thread_info()->fpregs; | ||
35 | unsigned long fprs; | ||
36 | int err; | ||
37 | |||
38 | err = __get_user(fprs, &fpu->si_fprs); | ||
39 | fprs_write(0); | ||
40 | regs->tstate &= ~TSTATE_PEF; | ||
41 | if (fprs & FPRS_DL) | ||
42 | err |= copy_from_user(fpregs, &fpu->si_float_regs[0], | ||
43 | (sizeof(unsigned int) * 32)); | ||
44 | if (fprs & FPRS_DU) | ||
45 | err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], | ||
46 | (sizeof(unsigned int) * 32)); | ||
47 | err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr); | ||
48 | err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr); | ||
49 | current_thread_info()->fpsaved[0] |= fprs; | ||
50 | return err; | ||
51 | } | ||
52 | |||
53 | int save_rwin_state(int wsaved, __siginfo_rwin_t __user *rwin) | ||
54 | { | ||
55 | int i, err = __put_user(wsaved, &rwin->wsaved); | ||
56 | |||
57 | for (i = 0; i < wsaved; i++) { | ||
58 | struct reg_window *rp = ¤t_thread_info()->reg_window[i]; | ||
59 | unsigned long fp = current_thread_info()->rwbuf_stkptrs[i]; | ||
60 | |||
61 | err |= copy_to_user(&rwin->reg_window[i], rp, | ||
62 | sizeof(struct reg_window)); | ||
63 | err |= __put_user(fp, &rwin->rwbuf_stkptrs[i]); | ||
64 | } | ||
65 | return err; | ||
66 | } | ||
67 | |||
68 | int restore_rwin_state(__siginfo_rwin_t __user *rp) | ||
69 | { | ||
70 | struct thread_info *t = current_thread_info(); | ||
71 | int i, wsaved, err; | ||
72 | |||
73 | __get_user(wsaved, &rp->wsaved); | ||
74 | if (wsaved > NSWINS) | ||
75 | return -EFAULT; | ||
76 | |||
77 | err = 0; | ||
78 | for (i = 0; i < wsaved; i++) { | ||
79 | err |= copy_from_user(&t->reg_window[i], | ||
80 | &rp->reg_window[i], | ||
81 | sizeof(struct reg_window)); | ||
82 | err |= __get_user(t->rwbuf_stkptrs[i], | ||
83 | &rp->rwbuf_stkptrs[i]); | ||
84 | } | ||
85 | if (err) | ||
86 | return err; | ||
87 | |||
88 | set_thread_wsaved(wsaved); | ||
89 | synchronize_user_stack(); | ||
90 | if (get_thread_wsaved()) | ||
91 | return -EFAULT; | ||
92 | return 0; | ||
93 | } | ||
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index 21b125341bf..f671e7fd6dd 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | 23 | ||
24 | #include <asm/ptrace.h> | 24 | #include <asm/ptrace.h> |
25 | #include <asm/atomic.h> | 25 | #include <linux/atomic.h> |
26 | 26 | ||
27 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
28 | #include <asm/page.h> | 28 | #include <asm/page.h> |
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index 99cb17251bb..4a442c32e11 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <asm/head.h> | 29 | #include <asm/head.h> |
30 | #include <asm/ptrace.h> | 30 | #include <asm/ptrace.h> |
31 | #include <asm/atomic.h> | 31 | #include <linux/atomic.h> |
32 | #include <asm/tlbflush.h> | 32 | #include <asm/tlbflush.h> |
33 | #include <asm/mmu_context.h> | 33 | #include <asm/mmu_context.h> |
34 | #include <asm/cpudata.h> | 34 | #include <asm/cpudata.h> |
diff --git a/arch/sparc/kernel/sparc_ksyms_64.c b/arch/sparc/kernel/sparc_ksyms_64.c index 372ad59c4cb..83b47ab02d9 100644 --- a/arch/sparc/kernel/sparc_ksyms_64.c +++ b/arch/sparc/kernel/sparc_ksyms_64.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/bitops.h> | ||
11 | 12 | ||
12 | #include <asm/system.h> | 13 | #include <asm/system.h> |
13 | #include <asm/cpudata.h> | 14 | #include <asm/cpudata.h> |
@@ -38,5 +39,15 @@ EXPORT_SYMBOL(sun4v_niagara_setperf); | |||
38 | EXPORT_SYMBOL(sun4v_niagara2_getperf); | 39 | EXPORT_SYMBOL(sun4v_niagara2_getperf); |
39 | EXPORT_SYMBOL(sun4v_niagara2_setperf); | 40 | EXPORT_SYMBOL(sun4v_niagara2_setperf); |
40 | 41 | ||
42 | /* from hweight.S */ | ||
43 | EXPORT_SYMBOL(__arch_hweight8); | ||
44 | EXPORT_SYMBOL(__arch_hweight16); | ||
45 | EXPORT_SYMBOL(__arch_hweight32); | ||
46 | EXPORT_SYMBOL(__arch_hweight64); | ||
47 | |||
48 | /* from ffs_ffz.S */ | ||
49 | EXPORT_SYMBOL(ffs); | ||
50 | EXPORT_SYMBOL(__ffs); | ||
51 | |||
41 | /* Exporting a symbol from /init/main.c */ | 52 | /* Exporting a symbol from /init/main.c */ |
42 | EXPORT_SYMBOL(saved_command_line); | 53 | EXPORT_SYMBOL(saved_command_line); |
diff --git a/arch/sparc/kernel/sstate.c b/arch/sparc/kernel/sstate.c index 8cdbe5946b4..c59af546f52 100644 --- a/arch/sparc/kernel/sstate.c +++ b/arch/sparc/kernel/sstate.c | |||
@@ -14,14 +14,9 @@ | |||
14 | #include <asm/head.h> | 14 | #include <asm/head.h> |
15 | #include <asm/io.h> | 15 | #include <asm/io.h> |
16 | 16 | ||
17 | static int hv_supports_soft_state; | 17 | #include "kernel.h" |
18 | |||
19 | static unsigned long kimage_addr_to_ra(const char *p) | ||
20 | { | ||
21 | unsigned long val = (unsigned long) p; | ||
22 | 18 | ||
23 | return kern_base + (val - KERNBASE); | 19 | static int hv_supports_soft_state; |
24 | } | ||
25 | 20 | ||
26 | static void do_set_sstate(unsigned long state, const char *msg) | 21 | static void do_set_sstate(unsigned long state, const char *msg) |
27 | { | 22 | { |
diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S index 44e5faf1ad5..d97f3eb72e0 100644 --- a/arch/sparc/kernel/sys32.S +++ b/arch/sparc/kernel/sys32.S | |||
@@ -81,7 +81,6 @@ SIGN2(sys32_fadvise64, compat_sys_fadvise64, %o0, %o4) | |||
81 | SIGN2(sys32_fadvise64_64, compat_sys_fadvise64_64, %o0, %o5) | 81 | SIGN2(sys32_fadvise64_64, compat_sys_fadvise64_64, %o0, %o5) |
82 | SIGN2(sys32_bdflush, sys_bdflush, %o0, %o1) | 82 | SIGN2(sys32_bdflush, sys_bdflush, %o0, %o1) |
83 | SIGN1(sys32_mlockall, sys_mlockall, %o0) | 83 | SIGN1(sys32_mlockall, sys_mlockall, %o0) |
84 | SIGN1(sys32_nfsservctl, compat_sys_nfsservctl, %o0) | ||
85 | SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1) | 84 | SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1) |
86 | SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1) | 85 | SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1) |
87 | SIGN1(sys32_io_submit, compat_sys_io_submit, %o1) | 86 | SIGN1(sys32_io_submit, compat_sys_io_submit, %o1) |
diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S index 6e492d59f6b..09d8ec45445 100644 --- a/arch/sparc/kernel/systbls_32.S +++ b/arch/sparc/kernel/systbls_32.S | |||
@@ -67,7 +67,7 @@ sys_call_table: | |||
67 | /*235*/ .long sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys_mlockall | 67 | /*235*/ .long sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys_mlockall |
68 | /*240*/ .long sys_munlockall, sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler | 68 | /*240*/ .long sys_munlockall, sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler |
69 | /*245*/ .long sys_sched_yield, sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, sys_nanosleep | 69 | /*245*/ .long sys_sched_yield, sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, sys_nanosleep |
70 | /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl | 70 | /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall |
71 | /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep | 71 | /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep |
72 | /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun | 72 | /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun |
73 | /*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy | 73 | /*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy |
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S index f566518483b..edbec45d468 100644 --- a/arch/sparc/kernel/systbls_64.S +++ b/arch/sparc/kernel/systbls_64.S | |||
@@ -68,7 +68,7 @@ sys_call_table32: | |||
68 | .word compat_sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall | 68 | .word compat_sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall |
69 | /*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler | 69 | /*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler |
70 | .word sys_sched_yield, sys32_sched_get_priority_max, sys32_sched_get_priority_min, sys32_sched_rr_get_interval, compat_sys_nanosleep | 70 | .word sys_sched_yield, sys32_sched_get_priority_max, sys32_sched_get_priority_min, sys32_sched_rr_get_interval, compat_sys_nanosleep |
71 | /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl | 71 | /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall |
72 | .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep | 72 | .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep |
73 | /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun | 73 | /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun |
74 | .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy | 74 | .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy |
@@ -145,7 +145,7 @@ sys_call_table: | |||
145 | .word sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys_mlockall | 145 | .word sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys_mlockall |
146 | /*240*/ .word sys_munlockall, sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler | 146 | /*240*/ .word sys_munlockall, sys_sched_setparam, sys_sched_getparam, sys_sched_setscheduler, sys_sched_getscheduler |
147 | .word sys_sched_yield, sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, sys_nanosleep | 147 | .word sys_sched_yield, sys_sched_get_priority_max, sys_sched_get_priority_min, sys_sched_rr_get_interval, sys_nanosleep |
148 | /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl | 148 | /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall |
149 | .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep | 149 | .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep |
150 | /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun | 150 | /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun |
151 | .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy | 151 | .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy |
diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c index 4491f4cb269..7efbb2f9e77 100644 --- a/arch/sparc/kernel/unaligned_32.c +++ b/arch/sparc/kernel/unaligned_32.c | |||
@@ -247,7 +247,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
247 | unsigned long addr = compute_effective_address(regs, insn); | 247 | unsigned long addr = compute_effective_address(regs, insn); |
248 | int err; | 248 | int err; |
249 | 249 | ||
250 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); | 250 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr); |
251 | switch (dir) { | 251 | switch (dir) { |
252 | case load: | 252 | case load: |
253 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), | 253 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), |
@@ -338,7 +338,7 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
338 | } | 338 | } |
339 | 339 | ||
340 | addr = compute_effective_address(regs, insn); | 340 | addr = compute_effective_address(regs, insn); |
341 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); | 341 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr); |
342 | switch(dir) { | 342 | switch(dir) { |
343 | case load: | 343 | case load: |
344 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), | 344 | err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), |
diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c index b2b019ea8ca..76e4ac1a13e 100644 --- a/arch/sparc/kernel/unaligned_64.c +++ b/arch/sparc/kernel/unaligned_64.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/perf_event.h> | 23 | #include <linux/perf_event.h> |
24 | #include <linux/ratelimit.h> | 24 | #include <linux/ratelimit.h> |
25 | #include <linux/bitops.h> | ||
25 | #include <asm/fpumacro.h> | 26 | #include <asm/fpumacro.h> |
26 | 27 | ||
27 | enum direction { | 28 | enum direction { |
@@ -317,7 +318,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
317 | 318 | ||
318 | addr = compute_effective_address(regs, insn, | 319 | addr = compute_effective_address(regs, insn, |
319 | ((insn >> 25) & 0x1f)); | 320 | ((insn >> 25) & 0x1f)); |
320 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); | 321 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr); |
321 | switch (asi) { | 322 | switch (asi) { |
322 | case ASI_NL: | 323 | case ASI_NL: |
323 | case ASI_AIUPL: | 324 | case ASI_AIUPL: |
@@ -373,18 +374,13 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn) | |||
373 | } | 374 | } |
374 | } | 375 | } |
375 | 376 | ||
376 | static char popc_helper[] = { | ||
377 | 0, 1, 1, 2, 1, 2, 2, 3, | ||
378 | 1, 2, 2, 3, 2, 3, 3, 4, | ||
379 | }; | ||
380 | |||
381 | int handle_popc(u32 insn, struct pt_regs *regs) | 377 | int handle_popc(u32 insn, struct pt_regs *regs) |
382 | { | 378 | { |
383 | u64 value; | ||
384 | int ret, i, rd = ((insn >> 25) & 0x1f); | ||
385 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; | 379 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; |
380 | int ret, rd = ((insn >> 25) & 0x1f); | ||
381 | u64 value; | ||
386 | 382 | ||
387 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | 383 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); |
388 | if (insn & 0x2000) { | 384 | if (insn & 0x2000) { |
389 | maybe_flush_windows(0, 0, rd, from_kernel); | 385 | maybe_flush_windows(0, 0, rd, from_kernel); |
390 | value = sign_extend_imm13(insn); | 386 | value = sign_extend_imm13(insn); |
@@ -392,10 +388,7 @@ int handle_popc(u32 insn, struct pt_regs *regs) | |||
392 | maybe_flush_windows(0, insn & 0x1f, rd, from_kernel); | 388 | maybe_flush_windows(0, insn & 0x1f, rd, from_kernel); |
393 | value = fetch_reg(insn & 0x1f, regs); | 389 | value = fetch_reg(insn & 0x1f, regs); |
394 | } | 390 | } |
395 | for (ret = 0, i = 0; i < 16; i++) { | 391 | ret = hweight64(value); |
396 | ret += popc_helper[value & 0xf]; | ||
397 | value >>= 4; | ||
398 | } | ||
399 | if (rd < 16) { | 392 | if (rd < 16) { |
400 | if (rd) | 393 | if (rd) |
401 | regs->u_regs[rd] = ret; | 394 | regs->u_regs[rd] = ret; |
@@ -431,7 +424,7 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs) | |||
431 | int asi = decode_asi(insn, regs); | 424 | int asi = decode_asi(insn, regs); |
432 | int flag = (freg < 32) ? FPRS_DL : FPRS_DU; | 425 | int flag = (freg < 32) ? FPRS_DL : FPRS_DU; |
433 | 426 | ||
434 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | 427 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); |
435 | 428 | ||
436 | save_and_clear_fpu(); | 429 | save_and_clear_fpu(); |
437 | current_thread_info()->xfsr[0] &= ~0x1c000; | 430 | current_thread_info()->xfsr[0] &= ~0x1c000; |
@@ -554,7 +547,7 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs) | |||
554 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; | 547 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; |
555 | unsigned long *reg; | 548 | unsigned long *reg; |
556 | 549 | ||
557 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | 550 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); |
558 | 551 | ||
559 | maybe_flush_windows(0, 0, rd, from_kernel); | 552 | maybe_flush_windows(0, 0, rd, from_kernel); |
560 | reg = fetch_reg_addr(rd, regs); | 553 | reg = fetch_reg_addr(rd, regs); |
@@ -586,7 +579,7 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr | |||
586 | 579 | ||
587 | if (tstate & TSTATE_PRIV) | 580 | if (tstate & TSTATE_PRIV) |
588 | die_if_kernel("lddfmna from kernel", regs); | 581 | die_if_kernel("lddfmna from kernel", regs); |
589 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar); | 582 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, sfar); |
590 | if (test_thread_flag(TIF_32BIT)) | 583 | if (test_thread_flag(TIF_32BIT)) |
591 | pc = (u32)pc; | 584 | pc = (u32)pc; |
592 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { | 585 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { |
@@ -647,7 +640,7 @@ void handle_stdfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr | |||
647 | 640 | ||
648 | if (tstate & TSTATE_PRIV) | 641 | if (tstate & TSTATE_PRIV) |
649 | die_if_kernel("stdfmna from kernel", regs); | 642 | die_if_kernel("stdfmna from kernel", regs); |
650 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar); | 643 | perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, sfar); |
651 | if (test_thread_flag(TIF_32BIT)) | 644 | if (test_thread_flag(TIF_32BIT)) |
652 | pc = (u32)pc; | 645 | pc = (u32)pc; |
653 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { | 646 | if (get_user(insn, (u32 __user *) pc) != -EFAULT) { |
diff --git a/arch/sparc/kernel/visemul.c b/arch/sparc/kernel/visemul.c index 36357717d69..73370674ccf 100644 --- a/arch/sparc/kernel/visemul.c +++ b/arch/sparc/kernel/visemul.c | |||
@@ -713,17 +713,17 @@ static void pcmp(struct pt_regs *regs, unsigned int insn, unsigned int opf) | |||
713 | s16 b = (rs2 >> (i * 16)) & 0xffff; | 713 | s16 b = (rs2 >> (i * 16)) & 0xffff; |
714 | 714 | ||
715 | if (a > b) | 715 | if (a > b) |
716 | rd_val |= 1 << i; | 716 | rd_val |= 8 >> i; |
717 | } | 717 | } |
718 | break; | 718 | break; |
719 | 719 | ||
720 | case FCMPGT32_OPF: | 720 | case FCMPGT32_OPF: |
721 | for (i = 0; i < 2; i++) { | 721 | for (i = 0; i < 2; i++) { |
722 | s32 a = (rs1 >> (i * 32)) & 0xffff; | 722 | s32 a = (rs1 >> (i * 32)) & 0xffffffff; |
723 | s32 b = (rs2 >> (i * 32)) & 0xffff; | 723 | s32 b = (rs2 >> (i * 32)) & 0xffffffff; |
724 | 724 | ||
725 | if (a > b) | 725 | if (a > b) |
726 | rd_val |= 1 << i; | 726 | rd_val |= 2 >> i; |
727 | } | 727 | } |
728 | break; | 728 | break; |
729 | 729 | ||
@@ -733,17 +733,17 @@ static void pcmp(struct pt_regs *regs, unsigned int insn, unsigned int opf) | |||
733 | s16 b = (rs2 >> (i * 16)) & 0xffff; | 733 | s16 b = (rs2 >> (i * 16)) & 0xffff; |
734 | 734 | ||
735 | if (a <= b) | 735 | if (a <= b) |
736 | rd_val |= 1 << i; | 736 | rd_val |= 8 >> i; |
737 | } | 737 | } |
738 | break; | 738 | break; |
739 | 739 | ||
740 | case FCMPLE32_OPF: | 740 | case FCMPLE32_OPF: |
741 | for (i = 0; i < 2; i++) { | 741 | for (i = 0; i < 2; i++) { |
742 | s32 a = (rs1 >> (i * 32)) & 0xffff; | 742 | s32 a = (rs1 >> (i * 32)) & 0xffffffff; |
743 | s32 b = (rs2 >> (i * 32)) & 0xffff; | 743 | s32 b = (rs2 >> (i * 32)) & 0xffffffff; |
744 | 744 | ||
745 | if (a <= b) | 745 | if (a <= b) |
746 | rd_val |= 1 << i; | 746 | rd_val |= 2 >> i; |
747 | } | 747 | } |
748 | break; | 748 | break; |
749 | 749 | ||
@@ -753,17 +753,17 @@ static void pcmp(struct pt_regs *regs, unsigned int insn, unsigned int opf) | |||
753 | s16 b = (rs2 >> (i * 16)) & 0xffff; | 753 | s16 b = (rs2 >> (i * 16)) & 0xffff; |
754 | 754 | ||
755 | if (a != b) | 755 | if (a != b) |
756 | rd_val |= 1 << i; | 756 | rd_val |= 8 >> i; |
757 | } | 757 | } |
758 | break; | 758 | break; |
759 | 759 | ||
760 | case FCMPNE32_OPF: | 760 | case FCMPNE32_OPF: |
761 | for (i = 0; i < 2; i++) { | 761 | for (i = 0; i < 2; i++) { |
762 | s32 a = (rs1 >> (i * 32)) & 0xffff; | 762 | s32 a = (rs1 >> (i * 32)) & 0xffffffff; |
763 | s32 b = (rs2 >> (i * 32)) & 0xffff; | 763 | s32 b = (rs2 >> (i * 32)) & 0xffffffff; |
764 | 764 | ||
765 | if (a != b) | 765 | if (a != b) |
766 | rd_val |= 1 << i; | 766 | rd_val |= 2 >> i; |
767 | } | 767 | } |
768 | break; | 768 | break; |
769 | 769 | ||
@@ -773,17 +773,17 @@ static void pcmp(struct pt_regs *regs, unsigned int insn, unsigned int opf) | |||
773 | s16 b = (rs2 >> (i * 16)) & 0xffff; | 773 | s16 b = (rs2 >> (i * 16)) & 0xffff; |
774 | 774 | ||
775 | if (a == b) | 775 | if (a == b) |
776 | rd_val |= 1 << i; | 776 | rd_val |= 8 >> i; |
777 | } | 777 | } |
778 | break; | 778 | break; |
779 | 779 | ||
780 | case FCMPEQ32_OPF: | 780 | case FCMPEQ32_OPF: |
781 | for (i = 0; i < 2; i++) { | 781 | for (i = 0; i < 2; i++) { |
782 | s32 a = (rs1 >> (i * 32)) & 0xffff; | 782 | s32 a = (rs1 >> (i * 32)) & 0xffffffff; |
783 | s32 b = (rs2 >> (i * 32)) & 0xffff; | 783 | s32 b = (rs2 >> (i * 32)) & 0xffffffff; |
784 | 784 | ||
785 | if (a == b) | 785 | if (a == b) |
786 | rd_val |= 1 << i; | 786 | rd_val |= 2 >> i; |
787 | } | 787 | } |
788 | break; | 788 | break; |
789 | } | 789 | } |
@@ -802,7 +802,7 @@ int vis_emul(struct pt_regs *regs, unsigned int insn) | |||
802 | 802 | ||
803 | BUG_ON(regs->tstate & TSTATE_PRIV); | 803 | BUG_ON(regs->tstate & TSTATE_PRIV); |
804 | 804 | ||
805 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0); | 805 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); |
806 | 806 | ||
807 | if (test_thread_flag(TIF_32BIT)) | 807 | if (test_thread_flag(TIF_32BIT)) |
808 | pc = (u32)pc; | 808 | pc = (u32)pc; |
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S index c0220759003..0e1605697b4 100644 --- a/arch/sparc/kernel/vmlinux.lds.S +++ b/arch/sparc/kernel/vmlinux.lds.S | |||
@@ -107,7 +107,26 @@ SECTIONS | |||
107 | *(.sun4v_2insn_patch) | 107 | *(.sun4v_2insn_patch) |
108 | __sun4v_2insn_patch_end = .; | 108 | __sun4v_2insn_patch_end = .; |
109 | } | 109 | } |
110 | 110 | .swapper_tsb_phys_patch : { | |
111 | __swapper_tsb_phys_patch = .; | ||
112 | *(.swapper_tsb_phys_patch) | ||
113 | __swapper_tsb_phys_patch_end = .; | ||
114 | } | ||
115 | .swapper_4m_tsb_phys_patch : { | ||
116 | __swapper_4m_tsb_phys_patch = .; | ||
117 | *(.swapper_4m_tsb_phys_patch) | ||
118 | __swapper_4m_tsb_phys_patch_end = .; | ||
119 | } | ||
120 | .popc_3insn_patch : { | ||
121 | __popc_3insn_patch = .; | ||
122 | *(.popc_3insn_patch) | ||
123 | __popc_3insn_patch_end = .; | ||
124 | } | ||
125 | .popc_6insn_patch : { | ||
126 | __popc_6insn_patch = .; | ||
127 | *(.popc_6insn_patch) | ||
128 | __popc_6insn_patch_end = .; | ||
129 | } | ||
111 | PERCPU_SECTION(SMP_CACHE_BYTES) | 130 | PERCPU_SECTION(SMP_CACHE_BYTES) |
112 | 131 | ||
113 | . = ALIGN(PAGE_SIZE); | 132 | . = ALIGN(PAGE_SIZE); |