aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 12:58:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 12:58:09 -0500
commit16e024f30ce96ef5fa651e2914e19d175a924cab (patch)
treed68106151a0b36e22625d7af7b23081a48c92e87 /arch/powerpc/kernel
parentc36e0501ee91d7616a188efbf9714b1fce150032 (diff)
parent376bddd34433065aeb9b9a140870537feecf90ef (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
Pull powerpc update from Benjamin Herrenschmidt: "The main highlight is probably some base POWER8 support. There's more to come such as transactional memory support but that will wait for the next one. Overall it's pretty quiet, or rather I've been pretty poor at picking things up from patchwork and reviewing them this time around and Kumar no better on the FSL side it seems..." * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (73 commits) powerpc+of: Rename and fix OF reconfig notifier error inject module powerpc: mpc5200: Add a3m071 board support powerpc/512x: don't compile any platform DIU code if the DIU is not enabled powerpc/mpc52xx: use module_platform_driver macro powerpc+of: Export of_reconfig_notifier_[register,unregister] powerpc/dma/raidengine: add raidengine device powerpc/iommu/fsl: Add PAMU bypass enable register to ccsr_guts struct powerpc/mpc85xx: Change spin table to cached memory powerpc/fsl-pci: Add PCI controller ATMU PM support powerpc/86xx: fsl_pcibios_fixup_bus requires CONFIG_PCI drivers/virt: the Freescale hypervisor driver doesn't need to check MSR[GS] powerpc/85xx: p1022ds: Use NULL instead of 0 for pointers powerpc: Disable relocation on exceptions when kexecing powerpc: Enable relocation on during exceptions at boot powerpc: Move get_longbusy_msecs into hvcall.h and remove duplicate function powerpc: Add wrappers to enable/disable relocation on exceptions powerpc: Add set_mode hcall powerpc: Setup relocation on exceptions for bare metal systems powerpc: Move initial mfspr LPCR out of __init_LPCR powerpc: Add relocation on exception vector handlers ...
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/cpu_setup_power.S (renamed from arch/powerpc/kernel/cpu_setup_power7.S)32
-rw-r--r--arch/powerpc/kernel/cputable.c38
-rw-r--r--arch/powerpc/kernel/entry_64.S2
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S308
-rw-r--r--arch/powerpc/kernel/head_64.S6
-rw-r--r--arch/powerpc/kernel/idle.c3
-rw-r--r--arch/powerpc/kernel/iommu.c16
-rw-r--r--arch/powerpc/kernel/machine_kexec.c14
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c8
-rw-r--r--arch/powerpc/kernel/pci_32.c2
-rw-r--r--arch/powerpc/kernel/prom.c7
-rw-r--r--arch/powerpc/kernel/prom_init.c11
-rw-r--r--arch/powerpc/kernel/ptrace.c90
-rw-r--r--arch/powerpc/kernel/rtas.c1
-rw-r--r--arch/powerpc/kernel/rtas_flash.c4
-rw-r--r--arch/powerpc/kernel/setup_64.c5
-rw-r--r--arch/powerpc/kernel/udbg.c23
18 files changed, 451 insertions, 121 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index cde12f8a4ebc..8f619342f14c 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -38,7 +38,7 @@ obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
38 paca.o nvram_64.o firmware.o 38 paca.o nvram_64.o firmware.o
39obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o 39obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
40obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o 40obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o
41obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power7.o 41obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o
42obj64-$(CONFIG_RELOCATABLE) += reloc_64.o 42obj64-$(CONFIG_RELOCATABLE) += reloc_64.o
43obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o 43obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o
44obj-$(CONFIG_PPC_A2) += cpu_setup_a2.o 44obj-$(CONFIG_PPC_A2) += cpu_setup_a2.o
diff --git a/arch/powerpc/kernel/cpu_setup_power7.S b/arch/powerpc/kernel/cpu_setup_power.S
index 76797c5105d6..57cf14065aec 100644
--- a/arch/powerpc/kernel/cpu_setup_power7.S
+++ b/arch/powerpc/kernel/cpu_setup_power.S
@@ -27,6 +27,7 @@ _GLOBAL(__setup_cpu_power7)
27 beqlr 27 beqlr
28 li r0,0 28 li r0,0
29 mtspr SPRN_LPID,r0 29 mtspr SPRN_LPID,r0
30 mfspr r3,SPRN_LPCR
30 bl __init_LPCR 31 bl __init_LPCR
31 bl __init_TLB 32 bl __init_TLB
32 mtlr r11 33 mtlr r11
@@ -39,6 +40,35 @@ _GLOBAL(__restore_cpu_power7)
39 beqlr 40 beqlr
40 li r0,0 41 li r0,0
41 mtspr SPRN_LPID,r0 42 mtspr SPRN_LPID,r0
43 mfspr r3,SPRN_LPCR
44 bl __init_LPCR
45 bl __init_TLB
46 mtlr r11
47 blr
48
49_GLOBAL(__setup_cpu_power8)
50 mflr r11
51 bl __init_hvmode_206
52 mtlr r11
53 beqlr
54 li r0,0
55 mtspr SPRN_LPID,r0
56 mfspr r3,SPRN_LPCR
57 oris r3, r3, LPCR_AIL_3@h
58 bl __init_LPCR
59 bl __init_TLB
60 mtlr r11
61 blr
62
63_GLOBAL(__restore_cpu_power8)
64 mflr r11
65 mfmsr r3
66 rldicl. r0,r3,4,63
67 beqlr
68 li r0,0
69 mtspr SPRN_LPID,r0
70 mfspr r3,SPRN_LPCR
71 oris r3, r3, LPCR_AIL_3@h
42 bl __init_LPCR 72 bl __init_LPCR
43 bl __init_TLB 73 bl __init_TLB
44 mtlr r11 74 mtlr r11
@@ -57,6 +87,7 @@ __init_hvmode_206:
57 87
58__init_LPCR: 88__init_LPCR:
59 /* Setup a sane LPCR: 89 /* Setup a sane LPCR:
90 * Called with initial LPCR in R3
60 * 91 *
61 * LPES = 0b01 (HSRR0/1 used for 0x500) 92 * LPES = 0b01 (HSRR0/1 used for 0x500)
62 * PECE = 0b111 93 * PECE = 0b111
@@ -67,7 +98,6 @@ __init_LPCR:
67 * 98 *
68 * Other bits untouched for now 99 * Other bits untouched for now
69 */ 100 */
70 mfspr r3,SPRN_LPCR
71 li r5,1 101 li r5,1
72 rldimi r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2 102 rldimi r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
73 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2) 103 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 0514c21f138b..75a3d71b895d 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -68,6 +68,8 @@ extern void __restore_cpu_pa6t(void);
68extern void __restore_cpu_ppc970(void); 68extern void __restore_cpu_ppc970(void);
69extern void __setup_cpu_power7(unsigned long offset, struct cpu_spec* spec); 69extern void __setup_cpu_power7(unsigned long offset, struct cpu_spec* spec);
70extern void __restore_cpu_power7(void); 70extern void __restore_cpu_power7(void);
71extern void __setup_cpu_power8(unsigned long offset, struct cpu_spec* spec);
72extern void __restore_cpu_power8(void);
71extern void __restore_cpu_a2(void); 73extern void __restore_cpu_a2(void);
72#endif /* CONFIG_PPC64 */ 74#endif /* CONFIG_PPC64 */
73#if defined(CONFIG_E500) 75#if defined(CONFIG_E500)
@@ -94,6 +96,10 @@ extern void __restore_cpu_e5500(void);
94 PPC_FEATURE_SMT | PPC_FEATURE_ICACHE_SNOOP | \ 96 PPC_FEATURE_SMT | PPC_FEATURE_ICACHE_SNOOP | \
95 PPC_FEATURE_TRUE_LE | \ 97 PPC_FEATURE_TRUE_LE | \
96 PPC_FEATURE_PSERIES_PERFMON_COMPAT) 98 PPC_FEATURE_PSERIES_PERFMON_COMPAT)
99#define COMMON_USER_POWER8 (COMMON_USER_PPC64 | PPC_FEATURE_ARCH_2_06 |\
100 PPC_FEATURE_SMT | PPC_FEATURE_ICACHE_SNOOP | \
101 PPC_FEATURE_TRUE_LE | \
102 PPC_FEATURE_PSERIES_PERFMON_COMPAT)
97#define COMMON_USER_PA6T (COMMON_USER_PPC64 | PPC_FEATURE_PA6T |\ 103#define COMMON_USER_PA6T (COMMON_USER_PPC64 | PPC_FEATURE_PA6T |\
98 PPC_FEATURE_TRUE_LE | \ 104 PPC_FEATURE_TRUE_LE | \
99 PPC_FEATURE_HAS_ALTIVEC_COMP) 105 PPC_FEATURE_HAS_ALTIVEC_COMP)
@@ -429,6 +435,21 @@ static struct cpu_spec __initdata cpu_specs[] = {
429 .cpu_restore = __restore_cpu_power7, 435 .cpu_restore = __restore_cpu_power7,
430 .platform = "power7", 436 .platform = "power7",
431 }, 437 },
438 { /* 2.07-compliant processor, i.e. Power8 "architected" mode */
439 .pvr_mask = 0xffffffff,
440 .pvr_value = 0x0f000004,
441 .cpu_name = "POWER8 (architected)",
442 .cpu_features = CPU_FTRS_POWER8,
443 .cpu_user_features = COMMON_USER_POWER8,
444 .mmu_features = MMU_FTRS_POWER8,
445 .icache_bsize = 128,
446 .dcache_bsize = 128,
447 .oprofile_type = PPC_OPROFILE_POWER4,
448 .oprofile_cpu_type = "ppc64/ibm-compat-v1",
449 .cpu_setup = __setup_cpu_power8,
450 .cpu_restore = __restore_cpu_power8,
451 .platform = "power8",
452 },
432 { /* Power7 */ 453 { /* Power7 */
433 .pvr_mask = 0xffff0000, 454 .pvr_mask = 0xffff0000,
434 .pvr_value = 0x003f0000, 455 .pvr_value = 0x003f0000,
@@ -463,6 +484,23 @@ static struct cpu_spec __initdata cpu_specs[] = {
463 .cpu_restore = __restore_cpu_power7, 484 .cpu_restore = __restore_cpu_power7,
464 .platform = "power7+", 485 .platform = "power7+",
465 }, 486 },
487 { /* Power8 */
488 .pvr_mask = 0xffff0000,
489 .pvr_value = 0x004b0000,
490 .cpu_name = "POWER8 (raw)",
491 .cpu_features = CPU_FTRS_POWER8,
492 .cpu_user_features = COMMON_USER_POWER8,
493 .mmu_features = MMU_FTRS_POWER8,
494 .icache_bsize = 128,
495 .dcache_bsize = 128,
496 .num_pmcs = 6,
497 .pmc_type = PPC_PMC_IBM,
498 .oprofile_cpu_type = "ppc64/power8",
499 .oprofile_type = PPC_OPROFILE_POWER4,
500 .cpu_setup = __setup_cpu_power8,
501 .cpu_restore = __restore_cpu_power8,
502 .platform = "power8",
503 },
466 { /* Cell Broadband Engine */ 504 { /* Cell Broadband Engine */
467 .pvr_mask = 0xffff0000, 505 .pvr_mask = 0xffff0000,
468 .pvr_value = 0x00700000, 506 .pvr_value = 0x00700000,
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index e9a906c27234..b310a0573625 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -373,6 +373,8 @@ _GLOBAL(ret_from_fork)
373_GLOBAL(ret_from_kernel_thread) 373_GLOBAL(ret_from_kernel_thread)
374 bl .schedule_tail 374 bl .schedule_tail
375 REST_NVGPRS(r1) 375 REST_NVGPRS(r1)
376 li r3,0
377 std r3,0(r1)
376 ld r14, 0(r14) 378 ld r14, 0(r14)
377 mtlr r14 379 mtlr r14
378 mr r3,r15 380 mr r3,r15
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 10b658ad65e1..4665e82fa377 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -19,12 +19,76 @@
19/* 19/*
20 * We layout physical memory as follows: 20 * We layout physical memory as follows:
21 * 0x0000 - 0x00ff : Secondary processor spin code 21 * 0x0000 - 0x00ff : Secondary processor spin code
22 * 0x0100 - 0x2fff : pSeries Interrupt prologs 22 * 0x0100 - 0x17ff : pSeries Interrupt prologs
23 * 0x3000 - 0x5fff : interrupt support common interrupt prologs 23 * 0x1800 - 0x4000 : interrupt support common interrupt prologs
24 * 0x6000 - 0x6fff : Initial (CPU0) segment table 24 * 0x4000 - 0x5fff : pSeries interrupts with IR=1,DR=1
25 * 0x6000 - 0x6fff : more interrupt support including for IR=1,DR=1
25 * 0x7000 - 0x7fff : FWNMI data area 26 * 0x7000 - 0x7fff : FWNMI data area
26 * 0x8000 - : Early init and support code 27 * 0x8000 - 0x8fff : Initial (CPU0) segment table
28 * 0x9000 - : Early init and support code
27 */ 29 */
30 /* Syscall routine is used twice, in reloc-off and reloc-on paths */
31#define SYSCALL_PSERIES_1 \
32BEGIN_FTR_SECTION \
33 cmpdi r0,0x1ebe ; \
34 beq- 1f ; \
35END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
36 mr r9,r13 ; \
37 GET_PACA(r13) ; \
38 mfspr r11,SPRN_SRR0 ; \
390:
40
41#define SYSCALL_PSERIES_2_RFID \
42 mfspr r12,SPRN_SRR1 ; \
43 ld r10,PACAKBASE(r13) ; \
44 LOAD_HANDLER(r10, system_call_entry) ; \
45 mtspr SPRN_SRR0,r10 ; \
46 ld r10,PACAKMSR(r13) ; \
47 mtspr SPRN_SRR1,r10 ; \
48 rfid ; \
49 b . ; /* prevent speculative execution */
50
51#define SYSCALL_PSERIES_3 \
52 /* Fast LE/BE switch system call */ \
531: mfspr r12,SPRN_SRR1 ; \
54 xori r12,r12,MSR_LE ; \
55 mtspr SPRN_SRR1,r12 ; \
56 rfid ; /* return to userspace */ \
57 b . ; \
582: mfspr r12,SPRN_SRR1 ; \
59 andi. r12,r12,MSR_PR ; \
60 bne 0b ; \
61 mtspr SPRN_SRR0,r3 ; \
62 mtspr SPRN_SRR1,r4 ; \
63 mtspr SPRN_SDR1,r5 ; \
64 rfid ; \
65 b . ; /* prevent speculative execution */
66
67#if defined(CONFIG_RELOCATABLE)
68 /*
69 * We can't branch directly; in the direct case we use LR
70 * and system_call_entry restores LR. (We thus need to move
71 * LR to r10 in the RFID case too.)
72 */
73#define SYSCALL_PSERIES_2_DIRECT \
74 mflr r10 ; \
75 ld r12,PACAKBASE(r13) ; \
76 LOAD_HANDLER(r12, system_call_entry_direct) ; \
77 mtlr r12 ; \
78 mfspr r12,SPRN_SRR1 ; \
79 /* Re-use of r13... No spare regs to do this */ \
80 li r13,MSR_RI ; \
81 mtmsrd r13,1 ; \
82 GET_PACA(r13) ; /* get r13 back */ \
83 blr ;
84#else
85 /* We can branch directly */
86#define SYSCALL_PSERIES_2_DIRECT \
87 mfspr r12,SPRN_SRR1 ; \
88 li r10,MSR_RI ; \
89 mtmsrd r10,1 ; /* Set RI (EE=0) */ \
90 b system_call_entry_direct ;
91#endif
28 92
29/* 93/*
30 * This is the start of the interrupt handlers for pSeries 94 * This is the start of the interrupt handlers for pSeries
@@ -207,31 +271,11 @@ system_call_pSeries:
207 KVMTEST(0xc00) 271 KVMTEST(0xc00)
208 GET_SCRATCH0(r13) 272 GET_SCRATCH0(r13)
209#endif 273#endif
210BEGIN_FTR_SECTION 274 SYSCALL_PSERIES_1
211 cmpdi r0,0x1ebe 275 SYSCALL_PSERIES_2_RFID
212 beq- 1f 276 SYSCALL_PSERIES_3
213END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
214 mr r9,r13
215 GET_PACA(r13)
216 mfspr r11,SPRN_SRR0
217 mfspr r12,SPRN_SRR1
218 ld r10,PACAKBASE(r13)
219 LOAD_HANDLER(r10, system_call_entry)
220 mtspr SPRN_SRR0,r10
221 ld r10,PACAKMSR(r13)
222 mtspr SPRN_SRR1,r10
223 rfid
224 b . /* prevent speculative execution */
225
226 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00) 277 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
227 278
228/* Fast LE/BE switch system call */
2291: mfspr r12,SPRN_SRR1
230 xori r12,r12,MSR_LE
231 mtspr SPRN_SRR1,r12
232 rfid /* return to userspace */
233 b .
234
235 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step) 279 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
236 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00) 280 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
237 281
@@ -276,7 +320,7 @@ vsx_unavailable_pSeries_1:
276 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300) 320 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
277 321
278 . = 0x1500 322 . = 0x1500
279 .global denorm_Hypervisor 323 .global denorm_exception_hv
280denorm_exception_hv: 324denorm_exception_hv:
281 HMT_MEDIUM 325 HMT_MEDIUM
282 mtspr SPRN_SPRG_HSCRATCH0,r13 326 mtspr SPRN_SPRG_HSCRATCH0,r13
@@ -311,12 +355,14 @@ denorm_exception_hv:
311#ifdef CONFIG_CBE_RAS 355#ifdef CONFIG_CBE_RAS
312 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal) 356 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
313 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802) 357 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
358#else
359 . = 0x1800
314#endif /* CONFIG_CBE_RAS */ 360#endif /* CONFIG_CBE_RAS */
315 361
316 . = 0x3000
317 362
318/*** Out of line interrupts support ***/ 363/*** Out of line interrupts support ***/
319 364
365 .align 7
320 /* moved from 0x200 */ 366 /* moved from 0x200 */
321machine_check_pSeries: 367machine_check_pSeries:
322 .globl machine_check_fwnmi 368 .globl machine_check_fwnmi
@@ -575,16 +621,12 @@ slb_miss_user_pseries:
575 b . /* prevent spec. execution */ 621 b . /* prevent spec. execution */
576#endif /* __DISABLED__ */ 622#endif /* __DISABLED__ */
577 623
578 .align 7
579 .globl __end_interrupts
580__end_interrupts:
581
582/* 624/*
583 * Code from here down to __end_handlers is invoked from the 625 * Code from here down to __end_handlers is invoked from the
584 * exception prologs above. Because the prologs assemble the 626 * exception prologs above. Because the prologs assemble the
585 * addresses of these handlers using the LOAD_HANDLER macro, 627 * addresses of these handlers using the LOAD_HANDLER macro,
586 * which uses an addi instruction, these handlers must be in 628 * which uses an ori instruction, these handlers must be in
587 * the first 32k of the kernel image. 629 * the first 64k of the kernel image.
588 */ 630 */
589 631
590/*** Common interrupt handlers ***/ 632/*** Common interrupt handlers ***/
@@ -613,8 +655,8 @@ machine_check_common:
613 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) 655 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
614 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) 656 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
615 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) 657 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
616 STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception) 658 STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception)
617 STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception) 659 STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception)
618 STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception) 660 STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception)
619 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) 661 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
620 STD_EXCEPTION_COMMON(0x1502, denorm, .unknown_exception) 662 STD_EXCEPTION_COMMON(0x1502, denorm, .unknown_exception)
@@ -629,7 +671,158 @@ machine_check_common:
629 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) 671 STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
630#endif /* CONFIG_CBE_RAS */ 672#endif /* CONFIG_CBE_RAS */
631 673
674 /*
675 * Relocation-on interrupts: A subset of the interrupts can be delivered
676 * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering
677 * it. Addresses are the same as the original interrupt addresses, but
678 * offset by 0xc000000000004000.
679 * It's impossible to receive interrupts below 0x300 via this mechanism.
680 * KVM: None of these traps are from the guest ; anything that escalated
681 * to HV=1 from HV=0 is delivered via real mode handlers.
682 */
683
684 /*
685 * This uses the standard macro, since the original 0x300 vector
686 * only has extra guff for STAB-based processors -- which never
687 * come here.
688 */
689 STD_RELON_EXCEPTION_PSERIES(0x4300, 0x300, data_access)
690 . = 0x4380
691 .globl data_access_slb_relon_pSeries
692data_access_slb_relon_pSeries:
693 HMT_MEDIUM
694 SET_SCRATCH0(r13)
695 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
696 std r3,PACA_EXSLB+EX_R3(r13)
697 mfspr r3,SPRN_DAR
698 mfspr r12,SPRN_SRR1
699#ifndef CONFIG_RELOCATABLE
700 b .slb_miss_realmode
701#else
702 /*
703 * We can't just use a direct branch to .slb_miss_realmode
704 * because the distance from here to there depends on where
705 * the kernel ends up being put.
706 */
707 mfctr r11
708 ld r10,PACAKBASE(r13)
709 LOAD_HANDLER(r10, .slb_miss_realmode)
710 mtctr r10
711 bctr
712#endif
713
714 STD_RELON_EXCEPTION_PSERIES(0x4400, 0x400, instruction_access)
715 . = 0x4480
716 .globl instruction_access_slb_relon_pSeries
717instruction_access_slb_relon_pSeries:
718 HMT_MEDIUM
719 SET_SCRATCH0(r13)
720 EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
721 std r3,PACA_EXSLB+EX_R3(r13)
722 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
723 mfspr r12,SPRN_SRR1
724#ifndef CONFIG_RELOCATABLE
725 b .slb_miss_realmode
726#else
727 mfctr r11
728 ld r10,PACAKBASE(r13)
729 LOAD_HANDLER(r10, .slb_miss_realmode)
730 mtctr r10
731 bctr
732#endif
733
734 . = 0x4500
735 .globl hardware_interrupt_relon_pSeries;
736 .globl hardware_interrupt_relon_hv;
737hardware_interrupt_relon_pSeries:
738hardware_interrupt_relon_hv:
739 BEGIN_FTR_SECTION
740 _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV)
741 FTR_SECTION_ELSE
742 _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR)
743 ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_206)
744 STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment)
745 STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check)
746 STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable)
747 MASKABLE_RELON_EXCEPTION_PSERIES(0x4900, 0x900, decrementer)
748 STD_RELON_EXCEPTION_HV(0x4980, 0x982, hdecrementer)
749 STD_RELON_EXCEPTION_PSERIES(0x4b00, 0xb00, trap_0b)
750
751 . = 0x4c00
752 .globl system_call_relon_pSeries
753system_call_relon_pSeries:
754 HMT_MEDIUM
755 SYSCALL_PSERIES_1
756 SYSCALL_PSERIES_2_DIRECT
757 SYSCALL_PSERIES_3
758
759 STD_RELON_EXCEPTION_PSERIES(0x4d00, 0xd00, single_step)
760
761 . = 0x4e00
762 b h_data_storage_relon_hv
763
764 . = 0x4e20
765 b h_instr_storage_relon_hv
766
767 . = 0x4e40
768 b emulation_assist_relon_hv
769
770 . = 0x4e50
771 b hmi_exception_relon_hv
772
773 . = 0x4e60
774 b hmi_exception_relon_hv
775
776 /* For when we support the doorbell interrupt:
777 STD_RELON_EXCEPTION_HYPERVISOR(0x4e80, 0xe80, doorbell_hyper)
778 */
779
780performance_monitor_relon_pSeries_1:
781 . = 0x4f00
782 b performance_monitor_relon_pSeries
783
784altivec_unavailable_relon_pSeries_1:
785 . = 0x4f20
786 b altivec_unavailable_relon_pSeries
787
788vsx_unavailable_relon_pSeries_1:
789 . = 0x4f40
790 b vsx_unavailable_relon_pSeries
791
792#ifdef CONFIG_CBE_RAS
793 STD_RELON_EXCEPTION_HV(0x5200, 0x1202, cbe_system_error)
794#endif /* CONFIG_CBE_RAS */
795 STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint)
796#ifdef CONFIG_PPC_DENORMALISATION
797 . = 0x5500
798 b denorm_exception_hv
799#endif
800#ifdef CONFIG_CBE_RAS
801 STD_RELON_EXCEPTION_HV(0x5600, 0x1602, cbe_maintenance)
802#else
803#ifdef CONFIG_HVC_SCOM
804 STD_RELON_EXCEPTION_HV(0x5600, 0x1600, maintence_interrupt)
805 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1600)
806#endif /* CONFIG_HVC_SCOM */
807#endif /* CONFIG_CBE_RAS */
808 STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist)
809#ifdef CONFIG_CBE_RAS
810 STD_RELON_EXCEPTION_HV(0x5800, 0x1802, cbe_thermal)
811#endif /* CONFIG_CBE_RAS */
812
813 /* Other future vectors */
632 .align 7 814 .align 7
815 .globl __end_interrupts
816__end_interrupts:
817
818 .align 7
819system_call_entry_direct:
820#if defined(CONFIG_RELOCATABLE)
821 /* The first level prologue may have used LR to get here, saving
822 * orig in r10. To save hacking/ifdeffing common code, restore here.
823 */
824 mtlr r10
825#endif
633system_call_entry: 826system_call_entry:
634 b system_call_common 827 b system_call_common
635 828
@@ -714,21 +907,21 @@ data_access_common:
714 ld r3,PACA_EXGEN+EX_DAR(r13) 907 ld r3,PACA_EXGEN+EX_DAR(r13)
715 lwz r4,PACA_EXGEN+EX_DSISR(r13) 908 lwz r4,PACA_EXGEN+EX_DSISR(r13)
716 li r5,0x300 909 li r5,0x300
717 b .do_hash_page /* Try to handle as hpte fault */ 910 b .do_hash_page /* Try to handle as hpte fault */
718 911
719 .align 7 912 .align 7
720 .globl h_data_storage_common 913 .globl h_data_storage_common
721h_data_storage_common: 914h_data_storage_common:
722 mfspr r10,SPRN_HDAR 915 mfspr r10,SPRN_HDAR
723 std r10,PACA_EXGEN+EX_DAR(r13) 916 std r10,PACA_EXGEN+EX_DAR(r13)
724 mfspr r10,SPRN_HDSISR 917 mfspr r10,SPRN_HDSISR
725 stw r10,PACA_EXGEN+EX_DSISR(r13) 918 stw r10,PACA_EXGEN+EX_DSISR(r13)
726 EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN) 919 EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
727 bl .save_nvgprs 920 bl .save_nvgprs
728 DISABLE_INTS 921 DISABLE_INTS
729 addi r3,r1,STACK_FRAME_OVERHEAD 922 addi r3,r1,STACK_FRAME_OVERHEAD
730 bl .unknown_exception 923 bl .unknown_exception
731 b .ret_from_except 924 b .ret_from_except
732 925
733 .align 7 926 .align 7
734 .globl instruction_access_common 927 .globl instruction_access_common
@@ -741,7 +934,7 @@ instruction_access_common:
741 li r5,0x400 934 li r5,0x400
742 b .do_hash_page /* Try to handle as hpte fault */ 935 b .do_hash_page /* Try to handle as hpte fault */
743 936
744 STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception) 937 STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception)
745 938
746/* 939/*
747 * Here is the common SLB miss user that is used when going to virtual 940 * Here is the common SLB miss user that is used when going to virtual
@@ -1152,6 +1345,21 @@ _GLOBAL(do_stab_bolted)
1152 rfid 1345 rfid
1153 b . /* prevent speculative execution */ 1346 b . /* prevent speculative execution */
1154 1347
1348
1349 /* Equivalents to the above handlers for relocation-on interrupt vectors */
1350 STD_RELON_EXCEPTION_HV(., 0xe00, h_data_storage)
1351 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe00)
1352 STD_RELON_EXCEPTION_HV(., 0xe20, h_instr_storage)
1353 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe20)
1354 STD_RELON_EXCEPTION_HV(., 0xe40, emulation_assist)
1355 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe40)
1356 STD_RELON_EXCEPTION_HV(., 0xe60, hmi_exception)
1357 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe60)
1358
1359 STD_RELON_EXCEPTION_PSERIES(., 0xf00, performance_monitor)
1360 STD_RELON_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable)
1361 STD_RELON_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable)
1362
1155#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) 1363#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1156/* 1364/*
1157 * Data area reserved for FWNMI option. 1365 * Data area reserved for FWNMI option.
@@ -1164,7 +1372,7 @@ fwnmi_data_area:
1164 /* pseries and powernv need to keep the whole page from 1372 /* pseries and powernv need to keep the whole page from
1165 * 0x7000 to 0x8000 free for use by the firmware 1373 * 0x7000 to 0x8000 free for use by the firmware
1166 */ 1374 */
1167 . = 0x8000 1375 . = 0x8000
1168#endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */ 1376#endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
1169 1377
1170/* Space for CPU0's segment table */ 1378/* Space for CPU0's segment table */
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 58bddee8e1e8..116f0868695b 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -422,7 +422,7 @@ _STATIC(__after_prom_start)
422 tovirt(r6,r6) /* on booke, we already run at PAGE_OFFSET */ 422 tovirt(r6,r6) /* on booke, we already run at PAGE_OFFSET */
423#endif 423#endif
424 424
425#ifdef CONFIG_CRASH_DUMP 425#ifdef CONFIG_RELOCATABLE
426/* 426/*
427 * Check if the kernel has to be running as relocatable kernel based on the 427 * Check if the kernel has to be running as relocatable kernel based on the
428 * variable __run_at_load, if it is set the kernel is treated as relocatable 428 * variable __run_at_load, if it is set the kernel is treated as relocatable
@@ -432,7 +432,8 @@ _STATIC(__after_prom_start)
432 cmplwi cr0,r7,1 432 cmplwi cr0,r7,1
433 bne 3f 433 bne 3f
434 434
435 li r5,__end_interrupts - _stext /* just copy interrupts */ 435 /* just copy interrupts */
436 LOAD_REG_IMMEDIATE(r5, __end_interrupts - _stext)
436 b 5f 437 b 5f
4373: 4383:
438#endif 439#endif
@@ -703,6 +704,7 @@ _INIT_STATIC(start_here_multiplatform)
703 704
704#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL 705#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL
705 /* Setup OPAL entry */ 706 /* Setup OPAL entry */
707 LOAD_REG_ADDR(r11, opal)
706 std r28,0(r11); 708 std r28,0(r11);
707 std r29,8(r11); 709 std r29,8(r11);
708#endif 710#endif
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index 2099d9a879e8..ea78761aa169 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -55,9 +55,6 @@ __setup("powersave=off", powersave_off);
55 */ 55 */
56void cpu_idle(void) 56void cpu_idle(void)
57{ 57{
58 if (ppc_md.idle_loop)
59 ppc_md.idle_loop(); /* doesn't return */
60
61 set_thread_flag(TIF_POLLING_NRFLAG); 58 set_thread_flag(TIF_POLLING_NRFLAG);
62 while (1) { 59 while (1) {
63 tick_nohz_idle_enter(); 60 tick_nohz_idle_enter();
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 8226c6cb348a..c862fd716fe3 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -656,7 +656,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
656 struct iommu_pool *p; 656 struct iommu_pool *p;
657 657
658 /* number of bytes needed for the bitmap */ 658 /* number of bytes needed for the bitmap */
659 sz = (tbl->it_size + 7) >> 3; 659 sz = BITS_TO_LONGS(tbl->it_size) * sizeof(unsigned long);
660 660
661 page = alloc_pages_node(nid, GFP_ATOMIC, get_order(sz)); 661 page = alloc_pages_node(nid, GFP_ATOMIC, get_order(sz));
662 if (!page) 662 if (!page)
@@ -708,7 +708,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
708 708
709void iommu_free_table(struct iommu_table *tbl, const char *node_name) 709void iommu_free_table(struct iommu_table *tbl, const char *node_name)
710{ 710{
711 unsigned long bitmap_sz, i; 711 unsigned long bitmap_sz;
712 unsigned int order; 712 unsigned int order;
713 713
714 if (!tbl || !tbl->it_map) { 714 if (!tbl || !tbl->it_map) {
@@ -718,17 +718,11 @@ void iommu_free_table(struct iommu_table *tbl, const char *node_name)
718 } 718 }
719 719
720 /* verify that table contains no entries */ 720 /* verify that table contains no entries */
721 /* it_size is in entries, and we're examining 64 at a time */ 721 if (!bitmap_empty(tbl->it_map, tbl->it_size))
722 for (i = 0; i < (tbl->it_size/64); i++) { 722 pr_warn("%s: Unexpected TCEs for %s\n", __func__, node_name);
723 if (tbl->it_map[i] != 0) {
724 printk(KERN_WARNING "%s: Unexpected TCEs for %s\n",
725 __func__, node_name);
726 break;
727 }
728 }
729 723
730 /* calculate bitmap size in bytes */ 724 /* calculate bitmap size in bytes */
731 bitmap_sz = (tbl->it_size + 7) / 8; 725 bitmap_sz = BITS_TO_LONGS(tbl->it_size) * sizeof(unsigned long);
732 726
733 /* free bitmap */ 727 /* free bitmap */
734 order = get_order(bitmap_sz); 728 order = get_order(bitmap_sz);
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index fa9f6c72f557..e1ec57e87b3b 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -218,23 +218,23 @@ static void __init export_crashk_values(struct device_node *node)
218 * be sure what's in them, so remove them. */ 218 * be sure what's in them, so remove them. */
219 prop = of_find_property(node, "linux,crashkernel-base", NULL); 219 prop = of_find_property(node, "linux,crashkernel-base", NULL);
220 if (prop) 220 if (prop)
221 prom_remove_property(node, prop); 221 of_remove_property(node, prop);
222 222
223 prop = of_find_property(node, "linux,crashkernel-size", NULL); 223 prop = of_find_property(node, "linux,crashkernel-size", NULL);
224 if (prop) 224 if (prop)
225 prom_remove_property(node, prop); 225 of_remove_property(node, prop);
226 226
227 if (crashk_res.start != 0) { 227 if (crashk_res.start != 0) {
228 prom_add_property(node, &crashk_base_prop); 228 of_add_property(node, &crashk_base_prop);
229 crashk_size = resource_size(&crashk_res); 229 crashk_size = resource_size(&crashk_res);
230 prom_add_property(node, &crashk_size_prop); 230 of_add_property(node, &crashk_size_prop);
231 } 231 }
232 232
233 /* 233 /*
234 * memory_limit is required by the kexec-tools to limit the 234 * memory_limit is required by the kexec-tools to limit the
235 * crash regions to the actual memory used. 235 * crash regions to the actual memory used.
236 */ 236 */
237 prom_update_property(node, &memory_limit_prop); 237 of_update_property(node, &memory_limit_prop);
238} 238}
239 239
240static int __init kexec_setup(void) 240static int __init kexec_setup(void)
@@ -249,11 +249,11 @@ static int __init kexec_setup(void)
249 /* remove any stale properties so ours can be found */ 249 /* remove any stale properties so ours can be found */
250 prop = of_find_property(node, kernel_end_prop.name, NULL); 250 prop = of_find_property(node, kernel_end_prop.name, NULL);
251 if (prop) 251 if (prop)
252 prom_remove_property(node, prop); 252 of_remove_property(node, prop);
253 253
254 /* information needed by userspace when using default_machine_kexec */ 254 /* information needed by userspace when using default_machine_kexec */
255 kernel_end = __pa(_end); 255 kernel_end = __pa(_end);
256 prom_add_property(node, &kernel_end_prop); 256 of_add_property(node, &kernel_end_prop);
257 257
258 export_crashk_values(node); 258 export_crashk_values(node);
259 259
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index d7f609086a99..7206701b1ff1 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -389,14 +389,14 @@ static int __init export_htab_values(void)
389 /* remove any stale propertys so ours can be found */ 389 /* remove any stale propertys so ours can be found */
390 prop = of_find_property(node, htab_base_prop.name, NULL); 390 prop = of_find_property(node, htab_base_prop.name, NULL);
391 if (prop) 391 if (prop)
392 prom_remove_property(node, prop); 392 of_remove_property(node, prop);
393 prop = of_find_property(node, htab_size_prop.name, NULL); 393 prop = of_find_property(node, htab_size_prop.name, NULL);
394 if (prop) 394 if (prop)
395 prom_remove_property(node, prop); 395 of_remove_property(node, prop);
396 396
397 htab_base = __pa(htab_address); 397 htab_base = __pa(htab_address);
398 prom_add_property(node, &htab_base_prop); 398 of_add_property(node, &htab_base_prop);
399 prom_add_property(node, &htab_size_prop); 399 of_add_property(node, &htab_size_prop);
400 400
401 of_node_put(node); 401 of_node_put(node);
402 return 0; 402 return 0;
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 4b06ec5a502e..64f526a321f5 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -208,7 +208,7 @@ pci_create_OF_bus_map(void)
208 of_prop->name = "pci-OF-bus-map"; 208 of_prop->name = "pci-OF-bus-map";
209 of_prop->length = 256; 209 of_prop->length = 256;
210 of_prop->value = &of_prop[1]; 210 of_prop->value = &of_prop[1];
211 prom_add_property(dn, of_prop); 211 of_add_property(dn, of_prop);
212 of_node_put(dn); 212 of_node_put(dn);
213 } 213 }
214} 214}
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 37725e86651e..8b6f7a99cce2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -32,6 +32,7 @@
32#include <linux/debugfs.h> 32#include <linux/debugfs.h>
33#include <linux/irq.h> 33#include <linux/irq.h>
34#include <linux/memblock.h> 34#include <linux/memblock.h>
35#include <linux/of.h>
35 36
36#include <asm/prom.h> 37#include <asm/prom.h>
37#include <asm/rtas.h> 38#include <asm/rtas.h>
@@ -49,11 +50,11 @@
49#include <asm/btext.h> 50#include <asm/btext.h>
50#include <asm/sections.h> 51#include <asm/sections.h>
51#include <asm/machdep.h> 52#include <asm/machdep.h>
52#include <asm/pSeries_reconfig.h>
53#include <asm/pci-bridge.h> 53#include <asm/pci-bridge.h>
54#include <asm/kexec.h> 54#include <asm/kexec.h>
55#include <asm/opal.h> 55#include <asm/opal.h>
56#include <asm/fadump.h> 56#include <asm/fadump.h>
57#include <asm/debug.h>
57 58
58#include <mm/mmu_decl.h> 59#include <mm/mmu_decl.h>
59 60
@@ -802,7 +803,7 @@ static int prom_reconfig_notifier(struct notifier_block *nb,
802 int err; 803 int err;
803 804
804 switch (action) { 805 switch (action) {
805 case PSERIES_RECONFIG_ADD: 806 case OF_RECONFIG_ATTACH_NODE:
806 err = of_finish_dynamic_node(node); 807 err = of_finish_dynamic_node(node);
807 if (err < 0) 808 if (err < 0)
808 printk(KERN_ERR "finish_node returned %d\n", err); 809 printk(KERN_ERR "finish_node returned %d\n", err);
@@ -821,7 +822,7 @@ static struct notifier_block prom_reconfig_nb = {
821 822
822static int __init prom_reconfig_setup(void) 823static int __init prom_reconfig_setup(void)
823{ 824{
824 return pSeries_reconfig_notifier_register(&prom_reconfig_nb); 825 return of_reconfig_notifier_register(&prom_reconfig_nb);
825} 826}
826__initcall(prom_reconfig_setup); 827__initcall(prom_reconfig_setup);
827#endif 828#endif
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index cb6c123722a2..779f34049a56 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -671,6 +671,7 @@ static void __init early_cmdline_parse(void)
671#define OV1_PPC_2_04 0x08 /* set if we support PowerPC 2.04 */ 671#define OV1_PPC_2_04 0x08 /* set if we support PowerPC 2.04 */
672#define OV1_PPC_2_05 0x04 /* set if we support PowerPC 2.05 */ 672#define OV1_PPC_2_05 0x04 /* set if we support PowerPC 2.05 */
673#define OV1_PPC_2_06 0x02 /* set if we support PowerPC 2.06 */ 673#define OV1_PPC_2_06 0x02 /* set if we support PowerPC 2.06 */
674#define OV1_PPC_2_07 0x01 /* set if we support PowerPC 2.07 */
674 675
675/* Option vector 2: Open Firmware options supported */ 676/* Option vector 2: Open Firmware options supported */
676#define OV2_REAL_MODE 0x20 /* set if we want OF in real mode */ 677#define OV2_REAL_MODE 0x20 /* set if we want OF in real mode */
@@ -707,6 +708,7 @@ static void __init early_cmdline_parse(void)
707#define OV5_PFO_HW_RNG 0x80 /* PFO Random Number Generator */ 708#define OV5_PFO_HW_RNG 0x80 /* PFO Random Number Generator */
708#define OV5_PFO_HW_842 0x40 /* PFO Compression Accelerator */ 709#define OV5_PFO_HW_842 0x40 /* PFO Compression Accelerator */
709#define OV5_PFO_HW_ENCR 0x20 /* PFO Encryption Accelerator */ 710#define OV5_PFO_HW_ENCR 0x20 /* PFO Encryption Accelerator */
711#define OV5_SUB_PROCESSORS 0x01 /* 1,2,or 4 Sub-Processors supported */
710 712
711/* Option Vector 6: IBM PAPR hints */ 713/* Option Vector 6: IBM PAPR hints */
712#define OV6_LINUX 0x02 /* Linux is our OS */ 714#define OV6_LINUX 0x02 /* Linux is our OS */
@@ -719,6 +721,8 @@ static unsigned char ibm_architecture_vec[] = {
719 W(0xfffe0000), W(0x003a0000), /* POWER5/POWER5+ */ 721 W(0xfffe0000), W(0x003a0000), /* POWER5/POWER5+ */
720 W(0xffff0000), W(0x003e0000), /* POWER6 */ 722 W(0xffff0000), W(0x003e0000), /* POWER6 */
721 W(0xffff0000), W(0x003f0000), /* POWER7 */ 723 W(0xffff0000), W(0x003f0000), /* POWER7 */
724 W(0xffff0000), W(0x004b0000), /* POWER8 */
725 W(0xffffffff), W(0x0f000004), /* all 2.07-compliant */
722 W(0xffffffff), W(0x0f000003), /* all 2.06-compliant */ 726 W(0xffffffff), W(0x0f000003), /* all 2.06-compliant */
723 W(0xffffffff), W(0x0f000002), /* all 2.05-compliant */ 727 W(0xffffffff), W(0x0f000002), /* all 2.05-compliant */
724 W(0xfffffffe), W(0x0f000001), /* all 2.04-compliant and earlier */ 728 W(0xfffffffe), W(0x0f000001), /* all 2.04-compliant and earlier */
@@ -728,7 +732,7 @@ static unsigned char ibm_architecture_vec[] = {
728 3 - 2, /* length */ 732 3 - 2, /* length */
729 0, /* don't ignore, don't halt */ 733 0, /* don't ignore, don't halt */
730 OV1_PPC_2_00 | OV1_PPC_2_01 | OV1_PPC_2_02 | OV1_PPC_2_03 | 734 OV1_PPC_2_00 | OV1_PPC_2_01 | OV1_PPC_2_02 | OV1_PPC_2_03 |
731 OV1_PPC_2_04 | OV1_PPC_2_05 | OV1_PPC_2_06, 735 OV1_PPC_2_04 | OV1_PPC_2_05 | OV1_PPC_2_06 | OV1_PPC_2_07,
732 736
733 /* option vector 2: Open Firmware options supported */ 737 /* option vector 2: Open Firmware options supported */
734 34 - 2, /* length */ 738 34 - 2, /* length */
@@ -755,7 +759,7 @@ static unsigned char ibm_architecture_vec[] = {
755 OV4_MIN_ENT_CAP, /* minimum VP entitled capacity */ 759 OV4_MIN_ENT_CAP, /* minimum VP entitled capacity */
756 760
757 /* option vector 5: PAPR/OF options */ 761 /* option vector 5: PAPR/OF options */
758 18 - 2, /* length */ 762 19 - 2, /* length */
759 0, /* don't ignore, don't halt */ 763 0, /* don't ignore, don't halt */
760 OV5_LPAR | OV5_SPLPAR | OV5_LARGE_PAGES | OV5_DRCONF_MEMORY | 764 OV5_LPAR | OV5_SPLPAR | OV5_LARGE_PAGES | OV5_DRCONF_MEMORY |
761 OV5_DONATE_DEDICATE_CPU | OV5_MSI, 765 OV5_DONATE_DEDICATE_CPU | OV5_MSI,
@@ -769,13 +773,14 @@ static unsigned char ibm_architecture_vec[] = {
769 * must match by the macro below. Update the definition if 773 * must match by the macro below. Update the definition if
770 * the structure layout changes. 774 * the structure layout changes.
771 */ 775 */
772#define IBM_ARCH_VEC_NRCORES_OFFSET 101 776#define IBM_ARCH_VEC_NRCORES_OFFSET 117
773 W(NR_CPUS), /* number of cores supported */ 777 W(NR_CPUS), /* number of cores supported */
774 0, 778 0,
775 0, 779 0,
776 0, 780 0,
777 0, 781 0,
778 OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR | OV5_PFO_HW_842, 782 OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR | OV5_PFO_HW_842,
783 OV5_SUB_PROCESSORS,
779 /* option vector 6: IBM PAPR hints */ 784 /* option vector 6: IBM PAPR hints */
780 4 - 2, /* length */ 785 4 - 2, /* length */
781 0, 786 0,
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 79d8e56470df..c4970004d44d 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -952,6 +952,10 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
952 arch_bp_generic_fields(data & 952 arch_bp_generic_fields(data &
953 (DABR_DATA_WRITE | DABR_DATA_READ), 953 (DABR_DATA_WRITE | DABR_DATA_READ),
954 &attr.bp_type); 954 &attr.bp_type);
955
956 /* Enable breakpoint */
957 attr.disabled = false;
958
955 ret = modify_user_hw_breakpoint(bp, &attr); 959 ret = modify_user_hw_breakpoint(bp, &attr);
956 if (ret) { 960 if (ret) {
957 ptrace_put_breakpoints(task); 961 ptrace_put_breakpoints(task);
@@ -1037,7 +1041,7 @@ void ptrace_disable(struct task_struct *child)
1037} 1041}
1038 1042
1039#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1043#ifdef CONFIG_PPC_ADV_DEBUG_REGS
1040static long set_intruction_bp(struct task_struct *child, 1044static long set_instruction_bp(struct task_struct *child,
1041 struct ppc_hw_breakpoint *bp_info) 1045 struct ppc_hw_breakpoint *bp_info)
1042{ 1046{
1043 int slot; 1047 int slot;
@@ -1338,6 +1342,12 @@ static int set_dac_range(struct task_struct *child,
1338static long ppc_set_hwdebug(struct task_struct *child, 1342static long ppc_set_hwdebug(struct task_struct *child,
1339 struct ppc_hw_breakpoint *bp_info) 1343 struct ppc_hw_breakpoint *bp_info)
1340{ 1344{
1345#ifdef CONFIG_HAVE_HW_BREAKPOINT
1346 int len = 0;
1347 struct thread_struct *thread = &(child->thread);
1348 struct perf_event *bp;
1349 struct perf_event_attr attr;
1350#endif /* CONFIG_HAVE_HW_BREAKPOINT */
1341#ifndef CONFIG_PPC_ADV_DEBUG_REGS 1351#ifndef CONFIG_PPC_ADV_DEBUG_REGS
1342 unsigned long dabr; 1352 unsigned long dabr;
1343#endif 1353#endif
@@ -1365,7 +1375,7 @@ static long ppc_set_hwdebug(struct task_struct *child,
1365 if ((bp_info->trigger_type != PPC_BREAKPOINT_TRIGGER_EXECUTE) || 1375 if ((bp_info->trigger_type != PPC_BREAKPOINT_TRIGGER_EXECUTE) ||
1366 (bp_info->condition_mode != PPC_BREAKPOINT_CONDITION_NONE)) 1376 (bp_info->condition_mode != PPC_BREAKPOINT_CONDITION_NONE))
1367 return -EINVAL; 1377 return -EINVAL;
1368 return set_intruction_bp(child, bp_info); 1378 return set_instruction_bp(child, bp_info);
1369 } 1379 }
1370 if (bp_info->addr_mode == PPC_BREAKPOINT_MODE_EXACT) 1380 if (bp_info->addr_mode == PPC_BREAKPOINT_MODE_EXACT)
1371 return set_dac(child, bp_info); 1381 return set_dac(child, bp_info);
@@ -1381,13 +1391,9 @@ static long ppc_set_hwdebug(struct task_struct *child,
1381 */ 1391 */
1382 if ((bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_RW) == 0 || 1392 if ((bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_RW) == 0 ||
1383 (bp_info->trigger_type & ~PPC_BREAKPOINT_TRIGGER_RW) != 0 || 1393 (bp_info->trigger_type & ~PPC_BREAKPOINT_TRIGGER_RW) != 0 ||
1384 bp_info->addr_mode != PPC_BREAKPOINT_MODE_EXACT ||
1385 bp_info->condition_mode != PPC_BREAKPOINT_CONDITION_NONE) 1394 bp_info->condition_mode != PPC_BREAKPOINT_CONDITION_NONE)
1386 return -EINVAL; 1395 return -EINVAL;
1387 1396
1388 if (child->thread.dabr)
1389 return -ENOSPC;
1390
1391 if ((unsigned long)bp_info->addr >= TASK_SIZE) 1397 if ((unsigned long)bp_info->addr >= TASK_SIZE)
1392 return -EIO; 1398 return -EIO;
1393 1399
@@ -1397,6 +1403,50 @@ static long ppc_set_hwdebug(struct task_struct *child,
1397 dabr |= DABR_DATA_READ; 1403 dabr |= DABR_DATA_READ;
1398 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE) 1404 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE)
1399 dabr |= DABR_DATA_WRITE; 1405 dabr |= DABR_DATA_WRITE;
1406#ifdef CONFIG_HAVE_HW_BREAKPOINT
1407 if (ptrace_get_breakpoints(child) < 0)
1408 return -ESRCH;
1409
1410 /*
1411 * Check if the request is for 'range' breakpoints. We can
1412 * support it if range < 8 bytes.
1413 */
1414 if (bp_info->addr_mode == PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE) {
1415 len = bp_info->addr2 - bp_info->addr;
1416 } else if (bp_info->addr_mode != PPC_BREAKPOINT_MODE_EXACT) {
1417 ptrace_put_breakpoints(child);
1418 return -EINVAL;
1419 }
1420 bp = thread->ptrace_bps[0];
1421 if (bp) {
1422 ptrace_put_breakpoints(child);
1423 return -ENOSPC;
1424 }
1425
1426 /* Create a new breakpoint request if one doesn't exist already */
1427 hw_breakpoint_init(&attr);
1428 attr.bp_addr = (unsigned long)bp_info->addr & ~HW_BREAKPOINT_ALIGN;
1429 attr.bp_len = len;
1430 arch_bp_generic_fields(dabr & (DABR_DATA_WRITE | DABR_DATA_READ),
1431 &attr.bp_type);
1432
1433 thread->ptrace_bps[0] = bp = register_user_hw_breakpoint(&attr,
1434 ptrace_triggered, NULL, child);
1435 if (IS_ERR(bp)) {
1436 thread->ptrace_bps[0] = NULL;
1437 ptrace_put_breakpoints(child);
1438 return PTR_ERR(bp);
1439 }
1440
1441 ptrace_put_breakpoints(child);
1442 return 1;
1443#endif /* CONFIG_HAVE_HW_BREAKPOINT */
1444
1445 if (bp_info->addr_mode != PPC_BREAKPOINT_MODE_EXACT)
1446 return -EINVAL;
1447
1448 if (child->thread.dabr)
1449 return -ENOSPC;
1400 1450
1401 child->thread.dabr = dabr; 1451 child->thread.dabr = dabr;
1402 child->thread.dabrx = DABRX_ALL; 1452 child->thread.dabrx = DABRX_ALL;
@@ -1405,8 +1455,13 @@ static long ppc_set_hwdebug(struct task_struct *child,
1405#endif /* !CONFIG_PPC_ADV_DEBUG_DVCS */ 1455#endif /* !CONFIG_PPC_ADV_DEBUG_DVCS */
1406} 1456}
1407 1457
1408static long ppc_del_hwdebug(struct task_struct *child, long addr, long data) 1458static long ppc_del_hwdebug(struct task_struct *child, long data)
1409{ 1459{
1460#ifdef CONFIG_HAVE_HW_BREAKPOINT
1461 int ret = 0;
1462 struct thread_struct *thread = &(child->thread);
1463 struct perf_event *bp;
1464#endif /* CONFIG_HAVE_HW_BREAKPOINT */
1410#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1465#ifdef CONFIG_PPC_ADV_DEBUG_REGS
1411 int rc; 1466 int rc;
1412 1467
@@ -1426,10 +1481,25 @@ static long ppc_del_hwdebug(struct task_struct *child, long addr, long data)
1426#else 1481#else
1427 if (data != 1) 1482 if (data != 1)
1428 return -EINVAL; 1483 return -EINVAL;
1484
1485#ifdef CONFIG_HAVE_HW_BREAKPOINT
1486 if (ptrace_get_breakpoints(child) < 0)
1487 return -ESRCH;
1488
1489 bp = thread->ptrace_bps[0];
1490 if (bp) {
1491 unregister_hw_breakpoint(bp);
1492 thread->ptrace_bps[0] = NULL;
1493 } else
1494 ret = -ENOENT;
1495 ptrace_put_breakpoints(child);
1496 return ret;
1497#else /* CONFIG_HAVE_HW_BREAKPOINT */
1429 if (child->thread.dabr == 0) 1498 if (child->thread.dabr == 0)
1430 return -ENOENT; 1499 return -ENOENT;
1431 1500
1432 child->thread.dabr = 0; 1501 child->thread.dabr = 0;
1502#endif /* CONFIG_HAVE_HW_BREAKPOINT */
1433 1503
1434 return 0; 1504 return 0;
1435#endif 1505#endif
@@ -1536,7 +1606,11 @@ long arch_ptrace(struct task_struct *child, long request,
1536 dbginfo.data_bp_alignment = 4; 1606 dbginfo.data_bp_alignment = 4;
1537#endif 1607#endif
1538 dbginfo.sizeof_condition = 0; 1608 dbginfo.sizeof_condition = 0;
1609#ifdef CONFIG_HAVE_HW_BREAKPOINT
1610 dbginfo.features = PPC_DEBUG_FEATURE_DATA_BP_RANGE;
1611#else
1539 dbginfo.features = 0; 1612 dbginfo.features = 0;
1613#endif /* CONFIG_HAVE_HW_BREAKPOINT */
1540#endif /* CONFIG_PPC_ADV_DEBUG_REGS */ 1614#endif /* CONFIG_PPC_ADV_DEBUG_REGS */
1541 1615
1542 if (!access_ok(VERIFY_WRITE, datavp, 1616 if (!access_ok(VERIFY_WRITE, datavp,
@@ -1563,7 +1637,7 @@ long arch_ptrace(struct task_struct *child, long request,
1563 } 1637 }
1564 1638
1565 case PPC_PTRACE_DELHWDEBUG: { 1639 case PPC_PTRACE_DELHWDEBUG: {
1566 ret = ppc_del_hwdebug(child, addr, data); 1640 ret = ppc_del_hwdebug(child, data);
1567 break; 1641 break;
1568 } 1642 }
1569 1643
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index fcec38241f79..1fd6e7b2f390 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -42,7 +42,6 @@
42#include <asm/time.h> 42#include <asm/time.h>
43#include <asm/mmu.h> 43#include <asm/mmu.h>
44#include <asm/topology.h> 44#include <asm/topology.h>
45#include <asm/pSeries_reconfig.h>
46 45
47struct rtas_t rtas = { 46struct rtas_t rtas = {
48 .lock = __ARCH_SPIN_LOCK_UNLOCKED 47 .lock = __ARCH_SPIN_LOCK_UNLOCKED
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 20b0120db0c3..8329190312c1 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -650,10 +650,8 @@ static int initialize_flash_pde_data(const char *rtas_call_name,
650 int token; 650 int token;
651 651
652 dp->data = kzalloc(buf_size, GFP_KERNEL); 652 dp->data = kzalloc(buf_size, GFP_KERNEL);
653 if (dp->data == NULL) { 653 if (dp->data == NULL)
654 remove_flash_pde(dp);
655 return -ENOMEM; 654 return -ENOMEM;
656 }
657 655
658 /* 656 /*
659 * This code assumes that the status int is the first member of the 657 * This code assumes that the status int is the first member of the
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index efb6a41b3131..6da881b35dac 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -601,6 +601,11 @@ void __init setup_arch(char **cmdline_p)
601 601
602 kvm_linear_init(); 602 kvm_linear_init();
603 603
604 /* Interrupt code needs to be 64K-aligned */
605 if ((unsigned long)_stext & 0xffff)
606 panic("Kernelbase not 64K-aligned (0x%lx)!\n",
607 (unsigned long)_stext);
608
604 ppc64_boot_msg(0x15, "Setup Done"); 609 ppc64_boot_msg(0x15, "Setup Done");
605} 610}
606 611
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index c39c1ca77f46..f9748498fe58 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -122,29 +122,6 @@ int udbg_write(const char *s, int n)
122 return n - remain; 122 return n - remain;
123} 123}
124 124
125int udbg_read(char *buf, int buflen)
126{
127 char *p = buf;
128 int i, c;
129
130 if (!udbg_getc)
131 return 0;
132
133 for (i = 0; i < buflen; ++i) {
134 do {
135 c = udbg_getc();
136 if (c == -1 && i == 0)
137 return -1;
138
139 } while (c == 0x11 || c == 0x13);
140 if (c == 0 || c == -1)
141 break;
142 *p++ = c;
143 }
144
145 return i;
146}
147
148#define UDBG_BUFSIZE 256 125#define UDBG_BUFSIZE 256
149void udbg_printf(const char *fmt, ...) 126void udbg_printf(const char *fmt, ...)
150{ 127{