aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/asm-offsets.c193
-rw-r--r--arch/powerpc/kernel/cpu_setup_power7.S22
-rw-r--r--arch/powerpc/kernel/cpu_setup_ppc970.S26
-rw-r--r--arch/powerpc/kernel/cputable.c11
-rw-r--r--arch/powerpc/kernel/crash.c6
-rw-r--r--arch/powerpc/kernel/dma.c4
-rw-r--r--arch/powerpc/kernel/e500-pmu.c5
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S22
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S228
-rw-r--r--arch/powerpc/kernel/head_44x.S42
-rw-r--r--arch/powerpc/kernel/head_64.S2
-rw-r--r--arch/powerpc/kernel/head_booke.h42
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S57
-rw-r--r--arch/powerpc/kernel/idle_e500.S12
-rw-r--r--arch/powerpc/kernel/idle_power7.S2
-rw-r--r--arch/powerpc/kernel/iomap.c2
-rw-r--r--arch/powerpc/kernel/irq.c65
-rw-r--r--arch/powerpc/kernel/jump_label.c23
-rw-r--r--arch/powerpc/kernel/kvm.c1
-rw-r--r--arch/powerpc/kernel/machine_kexec.c14
-rw-r--r--arch/powerpc/kernel/misc_64.S4
-rw-r--r--arch/powerpc/kernel/module.c18
-rw-r--r--arch/powerpc/kernel/module_32.c11
-rw-r--r--arch/powerpc/kernel/module_64.c10
-rw-r--r--arch/powerpc/kernel/mpc7450-pmu.c7
-rw-r--r--arch/powerpc/kernel/of_platform.c2
-rw-r--r--arch/powerpc/kernel/paca.c2
-rw-r--r--arch/powerpc/kernel/pci-common.c53
-rw-r--r--arch/powerpc/kernel/pci_32.c171
-rw-r--r--arch/powerpc/kernel/pci_64.c4
-rw-r--r--arch/powerpc/kernel/pci_dn.c47
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c9
-rw-r--r--arch/powerpc/kernel/perf_callchain.c20
-rw-r--r--arch/powerpc/kernel/perf_event.c8
-rw-r--r--arch/powerpc/kernel/perf_event_fsl_emb.c6
-rw-r--r--arch/powerpc/kernel/power4-pmu.c7
-rw-r--r--arch/powerpc/kernel/power5+-pmu.c7
-rw-r--r--arch/powerpc/kernel/power5-pmu.c7
-rw-r--r--arch/powerpc/kernel/power6-pmu.c7
-rw-r--r--arch/powerpc/kernel/power7-pmu.c7
-rw-r--r--arch/powerpc/kernel/ppc970-pmu.c7
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c2
-rw-r--r--arch/powerpc/kernel/process.c8
-rw-r--r--arch/powerpc/kernel/prom.c16
-rw-r--r--arch/powerpc/kernel/prom_init.c14
-rw-r--r--arch/powerpc/kernel/ptrace.c4
-rw-r--r--arch/powerpc/kernel/rtas.c3
-rw-r--r--arch/powerpc/kernel/rtas_flash.c1
-rw-r--r--arch/powerpc/kernel/rtas_pci.c2
-rw-r--r--arch/powerpc/kernel/rtasd.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c30
-rw-r--r--arch/powerpc/kernel/setup_32.c6
-rw-r--r--arch/powerpc/kernel/setup_64.c10
-rw-r--r--arch/powerpc/kernel/smp-tbsync.c2
-rw-r--r--arch/powerpc/kernel/smp.c33
-rw-r--r--arch/powerpc/kernel/time.c11
-rw-r--r--arch/powerpc/kernel/traps.c5
-rw-r--r--arch/powerpc/kernel/udbg.c5
59 files changed, 763 insertions, 585 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index e8b981897d4..ce4f7f17911 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_MODULES) += module.o module_$(CONFIG_WORD_SIZE).o
76obj-$(CONFIG_44x) += cpu_setup_44x.o 76obj-$(CONFIG_44x) += cpu_setup_44x.o
77obj-$(CONFIG_PPC_FSL_BOOK3E) += cpu_setup_fsl_booke.o dbell.o 77obj-$(CONFIG_PPC_FSL_BOOK3E) += cpu_setup_fsl_booke.o dbell.o
78obj-$(CONFIG_PPC_BOOK3E_64) += dbell.o 78obj-$(CONFIG_PPC_BOOK3E_64) += dbell.o
79obj-$(CONFIG_JUMP_LABEL) += jump_label.o
79 80
80extra-y := head_$(CONFIG_WORD_SIZE).o 81extra-y := head_$(CONFIG_WORD_SIZE).o
81extra-$(CONFIG_40x) := head_40x.o 82extra-$(CONFIG_40x) := head_40x.o
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 36e1c8a29be..5f078bc2063 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -82,6 +82,9 @@ int main(void)
82 DEFINE(KSP, offsetof(struct thread_struct, ksp)); 82 DEFINE(KSP, offsetof(struct thread_struct, ksp));
83 DEFINE(KSP_LIMIT, offsetof(struct thread_struct, ksp_limit)); 83 DEFINE(KSP_LIMIT, offsetof(struct thread_struct, ksp_limit));
84 DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); 84 DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
85#ifdef CONFIG_BOOKE
86 DEFINE(THREAD_NORMSAVES, offsetof(struct thread_struct, normsave[0]));
87#endif
85 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); 88 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
86 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); 89 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));
87 DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr)); 90 DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr));
@@ -128,6 +131,7 @@ int main(void)
128 DEFINE(ICACHEL1LINESPERPAGE, offsetof(struct ppc64_caches, ilines_per_page)); 131 DEFINE(ICACHEL1LINESPERPAGE, offsetof(struct ppc64_caches, ilines_per_page));
129 /* paca */ 132 /* paca */
130 DEFINE(PACA_SIZE, sizeof(struct paca_struct)); 133 DEFINE(PACA_SIZE, sizeof(struct paca_struct));
134 DEFINE(PACA_LOCK_TOKEN, offsetof(struct paca_struct, lock_token));
131 DEFINE(PACAPACAINDEX, offsetof(struct paca_struct, paca_index)); 135 DEFINE(PACAPACAINDEX, offsetof(struct paca_struct, paca_index));
132 DEFINE(PACAPROCSTART, offsetof(struct paca_struct, cpu_start)); 136 DEFINE(PACAPROCSTART, offsetof(struct paca_struct, cpu_start));
133 DEFINE(PACAKSAVE, offsetof(struct paca_struct, kstack)); 137 DEFINE(PACAKSAVE, offsetof(struct paca_struct, kstack));
@@ -187,7 +191,9 @@ int main(void)
187 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1)); 191 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1));
188 DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int)); 192 DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int));
189 DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int)); 193 DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int));
194 DEFINE(LPPACA_PMCINUSE, offsetof(struct lppaca, pmcregs_in_use));
190 DEFINE(LPPACA_DTLIDX, offsetof(struct lppaca, dtl_idx)); 195 DEFINE(LPPACA_DTLIDX, offsetof(struct lppaca, dtl_idx));
196 DEFINE(LPPACA_YIELDCOUNT, offsetof(struct lppaca, yield_count));
191 DEFINE(PACA_DTL_RIDX, offsetof(struct paca_struct, dtl_ridx)); 197 DEFINE(PACA_DTL_RIDX, offsetof(struct paca_struct, dtl_ridx));
192#endif /* CONFIG_PPC_STD_MMU_64 */ 198#endif /* CONFIG_PPC_STD_MMU_64 */
193 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp)); 199 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp));
@@ -198,11 +204,6 @@ int main(void)
198 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time)); 204 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
199 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); 205 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
200 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save)); 206 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));
201#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
202 DEFINE(PACA_KVM_SVCPU, offsetof(struct paca_struct, shadow_vcpu));
203 DEFINE(SVCPU_SLB, offsetof(struct kvmppc_book3s_shadow_vcpu, slb));
204 DEFINE(SVCPU_SLB_MAX, offsetof(struct kvmppc_book3s_shadow_vcpu, slb_max));
205#endif
206#endif /* CONFIG_PPC64 */ 207#endif /* CONFIG_PPC64 */
207 208
208 /* RTAS */ 209 /* RTAS */
@@ -397,67 +398,160 @@ int main(void)
397 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 398 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
398 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); 399 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr));
399 DEFINE(VCPU_VRSAVE, offsetof(struct kvm_vcpu, arch.vrsave)); 400 DEFINE(VCPU_VRSAVE, offsetof(struct kvm_vcpu, arch.vrsave));
401 DEFINE(VCPU_FPRS, offsetof(struct kvm_vcpu, arch.fpr));
402 DEFINE(VCPU_FPSCR, offsetof(struct kvm_vcpu, arch.fpscr));
403#ifdef CONFIG_ALTIVEC
404 DEFINE(VCPU_VRS, offsetof(struct kvm_vcpu, arch.vr));
405 DEFINE(VCPU_VSCR, offsetof(struct kvm_vcpu, arch.vscr));
406#endif
407#ifdef CONFIG_VSX
408 DEFINE(VCPU_VSRS, offsetof(struct kvm_vcpu, arch.vsr));
409#endif
410 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer));
411 DEFINE(VCPU_CTR, offsetof(struct kvm_vcpu, arch.ctr));
412 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr));
413 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr));
414 DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc));
415#ifdef CONFIG_KVM_BOOK3S_64_HV
416 DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.shregs.msr));
417 DEFINE(VCPU_SRR0, offsetof(struct kvm_vcpu, arch.shregs.srr0));
418 DEFINE(VCPU_SRR1, offsetof(struct kvm_vcpu, arch.shregs.srr1));
419 DEFINE(VCPU_SPRG0, offsetof(struct kvm_vcpu, arch.shregs.sprg0));
420 DEFINE(VCPU_SPRG1, offsetof(struct kvm_vcpu, arch.shregs.sprg1));
421 DEFINE(VCPU_SPRG2, offsetof(struct kvm_vcpu, arch.shregs.sprg2));
422 DEFINE(VCPU_SPRG3, offsetof(struct kvm_vcpu, arch.shregs.sprg3));
423#endif
400 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4)); 424 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4));
401 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5)); 425 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5));
402 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); 426 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6));
403 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7)); 427 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7));
404 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid)); 428 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid));
429 DEFINE(VCPU_SHADOW_PID1, offsetof(struct kvm_vcpu, arch.shadow_pid1));
405 DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared)); 430 DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared));
406 DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr)); 431 DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr));
432 DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr));
407 433
408 /* book3s */ 434 /* book3s */
435#ifdef CONFIG_KVM_BOOK3S_64_HV
436 DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid));
437 DEFINE(KVM_SDR1, offsetof(struct kvm, arch.sdr1));
438 DEFINE(KVM_HOST_LPID, offsetof(struct kvm, arch.host_lpid));
439 DEFINE(KVM_HOST_LPCR, offsetof(struct kvm, arch.host_lpcr));
440 DEFINE(KVM_HOST_SDR1, offsetof(struct kvm, arch.host_sdr1));
441 DEFINE(KVM_TLBIE_LOCK, offsetof(struct kvm, arch.tlbie_lock));
442 DEFINE(KVM_ONLINE_CPUS, offsetof(struct kvm, online_vcpus.counter));
443 DEFINE(KVM_LAST_VCPU, offsetof(struct kvm, arch.last_vcpu));
444 DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr));
445 DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor));
446 DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr));
447 DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar));
448#endif
409#ifdef CONFIG_PPC_BOOK3S 449#ifdef CONFIG_PPC_BOOK3S
450 DEFINE(VCPU_KVM, offsetof(struct kvm_vcpu, kvm));
451 DEFINE(VCPU_VCPUID, offsetof(struct kvm_vcpu, vcpu_id));
410 DEFINE(VCPU_HOST_RETIP, offsetof(struct kvm_vcpu, arch.host_retip)); 452 DEFINE(VCPU_HOST_RETIP, offsetof(struct kvm_vcpu, arch.host_retip));
411 DEFINE(VCPU_HOST_MSR, offsetof(struct kvm_vcpu, arch.host_msr)); 453 DEFINE(VCPU_HOST_MSR, offsetof(struct kvm_vcpu, arch.host_msr));
412 DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr)); 454 DEFINE(VCPU_PURR, offsetof(struct kvm_vcpu, arch.purr));
455 DEFINE(VCPU_SPURR, offsetof(struct kvm_vcpu, arch.spurr));
456 DEFINE(VCPU_DSCR, offsetof(struct kvm_vcpu, arch.dscr));
457 DEFINE(VCPU_AMR, offsetof(struct kvm_vcpu, arch.amr));
458 DEFINE(VCPU_UAMOR, offsetof(struct kvm_vcpu, arch.uamor));
459 DEFINE(VCPU_CTRL, offsetof(struct kvm_vcpu, arch.ctrl));
460 DEFINE(VCPU_DABR, offsetof(struct kvm_vcpu, arch.dabr));
413 DEFINE(VCPU_TRAMPOLINE_LOWMEM, offsetof(struct kvm_vcpu, arch.trampoline_lowmem)); 461 DEFINE(VCPU_TRAMPOLINE_LOWMEM, offsetof(struct kvm_vcpu, arch.trampoline_lowmem));
414 DEFINE(VCPU_TRAMPOLINE_ENTER, offsetof(struct kvm_vcpu, arch.trampoline_enter)); 462 DEFINE(VCPU_TRAMPOLINE_ENTER, offsetof(struct kvm_vcpu, arch.trampoline_enter));
415 DEFINE(VCPU_HIGHMEM_HANDLER, offsetof(struct kvm_vcpu, arch.highmem_handler)); 463 DEFINE(VCPU_HIGHMEM_HANDLER, offsetof(struct kvm_vcpu, arch.highmem_handler));
416 DEFINE(VCPU_RMCALL, offsetof(struct kvm_vcpu, arch.rmcall)); 464 DEFINE(VCPU_RMCALL, offsetof(struct kvm_vcpu, arch.rmcall));
417 DEFINE(VCPU_HFLAGS, offsetof(struct kvm_vcpu, arch.hflags)); 465 DEFINE(VCPU_HFLAGS, offsetof(struct kvm_vcpu, arch.hflags));
466 DEFINE(VCPU_DEC, offsetof(struct kvm_vcpu, arch.dec));
467 DEFINE(VCPU_DEC_EXPIRES, offsetof(struct kvm_vcpu, arch.dec_expires));
468 DEFINE(VCPU_PENDING_EXC, offsetof(struct kvm_vcpu, arch.pending_exceptions));
469 DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa));
470 DEFINE(VCPU_MMCR, offsetof(struct kvm_vcpu, arch.mmcr));
471 DEFINE(VCPU_PMC, offsetof(struct kvm_vcpu, arch.pmc));
472 DEFINE(VCPU_SLB, offsetof(struct kvm_vcpu, arch.slb));
473 DEFINE(VCPU_SLB_MAX, offsetof(struct kvm_vcpu, arch.slb_max));
474 DEFINE(VCPU_SLB_NR, offsetof(struct kvm_vcpu, arch.slb_nr));
475 DEFINE(VCPU_LAST_CPU, offsetof(struct kvm_vcpu, arch.last_cpu));
476 DEFINE(VCPU_FAULT_DSISR, offsetof(struct kvm_vcpu, arch.fault_dsisr));
477 DEFINE(VCPU_FAULT_DAR, offsetof(struct kvm_vcpu, arch.fault_dar));
478 DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst));
479 DEFINE(VCPU_TRAP, offsetof(struct kvm_vcpu, arch.trap));
480 DEFINE(VCPU_PTID, offsetof(struct kvm_vcpu, arch.ptid));
481 DEFINE(VCORE_ENTRY_EXIT, offsetof(struct kvmppc_vcore, entry_exit_count));
482 DEFINE(VCORE_NAP_COUNT, offsetof(struct kvmppc_vcore, nap_count));
483 DEFINE(VCORE_IN_GUEST, offsetof(struct kvmppc_vcore, in_guest));
418 DEFINE(VCPU_SVCPU, offsetof(struct kvmppc_vcpu_book3s, shadow_vcpu) - 484 DEFINE(VCPU_SVCPU, offsetof(struct kvmppc_vcpu_book3s, shadow_vcpu) -
419 offsetof(struct kvmppc_vcpu_book3s, vcpu)); 485 offsetof(struct kvmppc_vcpu_book3s, vcpu));
420 DEFINE(SVCPU_CR, offsetof(struct kvmppc_book3s_shadow_vcpu, cr)); 486 DEFINE(VCPU_SLB_E, offsetof(struct kvmppc_slb, orige));
421 DEFINE(SVCPU_XER, offsetof(struct kvmppc_book3s_shadow_vcpu, xer)); 487 DEFINE(VCPU_SLB_V, offsetof(struct kvmppc_slb, origv));
422 DEFINE(SVCPU_CTR, offsetof(struct kvmppc_book3s_shadow_vcpu, ctr)); 488 DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb));
423 DEFINE(SVCPU_LR, offsetof(struct kvmppc_book3s_shadow_vcpu, lr)); 489
424 DEFINE(SVCPU_PC, offsetof(struct kvmppc_book3s_shadow_vcpu, pc)); 490#ifdef CONFIG_PPC_BOOK3S_64
425 DEFINE(SVCPU_R0, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[0])); 491#ifdef CONFIG_KVM_BOOK3S_PR
426 DEFINE(SVCPU_R1, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[1])); 492# define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f))
427 DEFINE(SVCPU_R2, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[2])); 493#else
428 DEFINE(SVCPU_R3, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[3])); 494# define SVCPU_FIELD(x, f)
429 DEFINE(SVCPU_R4, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[4])); 495#endif
430 DEFINE(SVCPU_R5, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[5])); 496# define HSTATE_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, kvm_hstate.f))
431 DEFINE(SVCPU_R6, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[6])); 497#else /* 32-bit */
432 DEFINE(SVCPU_R7, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[7])); 498# define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct kvmppc_book3s_shadow_vcpu, f))
433 DEFINE(SVCPU_R8, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[8])); 499# define HSTATE_FIELD(x, f) DEFINE(x, offsetof(struct kvmppc_book3s_shadow_vcpu, hstate.f))
434 DEFINE(SVCPU_R9, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[9])); 500#endif
435 DEFINE(SVCPU_R10, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[10])); 501
436 DEFINE(SVCPU_R11, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[11])); 502 SVCPU_FIELD(SVCPU_CR, cr);
437 DEFINE(SVCPU_R12, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[12])); 503 SVCPU_FIELD(SVCPU_XER, xer);
438 DEFINE(SVCPU_R13, offsetof(struct kvmppc_book3s_shadow_vcpu, gpr[13])); 504 SVCPU_FIELD(SVCPU_CTR, ctr);
439 DEFINE(SVCPU_HOST_R1, offsetof(struct kvmppc_book3s_shadow_vcpu, host_r1)); 505 SVCPU_FIELD(SVCPU_LR, lr);
440 DEFINE(SVCPU_HOST_R2, offsetof(struct kvmppc_book3s_shadow_vcpu, host_r2)); 506 SVCPU_FIELD(SVCPU_PC, pc);
441 DEFINE(SVCPU_VMHANDLER, offsetof(struct kvmppc_book3s_shadow_vcpu, 507 SVCPU_FIELD(SVCPU_R0, gpr[0]);
442 vmhandler)); 508 SVCPU_FIELD(SVCPU_R1, gpr[1]);
443 DEFINE(SVCPU_SCRATCH0, offsetof(struct kvmppc_book3s_shadow_vcpu, 509 SVCPU_FIELD(SVCPU_R2, gpr[2]);
444 scratch0)); 510 SVCPU_FIELD(SVCPU_R3, gpr[3]);
445 DEFINE(SVCPU_SCRATCH1, offsetof(struct kvmppc_book3s_shadow_vcpu, 511 SVCPU_FIELD(SVCPU_R4, gpr[4]);
446 scratch1)); 512 SVCPU_FIELD(SVCPU_R5, gpr[5]);
447 DEFINE(SVCPU_IN_GUEST, offsetof(struct kvmppc_book3s_shadow_vcpu, 513 SVCPU_FIELD(SVCPU_R6, gpr[6]);
448 in_guest)); 514 SVCPU_FIELD(SVCPU_R7, gpr[7]);
449 DEFINE(SVCPU_FAULT_DSISR, offsetof(struct kvmppc_book3s_shadow_vcpu, 515 SVCPU_FIELD(SVCPU_R8, gpr[8]);
450 fault_dsisr)); 516 SVCPU_FIELD(SVCPU_R9, gpr[9]);
451 DEFINE(SVCPU_FAULT_DAR, offsetof(struct kvmppc_book3s_shadow_vcpu, 517 SVCPU_FIELD(SVCPU_R10, gpr[10]);
452 fault_dar)); 518 SVCPU_FIELD(SVCPU_R11, gpr[11]);
453 DEFINE(SVCPU_LAST_INST, offsetof(struct kvmppc_book3s_shadow_vcpu, 519 SVCPU_FIELD(SVCPU_R12, gpr[12]);
454 last_inst)); 520 SVCPU_FIELD(SVCPU_R13, gpr[13]);
455 DEFINE(SVCPU_SHADOW_SRR1, offsetof(struct kvmppc_book3s_shadow_vcpu, 521 SVCPU_FIELD(SVCPU_FAULT_DSISR, fault_dsisr);
456 shadow_srr1)); 522 SVCPU_FIELD(SVCPU_FAULT_DAR, fault_dar);
523 SVCPU_FIELD(SVCPU_LAST_INST, last_inst);
524 SVCPU_FIELD(SVCPU_SHADOW_SRR1, shadow_srr1);
457#ifdef CONFIG_PPC_BOOK3S_32 525#ifdef CONFIG_PPC_BOOK3S_32
458 DEFINE(SVCPU_SR, offsetof(struct kvmppc_book3s_shadow_vcpu, sr)); 526 SVCPU_FIELD(SVCPU_SR, sr);
459#endif 527#endif
460#else 528#ifdef CONFIG_PPC64
529 SVCPU_FIELD(SVCPU_SLB, slb);
530 SVCPU_FIELD(SVCPU_SLB_MAX, slb_max);
531#endif
532
533 HSTATE_FIELD(HSTATE_HOST_R1, host_r1);
534 HSTATE_FIELD(HSTATE_HOST_R2, host_r2);
535 HSTATE_FIELD(HSTATE_HOST_MSR, host_msr);
536 HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler);
537 HSTATE_FIELD(HSTATE_SCRATCH0, scratch0);
538 HSTATE_FIELD(HSTATE_SCRATCH1, scratch1);
539 HSTATE_FIELD(HSTATE_IN_GUEST, in_guest);
540
541#ifdef CONFIG_KVM_BOOK3S_64_HV
542 HSTATE_FIELD(HSTATE_KVM_VCPU, kvm_vcpu);
543 HSTATE_FIELD(HSTATE_KVM_VCORE, kvm_vcore);
544 HSTATE_FIELD(HSTATE_XICS_PHYS, xics_phys);
545 HSTATE_FIELD(HSTATE_MMCR, host_mmcr);
546 HSTATE_FIELD(HSTATE_PMC, host_pmc);
547 HSTATE_FIELD(HSTATE_PURR, host_purr);
548 HSTATE_FIELD(HSTATE_SPURR, host_spurr);
549 HSTATE_FIELD(HSTATE_DSCR, host_dscr);
550 HSTATE_FIELD(HSTATE_DABR, dabr);
551 HSTATE_FIELD(HSTATE_DECEXP, dec_expires);
552#endif /* CONFIG_KVM_BOOK3S_64_HV */
553
554#else /* CONFIG_PPC_BOOK3S */
461 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); 555 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr));
462 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer)); 556 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer));
463 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); 557 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr));
@@ -467,7 +561,7 @@ int main(void)
467 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear)); 561 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
468 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); 562 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
469#endif /* CONFIG_PPC_BOOK3S */ 563#endif /* CONFIG_PPC_BOOK3S */
470#endif 564#endif /* CONFIG_KVM */
471 565
472#ifdef CONFIG_KVM_GUEST 566#ifdef CONFIG_KVM_GUEST
473 DEFINE(KVM_MAGIC_SCRATCH1, offsetof(struct kvm_vcpu_arch_shared, 567 DEFINE(KVM_MAGIC_SCRATCH1, offsetof(struct kvm_vcpu_arch_shared,
@@ -497,6 +591,13 @@ int main(void)
497 DEFINE(TLBCAM_MAS7, offsetof(struct tlbcam, MAS7)); 591 DEFINE(TLBCAM_MAS7, offsetof(struct tlbcam, MAS7));
498#endif 592#endif
499 593
594#if defined(CONFIG_KVM) && defined(CONFIG_SPE)
595 DEFINE(VCPU_EVR, offsetof(struct kvm_vcpu, arch.evr[0]));
596 DEFINE(VCPU_ACC, offsetof(struct kvm_vcpu, arch.acc));
597 DEFINE(VCPU_SPEFSCR, offsetof(struct kvm_vcpu, arch.spefscr));
598 DEFINE(VCPU_HOST_SPEFSCR, offsetof(struct kvm_vcpu, arch.host_spefscr));
599#endif
600
500#ifdef CONFIG_KVM_EXIT_TIMING 601#ifdef CONFIG_KVM_EXIT_TIMING
501 DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu, 602 DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu,
502 arch.timing_exit.tv32.tbu)); 603 arch.timing_exit.tv32.tbu));
diff --git a/arch/powerpc/kernel/cpu_setup_power7.S b/arch/powerpc/kernel/cpu_setup_power7.S
index 4f9a93fcfe0..76797c5105d 100644
--- a/arch/powerpc/kernel/cpu_setup_power7.S
+++ b/arch/powerpc/kernel/cpu_setup_power7.S
@@ -45,12 +45,12 @@ _GLOBAL(__restore_cpu_power7)
45 blr 45 blr
46 46
47__init_hvmode_206: 47__init_hvmode_206:
48 /* Disable CPU_FTR_HVMODE_206 and exit if MSR:HV is not set */ 48 /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
49 mfmsr r3 49 mfmsr r3
50 rldicl. r0,r3,4,63 50 rldicl. r0,r3,4,63
51 bnelr 51 bnelr
52 ld r5,CPU_SPEC_FEATURES(r4) 52 ld r5,CPU_SPEC_FEATURES(r4)
53 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE_206) 53 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
54 xor r5,r5,r6 54 xor r5,r5,r6
55 std r5,CPU_SPEC_FEATURES(r4) 55 std r5,CPU_SPEC_FEATURES(r4)
56 blr 56 blr
@@ -61,19 +61,23 @@ __init_LPCR:
61 * LPES = 0b01 (HSRR0/1 used for 0x500) 61 * LPES = 0b01 (HSRR0/1 used for 0x500)
62 * PECE = 0b111 62 * PECE = 0b111
63 * DPFD = 4 63 * DPFD = 4
64 * HDICE = 0
65 * VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
66 * VRMASD = 0b10000 (L=1, LP=00)
64 * 67 *
65 * Other bits untouched for now 68 * Other bits untouched for now
66 */ 69 */
67 mfspr r3,SPRN_LPCR 70 mfspr r3,SPRN_LPCR
68 ori r3,r3,(LPCR_LPES0|LPCR_LPES1) 71 li r5,1
69 xori r3,r3, LPCR_LPES0 72 rldimi r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
70 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2) 73 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
71 li r5,7
72 sldi r5,r5,LPCR_DPFD_SH
73 andc r3,r3,r5
74 li r5,4 74 li r5,4
75 sldi r5,r5,LPCR_DPFD_SH 75 rldimi r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
76 or r3,r3,r5 76 clrrdi r3,r3,1 /* clear HDICE */
77 li r5,4
78 rldimi r3,r5, LPCR_VC_SH, 0
79 li r5,0x10
80 rldimi r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
77 mtspr SPRN_LPCR,r3 81 mtspr SPRN_LPCR,r3
78 isync 82 isync
79 blr 83 blr
diff --git a/arch/powerpc/kernel/cpu_setup_ppc970.S b/arch/powerpc/kernel/cpu_setup_ppc970.S
index 27f2507279d..12fac8df01c 100644
--- a/arch/powerpc/kernel/cpu_setup_ppc970.S
+++ b/arch/powerpc/kernel/cpu_setup_ppc970.S
@@ -76,7 +76,7 @@ _GLOBAL(__setup_cpu_ppc970)
76 /* Do nothing if not running in HV mode */ 76 /* Do nothing if not running in HV mode */
77 mfmsr r0 77 mfmsr r0
78 rldicl. r0,r0,4,63 78 rldicl. r0,r0,4,63
79 beqlr 79 beq no_hv_mode
80 80
81 mfspr r0,SPRN_HID0 81 mfspr r0,SPRN_HID0
82 li r11,5 /* clear DOZE and SLEEP */ 82 li r11,5 /* clear DOZE and SLEEP */
@@ -90,7 +90,7 @@ _GLOBAL(__setup_cpu_ppc970MP)
90 /* Do nothing if not running in HV mode */ 90 /* Do nothing if not running in HV mode */
91 mfmsr r0 91 mfmsr r0
92 rldicl. r0,r0,4,63 92 rldicl. r0,r0,4,63
93 beqlr 93 beq no_hv_mode
94 94
95 mfspr r0,SPRN_HID0 95 mfspr r0,SPRN_HID0
96 li r11,0x15 /* clear DOZE and SLEEP */ 96 li r11,0x15 /* clear DOZE and SLEEP */
@@ -109,6 +109,14 @@ load_hids:
109 sync 109 sync
110 isync 110 isync
111 111
112 /* Try to set LPES = 01 in HID4 */
113 mfspr r0,SPRN_HID4
114 clrldi r0,r0,1 /* clear LPES0 */
115 ori r0,r0,HID4_LPES1 /* set LPES1 */
116 sync
117 mtspr SPRN_HID4,r0
118 isync
119
112 /* Save away cpu state */ 120 /* Save away cpu state */
113 LOAD_REG_ADDR(r5,cpu_state_storage) 121 LOAD_REG_ADDR(r5,cpu_state_storage)
114 122
@@ -117,11 +125,21 @@ load_hids:
117 std r3,CS_HID0(r5) 125 std r3,CS_HID0(r5)
118 mfspr r3,SPRN_HID1 126 mfspr r3,SPRN_HID1
119 std r3,CS_HID1(r5) 127 std r3,CS_HID1(r5)
120 mfspr r3,SPRN_HID4 128 mfspr r4,SPRN_HID4
121 std r3,CS_HID4(r5) 129 std r4,CS_HID4(r5)
122 mfspr r3,SPRN_HID5 130 mfspr r3,SPRN_HID5
123 std r3,CS_HID5(r5) 131 std r3,CS_HID5(r5)
124 132
133 /* See if we successfully set LPES1 to 1; if not we are in Apple mode */
134 andi. r4,r4,HID4_LPES1
135 bnelr
136
137no_hv_mode:
138 /* Disable CPU_FTR_HVMODE and exit, since we don't have HV mode */
139 ld r5,CPU_SPEC_FEATURES(r4)
140 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
141 andc r5,r5,r6
142 std r5,CPU_SPEC_FEATURES(r4)
125 blr 143 blr
126 144
127/* Called with no MMU context (typically MSR:IR/DR off) to 145/* Called with no MMU context (typically MSR:IR/DR off) to
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 9fb933248ab..fa44ff53886 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -2051,7 +2051,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
2051 2051
2052static struct cpu_spec the_cpu_spec; 2052static struct cpu_spec the_cpu_spec;
2053 2053
2054static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s) 2054static struct cpu_spec * __init setup_cpu_spec(unsigned long offset,
2055 struct cpu_spec *s)
2055{ 2056{
2056 struct cpu_spec *t = &the_cpu_spec; 2057 struct cpu_spec *t = &the_cpu_spec;
2057 struct cpu_spec old; 2058 struct cpu_spec old;
@@ -2114,6 +2115,8 @@ static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
2114 t->cpu_setup(offset, t); 2115 t->cpu_setup(offset, t);
2115 } 2116 }
2116#endif /* CONFIG_PPC64 || CONFIG_BOOKE */ 2117#endif /* CONFIG_PPC64 || CONFIG_BOOKE */
2118
2119 return t;
2117} 2120}
2118 2121
2119struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) 2122struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
@@ -2124,10 +2127,8 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
2124 s = PTRRELOC(s); 2127 s = PTRRELOC(s);
2125 2128
2126 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) { 2129 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) {
2127 if ((pvr & s->pvr_mask) == s->pvr_value) { 2130 if ((pvr & s->pvr_mask) == s->pvr_value)
2128 setup_cpu_spec(offset, s); 2131 return setup_cpu_spec(offset, s);
2129 return s;
2130 }
2131 } 2132 }
2132 2133
2133 BUG(); 2134 BUG();
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 4e6ee944495..cc6a9d5d69a 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -242,12 +242,8 @@ static void crash_kexec_wait_realmode(int cpu)
242 242
243 while (paca[i].kexec_state < KEXEC_STATE_REAL_MODE) { 243 while (paca[i].kexec_state < KEXEC_STATE_REAL_MODE) {
244 barrier(); 244 barrier();
245 if (!cpu_possible(i)) { 245 if (!cpu_possible(i) || !cpu_online(i) || (msecs <= 0))
246 break; 246 break;
247 }
248 if (!cpu_online(i)) {
249 break;
250 }
251 msecs--; 247 msecs--;
252 mdelay(1); 248 mdelay(1);
253 } 249 }
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index d238c082c3c..4f0959fbfbe 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -161,9 +161,7 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
161 161
162 if (ppc_md.dma_set_mask) 162 if (ppc_md.dma_set_mask)
163 return ppc_md.dma_set_mask(dev, dma_mask); 163 return ppc_md.dma_set_mask(dev, dma_mask);
164 if (unlikely(dma_ops == NULL)) 164 if ((dma_ops != NULL) && (dma_ops->set_dma_mask != NULL))
165 return -EIO;
166 if (dma_ops->set_dma_mask != NULL)
167 return dma_ops->set_dma_mask(dev, dma_mask); 165 return dma_ops->set_dma_mask(dev, dma_mask);
168 if (!dev->dma_mask || !dma_supported(dev, dma_mask)) 166 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
169 return -EIO; 167 return -EIO;
diff --git a/arch/powerpc/kernel/e500-pmu.c b/arch/powerpc/kernel/e500-pmu.c
index b150b510510..cb2e2949c8d 100644
--- a/arch/powerpc/kernel/e500-pmu.c
+++ b/arch/powerpc/kernel/e500-pmu.c
@@ -75,6 +75,11 @@ static int e500_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
75 [C(OP_WRITE)] = { -1, -1 }, 75 [C(OP_WRITE)] = { -1, -1 },
76 [C(OP_PREFETCH)] = { -1, -1 }, 76 [C(OP_PREFETCH)] = { -1, -1 },
77 }, 77 },
78 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
79 [C(OP_READ)] = { -1, -1 },
80 [C(OP_WRITE)] = { -1, -1 },
81 [C(OP_PREFETCH)] = { -1, -1 },
82 },
78}; 83};
79 84
80static int num_events = 128; 85static int num_events = 128;
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index d24d4400cc7..429983c06f9 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -120,6 +120,12 @@
120 std r14,PACA_EXMC+EX_R14(r13); \ 120 std r14,PACA_EXMC+EX_R14(r13); \
121 std r15,PACA_EXMC+EX_R15(r13) 121 std r15,PACA_EXMC+EX_R15(r13)
122 122
123#define PROLOG_ADDITION_DOORBELL_GEN \
124 lbz r11,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \
125 cmpwi cr0,r11,0; /* yes -> go out of line */ \
126 beq masked_doorbell_book3e
127
128
123/* Core exception code for all exceptions except TLB misses. 129/* Core exception code for all exceptions except TLB misses.
124 * XXX: Needs to make SPRN_SPRG_GEN depend on exception type 130 * XXX: Needs to make SPRN_SPRG_GEN depend on exception type
125 */ 131 */
@@ -522,7 +528,13 @@ kernel_dbg_exc:
522 MASKABLE_EXCEPTION(0x260, perfmon, .performance_monitor_exception, ACK_NONE) 528 MASKABLE_EXCEPTION(0x260, perfmon, .performance_monitor_exception, ACK_NONE)
523 529
524/* Doorbell interrupt */ 530/* Doorbell interrupt */
525 MASKABLE_EXCEPTION(0x2070, doorbell, .doorbell_exception, ACK_NONE) 531 START_EXCEPTION(doorbell)
532 NORMAL_EXCEPTION_PROLOG(0x2070, PROLOG_ADDITION_DOORBELL)
533 EXCEPTION_COMMON(0x2070, PACA_EXGEN, INTS_DISABLE_ALL)
534 CHECK_NAPPING()
535 addi r3,r1,STACK_FRAME_OVERHEAD
536 bl .doorbell_exception
537 b .ret_from_except_lite
526 538
527/* Doorbell critical Interrupt */ 539/* Doorbell critical Interrupt */
528 START_EXCEPTION(doorbell_crit); 540 START_EXCEPTION(doorbell_crit);
@@ -545,8 +557,16 @@ kernel_dbg_exc:
545 * An interrupt came in while soft-disabled; clear EE in SRR1, 557 * An interrupt came in while soft-disabled; clear EE in SRR1,
546 * clear paca->hard_enabled and return. 558 * clear paca->hard_enabled and return.
547 */ 559 */
560masked_doorbell_book3e:
561 mtcr r10
562 /* Resend the doorbell to fire again when ints enabled */
563 mfspr r10,SPRN_PIR
564 PPC_MSGSND(r10)
565 b masked_interrupt_book3e_common
566
548masked_interrupt_book3e: 567masked_interrupt_book3e:
549 mtcr r10 568 mtcr r10
569masked_interrupt_book3e_common:
550 stb r11,PACAHARDIRQEN(r13) 570 stb r11,PACAHARDIRQEN(r13)
551 mfspr r10,SPRN_SRR1 571 mfspr r10,SPRN_SRR1
552 rldicl r11,r10,48,1 /* clear MSR_EE */ 572 rldicl r11,r10,48,1 /* clear MSR_EE */
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index a85f4874cba..41b02c792aa 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -40,7 +40,6 @@ __start_interrupts:
40 .globl system_reset_pSeries; 40 .globl system_reset_pSeries;
41system_reset_pSeries: 41system_reset_pSeries:
42 HMT_MEDIUM; 42 HMT_MEDIUM;
43 DO_KVM 0x100;
44 SET_SCRATCH0(r13) 43 SET_SCRATCH0(r13)
45#ifdef CONFIG_PPC_P7_NAP 44#ifdef CONFIG_PPC_P7_NAP
46BEGIN_FTR_SECTION 45BEGIN_FTR_SECTION
@@ -50,82 +49,73 @@ BEGIN_FTR_SECTION
50 * state loss at this time. 49 * state loss at this time.
51 */ 50 */
52 mfspr r13,SPRN_SRR1 51 mfspr r13,SPRN_SRR1
53 rlwinm r13,r13,47-31,30,31 52 rlwinm. r13,r13,47-31,30,31
54 cmpwi cr0,r13,1 53 beq 9f
55 bne 1f 54
56 b .power7_wakeup_noloss 55 /* waking up from powersave (nap) state */
571: cmpwi cr0,r13,2 56 cmpwi cr1,r13,2
58 bne 1f
59 b .power7_wakeup_loss
60 /* Total loss of HV state is fatal, we could try to use the 57 /* Total loss of HV state is fatal, we could try to use the
61 * PIR to locate a PACA, then use an emergency stack etc... 58 * PIR to locate a PACA, then use an emergency stack etc...
62 * but for now, let's just stay stuck here 59 * but for now, let's just stay stuck here
63 */ 60 */
641: cmpwi cr0,r13,3 61 bgt cr1,.
65 beq . 62 GET_PACA(r13)
66END_FTR_SECTION_IFSET(CPU_FTR_HVMODE_206) 63
64#ifdef CONFIG_KVM_BOOK3S_64_HV
65 lbz r0,PACAPROCSTART(r13)
66 cmpwi r0,0x80
67 bne 1f
68 li r0,0
69 stb r0,PACAPROCSTART(r13)
70 b kvm_start_guest
711:
72#endif
73
74 beq cr1,2f
75 b .power7_wakeup_noloss
762: b .power7_wakeup_loss
779:
78END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
67#endif /* CONFIG_PPC_P7_NAP */ 79#endif /* CONFIG_PPC_P7_NAP */
68 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD) 80 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
81 NOTEST, 0x100)
69 82
70 . = 0x200 83 . = 0x200
71_machine_check_pSeries: 84machine_check_pSeries_1:
72 HMT_MEDIUM 85 /* This is moved out of line as it can be patched by FW, but
73 DO_KVM 0x200 86 * some code path might still want to branch into the original
74 SET_SCRATCH0(r13) 87 * vector
75 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common, EXC_STD) 88 */
89 b machine_check_pSeries
76 90
77 . = 0x300 91 . = 0x300
78 .globl data_access_pSeries 92 .globl data_access_pSeries
79data_access_pSeries: 93data_access_pSeries:
80 HMT_MEDIUM 94 HMT_MEDIUM
81 DO_KVM 0x300
82 SET_SCRATCH0(r13) 95 SET_SCRATCH0(r13)
96#ifndef CONFIG_POWER4_ONLY
83BEGIN_FTR_SECTION 97BEGIN_FTR_SECTION
84 GET_PACA(r13) 98 b data_access_check_stab
85 std r9,PACA_EXSLB+EX_R9(r13) 99data_access_not_stab:
86 std r10,PACA_EXSLB+EX_R10(r13) 100END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
87 mfspr r10,SPRN_DAR 101#endif
88 mfspr r9,SPRN_DSISR 102 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
89 srdi r10,r10,60 103 KVMTEST_PR, 0x300)
90 rlwimi r10,r9,16,0x20
91 mfcr r9
92 cmpwi r10,0x2c
93 beq do_stab_bolted_pSeries
94 ld r10,PACA_EXSLB+EX_R10(r13)
95 std r11,PACA_EXGEN+EX_R11(r13)
96 ld r11,PACA_EXSLB+EX_R9(r13)
97 std r12,PACA_EXGEN+EX_R12(r13)
98 GET_SCRATCH0(r12)
99 std r10,PACA_EXGEN+EX_R10(r13)
100 std r11,PACA_EXGEN+EX_R9(r13)
101 std r12,PACA_EXGEN+EX_R13(r13)
102 EXCEPTION_PROLOG_PSERIES_1(data_access_common, EXC_STD)
103FTR_SECTION_ELSE
104 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD)
105ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_SLB)
106 104
107 . = 0x380 105 . = 0x380
108 .globl data_access_slb_pSeries 106 .globl data_access_slb_pSeries
109data_access_slb_pSeries: 107data_access_slb_pSeries:
110 HMT_MEDIUM 108 HMT_MEDIUM
111 DO_KVM 0x380
112 SET_SCRATCH0(r13) 109 SET_SCRATCH0(r13)
113 GET_PACA(r13) 110 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380)
114 std r3,PACA_EXSLB+EX_R3(r13) 111 std r3,PACA_EXSLB+EX_R3(r13)
115 mfspr r3,SPRN_DAR 112 mfspr r3,SPRN_DAR
116 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
117 mfcr r9
118#ifdef __DISABLED__ 113#ifdef __DISABLED__
119 /* Keep that around for when we re-implement dynamic VSIDs */ 114 /* Keep that around for when we re-implement dynamic VSIDs */
120 cmpdi r3,0 115 cmpdi r3,0
121 bge slb_miss_user_pseries 116 bge slb_miss_user_pseries
122#endif /* __DISABLED__ */ 117#endif /* __DISABLED__ */
123 std r10,PACA_EXSLB+EX_R10(r13) 118 mfspr r12,SPRN_SRR1
124 std r11,PACA_EXSLB+EX_R11(r13)
125 std r12,PACA_EXSLB+EX_R12(r13)
126 GET_SCRATCH0(r10)
127 std r10,PACA_EXSLB+EX_R13(r13)
128 mfspr r12,SPRN_SRR1 /* and SRR1 */
129#ifndef CONFIG_RELOCATABLE 119#ifndef CONFIG_RELOCATABLE
130 b .slb_miss_realmode 120 b .slb_miss_realmode
131#else 121#else
@@ -147,24 +137,16 @@ data_access_slb_pSeries:
147 .globl instruction_access_slb_pSeries 137 .globl instruction_access_slb_pSeries
148instruction_access_slb_pSeries: 138instruction_access_slb_pSeries:
149 HMT_MEDIUM 139 HMT_MEDIUM
150 DO_KVM 0x480
151 SET_SCRATCH0(r13) 140 SET_SCRATCH0(r13)
152 GET_PACA(r13) 141 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
153 std r3,PACA_EXSLB+EX_R3(r13) 142 std r3,PACA_EXSLB+EX_R3(r13)
154 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ 143 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
155 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
156 mfcr r9
157#ifdef __DISABLED__ 144#ifdef __DISABLED__
158 /* Keep that around for when we re-implement dynamic VSIDs */ 145 /* Keep that around for when we re-implement dynamic VSIDs */
159 cmpdi r3,0 146 cmpdi r3,0
160 bge slb_miss_user_pseries 147 bge slb_miss_user_pseries
161#endif /* __DISABLED__ */ 148#endif /* __DISABLED__ */
162 std r10,PACA_EXSLB+EX_R10(r13) 149 mfspr r12,SPRN_SRR1
163 std r11,PACA_EXSLB+EX_R11(r13)
164 std r12,PACA_EXSLB+EX_R12(r13)
165 GET_SCRATCH0(r10)
166 std r10,PACA_EXSLB+EX_R13(r13)
167 mfspr r12,SPRN_SRR1 /* and SRR1 */
168#ifndef CONFIG_RELOCATABLE 150#ifndef CONFIG_RELOCATABLE
169 b .slb_miss_realmode 151 b .slb_miss_realmode
170#else 152#else
@@ -184,26 +166,46 @@ instruction_access_slb_pSeries:
184hardware_interrupt_pSeries: 166hardware_interrupt_pSeries:
185hardware_interrupt_hv: 167hardware_interrupt_hv:
186 BEGIN_FTR_SECTION 168 BEGIN_FTR_SECTION
187 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD) 169 _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
170 EXC_HV, SOFTEN_TEST_HV)
171 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
188 FTR_SECTION_ELSE 172 FTR_SECTION_ELSE
189 _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV) 173 _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
190 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_HVMODE_206) 174 EXC_STD, SOFTEN_TEST_HV_201)
175 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
176 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
191 177
192 STD_EXCEPTION_PSERIES(0x600, 0x600, alignment) 178 STD_EXCEPTION_PSERIES(0x600, 0x600, alignment)
179 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600)
180
193 STD_EXCEPTION_PSERIES(0x700, 0x700, program_check) 181 STD_EXCEPTION_PSERIES(0x700, 0x700, program_check)
182 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700)
183
194 STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable) 184 STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
185 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
195 186
196 MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer) 187 MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer)
197 MASKABLE_EXCEPTION_HV(0x980, 0x980, decrementer) 188 MASKABLE_EXCEPTION_HV(0x980, 0x982, decrementer)
198 189
199 STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a) 190 STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a)
191 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
192
200 STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b) 193 STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b)
194 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00)
201 195
202 . = 0xc00 196 . = 0xc00
203 .globl system_call_pSeries 197 .globl system_call_pSeries
204system_call_pSeries: 198system_call_pSeries:
205 HMT_MEDIUM 199 HMT_MEDIUM
206 DO_KVM 0xc00 200#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
201 SET_SCRATCH0(r13)
202 GET_PACA(r13)
203 std r9,PACA_EXGEN+EX_R9(r13)
204 std r10,PACA_EXGEN+EX_R10(r13)
205 mfcr r9
206 KVMTEST(0xc00)
207 GET_SCRATCH0(r13)
208#endif
207BEGIN_FTR_SECTION 209BEGIN_FTR_SECTION
208 cmpdi r0,0x1ebe 210 cmpdi r0,0x1ebe
209 beq- 1f 211 beq- 1f
@@ -220,6 +222,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
220 rfid 222 rfid
221 b . /* prevent speculative execution */ 223 b . /* prevent speculative execution */
222 224
225 KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
226
223/* Fast LE/BE switch system call */ 227/* Fast LE/BE switch system call */
2241: mfspr r12,SPRN_SRR1 2281: mfspr r12,SPRN_SRR1
225 xori r12,r12,MSR_LE 229 xori r12,r12,MSR_LE
@@ -228,6 +232,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
228 b . 232 b .
229 233
230 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step) 234 STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
235 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
231 236
232 /* At 0xe??? we have a bunch of hypervisor exceptions, we branch 237 /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
233 * out of line to handle them 238 * out of line to handle them
@@ -262,30 +267,93 @@ vsx_unavailable_pSeries_1:
262 267
263#ifdef CONFIG_CBE_RAS 268#ifdef CONFIG_CBE_RAS
264 STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error) 269 STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
270 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
265#endif /* CONFIG_CBE_RAS */ 271#endif /* CONFIG_CBE_RAS */
272
266 STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint) 273 STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
274 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
275
267#ifdef CONFIG_CBE_RAS 276#ifdef CONFIG_CBE_RAS
268 STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance) 277 STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
278 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
269#endif /* CONFIG_CBE_RAS */ 279#endif /* CONFIG_CBE_RAS */
280
270 STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist) 281 STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
282 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700)
283
271#ifdef CONFIG_CBE_RAS 284#ifdef CONFIG_CBE_RAS
272 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal) 285 STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
286 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
273#endif /* CONFIG_CBE_RAS */ 287#endif /* CONFIG_CBE_RAS */
274 288
275 . = 0x3000 289 . = 0x3000
276 290
277/*** Out of line interrupts support ***/ 291/*** Out of line interrupts support ***/
278 292
293 /* moved from 0x200 */
294machine_check_pSeries:
295 .globl machine_check_fwnmi
296machine_check_fwnmi:
297 HMT_MEDIUM
298 SET_SCRATCH0(r13) /* save r13 */
299 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common,
300 EXC_STD, KVMTEST, 0x200)
301 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
302
303#ifndef CONFIG_POWER4_ONLY
304 /* moved from 0x300 */
305data_access_check_stab:
306 GET_PACA(r13)
307 std r9,PACA_EXSLB+EX_R9(r13)
308 std r10,PACA_EXSLB+EX_R10(r13)
309 mfspr r10,SPRN_DAR
310 mfspr r9,SPRN_DSISR
311 srdi r10,r10,60
312 rlwimi r10,r9,16,0x20
313#ifdef CONFIG_KVM_BOOK3S_PR
314 lbz r9,HSTATE_IN_GUEST(r13)
315 rlwimi r10,r9,8,0x300
316#endif
317 mfcr r9
318 cmpwi r10,0x2c
319 beq do_stab_bolted_pSeries
320 mtcrf 0x80,r9
321 ld r9,PACA_EXSLB+EX_R9(r13)
322 ld r10,PACA_EXSLB+EX_R10(r13)
323 b data_access_not_stab
324do_stab_bolted_pSeries:
325 std r11,PACA_EXSLB+EX_R11(r13)
326 std r12,PACA_EXSLB+EX_R12(r13)
327 GET_SCRATCH0(r10)
328 std r10,PACA_EXSLB+EX_R13(r13)
329 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
330#endif /* CONFIG_POWER4_ONLY */
331
332 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x300)
333 KVM_HANDLER_PR_SKIP(PACA_EXSLB, EXC_STD, 0x380)
334 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
335 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
336 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
337 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
338
339 .align 7
279 /* moved from 0xe00 */ 340 /* moved from 0xe00 */
280 STD_EXCEPTION_HV(., 0xe00, h_data_storage) 341 STD_EXCEPTION_HV(., 0xe02, h_data_storage)
281 STD_EXCEPTION_HV(., 0xe20, h_instr_storage) 342 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02)
282 STD_EXCEPTION_HV(., 0xe40, emulation_assist) 343 STD_EXCEPTION_HV(., 0xe22, h_instr_storage)
283 STD_EXCEPTION_HV(., 0xe60, hmi_exception) /* need to flush cache ? */ 344 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22)
345 STD_EXCEPTION_HV(., 0xe42, emulation_assist)
346 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42)
347 STD_EXCEPTION_HV(., 0xe62, hmi_exception) /* need to flush cache ? */
348 KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62)
284 349
285 /* moved from 0xf00 */ 350 /* moved from 0xf00 */
286 STD_EXCEPTION_PSERIES(., 0xf00, performance_monitor) 351 STD_EXCEPTION_PSERIES(., 0xf00, performance_monitor)
352 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00)
287 STD_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable) 353 STD_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable)
354 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20)
288 STD_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable) 355 STD_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable)
356 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40)
289 357
290/* 358/*
291 * An interrupt came in while soft-disabled; clear EE in SRR1, 359 * An interrupt came in while soft-disabled; clear EE in SRR1,
@@ -317,14 +385,6 @@ masked_Hinterrupt:
317 hrfid 385 hrfid
318 b . 386 b .
319 387
320 .align 7
321do_stab_bolted_pSeries:
322 std r11,PACA_EXSLB+EX_R11(r13)
323 std r12,PACA_EXSLB+EX_R12(r13)
324 GET_SCRATCH0(r10)
325 std r10,PACA_EXSLB+EX_R13(r13)
326 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
327
328#ifdef CONFIG_PPC_PSERIES 388#ifdef CONFIG_PPC_PSERIES
329/* 389/*
330 * Vectors for the FWNMI option. Share common code. 390 * Vectors for the FWNMI option. Share common code.
@@ -334,14 +394,8 @@ do_stab_bolted_pSeries:
334system_reset_fwnmi: 394system_reset_fwnmi:
335 HMT_MEDIUM 395 HMT_MEDIUM
336 SET_SCRATCH0(r13) /* save r13 */ 396 SET_SCRATCH0(r13) /* save r13 */
337 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD) 397 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
338 398 NOTEST, 0x100)
339 .globl machine_check_fwnmi
340 .align 7
341machine_check_fwnmi:
342 HMT_MEDIUM
343 SET_SCRATCH0(r13) /* save r13 */
344 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common, EXC_STD)
345 399
346#endif /* CONFIG_PPC_PSERIES */ 400#endif /* CONFIG_PPC_PSERIES */
347 401
@@ -376,7 +430,11 @@ slb_miss_user_pseries:
376/* KVM's trampoline code needs to be close to the interrupt handlers */ 430/* KVM's trampoline code needs to be close to the interrupt handlers */
377 431
378#ifdef CONFIG_KVM_BOOK3S_64_HANDLER 432#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
433#ifdef CONFIG_KVM_BOOK3S_PR
379#include "../kvm/book3s_rmhandlers.S" 434#include "../kvm/book3s_rmhandlers.S"
435#else
436#include "../kvm/book3s_hv_rmhandlers.S"
437#endif
380#endif 438#endif
381 439
382 .align 7 440 .align 7
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 5e12b741ba5..f8e971ba94f 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -93,6 +93,30 @@ _ENTRY(_start);
93 93
94 bl early_init 94 bl early_init
95 95
96#ifdef CONFIG_RELOCATABLE
97 /*
98 * r25 will contain RPN/ERPN for the start address of memory
99 *
100 * Add the difference between KERNELBASE and PAGE_OFFSET to the
101 * start of physical memory to get kernstart_addr.
102 */
103 lis r3,kernstart_addr@ha
104 la r3,kernstart_addr@l(r3)
105
106 lis r4,KERNELBASE@h
107 ori r4,r4,KERNELBASE@l
108 lis r5,PAGE_OFFSET@h
109 ori r5,r5,PAGE_OFFSET@l
110 subf r4,r5,r4
111
112 rlwinm r6,r25,0,28,31 /* ERPN */
113 rlwinm r7,r25,0,0,3 /* RPN - assuming 256 MB page size */
114 add r7,r7,r4
115
116 stw r6,0(r3)
117 stw r7,4(r3)
118#endif
119
96/* 120/*
97 * Decide what sort of machine this is and initialize the MMU. 121 * Decide what sort of machine this is and initialize the MMU.
98 */ 122 */
@@ -1001,9 +1025,6 @@ clear_utlb_entry:
1001 lis r3,PAGE_OFFSET@h 1025 lis r3,PAGE_OFFSET@h
1002 ori r3,r3,PAGE_OFFSET@l 1026 ori r3,r3,PAGE_OFFSET@l
1003 1027
1004 /* Kernel is at the base of RAM */
1005 li r4, 0 /* Load the kernel physical address */
1006
1007 /* Load the kernel PID = 0 */ 1028 /* Load the kernel PID = 0 */
1008 li r0,0 1029 li r0,0
1009 mtspr SPRN_PID,r0 1030 mtspr SPRN_PID,r0
@@ -1013,9 +1034,8 @@ clear_utlb_entry:
1013 clrrwi r3,r3,12 /* Mask off the effective page number */ 1034 clrrwi r3,r3,12 /* Mask off the effective page number */
1014 ori r3,r3,PPC47x_TLB0_VALID | PPC47x_TLB0_256M 1035 ori r3,r3,PPC47x_TLB0_VALID | PPC47x_TLB0_256M
1015 1036
1016 /* Word 1 */ 1037 /* Word 1 - use r25. RPN is the same as the original entry */
1017 clrrwi r4,r4,12 /* Mask off the real page number */ 1038
1018 /* ERPN is 0 for first 4GB page */
1019 /* Word 2 */ 1039 /* Word 2 */
1020 li r5,0 1040 li r5,0
1021 ori r5,r5,PPC47x_TLB2_S_RWX 1041 ori r5,r5,PPC47x_TLB2_S_RWX
@@ -1026,7 +1046,7 @@ clear_utlb_entry:
1026 /* We write to way 0 and bolted 0 */ 1046 /* We write to way 0 and bolted 0 */
1027 lis r0,0x8800 1047 lis r0,0x8800
1028 tlbwe r3,r0,0 1048 tlbwe r3,r0,0
1029 tlbwe r4,r0,1 1049 tlbwe r25,r0,1
1030 tlbwe r5,r0,2 1050 tlbwe r5,r0,2
1031 1051
1032/* 1052/*
@@ -1124,7 +1144,13 @@ head_start_common:
1124 lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */ 1144 lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */
1125 mtspr SPRN_IVPR,r4 1145 mtspr SPRN_IVPR,r4
1126 1146
1127 addis r22,r22,KERNELBASE@h 1147 /*
1148 * If the kernel was loaded at a non-zero 256 MB page, we need to
1149 * mask off the most significant 4 bits to get the relative address
1150 * from the start of physical memory
1151 */
1152 rlwinm r22,r22,0,4,31
1153 addis r22,r22,PAGE_OFFSET@h
1128 mtlr r22 1154 mtlr r22
1129 isync 1155 isync
1130 blr 1156 blr
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index ba504099844..3564c49c683 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -255,7 +255,7 @@ generic_secondary_common_init:
255 mtctr r23 255 mtctr r23
256 bctrl 256 bctrl
257 257
2583: LOAD_REG_ADDR(r3, boot_cpu_count) /* Decrement boot_cpu_count */ 2583: LOAD_REG_ADDR(r3, spinning_secondaries) /* Decrement spinning_secondaries */
259 lwarx r4,0,r3 259 lwarx r4,0,r3
260 subi r4,r4,1 260 subi r4,r4,1
261 stwcx. r4,0,r3 261 stwcx. r4,0,r3
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index a0bf158c8b4..fc921bf62e1 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -20,33 +20,43 @@
20 addi reg,reg,val@l 20 addi reg,reg,val@l
21#endif 21#endif
22 22
23/*
24 * Macro used to get to thread save registers.
25 * Note that entries 0-3 are used for the prolog code, and the remaining
26 * entries are available for specific exception use in the event a handler
27 * requires more than 4 scratch registers.
28 */
29#define THREAD_NORMSAVE(offset) (THREAD_NORMSAVES + (offset * 4))
30
23#define NORMAL_EXCEPTION_PROLOG \ 31#define NORMAL_EXCEPTION_PROLOG \
24 mtspr SPRN_SPRG_WSCRATCH0,r10;/* save two registers to work with */\ 32 mtspr SPRN_SPRG_WSCRATCH0, r10; /* save one register */ \
25 mtspr SPRN_SPRG_WSCRATCH1,r11; \ 33 mfspr r10, SPRN_SPRG_THREAD; \
26 mtspr SPRN_SPRG_WSCRATCH2,r1; \ 34 stw r11, THREAD_NORMSAVE(0)(r10); \
27 mfcr r10; /* save CR in r10 for now */\ 35 stw r13, THREAD_NORMSAVE(2)(r10); \
36 mfcr r13; /* save CR in r13 for now */\
28 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ 37 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
29 andi. r11,r11,MSR_PR; \ 38 andi. r11,r11,MSR_PR; \
39 mr r11, r1; \
30 beq 1f; \ 40 beq 1f; \
31 mfspr r1,SPRN_SPRG_THREAD; /* if from user, start at top of */\ 41 /* if from user, start at top of this thread's kernel stack */ \
32 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ 42 lwz r11, THREAD_INFO-THREAD(r10); \
33 ALLOC_STACK_FRAME(r1, THREAD_SIZE); \ 43 ALLOC_STACK_FRAME(r11, THREAD_SIZE); \
341: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\ 441 : subi r11, r11, INT_FRAME_SIZE; /* Allocate exception frame */ \
35 mr r11,r1; \ 45 stw r13, _CCR(r11); /* save various registers */ \
36 stw r10,_CCR(r11); /* save various registers */\
37 stw r12,GPR12(r11); \ 46 stw r12,GPR12(r11); \
38 stw r9,GPR9(r11); \ 47 stw r9,GPR9(r11); \
39 mfspr r10,SPRN_SPRG_RSCRATCH0; \ 48 mfspr r13, SPRN_SPRG_RSCRATCH0; \
40 stw r10,GPR10(r11); \ 49 stw r13, GPR10(r11); \
41 mfspr r12,SPRN_SPRG_RSCRATCH1; \ 50 lwz r12, THREAD_NORMSAVE(0)(r10); \
42 stw r12,GPR11(r11); \ 51 stw r12,GPR11(r11); \
52 lwz r13, THREAD_NORMSAVE(2)(r10); /* restore r13 */ \
43 mflr r10; \ 53 mflr r10; \
44 stw r10,_LINK(r11); \ 54 stw r10,_LINK(r11); \
45 mfspr r10,SPRN_SPRG_RSCRATCH2; \
46 mfspr r12,SPRN_SRR0; \ 55 mfspr r12,SPRN_SRR0; \
47 stw r10,GPR1(r11); \ 56 stw r1, GPR1(r11); \
48 mfspr r9,SPRN_SRR1; \ 57 mfspr r9,SPRN_SRR1; \
49 stw r10,0(r11); \ 58 stw r1, 0(r11); \
59 mr r1, r11; \
50 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\ 60 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
51 stw r0,GPR0(r11); \ 61 stw r0,GPR0(r11); \
52 lis r10, STACK_FRAME_REGS_MARKER@ha;/* exception frame marker */ \ 62 lis r10, STACK_FRAME_REGS_MARKER@ha;/* exception frame marker */ \
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 5ecf54cfa7d..50845924b7d 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -346,11 +346,12 @@ interrupt_base:
346 /* Data TLB Error Interrupt */ 346 /* Data TLB Error Interrupt */
347 START_EXCEPTION(DataTLBError) 347 START_EXCEPTION(DataTLBError)
348 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */ 348 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
349 mtspr SPRN_SPRG_WSCRATCH1, r11 349 mfspr r10, SPRN_SPRG_THREAD
350 mtspr SPRN_SPRG_WSCRATCH2, r12 350 stw r11, THREAD_NORMSAVE(0)(r10)
351 mtspr SPRN_SPRG_WSCRATCH3, r13 351 stw r12, THREAD_NORMSAVE(1)(r10)
352 mfcr r11 352 stw r13, THREAD_NORMSAVE(2)(r10)
353 mtspr SPRN_SPRG_WSCRATCH4, r11 353 mfcr r13
354 stw r13, THREAD_NORMSAVE(3)(r10)
354 mfspr r10, SPRN_DEAR /* Get faulting address */ 355 mfspr r10, SPRN_DEAR /* Get faulting address */
355 356
356 /* If we are faulting a kernel address, we have to use the 357 /* If we are faulting a kernel address, we have to use the
@@ -416,11 +417,12 @@ interrupt_base:
416 /* The bailout. Restore registers to pre-exception conditions 417 /* The bailout. Restore registers to pre-exception conditions
417 * and call the heavyweights to help us out. 418 * and call the heavyweights to help us out.
418 */ 419 */
419 mfspr r11, SPRN_SPRG_RSCRATCH4 420 mfspr r10, SPRN_SPRG_THREAD
421 lwz r11, THREAD_NORMSAVE(3)(r10)
420 mtcr r11 422 mtcr r11
421 mfspr r13, SPRN_SPRG_RSCRATCH3 423 lwz r13, THREAD_NORMSAVE(2)(r10)
422 mfspr r12, SPRN_SPRG_RSCRATCH2 424 lwz r12, THREAD_NORMSAVE(1)(r10)
423 mfspr r11, SPRN_SPRG_RSCRATCH1 425 lwz r11, THREAD_NORMSAVE(0)(r10)
424 mfspr r10, SPRN_SPRG_RSCRATCH0 426 mfspr r10, SPRN_SPRG_RSCRATCH0
425 b DataStorage 427 b DataStorage
426 428
@@ -432,11 +434,12 @@ interrupt_base:
432 */ 434 */
433 START_EXCEPTION(InstructionTLBError) 435 START_EXCEPTION(InstructionTLBError)
434 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */ 436 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
435 mtspr SPRN_SPRG_WSCRATCH1, r11 437 mfspr r10, SPRN_SPRG_THREAD
436 mtspr SPRN_SPRG_WSCRATCH2, r12 438 stw r11, THREAD_NORMSAVE(0)(r10)
437 mtspr SPRN_SPRG_WSCRATCH3, r13 439 stw r12, THREAD_NORMSAVE(1)(r10)
438 mfcr r11 440 stw r13, THREAD_NORMSAVE(2)(r10)
439 mtspr SPRN_SPRG_WSCRATCH4, r11 441 mfcr r13
442 stw r13, THREAD_NORMSAVE(3)(r10)
440 mfspr r10, SPRN_SRR0 /* Get faulting address */ 443 mfspr r10, SPRN_SRR0 /* Get faulting address */
441 444
442 /* If we are faulting a kernel address, we have to use the 445 /* If we are faulting a kernel address, we have to use the
@@ -496,11 +499,12 @@ interrupt_base:
496 /* The bailout. Restore registers to pre-exception conditions 499 /* The bailout. Restore registers to pre-exception conditions
497 * and call the heavyweights to help us out. 500 * and call the heavyweights to help us out.
498 */ 501 */
499 mfspr r11, SPRN_SPRG_RSCRATCH4 502 mfspr r10, SPRN_SPRG_THREAD
503 lwz r11, THREAD_NORMSAVE(3)(r10)
500 mtcr r11 504 mtcr r11
501 mfspr r13, SPRN_SPRG_RSCRATCH3 505 lwz r13, THREAD_NORMSAVE(2)(r10)
502 mfspr r12, SPRN_SPRG_RSCRATCH2 506 lwz r12, THREAD_NORMSAVE(1)(r10)
503 mfspr r11, SPRN_SPRG_RSCRATCH1 507 lwz r11, THREAD_NORMSAVE(0)(r10)
504 mfspr r10, SPRN_SPRG_RSCRATCH0 508 mfspr r10, SPRN_SPRG_RSCRATCH0
505 b InstructionStorage 509 b InstructionStorage
506 510
@@ -621,11 +625,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS)
621 tlbwe 625 tlbwe
622 626
623 /* Done...restore registers and get out of here. */ 627 /* Done...restore registers and get out of here. */
624 mfspr r11, SPRN_SPRG_RSCRATCH4 628 mfspr r10, SPRN_SPRG_THREAD
629 lwz r11, THREAD_NORMSAVE(3)(r10)
625 mtcr r11 630 mtcr r11
626 mfspr r13, SPRN_SPRG_RSCRATCH3 631 lwz r13, THREAD_NORMSAVE(2)(r10)
627 mfspr r12, SPRN_SPRG_RSCRATCH2 632 lwz r12, THREAD_NORMSAVE(1)(r10)
628 mfspr r11, SPRN_SPRG_RSCRATCH1 633 lwz r11, THREAD_NORMSAVE(0)(r10)
629 mfspr r10, SPRN_SPRG_RSCRATCH0 634 mfspr r10, SPRN_SPRG_RSCRATCH0
630 rfi /* Force context change */ 635 rfi /* Force context change */
631 636
@@ -656,7 +661,7 @@ load_up_spe:
656 cmpi 0,r4,0 661 cmpi 0,r4,0
657 beq 1f 662 beq 1f
658 addi r4,r4,THREAD /* want THREAD of last_task_used_spe */ 663 addi r4,r4,THREAD /* want THREAD of last_task_used_spe */
659 SAVE_32EVRS(0,r10,r4) 664 SAVE_32EVRS(0,r10,r4,THREAD_EVR0)
660 evxor evr10, evr10, evr10 /* clear out evr10 */ 665 evxor evr10, evr10, evr10 /* clear out evr10 */
661 evmwumiaa evr10, evr10, evr10 /* evr10 <- ACC = 0 * 0 + ACC */ 666 evmwumiaa evr10, evr10, evr10 /* evr10 <- ACC = 0 * 0 + ACC */
662 li r5,THREAD_ACC 667 li r5,THREAD_ACC
@@ -676,7 +681,7 @@ load_up_spe:
676 stw r4,THREAD_USED_SPE(r5) 681 stw r4,THREAD_USED_SPE(r5)
677 evlddx evr4,r10,r5 682 evlddx evr4,r10,r5
678 evmra evr4,evr4 683 evmra evr4,evr4
679 REST_32EVRS(0,r10,r5) 684 REST_32EVRS(0,r10,r5,THREAD_EVR0)
680#ifndef CONFIG_SMP 685#ifndef CONFIG_SMP
681 subi r4,r5,THREAD 686 subi r4,r5,THREAD
682 stw r4,last_task_used_spe@l(r3) 687 stw r4,last_task_used_spe@l(r3)
@@ -787,13 +792,11 @@ _GLOBAL(giveup_spe)
787 addi r3,r3,THREAD /* want THREAD of task */ 792 addi r3,r3,THREAD /* want THREAD of task */
788 lwz r5,PT_REGS(r3) 793 lwz r5,PT_REGS(r3)
789 cmpi 0,r5,0 794 cmpi 0,r5,0
790 SAVE_32EVRS(0, r4, r3) 795 SAVE_32EVRS(0, r4, r3, THREAD_EVR0)
791 evxor evr6, evr6, evr6 /* clear out evr6 */ 796 evxor evr6, evr6, evr6 /* clear out evr6 */
792 evmwumiaa evr6, evr6, evr6 /* evr6 <- ACC = 0 * 0 + ACC */ 797 evmwumiaa evr6, evr6, evr6 /* evr6 <- ACC = 0 * 0 + ACC */
793 li r4,THREAD_ACC 798 li r4,THREAD_ACC
794 evstddx evr6, r4, r3 /* save off accumulator */ 799 evstddx evr6, r4, r3 /* save off accumulator */
795 mfspr r6,SPRN_SPEFSCR
796 stw r6,THREAD_SPEFSCR(r3) /* save spefscr register value */
797 beq 1f 800 beq 1f
798 lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5) 801 lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)
799 lis r3,MSR_SPE@h 802 lis r3,MSR_SPE@h
diff --git a/arch/powerpc/kernel/idle_e500.S b/arch/powerpc/kernel/idle_e500.S
index 47a1a983ff8..3e2b95c6ae6 100644
--- a/arch/powerpc/kernel/idle_e500.S
+++ b/arch/powerpc/kernel/idle_e500.S
@@ -26,6 +26,17 @@ _GLOBAL(e500_idle)
26 ori r4,r4,_TLF_NAPPING /* so when we take an exception */ 26 ori r4,r4,_TLF_NAPPING /* so when we take an exception */
27 stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */ 27 stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
28 28
29#ifdef CONFIG_E500MC
30 wrteei 1
311: wait
32
33 /*
34 * Guard against spurious wakeups (e.g. from a hypervisor) --
35 * any real interrupt will cause us to return to LR due to
36 * _TLF_NAPPING.
37 */
38 b 1b
39#else
29 /* Check if we can nap or doze, put HID0 mask in r3 */ 40 /* Check if we can nap or doze, put HID0 mask in r3 */
30 lis r3,0 41 lis r3,0
31BEGIN_FTR_SECTION 42BEGIN_FTR_SECTION
@@ -72,6 +83,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_L2CSR|CPU_FTR_CAN_NAP)
72 mtmsr r7 83 mtmsr r7
73 isync 84 isync
742: b 2b 852: b 2b
86#endif /* !E500MC */
75 87
76/* 88/*
77 * Return from NAP/DOZE mode, restore some CPU specific registers, 89 * Return from NAP/DOZE mode, restore some CPU specific registers,
diff --git a/arch/powerpc/kernel/idle_power7.S b/arch/powerpc/kernel/idle_power7.S
index f8f0bc7f1d4..3a70845a51c 100644
--- a/arch/powerpc/kernel/idle_power7.S
+++ b/arch/powerpc/kernel/idle_power7.S
@@ -73,7 +73,6 @@ _GLOBAL(power7_idle)
73 b . 73 b .
74 74
75_GLOBAL(power7_wakeup_loss) 75_GLOBAL(power7_wakeup_loss)
76 GET_PACA(r13)
77 ld r1,PACAR1(r13) 76 ld r1,PACAR1(r13)
78 REST_NVGPRS(r1) 77 REST_NVGPRS(r1)
79 REST_GPR(2, r1) 78 REST_GPR(2, r1)
@@ -87,7 +86,6 @@ _GLOBAL(power7_wakeup_loss)
87 rfid 86 rfid
88 87
89_GLOBAL(power7_wakeup_noloss) 88_GLOBAL(power7_wakeup_noloss)
90 GET_PACA(r13)
91 ld r1,PACAR1(r13) 89 ld r1,PACAR1(r13)
92 ld r4,_MSR(r1) 90 ld r4,_MSR(r1)
93 ld r5,_NIP(r1) 91 ld r5,_NIP(r1)
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index 1577434f408..b25f6325fc7 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -117,6 +117,7 @@ void ioport_unmap(void __iomem *addr)
117EXPORT_SYMBOL(ioport_map); 117EXPORT_SYMBOL(ioport_map);
118EXPORT_SYMBOL(ioport_unmap); 118EXPORT_SYMBOL(ioport_unmap);
119 119
120#ifdef CONFIG_PCI
120void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max) 121void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
121{ 122{
122 resource_size_t start = pci_resource_start(dev, bar); 123 resource_size_t start = pci_resource_start(dev, bar);
@@ -146,3 +147,4 @@ void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
146 147
147EXPORT_SYMBOL(pci_iomap); 148EXPORT_SYMBOL(pci_iomap);
148EXPORT_SYMBOL(pci_iounmap); 149EXPORT_SYMBOL(pci_iounmap);
150#endif /* CONFIG_PCI */
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 5b428e30866..4b1e82a5823 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -157,12 +157,6 @@ notrace void arch_local_irq_restore(unsigned long en)
157 if (get_hard_enabled()) 157 if (get_hard_enabled())
158 return; 158 return;
159 159
160#if defined(CONFIG_BOOKE) && defined(CONFIG_SMP)
161 /* Check for pending doorbell interrupts and resend to ourself */
162 if (cpu_has_feature(CPU_FTR_DBELL))
163 smp_muxed_ipi_resend();
164#endif
165
166 /* 160 /*
167 * Need to hard-enable interrupts here. Since currently disabled, 161 * Need to hard-enable interrupts here. Since currently disabled,
168 * no need to take further asm precautions against preemption; but 162 * no need to take further asm precautions against preemption; but
@@ -170,16 +164,13 @@ notrace void arch_local_irq_restore(unsigned long en)
170 */ 164 */
171 local_paca->hard_enabled = en; 165 local_paca->hard_enabled = en;
172 166
173#ifndef CONFIG_BOOKE 167 /*
174 /* On server, re-trigger the decrementer if it went negative since 168 * Trigger the decrementer if we have a pending event. Some processors
175 * some processors only trigger on edge transitions of the sign bit. 169 * only trigger on edge transitions of the sign bit. We might also
176 * 170 * have disabled interrupts long enough that the decrementer wrapped
177 * BookE has a level sensitive decrementer (latches in TSR) so we 171 * to positive.
178 * don't need that
179 */ 172 */
180 if ((int)mfspr(SPRN_DEC) < 0) 173 decrementer_check_overflow();
181 mtspr(SPRN_DEC, 1);
182#endif /* CONFIG_BOOKE */
183 174
184 /* 175 /*
185 * Force the delivery of pending soft-disabled interrupts on PS3. 176 * Force the delivery of pending soft-disabled interrupts on PS3.
@@ -457,11 +448,18 @@ static inline void do_softirq_onstack(void)
457 curtp = current_thread_info(); 448 curtp = current_thread_info();
458 irqtp = softirq_ctx[smp_processor_id()]; 449 irqtp = softirq_ctx[smp_processor_id()];
459 irqtp->task = curtp->task; 450 irqtp->task = curtp->task;
451 irqtp->flags = 0;
460 current->thread.ksp_limit = (unsigned long)irqtp + 452 current->thread.ksp_limit = (unsigned long)irqtp +
461 _ALIGN_UP(sizeof(struct thread_info), 16); 453 _ALIGN_UP(sizeof(struct thread_info), 16);
462 call_do_softirq(irqtp); 454 call_do_softirq(irqtp);
463 current->thread.ksp_limit = saved_sp_limit; 455 current->thread.ksp_limit = saved_sp_limit;
464 irqtp->task = NULL; 456 irqtp->task = NULL;
457
458 /* Set any flag that may have been set on the
459 * alternate stack
460 */
461 if (irqtp->flags)
462 set_bits(irqtp->flags, &curtp->flags);
465} 463}
466 464
467void do_softirq(void) 465void do_softirq(void)
@@ -750,7 +748,7 @@ unsigned int irq_create_mapping(struct irq_host *host,
750 if (irq_setup_virq(host, virq, hwirq)) 748 if (irq_setup_virq(host, virq, hwirq))
751 return NO_IRQ; 749 return NO_IRQ;
752 750
753 printk(KERN_DEBUG "irq: irq %lu on host %s mapped to virtual irq %u\n", 751 pr_debug("irq: irq %lu on host %s mapped to virtual irq %u\n",
754 hwirq, host->of_node ? host->of_node->full_name : "null", virq); 752 hwirq, host->of_node ? host->of_node->full_name : "null", virq);
755 753
756 return virq; 754 return virq;
@@ -882,6 +880,41 @@ unsigned int irq_find_mapping(struct irq_host *host,
882} 880}
883EXPORT_SYMBOL_GPL(irq_find_mapping); 881EXPORT_SYMBOL_GPL(irq_find_mapping);
884 882
883#ifdef CONFIG_SMP
884int irq_choose_cpu(const struct cpumask *mask)
885{
886 int cpuid;
887
888 if (cpumask_equal(mask, cpu_all_mask)) {
889 static int irq_rover;
890 static DEFINE_RAW_SPINLOCK(irq_rover_lock);
891 unsigned long flags;
892
893 /* Round-robin distribution... */
894do_round_robin:
895 raw_spin_lock_irqsave(&irq_rover_lock, flags);
896
897 irq_rover = cpumask_next(irq_rover, cpu_online_mask);
898 if (irq_rover >= nr_cpu_ids)
899 irq_rover = cpumask_first(cpu_online_mask);
900
901 cpuid = irq_rover;
902
903 raw_spin_unlock_irqrestore(&irq_rover_lock, flags);
904 } else {
905 cpuid = cpumask_first_and(mask, cpu_online_mask);
906 if (cpuid >= nr_cpu_ids)
907 goto do_round_robin;
908 }
909
910 return get_hard_smp_processor_id(cpuid);
911}
912#else
913int irq_choose_cpu(const struct cpumask *mask)
914{
915 return hard_smp_processor_id();
916}
917#endif
885 918
886unsigned int irq_radix_revmap_lookup(struct irq_host *host, 919unsigned int irq_radix_revmap_lookup(struct irq_host *host,
887 irq_hw_number_t hwirq) 920 irq_hw_number_t hwirq)
diff --git a/arch/powerpc/kernel/jump_label.c b/arch/powerpc/kernel/jump_label.c
new file mode 100644
index 00000000000..368d158d665
--- /dev/null
+++ b/arch/powerpc/kernel/jump_label.c
@@ -0,0 +1,23 @@
1/*
2 * Copyright 2010 Michael Ellerman, IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#include <linux/kernel.h>
11#include <linux/jump_label.h>
12#include <asm/code-patching.h>
13
14void arch_jump_label_transform(struct jump_entry *entry,
15 enum jump_label_type type)
16{
17 u32 *addr = (u32 *)(unsigned long)entry->code;
18
19 if (type == JUMP_LABEL_ENABLE)
20 patch_branch(addr, entry->target, 0);
21 else
22 patch_instruction(addr, PPC_INST_NOP);
23}
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index b06bdae0406..ad892f7a757 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -131,7 +131,6 @@ static void kvm_patch_ins_b(u32 *inst, int addr)
131 /* On relocatable kernels interrupts handlers and our code 131 /* On relocatable kernels interrupts handlers and our code
132 can be in different regions, so we don't patch them */ 132 can be in different regions, so we don't patch them */
133 133
134 extern u32 __end_interrupts;
135 if ((ulong)inst < (ulong)&__end_interrupts) 134 if ((ulong)inst < (ulong)&__end_interrupts)
136 return; 135 return;
137#endif 136#endif
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 7ee50f0547c..9ce1672afb5 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -126,7 +126,7 @@ void __init reserve_crashkernel(void)
126 /* We might have got these values via the command line or the 126 /* We might have got these values via the command line or the
127 * device tree, either way sanitise them now. */ 127 * device tree, either way sanitise them now. */
128 128
129 crash_size = crashk_res.end - crashk_res.start + 1; 129 crash_size = resource_size(&crashk_res);
130 130
131#ifndef CONFIG_RELOCATABLE 131#ifndef CONFIG_RELOCATABLE
132 if (crashk_res.start != KDUMP_KERNELBASE) 132 if (crashk_res.start != KDUMP_KERNELBASE)
@@ -136,12 +136,16 @@ void __init reserve_crashkernel(void)
136 crashk_res.start = KDUMP_KERNELBASE; 136 crashk_res.start = KDUMP_KERNELBASE;
137#else 137#else
138 if (!crashk_res.start) { 138 if (!crashk_res.start) {
139#ifdef CONFIG_PPC64
139 /* 140 /*
140 * unspecified address, choose a region of specified size 141 * On 64bit we split the RMO in half but cap it at half of
141 * can overlap with initrd (ignoring corruption when retained) 142 * a small SLB (128MB) since the crash kernel needs to place
142 * ppc64 requires kernel and some stacks to be in first segemnt 143 * itself and some stacks to be in the first segment.
143 */ 144 */
145 crashk_res.start = min(0x80000000ULL, (ppc64_rma_size / 2));
146#else
144 crashk_res.start = KDUMP_KERNELBASE; 147 crashk_res.start = KDUMP_KERNELBASE;
148#endif
145 } 149 }
146 150
147 crash_base = PAGE_ALIGN(crashk_res.start); 151 crash_base = PAGE_ALIGN(crashk_res.start);
@@ -222,7 +226,7 @@ static void __init export_crashk_values(struct device_node *node)
222 226
223 if (crashk_res.start != 0) { 227 if (crashk_res.start != 0) {
224 prom_add_property(node, &crashk_base_prop); 228 prom_add_property(node, &crashk_base_prop);
225 crashk_size = crashk_res.end - crashk_res.start + 1; 229 crashk_size = resource_size(&crashk_res);
226 prom_add_property(node, &crashk_size_prop); 230 prom_add_property(node, &crashk_size_prop);
227 } 231 }
228} 232}
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index e89df59cdc5..616921ef143 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -339,7 +339,7 @@ _GLOBAL(real_205_writeb)
339#endif /* CONFIG_PPC_PASEMI */ 339#endif /* CONFIG_PPC_PASEMI */
340 340
341 341
342#ifdef CONFIG_CPU_FREQ_PMAC64 342#if defined(CONFIG_CPU_FREQ_PMAC64) || defined(CONFIG_CPU_FREQ_MAPLE)
343/* 343/*
344 * SCOM access functions for 970 (FX only for now) 344 * SCOM access functions for 970 (FX only for now)
345 * 345 *
@@ -408,7 +408,7 @@ _GLOBAL(scom970_write)
408 /* restore interrupts */ 408 /* restore interrupts */
409 mtmsrd r5,1 409 mtmsrd r5,1
410 blr 410 blr
411#endif /* CONFIG_CPU_FREQ_PMAC64 */ 411#endif /* CONFIG_CPU_FREQ_PMAC64 || CONFIG_CPU_FREQ_MAPLE */
412 412
413 413
414/* 414/*
diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c
index 49cee9df225..a1cd701b575 100644
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -31,20 +31,6 @@
31 31
32LIST_HEAD(module_bug_list); 32LIST_HEAD(module_bug_list);
33 33
34void *module_alloc(unsigned long size)
35{
36 if (size == 0)
37 return NULL;
38
39 return vmalloc_exec(size);
40}
41
42/* Free memory returned from module_alloc */
43void module_free(struct module *mod, void *module_region)
44{
45 vfree(module_region);
46}
47
48static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, 34static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
49 const Elf_Shdr *sechdrs, 35 const Elf_Shdr *sechdrs,
50 const char *name) 36 const char *name)
@@ -93,7 +79,3 @@ int module_finalize(const Elf_Ehdr *hdr,
93 79
94 return 0; 80 return 0;
95} 81}
96
97void module_arch_cleanup(struct module *mod)
98{
99}
diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index f832773fc28..0b6d79617d7 100644
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -174,17 +174,6 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
174 return 0; 174 return 0;
175} 175}
176 176
177int apply_relocate(Elf32_Shdr *sechdrs,
178 const char *strtab,
179 unsigned int symindex,
180 unsigned int relsec,
181 struct module *module)
182{
183 printk(KERN_ERR "%s: Non-ADD RELOCATION unsupported\n",
184 module->name);
185 return -ENOEXEC;
186}
187
188static inline int entry_matches(struct ppc_plt_entry *entry, Elf32_Addr val) 177static inline int entry_matches(struct ppc_plt_entry *entry, Elf32_Addr val)
189{ 178{
190 if (entry->jump[0] == 0x3d600000 + ((val + 0x8000) >> 16) 179 if (entry->jump[0] == 0x3d600000 + ((val + 0x8000) >> 16)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 8fbb12508bf..9f44a775a10 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -243,16 +243,6 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr,
243 return 0; 243 return 0;
244} 244}
245 245
246int apply_relocate(Elf64_Shdr *sechdrs,
247 const char *strtab,
248 unsigned int symindex,
249 unsigned int relsec,
250 struct module *me)
251{
252 printk(KERN_ERR "%s: Non-ADD RELOCATION unsupported\n", me->name);
253 return -ENOEXEC;
254}
255
256/* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this 246/* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this
257 gives the value maximum span in an instruction which uses a signed 247 gives the value maximum span in an instruction which uses a signed
258 offset) */ 248 offset) */
diff --git a/arch/powerpc/kernel/mpc7450-pmu.c b/arch/powerpc/kernel/mpc7450-pmu.c
index 2cc5e0301d0..fe21b515ca4 100644
--- a/arch/powerpc/kernel/mpc7450-pmu.c
+++ b/arch/powerpc/kernel/mpc7450-pmu.c
@@ -388,6 +388,11 @@ static int mpc7450_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
388 [C(OP_WRITE)] = { -1, -1 }, 388 [C(OP_WRITE)] = { -1, -1 },
389 [C(OP_PREFETCH)] = { -1, -1 }, 389 [C(OP_PREFETCH)] = { -1, -1 },
390 }, 390 },
391 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
392 [C(OP_READ)] = { -1, -1 },
393 [C(OP_WRITE)] = { -1, -1 },
394 [C(OP_PREFETCH)] = { -1, -1 },
395 },
391}; 396};
392 397
393struct power_pmu mpc7450_pmu = { 398struct power_pmu mpc7450_pmu = {
@@ -405,7 +410,7 @@ struct power_pmu mpc7450_pmu = {
405 .cache_events = &mpc7450_cache_events, 410 .cache_events = &mpc7450_cache_events,
406}; 411};
407 412
408static int init_mpc7450_pmu(void) 413static int __init init_mpc7450_pmu(void)
409{ 414{
410 if (!cur_cpu_spec->oprofile_cpu_type || 415 if (!cur_cpu_spec->oprofile_cpu_type ||
411 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450")) 416 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450"))
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 24582181b6e..59dbf6abaaf 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -26,7 +26,7 @@
26#include <asm/topology.h> 26#include <asm/topology.h>
27#include <asm/pci-bridge.h> 27#include <asm/pci-bridge.h>
28#include <asm/ppc-pci.h> 28#include <asm/ppc-pci.h>
29#include <asm/atomic.h> 29#include <linux/atomic.h>
30 30
31#ifdef CONFIG_PPC_OF_PLATFORM_PCI 31#ifdef CONFIG_PPC_OF_PLATFORM_PCI
32 32
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index efeb8818418..0a5a899846b 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -167,7 +167,7 @@ void setup_paca(struct paca_struct *new_paca)
167 * if we do a GET_PACA() before the feature fixups have been 167 * if we do a GET_PACA() before the feature fixups have been
168 * applied 168 * applied
169 */ 169 */
170 if (cpu_has_feature(CPU_FTR_HVMODE_206)) 170 if (cpu_has_feature(CPU_FTR_HVMODE))
171 mtspr(SPRN_SPRG_HPACA, local_paca); 171 mtspr(SPRN_SPRG_HPACA, local_paca);
172#endif 172#endif
173 mtspr(SPRN_SPRG_PACA, local_paca); 173 mtspr(SPRN_SPRG_PACA, local_paca);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 893af2a9cd0..32656f10525 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,7 +50,7 @@ static int global_phb_number; /* Global phb counter */
50resource_size_t isa_mem_base; 50resource_size_t isa_mem_base;
51 51
52/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */ 52/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */
53unsigned int ppc_pci_flags = 0; 53unsigned int pci_flags = 0;
54 54
55 55
56static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 56static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
@@ -107,7 +107,7 @@ static resource_size_t pcibios_io_size(const struct pci_controller *hose)
107#ifdef CONFIG_PPC64 107#ifdef CONFIG_PPC64
108 return hose->pci_io_size; 108 return hose->pci_io_size;
109#else 109#else
110 return hose->io_resource.end - hose->io_resource.start + 1; 110 return resource_size(&hose->io_resource);
111#endif 111#endif
112} 112}
113 113
@@ -842,9 +842,9 @@ int pci_proc_domain(struct pci_bus *bus)
842{ 842{
843 struct pci_controller *hose = pci_bus_to_host(bus); 843 struct pci_controller *hose = pci_bus_to_host(bus);
844 844
845 if (!(ppc_pci_flags & PPC_PCI_ENABLE_PROC_DOMAINS)) 845 if (!pci_has_flag(PCI_ENABLE_PROC_DOMAINS))
846 return 0; 846 return 0;
847 if (ppc_pci_flags & PPC_PCI_COMPAT_DOMAIN_0) 847 if (pci_has_flag(PCI_COMPAT_DOMAIN_0))
848 return hose->global_number != 0; 848 return hose->global_number != 0;
849 return 1; 849 return 1;
850} 850}
@@ -920,13 +920,13 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
920 struct resource *res = dev->resource + i; 920 struct resource *res = dev->resource + i;
921 if (!res->flags) 921 if (!res->flags)
922 continue; 922 continue;
923 /* On platforms that have PPC_PCI_PROBE_ONLY set, we don't 923 /* On platforms that have PCI_PROBE_ONLY set, we don't
924 * consider 0 as an unassigned BAR value. It's technically 924 * consider 0 as an unassigned BAR value. It's technically
925 * a valid value, but linux doesn't like it... so when we can 925 * a valid value, but linux doesn't like it... so when we can
926 * re-assign things, we do so, but if we can't, we keep it 926 * re-assign things, we do so, but if we can't, we keep it
927 * around and hope for the best... 927 * around and hope for the best...
928 */ 928 */
929 if (res->start == 0 && !(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) { 929 if (res->start == 0 && !pci_has_flag(PCI_PROBE_ONLY)) {
930 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] is unassigned\n", 930 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] is unassigned\n",
931 pci_name(dev), i, 931 pci_name(dev), i,
932 (unsigned long long)res->start, 932 (unsigned long long)res->start,
@@ -973,7 +973,7 @@ static int __devinit pcibios_uninitialized_bridge_resource(struct pci_bus *bus,
973 int i; 973 int i;
974 974
975 /* We don't do anything if PCI_PROBE_ONLY is set */ 975 /* We don't do anything if PCI_PROBE_ONLY is set */
976 if (ppc_pci_flags & PPC_PCI_PROBE_ONLY) 976 if (pci_has_flag(PCI_PROBE_ONLY))
977 return 0; 977 return 0;
978 978
979 /* Job is a bit different between memory and IO */ 979 /* Job is a bit different between memory and IO */
@@ -1097,9 +1097,6 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
1097 if (dev->is_added) 1097 if (dev->is_added)
1098 continue; 1098 continue;
1099 1099
1100 /* Setup OF node pointer in the device */
1101 dev->dev.of_node = pci_device_to_OF_node(dev);
1102
1103 /* Fixup NUMA node as it may not be setup yet by the generic 1100 /* Fixup NUMA node as it may not be setup yet by the generic
1104 * code and is needed by the DMA init 1101 * code and is needed by the DMA init
1105 */ 1102 */
@@ -1146,7 +1143,7 @@ void __devinit pci_fixup_cardbus(struct pci_bus *bus)
1146 1143
1147static int skip_isa_ioresource_align(struct pci_dev *dev) 1144static int skip_isa_ioresource_align(struct pci_dev *dev)
1148{ 1145{
1149 if ((ppc_pci_flags & PPC_PCI_CAN_SKIP_ISA_ALIGN) && 1146 if (pci_has_flag(PCI_CAN_SKIP_ISA_ALIGN) &&
1150 !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) 1147 !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA))
1151 return 1; 1148 return 1;
1152 return 0; 1149 return 0;
@@ -1274,7 +1271,7 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
1274 * and as such ensure proper re-allocation 1271 * and as such ensure proper re-allocation
1275 * later. 1272 * later.
1276 */ 1273 */
1277 if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC) 1274 if (pci_has_flag(PCI_REASSIGN_ALL_RSRC))
1278 goto clear_resource; 1275 goto clear_resource;
1279 pr = pci_find_parent_resource(bus->self, res); 1276 pr = pci_find_parent_resource(bus->self, res);
1280 if (pr == res) { 1277 if (pr == res) {
@@ -1459,7 +1456,7 @@ void __init pcibios_resource_survey(void)
1459 list_for_each_entry(b, &pci_root_buses, node) 1456 list_for_each_entry(b, &pci_root_buses, node)
1460 pcibios_allocate_bus_resources(b); 1457 pcibios_allocate_bus_resources(b);
1461 1458
1462 if (!(ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)) { 1459 if (!pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
1463 pcibios_allocate_resources(0); 1460 pcibios_allocate_resources(0);
1464 pcibios_allocate_resources(1); 1461 pcibios_allocate_resources(1);
1465 } 1462 }
@@ -1468,7 +1465,7 @@ void __init pcibios_resource_survey(void)
1468 * the low IO area and the VGA memory area if they intersect the 1465 * the low IO area and the VGA memory area if they intersect the
1469 * bus available resources to avoid allocating things on top of them 1466 * bus available resources to avoid allocating things on top of them
1470 */ 1467 */
1471 if (!(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) { 1468 if (!pci_has_flag(PCI_PROBE_ONLY)) {
1472 list_for_each_entry(b, &pci_root_buses, node) 1469 list_for_each_entry(b, &pci_root_buses, node)
1473 pcibios_reserve_legacy_regions(b); 1470 pcibios_reserve_legacy_regions(b);
1474 } 1471 }
@@ -1476,7 +1473,7 @@ void __init pcibios_resource_survey(void)
1476 /* Now, if the platform didn't decide to blindly trust the firmware, 1473 /* Now, if the platform didn't decide to blindly trust the firmware,
1477 * we proceed to assigning things that were left unassigned 1474 * we proceed to assigning things that were left unassigned
1478 */ 1475 */
1479 if (!(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) { 1476 if (!pci_has_flag(PCI_PROBE_ONLY)) {
1480 pr_debug("PCI: Assigning unassigned resources...\n"); 1477 pr_debug("PCI: Assigning unassigned resources...\n");
1481 pci_assign_unassigned_resources(); 1478 pci_assign_unassigned_resources();
1482 } 1479 }
@@ -1685,6 +1682,13 @@ int early_find_capability(struct pci_controller *hose, int bus, int devfn,
1685 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap); 1682 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
1686} 1683}
1687 1684
1685struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
1686{
1687 struct pci_controller *hose = bus->sysdata;
1688
1689 return of_node_get(hose->dn);
1690}
1691
1688/** 1692/**
1689 * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus 1693 * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
1690 * @hose: Pointer to the PCI host controller instance structure 1694 * @hose: Pointer to the PCI host controller instance structure
@@ -1705,7 +1709,6 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
1705 hose->global_number); 1709 hose->global_number);
1706 return; 1710 return;
1707 } 1711 }
1708 bus->dev.of_node = of_node_get(node);
1709 bus->secondary = hose->first_busno; 1712 bus->secondary = hose->first_busno;
1710 hose->bus = bus; 1713 hose->bus = bus;
1711 1714
@@ -1728,3 +1731,21 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
1728 if (mode == PCI_PROBE_NORMAL) 1731 if (mode == PCI_PROBE_NORMAL)
1729 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); 1732 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
1730} 1733}
1734
1735static void fixup_hide_host_resource_fsl(struct pci_dev *dev)
1736{
1737 int i, class = dev->class >> 8;
1738
1739 if ((class == PCI_CLASS_PROCESSOR_POWERPC ||
1740 class == PCI_CLASS_BRIDGE_OTHER) &&
1741 (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) &&
1742 (dev->bus->parent == NULL)) {
1743 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
1744 dev->resource[i].start = 0;
1745 dev->resource[i].end = 0;
1746 dev->resource[i].flags = 0;
1747 }
1748 }
1749}
1750DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl);
1751DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl);
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index bedb370459f..bb154511db5 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -51,25 +51,6 @@ struct pci_dev *isa_bridge_pcidev;
51EXPORT_SYMBOL_GPL(isa_bridge_pcidev); 51EXPORT_SYMBOL_GPL(isa_bridge_pcidev);
52 52
53static void 53static void
54fixup_hide_host_resource_fsl(struct pci_dev *dev)
55{
56 int i, class = dev->class >> 8;
57
58 if ((class == PCI_CLASS_PROCESSOR_POWERPC ||
59 class == PCI_CLASS_BRIDGE_OTHER) &&
60 (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) &&
61 (dev->bus->parent == NULL)) {
62 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
63 dev->resource[i].start = 0;
64 dev->resource[i].end = 0;
65 dev->resource[i].flags = 0;
66 }
67 }
68}
69DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl);
70DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl);
71
72static void
73fixup_cpc710_pci64(struct pci_dev* dev) 54fixup_cpc710_pci64(struct pci_dev* dev)
74{ 55{
75 /* Hide the PCI64 BARs from the kernel as their content doesn't 56 /* Hide the PCI64 BARs from the kernel as their content doesn't
@@ -167,150 +148,26 @@ pcibios_make_OF_bus_map(void)
167#endif 148#endif
168} 149}
169 150
170typedef int (*pci_OF_scan_iterator)(struct device_node* node, void* data);
171
172static struct device_node*
173scan_OF_pci_childs(struct device_node *parent, pci_OF_scan_iterator filter, void* data)
174{
175 struct device_node *node;
176 struct device_node* sub_node;
177
178 for_each_child_of_node(parent, node) {
179 const unsigned int *class_code;
180
181 if (filter(node, data)) {
182 of_node_put(node);
183 return node;
184 }
185
186 /* For PCI<->PCI bridges or CardBus bridges, we go down
187 * Note: some OFs create a parent node "multifunc-device" as
188 * a fake root for all functions of a multi-function device,
189 * we go down them as well.
190 */
191 class_code = of_get_property(node, "class-code", NULL);
192 if ((!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
193 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
194 strcmp(node->name, "multifunc-device"))
195 continue;
196 sub_node = scan_OF_pci_childs(node, filter, data);
197 if (sub_node) {
198 of_node_put(node);
199 return sub_node;
200 }
201 }
202 return NULL;
203}
204
205static struct device_node *scan_OF_for_pci_dev(struct device_node *parent,
206 unsigned int devfn)
207{
208 struct device_node *np, *cnp;
209 const u32 *reg;
210 unsigned int psize;
211
212 for_each_child_of_node(parent, np) {
213 reg = of_get_property(np, "reg", &psize);
214 if (reg && psize >= 4 && ((reg[0] >> 8) & 0xff) == devfn)
215 return np;
216
217 /* Note: some OFs create a parent node "multifunc-device" as
218 * a fake root for all functions of a multi-function device,
219 * we go down them as well. */
220 if (!strcmp(np->name, "multifunc-device")) {
221 cnp = scan_OF_for_pci_dev(np, devfn);
222 if (cnp)
223 return cnp;
224 }
225 }
226 return NULL;
227}
228
229
230static struct device_node *scan_OF_for_pci_bus(struct pci_bus *bus)
231{
232 struct device_node *parent, *np;
233
234 /* Are we a root bus ? */
235 if (bus->self == NULL || bus->parent == NULL) {
236 struct pci_controller *hose = pci_bus_to_host(bus);
237 if (hose == NULL)
238 return NULL;
239 return of_node_get(hose->dn);
240 }
241
242 /* not a root bus, we need to get our parent */
243 parent = scan_OF_for_pci_bus(bus->parent);
244 if (parent == NULL)
245 return NULL;
246
247 /* now iterate for children for a match */
248 np = scan_OF_for_pci_dev(parent, bus->self->devfn);
249 of_node_put(parent);
250
251 return np;
252}
253
254/*
255 * Scans the OF tree for a device node matching a PCI device
256 */
257struct device_node *
258pci_busdev_to_OF_node(struct pci_bus *bus, int devfn)
259{
260 struct device_node *parent, *np;
261
262 pr_debug("pci_busdev_to_OF_node(%d,0x%x)\n", bus->number, devfn);
263 parent = scan_OF_for_pci_bus(bus);
264 if (parent == NULL)
265 return NULL;
266 pr_debug(" parent is %s\n", parent ? parent->full_name : "<NULL>");
267 np = scan_OF_for_pci_dev(parent, devfn);
268 of_node_put(parent);
269 pr_debug(" result is %s\n", np ? np->full_name : "<NULL>");
270
271 /* XXX most callers don't release the returned node
272 * mostly because ppc64 doesn't increase the refcount,
273 * we need to fix that.
274 */
275 return np;
276}
277EXPORT_SYMBOL(pci_busdev_to_OF_node);
278
279struct device_node*
280pci_device_to_OF_node(struct pci_dev *dev)
281{
282 return pci_busdev_to_OF_node(dev->bus, dev->devfn);
283}
284EXPORT_SYMBOL(pci_device_to_OF_node);
285
286static int
287find_OF_pci_device_filter(struct device_node* node, void* data)
288{
289 return ((void *)node == data);
290}
291 151
292/* 152/*
293 * Returns the PCI device matching a given OF node 153 * Returns the PCI device matching a given OF node
294 */ 154 */
295int 155int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
296pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
297{ 156{
298 const unsigned int *reg; 157 struct pci_dev *dev = NULL;
299 struct pci_controller* hose; 158 const __be32 *reg;
300 struct pci_dev* dev = NULL; 159 int size;
301 160
302 /* Make sure it's really a PCI device */ 161 /* Check if it might have a chance to be a PCI device */
303 hose = pci_find_hose_for_OF_device(node); 162 if (!pci_find_hose_for_OF_device(node))
304 if (!hose || !hose->dn)
305 return -ENODEV;
306 if (!scan_OF_pci_childs(hose->dn,
307 find_OF_pci_device_filter, (void *)node))
308 return -ENODEV; 163 return -ENODEV;
309 reg = of_get_property(node, "reg", NULL); 164
310 if (!reg) 165 reg = of_get_property(node, "reg", &size);
166 if (!reg || size < 5 * sizeof(u32))
311 return -ENODEV; 167 return -ENODEV;
312 *bus = (reg[0] >> 16) & 0xff; 168
313 *devfn = ((reg[0] >> 8) & 0xff); 169 *bus = (be32_to_cpup(&reg[0]) >> 16) & 0xff;
170 *devfn = (be32_to_cpup(&reg[0]) >> 8) & 0xff;
314 171
315 /* Ok, here we need some tweak. If we have already renumbered 172 /* Ok, here we need some tweak. If we have already renumbered
316 * all busses, we can't rely on the OF bus number any more. 173 * all busses, we can't rely on the OF bus number any more.
@@ -373,7 +230,7 @@ static int __init pcibios_init(void)
373 230
374 printk(KERN_INFO "PCI: Probing PCI hardware\n"); 231 printk(KERN_INFO "PCI: Probing PCI hardware\n");
375 232
376 if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_BUS) 233 if (pci_has_flag(PCI_REASSIGN_ALL_BUS))
377 pci_assign_all_buses = 1; 234 pci_assign_all_buses = 1;
378 235
379 /* Scan all of the recorded PCI controllers. */ 236 /* Scan all of the recorded PCI controllers. */
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index fc6452b6be9..ab34046752b 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -55,12 +55,12 @@ static int __init pcibios_init(void)
55 ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot; 55 ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;
56 56
57 if (pci_probe_only) 57 if (pci_probe_only)
58 ppc_pci_flags |= PPC_PCI_PROBE_ONLY; 58 pci_add_flags(PCI_PROBE_ONLY);
59 59
60 /* On ppc64, we always enable PCI domains and we keep domain 0 60 /* On ppc64, we always enable PCI domains and we keep domain 0
61 * backward compatible in /proc for video cards 61 * backward compatible in /proc for video cards
62 */ 62 */
63 ppc_pci_flags |= PPC_PCI_ENABLE_PROC_DOMAINS | PPC_PCI_COMPAT_DOMAIN_0; 63 pci_add_flags(PCI_ENABLE_PROC_DOMAINS | PCI_COMPAT_DOMAIN_0);
64 64
65 /* Scan all of the recorded PCI controllers. */ 65 /* Scan all of the recorded PCI controllers. */
66 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { 66 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 6baabc13306..478f8d78716 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -142,53 +142,6 @@ void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb)
142 traverse_pci_devices(dn, update_dn_pci_info, phb); 142 traverse_pci_devices(dn, update_dn_pci_info, phb);
143} 143}
144 144
145/*
146 * Traversal func that looks for a <busno,devfcn> value.
147 * If found, the pci_dn is returned (thus terminating the traversal).
148 */
149static void *is_devfn_node(struct device_node *dn, void *data)
150{
151 int busno = ((unsigned long)data >> 8) & 0xff;
152 int devfn = ((unsigned long)data) & 0xff;
153 struct pci_dn *pci = dn->data;
154
155 if (pci && (devfn == pci->devfn) && (busno == pci->busno))
156 return dn;
157 return NULL;
158}
159
160/*
161 * This is the "slow" path for looking up a device_node from a
162 * pci_dev. It will hunt for the device under its parent's
163 * phb and then update of_node pointer.
164 *
165 * It may also do fixups on the actual device since this happens
166 * on the first read/write.
167 *
168 * Note that it also must deal with devices that don't exist.
169 * In this case it may probe for real hardware ("just in case")
170 * and add a device_node to the device tree if necessary.
171 *
172 * Is this function necessary anymore now that dev->dev.of_node is
173 * used to store the node pointer?
174 *
175 */
176struct device_node *fetch_dev_dn(struct pci_dev *dev)
177{
178 struct pci_controller *phb = dev->sysdata;
179 struct device_node *dn;
180 unsigned long searchval = (dev->bus->number << 8) | dev->devfn;
181
182 if (WARN_ON(!phb))
183 return NULL;
184
185 dn = traverse_pci_devices(phb->dn, is_devfn_node, (void *)searchval);
186 if (dn)
187 dev->dev.of_node = dn;
188 return dn;
189}
190EXPORT_SYMBOL(fetch_dev_dn);
191
192/** 145/**
193 * pci_devs_phb_init - Initialize phbs and pci devs under them. 146 * pci_devs_phb_init - Initialize phbs and pci devs under them.
194 * 147 *
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 1e89a72fd03..fe0a5ad6f73 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -202,9 +202,9 @@ EXPORT_SYMBOL(of_create_pci_dev);
202 * this routine in turn call of_scan_bus() recusively to scan for more child 202 * this routine in turn call of_scan_bus() recusively to scan for more child
203 * devices. 203 * devices.
204 */ 204 */
205void __devinit of_scan_pci_bridge(struct device_node *node, 205void __devinit of_scan_pci_bridge(struct pci_dev *dev)
206 struct pci_dev *dev)
207{ 206{
207 struct device_node *node = dev->dev.of_node;
208 struct pci_bus *bus; 208 struct pci_bus *bus;
209 const u32 *busrange, *ranges; 209 const u32 *busrange, *ranges;
210 int len, i, mode; 210 int len, i, mode;
@@ -238,7 +238,6 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
238 bus->primary = dev->bus->number; 238 bus->primary = dev->bus->number;
239 bus->subordinate = busrange[1]; 239 bus->subordinate = busrange[1];
240 bus->bridge_ctl = 0; 240 bus->bridge_ctl = 0;
241 bus->dev.of_node = of_node_get(node);
242 241
243 /* parse ranges property */ 242 /* parse ranges property */
244 /* PCI #address-cells == 3 and #size-cells == 2 always */ 243 /* PCI #address-cells == 3 and #size-cells == 2 always */
@@ -335,9 +334,7 @@ static void __devinit __of_scan_bus(struct device_node *node,
335 list_for_each_entry(dev, &bus->devices, bus_list) { 334 list_for_each_entry(dev, &bus->devices, bus_list) {
336 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 335 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
337 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { 336 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
338 struct device_node *child = pci_device_to_OF_node(dev); 337 of_scan_pci_bridge(dev);
339 if (child)
340 of_scan_pci_bridge(child, dev);
341 } 338 }
342 } 339 }
343} 340}
diff --git a/arch/powerpc/kernel/perf_callchain.c b/arch/powerpc/kernel/perf_callchain.c
index d05ae4204bb..564c1d8bdb5 100644
--- a/arch/powerpc/kernel/perf_callchain.c
+++ b/arch/powerpc/kernel/perf_callchain.c
@@ -154,8 +154,12 @@ static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret)
154 ((unsigned long)ptr & 7)) 154 ((unsigned long)ptr & 7))
155 return -EFAULT; 155 return -EFAULT;
156 156
157 if (!__get_user_inatomic(*ret, ptr)) 157 pagefault_disable();
158 if (!__get_user_inatomic(*ret, ptr)) {
159 pagefault_enable();
158 return 0; 160 return 0;
161 }
162 pagefault_enable();
159 163
160 return read_user_stack_slow(ptr, ret, 8); 164 return read_user_stack_slow(ptr, ret, 8);
161} 165}
@@ -166,8 +170,12 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
166 ((unsigned long)ptr & 3)) 170 ((unsigned long)ptr & 3))
167 return -EFAULT; 171 return -EFAULT;
168 172
169 if (!__get_user_inatomic(*ret, ptr)) 173 pagefault_disable();
174 if (!__get_user_inatomic(*ret, ptr)) {
175 pagefault_enable();
170 return 0; 176 return 0;
177 }
178 pagefault_enable();
171 179
172 return read_user_stack_slow(ptr, ret, 4); 180 return read_user_stack_slow(ptr, ret, 4);
173} 181}
@@ -294,11 +302,17 @@ static inline int current_is_64bit(void)
294 */ 302 */
295static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret) 303static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
296{ 304{
305 int rc;
306
297 if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) || 307 if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) ||
298 ((unsigned long)ptr & 3)) 308 ((unsigned long)ptr & 3))
299 return -EFAULT; 309 return -EFAULT;
300 310
301 return __get_user_inatomic(*ret, ptr); 311 pagefault_disable();
312 rc = __get_user_inatomic(*ret, ptr);
313 pagefault_enable();
314
315 return rc;
302} 316}
303 317
304static inline void perf_callchain_user_64(struct perf_callchain_entry *entry, 318static inline void perf_callchain_user_64(struct perf_callchain_entry *entry,
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c
index 822f63008ae..10a140f82cb 100644
--- a/arch/powerpc/kernel/perf_event.c
+++ b/arch/powerpc/kernel/perf_event.c
@@ -1207,7 +1207,7 @@ struct pmu power_pmu = {
1207 * here so there is no possibility of being interrupted. 1207 * here so there is no possibility of being interrupted.
1208 */ 1208 */
1209static void record_and_restart(struct perf_event *event, unsigned long val, 1209static void record_and_restart(struct perf_event *event, unsigned long val,
1210 struct pt_regs *regs, int nmi) 1210 struct pt_regs *regs)
1211{ 1211{
1212 u64 period = event->hw.sample_period; 1212 u64 period = event->hw.sample_period;
1213 s64 prev, delta, left; 1213 s64 prev, delta, left;
@@ -1258,7 +1258,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
1258 if (event->attr.sample_type & PERF_SAMPLE_ADDR) 1258 if (event->attr.sample_type & PERF_SAMPLE_ADDR)
1259 perf_get_data_addr(regs, &data.addr); 1259 perf_get_data_addr(regs, &data.addr);
1260 1260
1261 if (perf_event_overflow(event, nmi, &data, regs)) 1261 if (perf_event_overflow(event, &data, regs))
1262 power_pmu_stop(event, 0); 1262 power_pmu_stop(event, 0);
1263 } 1263 }
1264} 1264}
@@ -1346,7 +1346,7 @@ static void perf_event_interrupt(struct pt_regs *regs)
1346 if ((int)val < 0) { 1346 if ((int)val < 0) {
1347 /* event has overflowed */ 1347 /* event has overflowed */
1348 found = 1; 1348 found = 1;
1349 record_and_restart(event, val, regs, nmi); 1349 record_and_restart(event, val, regs);
1350 } 1350 }
1351 } 1351 }
1352 1352
@@ -1408,7 +1408,7 @@ power_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu
1408 return NOTIFY_OK; 1408 return NOTIFY_OK;
1409} 1409}
1410 1410
1411int register_power_pmu(struct power_pmu *pmu) 1411int __cpuinit register_power_pmu(struct power_pmu *pmu)
1412{ 1412{
1413 if (ppmu) 1413 if (ppmu)
1414 return -EBUSY; /* something's already registered */ 1414 return -EBUSY; /* something's already registered */
diff --git a/arch/powerpc/kernel/perf_event_fsl_emb.c b/arch/powerpc/kernel/perf_event_fsl_emb.c
index b0dc8f7069c..0a6d2a9d569 100644
--- a/arch/powerpc/kernel/perf_event_fsl_emb.c
+++ b/arch/powerpc/kernel/perf_event_fsl_emb.c
@@ -568,7 +568,7 @@ static struct pmu fsl_emb_pmu = {
568 * here so there is no possibility of being interrupted. 568 * here so there is no possibility of being interrupted.
569 */ 569 */
570static void record_and_restart(struct perf_event *event, unsigned long val, 570static void record_and_restart(struct perf_event *event, unsigned long val,
571 struct pt_regs *regs, int nmi) 571 struct pt_regs *regs)
572{ 572{
573 u64 period = event->hw.sample_period; 573 u64 period = event->hw.sample_period;
574 s64 prev, delta, left; 574 s64 prev, delta, left;
@@ -616,7 +616,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
616 perf_sample_data_init(&data, 0); 616 perf_sample_data_init(&data, 0);
617 data.period = event->hw.last_period; 617 data.period = event->hw.last_period;
618 618
619 if (perf_event_overflow(event, nmi, &data, regs)) 619 if (perf_event_overflow(event, &data, regs))
620 fsl_emb_pmu_stop(event, 0); 620 fsl_emb_pmu_stop(event, 0);
621 } 621 }
622} 622}
@@ -644,7 +644,7 @@ static void perf_event_interrupt(struct pt_regs *regs)
644 if (event) { 644 if (event) {
645 /* event has overflowed */ 645 /* event has overflowed */
646 found = 1; 646 found = 1;
647 record_and_restart(event, val, regs, nmi); 647 record_and_restart(event, val, regs);
648 } else { 648 } else {
649 /* 649 /*
650 * Disabled counter is negative, 650 * Disabled counter is negative,
diff --git a/arch/powerpc/kernel/power4-pmu.c b/arch/powerpc/kernel/power4-pmu.c
index ead8b3c2649..b4f1dda4d08 100644
--- a/arch/powerpc/kernel/power4-pmu.c
+++ b/arch/powerpc/kernel/power4-pmu.c
@@ -587,6 +587,11 @@ static int power4_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
587 [C(OP_WRITE)] = { -1, -1 }, 587 [C(OP_WRITE)] = { -1, -1 },
588 [C(OP_PREFETCH)] = { -1, -1 }, 588 [C(OP_PREFETCH)] = { -1, -1 },
589 }, 589 },
590 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
591 [C(OP_READ)] = { -1, -1 },
592 [C(OP_WRITE)] = { -1, -1 },
593 [C(OP_PREFETCH)] = { -1, -1 },
594 },
590}; 595};
591 596
592static struct power_pmu power4_pmu = { 597static struct power_pmu power4_pmu = {
@@ -604,7 +609,7 @@ static struct power_pmu power4_pmu = {
604 .cache_events = &power4_cache_events, 609 .cache_events = &power4_cache_events,
605}; 610};
606 611
607static int init_power4_pmu(void) 612static int __init init_power4_pmu(void)
608{ 613{
609 if (!cur_cpu_spec->oprofile_cpu_type || 614 if (!cur_cpu_spec->oprofile_cpu_type ||
610 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power4")) 615 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power4"))
diff --git a/arch/powerpc/kernel/power5+-pmu.c b/arch/powerpc/kernel/power5+-pmu.c
index eca0ac595cb..a8757baa28f 100644
--- a/arch/powerpc/kernel/power5+-pmu.c
+++ b/arch/powerpc/kernel/power5+-pmu.c
@@ -653,6 +653,11 @@ static int power5p_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
653 [C(OP_WRITE)] = { -1, -1 }, 653 [C(OP_WRITE)] = { -1, -1 },
654 [C(OP_PREFETCH)] = { -1, -1 }, 654 [C(OP_PREFETCH)] = { -1, -1 },
655 }, 655 },
656 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
657 [C(OP_READ)] = { -1, -1 },
658 [C(OP_WRITE)] = { -1, -1 },
659 [C(OP_PREFETCH)] = { -1, -1 },
660 },
656}; 661};
657 662
658static struct power_pmu power5p_pmu = { 663static struct power_pmu power5p_pmu = {
@@ -672,7 +677,7 @@ static struct power_pmu power5p_pmu = {
672 .cache_events = &power5p_cache_events, 677 .cache_events = &power5p_cache_events,
673}; 678};
674 679
675static int init_power5p_pmu(void) 680static int __init init_power5p_pmu(void)
676{ 681{
677 if (!cur_cpu_spec->oprofile_cpu_type || 682 if (!cur_cpu_spec->oprofile_cpu_type ||
678 (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+") 683 (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+")
diff --git a/arch/powerpc/kernel/power5-pmu.c b/arch/powerpc/kernel/power5-pmu.c
index d5ff0f64a5e..e7f06eb7a86 100644
--- a/arch/powerpc/kernel/power5-pmu.c
+++ b/arch/powerpc/kernel/power5-pmu.c
@@ -595,6 +595,11 @@ static int power5_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
595 [C(OP_WRITE)] = { -1, -1 }, 595 [C(OP_WRITE)] = { -1, -1 },
596 [C(OP_PREFETCH)] = { -1, -1 }, 596 [C(OP_PREFETCH)] = { -1, -1 },
597 }, 597 },
598 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
599 [C(OP_READ)] = { -1, -1 },
600 [C(OP_WRITE)] = { -1, -1 },
601 [C(OP_PREFETCH)] = { -1, -1 },
602 },
598}; 603};
599 604
600static struct power_pmu power5_pmu = { 605static struct power_pmu power5_pmu = {
@@ -612,7 +617,7 @@ static struct power_pmu power5_pmu = {
612 .cache_events = &power5_cache_events, 617 .cache_events = &power5_cache_events,
613}; 618};
614 619
615static int init_power5_pmu(void) 620static int __init init_power5_pmu(void)
616{ 621{
617 if (!cur_cpu_spec->oprofile_cpu_type || 622 if (!cur_cpu_spec->oprofile_cpu_type ||
618 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5")) 623 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5"))
diff --git a/arch/powerpc/kernel/power6-pmu.c b/arch/powerpc/kernel/power6-pmu.c
index 31603927e37..03b95e2c6d6 100644
--- a/arch/powerpc/kernel/power6-pmu.c
+++ b/arch/powerpc/kernel/power6-pmu.c
@@ -516,6 +516,11 @@ static int power6_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
516 [C(OP_WRITE)] = { -1, -1 }, 516 [C(OP_WRITE)] = { -1, -1 },
517 [C(OP_PREFETCH)] = { -1, -1 }, 517 [C(OP_PREFETCH)] = { -1, -1 },
518 }, 518 },
519 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
520 [C(OP_READ)] = { -1, -1 },
521 [C(OP_WRITE)] = { -1, -1 },
522 [C(OP_PREFETCH)] = { -1, -1 },
523 },
519}; 524};
520 525
521static struct power_pmu power6_pmu = { 526static struct power_pmu power6_pmu = {
@@ -535,7 +540,7 @@ static struct power_pmu power6_pmu = {
535 .cache_events = &power6_cache_events, 540 .cache_events = &power6_cache_events,
536}; 541};
537 542
538static int init_power6_pmu(void) 543static int __init init_power6_pmu(void)
539{ 544{
540 if (!cur_cpu_spec->oprofile_cpu_type || 545 if (!cur_cpu_spec->oprofile_cpu_type ||
541 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6")) 546 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
diff --git a/arch/powerpc/kernel/power7-pmu.c b/arch/powerpc/kernel/power7-pmu.c
index 593740fcb79..de83d6060dd 100644
--- a/arch/powerpc/kernel/power7-pmu.c
+++ b/arch/powerpc/kernel/power7-pmu.c
@@ -342,6 +342,11 @@ static int power7_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
342 [C(OP_WRITE)] = { -1, -1 }, 342 [C(OP_WRITE)] = { -1, -1 },
343 [C(OP_PREFETCH)] = { -1, -1 }, 343 [C(OP_PREFETCH)] = { -1, -1 },
344 }, 344 },
345 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
346 [C(OP_READ)] = { -1, -1 },
347 [C(OP_WRITE)] = { -1, -1 },
348 [C(OP_PREFETCH)] = { -1, -1 },
349 },
345}; 350};
346 351
347static struct power_pmu power7_pmu = { 352static struct power_pmu power7_pmu = {
@@ -360,7 +365,7 @@ static struct power_pmu power7_pmu = {
360 .cache_events = &power7_cache_events, 365 .cache_events = &power7_cache_events,
361}; 366};
362 367
363static int init_power7_pmu(void) 368static int __init init_power7_pmu(void)
364{ 369{
365 if (!cur_cpu_spec->oprofile_cpu_type || 370 if (!cur_cpu_spec->oprofile_cpu_type ||
366 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) 371 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7"))
diff --git a/arch/powerpc/kernel/ppc970-pmu.c b/arch/powerpc/kernel/ppc970-pmu.c
index 9a6e093858f..8c219020696 100644
--- a/arch/powerpc/kernel/ppc970-pmu.c
+++ b/arch/powerpc/kernel/ppc970-pmu.c
@@ -467,6 +467,11 @@ static int ppc970_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
467 [C(OP_WRITE)] = { -1, -1 }, 467 [C(OP_WRITE)] = { -1, -1 },
468 [C(OP_PREFETCH)] = { -1, -1 }, 468 [C(OP_PREFETCH)] = { -1, -1 },
469 }, 469 },
470 [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
471 [C(OP_READ)] = { -1, -1 },
472 [C(OP_WRITE)] = { -1, -1 },
473 [C(OP_PREFETCH)] = { -1, -1 },
474 },
470}; 475};
471 476
472static struct power_pmu ppc970_pmu = { 477static struct power_pmu ppc970_pmu = {
@@ -484,7 +489,7 @@ static struct power_pmu ppc970_pmu = {
484 .cache_events = &ppc970_cache_events, 489 .cache_events = &ppc970_cache_events,
485}; 490};
486 491
487static int init_ppc970_pmu(void) 492static int __init init_ppc970_pmu(void)
488{ 493{
489 if (!cur_cpu_spec->oprofile_cpu_type || 494 if (!cur_cpu_spec->oprofile_cpu_type ||
490 (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970") 495 (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970")
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 7d28f540200..f5ae872a2ef 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -18,7 +18,7 @@
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/uaccess.h> 19#include <asm/uaccess.h>
20#include <asm/io.h> 20#include <asm/io.h>
21#include <asm/atomic.h> 21#include <linux/atomic.h>
22#include <asm/checksum.h> 22#include <asm/checksum.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
24#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 91e52df3d81..8f53954e75a 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -96,6 +96,7 @@ void flush_fp_to_thread(struct task_struct *tsk)
96 preempt_enable(); 96 preempt_enable();
97 } 97 }
98} 98}
99EXPORT_SYMBOL_GPL(flush_fp_to_thread);
99 100
100void enable_kernel_fp(void) 101void enable_kernel_fp(void)
101{ 102{
@@ -145,6 +146,7 @@ void flush_altivec_to_thread(struct task_struct *tsk)
145 preempt_enable(); 146 preempt_enable();
146 } 147 }
147} 148}
149EXPORT_SYMBOL_GPL(flush_altivec_to_thread);
148#endif /* CONFIG_ALTIVEC */ 150#endif /* CONFIG_ALTIVEC */
149 151
150#ifdef CONFIG_VSX 152#ifdef CONFIG_VSX
@@ -186,6 +188,7 @@ void flush_vsx_to_thread(struct task_struct *tsk)
186 preempt_enable(); 188 preempt_enable();
187 } 189 }
188} 190}
191EXPORT_SYMBOL_GPL(flush_vsx_to_thread);
189#endif /* CONFIG_VSX */ 192#endif /* CONFIG_VSX */
190 193
191#ifdef CONFIG_SPE 194#ifdef CONFIG_SPE
@@ -213,6 +216,7 @@ void flush_spe_to_thread(struct task_struct *tsk)
213#ifdef CONFIG_SMP 216#ifdef CONFIG_SMP
214 BUG_ON(tsk != current); 217 BUG_ON(tsk != current);
215#endif 218#endif
219 tsk->thread.spefscr = mfspr(SPRN_SPEFSCR);
216 giveup_spe(tsk); 220 giveup_spe(tsk);
217 } 221 }
218 preempt_enable(); 222 preempt_enable();
@@ -650,6 +654,8 @@ void show_regs(struct pt_regs * regs)
650 printbits(regs->msr, msr_bits); 654 printbits(regs->msr, msr_bits);
651 printk(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer); 655 printk(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer);
652 trap = TRAP(regs); 656 trap = TRAP(regs);
657 if ((regs->trap != 0xc00) && cpu_has_feature(CPU_FTR_CFAR))
658 printk("CFAR: "REG"\n", regs->orig_gpr3);
653 if (trap == 0x300 || trap == 0x600) 659 if (trap == 0x300 || trap == 0x600)
654#ifdef CONFIG_PPC_ADV_DEBUG_REGS 660#ifdef CONFIG_PPC_ADV_DEBUG_REGS
655 printk("DEAR: "REG", ESR: "REG"\n", regs->dar, regs->dsisr); 661 printk("DEAR: "REG", ESR: "REG"\n", regs->dar, regs->dsisr);
@@ -831,8 +837,6 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
831 unsigned long load_addr = regs->gpr[2]; /* saved by ELF_PLAT_INIT */ 837 unsigned long load_addr = regs->gpr[2]; /* saved by ELF_PLAT_INIT */
832#endif 838#endif
833 839
834 set_fs(USER_DS);
835
836 /* 840 /*
837 * If we exec out of a kernel thread then thread.regs will not be 841 * If we exec out of a kernel thread then thread.regs will not be
838 * set. Do it now. 842 * set. Do it now.
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 8c3112a57cf..174e1e96175 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -69,6 +69,7 @@ unsigned long tce_alloc_start, tce_alloc_end;
69u64 ppc64_rma_size; 69u64 ppc64_rma_size;
70#endif 70#endif
71static phys_addr_t first_memblock_size; 71static phys_addr_t first_memblock_size;
72static int __initdata boot_cpu_count;
72 73
73static int __init early_parse_mem(char *p) 74static int __init early_parse_mem(char *p)
74{ 75{
@@ -769,6 +770,13 @@ void __init early_init_devtree(void *params)
769 */ 770 */
770 of_scan_flat_dt(early_init_dt_scan_cpus, NULL); 771 of_scan_flat_dt(early_init_dt_scan_cpus, NULL);
771 772
773#if defined(CONFIG_SMP) && defined(CONFIG_PPC64)
774 /* We'll later wait for secondaries to check in; there are
775 * NCPUS-1 non-boot CPUs :-)
776 */
777 spinning_secondaries = boot_cpu_count - 1;
778#endif
779
772 DBG(" <- early_init_devtree()\n"); 780 DBG(" <- early_init_devtree()\n");
773} 781}
774 782
@@ -862,16 +870,14 @@ static int prom_reconfig_notifier(struct notifier_block *nb,
862 switch (action) { 870 switch (action) {
863 case PSERIES_RECONFIG_ADD: 871 case PSERIES_RECONFIG_ADD:
864 err = of_finish_dynamic_node(node); 872 err = of_finish_dynamic_node(node);
865 if (err < 0) { 873 if (err < 0)
866 printk(KERN_ERR "finish_node returned %d\n", err); 874 printk(KERN_ERR "finish_node returned %d\n", err);
867 err = NOTIFY_BAD;
868 }
869 break; 875 break;
870 default: 876 default:
871 err = NOTIFY_DONE; 877 err = 0;
872 break; 878 break;
873 } 879 }
874 return err; 880 return notifier_from_errno(err);
875} 881}
876 882
877static struct notifier_block prom_reconfig_nb = { 883static struct notifier_block prom_reconfig_nb = {
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index c016033ba78..a909f4e9343 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1020,7 +1020,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
1020 } 1020 }
1021 if (addr == 0) 1021 if (addr == 0)
1022 return 0; 1022 return 0;
1023 RELOC(alloc_bottom) = addr; 1023 RELOC(alloc_bottom) = addr + size;
1024 1024
1025 prom_debug(" -> %x\n", addr); 1025 prom_debug(" -> %x\n", addr);
1026 prom_debug(" alloc_bottom : %x\n", RELOC(alloc_bottom)); 1026 prom_debug(" alloc_bottom : %x\n", RELOC(alloc_bottom));
@@ -1830,11 +1830,13 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
1830 if (room > DEVTREE_CHUNK_SIZE) 1830 if (room > DEVTREE_CHUNK_SIZE)
1831 room = DEVTREE_CHUNK_SIZE; 1831 room = DEVTREE_CHUNK_SIZE;
1832 if (room < PAGE_SIZE) 1832 if (room < PAGE_SIZE)
1833 prom_panic("No memory for flatten_device_tree (no room)"); 1833 prom_panic("No memory for flatten_device_tree "
1834 "(no room)\n");
1834 chunk = alloc_up(room, 0); 1835 chunk = alloc_up(room, 0);
1835 if (chunk == 0) 1836 if (chunk == 0)
1836 prom_panic("No memory for flatten_device_tree (claim failed)"); 1837 prom_panic("No memory for flatten_device_tree "
1837 *mem_end = RELOC(alloc_top); 1838 "(claim failed)\n");
1839 *mem_end = chunk + room;
1838 } 1840 }
1839 1841
1840 ret = (void *)*mem_start; 1842 ret = (void *)*mem_start;
@@ -2042,7 +2044,7 @@ static void __init flatten_device_tree(void)
2042 2044
2043 /* 2045 /*
2044 * Check how much room we have between alloc top & bottom (+/- a 2046 * Check how much room we have between alloc top & bottom (+/- a
2045 * few pages), crop to 4Mb, as this is our "chuck" size 2047 * few pages), crop to 1MB, as this is our "chunk" size
2046 */ 2048 */
2047 room = RELOC(alloc_top) - RELOC(alloc_bottom) - 0x4000; 2049 room = RELOC(alloc_top) - RELOC(alloc_bottom) - 0x4000;
2048 if (room > DEVTREE_CHUNK_SIZE) 2050 if (room > DEVTREE_CHUNK_SIZE)
@@ -2053,7 +2055,7 @@ static void __init flatten_device_tree(void)
2053 mem_start = (unsigned long)alloc_up(room, PAGE_SIZE); 2055 mem_start = (unsigned long)alloc_up(room, PAGE_SIZE);
2054 if (mem_start == 0) 2056 if (mem_start == 0)
2055 prom_panic("Can't allocate initial device-tree chunk\n"); 2057 prom_panic("Can't allocate initial device-tree chunk\n");
2056 mem_end = RELOC(alloc_top); 2058 mem_end = mem_start + room;
2057 2059
2058 /* Get root of tree */ 2060 /* Get root of tree */
2059 root = call_prom("peer", 1, 1, (phandle)0); 2061 root = call_prom("peer", 1, 1, (phandle)0);
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index cb22024f2b4..05b7dd217f6 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -882,7 +882,7 @@ void user_disable_single_step(struct task_struct *task)
882} 882}
883 883
884#ifdef CONFIG_HAVE_HW_BREAKPOINT 884#ifdef CONFIG_HAVE_HW_BREAKPOINT
885void ptrace_triggered(struct perf_event *bp, int nmi, 885void ptrace_triggered(struct perf_event *bp,
886 struct perf_sample_data *data, struct pt_regs *regs) 886 struct perf_sample_data *data, struct pt_regs *regs)
887{ 887{
888 struct perf_event_attr attr; 888 struct perf_event_attr attr;
@@ -973,7 +973,7 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
973 &attr.bp_type); 973 &attr.bp_type);
974 974
975 thread->ptrace_bps[0] = bp = register_user_hw_breakpoint(&attr, 975 thread->ptrace_bps[0] = bp = register_user_hw_breakpoint(&attr,
976 ptrace_triggered, task); 976 ptrace_triggered, NULL, task);
977 if (IS_ERR(bp)) { 977 if (IS_ERR(bp)) {
978 thread->ptrace_bps[0] = NULL; 978 thread->ptrace_bps[0] = NULL;
979 ptrace_put_breakpoints(task); 979 ptrace_put_breakpoints(task);
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 271ff6318ed..d5ca8236315 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -24,6 +24,7 @@
24#include <linux/cpumask.h> 24#include <linux/cpumask.h>
25#include <linux/memblock.h> 25#include <linux/memblock.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/reboot.h>
27 28
28#include <asm/prom.h> 29#include <asm/prom.h>
29#include <asm/rtas.h> 30#include <asm/rtas.h>
@@ -38,7 +39,7 @@
38#include <asm/udbg.h> 39#include <asm/udbg.h>
39#include <asm/syscalls.h> 40#include <asm/syscalls.h>
40#include <asm/smp.h> 41#include <asm/smp.h>
41#include <asm/atomic.h> 42#include <linux/atomic.h>
42#include <asm/time.h> 43#include <asm/time.h>
43#include <asm/mmu.h> 44#include <asm/mmu.h>
44#include <asm/topology.h> 45#include <asm/topology.h>
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index bf5f5ce3a7b..e037c7494fd 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/reboot.h>
20#include <asm/delay.h> 21#include <asm/delay.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include <asm/rtas.h> 23#include <asm/rtas.h>
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 54e66da8f74..6cd8f0196b6 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -291,7 +291,7 @@ void __init find_and_init_phbs(void)
291 prop = of_get_property(of_chosen, 291 prop = of_get_property(of_chosen,
292 "linux,pci-assign-all-buses", NULL); 292 "linux,pci-assign-all-buses", NULL);
293 if (prop && *prop) 293 if (prop && *prop)
294 ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS; 294 pci_add_flags(PCI_REASSIGN_ALL_BUS);
295#endif /* CONFIG_PPC32 */ 295#endif /* CONFIG_PPC32 */
296 } 296 }
297} 297}
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index 67f6c3b5135..481ef064c8f 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -27,7 +27,7 @@
27#include <asm/rtas.h> 27#include <asm/rtas.h>
28#include <asm/prom.h> 28#include <asm/prom.h>
29#include <asm/nvram.h> 29#include <asm/nvram.h>
30#include <asm/atomic.h> 30#include <linux/atomic.h>
31#include <asm/machdep.h> 31#include <asm/machdep.h>
32 32
33 33
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 79fca2651b6..b1d738d1289 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -375,6 +375,9 @@ void __init check_for_initrd(void)
375 375
376int threads_per_core, threads_shift; 376int threads_per_core, threads_shift;
377cpumask_t threads_core_mask; 377cpumask_t threads_core_mask;
378EXPORT_SYMBOL_GPL(threads_per_core);
379EXPORT_SYMBOL_GPL(threads_shift);
380EXPORT_SYMBOL_GPL(threads_core_mask);
378 381
379static void __init cpu_init_thread_core_maps(int tpc) 382static void __init cpu_init_thread_core_maps(int tpc)
380{ 383{
@@ -704,29 +707,14 @@ static int powerpc_debugfs_init(void)
704arch_initcall(powerpc_debugfs_init); 707arch_initcall(powerpc_debugfs_init);
705#endif 708#endif
706 709
707static int ppc_dflt_bus_notify(struct notifier_block *nb, 710void ppc_printk_progress(char *s, unsigned short hex)
708 unsigned long action, void *data)
709{ 711{
710 struct device *dev = data; 712 pr_info("%s\n", s);
711
712 /* We are only intereted in device addition */
713 if (action != BUS_NOTIFY_ADD_DEVICE)
714 return 0;
715
716 set_dma_ops(dev, &dma_direct_ops);
717
718 return NOTIFY_DONE;
719} 713}
720 714
721static struct notifier_block ppc_dflt_plat_bus_notifier = { 715void arch_setup_pdev_archdata(struct platform_device *pdev)
722 .notifier_call = ppc_dflt_bus_notify,
723 .priority = INT_MAX,
724};
725
726static int __init setup_bus_notifier(void)
727{ 716{
728 bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier); 717 pdev->archdata.dma_mask = DMA_BIT_MASK(32);
729 return 0; 718 pdev->dev.dma_mask = &pdev->archdata.dma_mask;
719 set_dma_ops(&pdev->dev, &dma_direct_ops);
730} 720}
731
732arch_initcall(setup_bus_notifier);
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 620d792b52e..912c36a45f6 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -48,8 +48,8 @@ extern void bootx_init(unsigned long r4, unsigned long phys);
48 48
49int boot_cpuid = -1; 49int boot_cpuid = -1;
50EXPORT_SYMBOL_GPL(boot_cpuid); 50EXPORT_SYMBOL_GPL(boot_cpuid);
51int __initdata boot_cpu_count;
52int boot_cpuid_phys; 51int boot_cpuid_phys;
52EXPORT_SYMBOL_GPL(boot_cpuid_phys);
53 53
54int smp_hw_index[NR_CPUS]; 54int smp_hw_index[NR_CPUS];
55 55
@@ -107,6 +107,8 @@ notrace unsigned long __init early_init(unsigned long dt_ptr)
107 PTRRELOC(&__start___lwsync_fixup), 107 PTRRELOC(&__start___lwsync_fixup),
108 PTRRELOC(&__stop___lwsync_fixup)); 108 PTRRELOC(&__stop___lwsync_fixup));
109 109
110 do_final_fixups();
111
110 return KERNELBASE + offset; 112 return KERNELBASE + offset;
111} 113}
112 114
@@ -127,6 +129,8 @@ notrace void __init machine_init(unsigned long dt_ptr)
127 /* Do some early initialization based on the flat device tree */ 129 /* Do some early initialization based on the flat device tree */
128 early_init_devtree(__va(dt_ptr)); 130 early_init_devtree(__va(dt_ptr));
129 131
132 early_init_mmu();
133
130 probe_machine(); 134 probe_machine();
131 135
132 setup_kdump_trampoline(); 136 setup_kdump_trampoline();
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index a88bf2713d4..e0f2031e23e 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -63,6 +63,7 @@
63#include <asm/kexec.h> 63#include <asm/kexec.h>
64#include <asm/mmu_context.h> 64#include <asm/mmu_context.h>
65#include <asm/code-patching.h> 65#include <asm/code-patching.h>
66#include <asm/kvm_ppc.h>
66 67
67#include "setup.h" 68#include "setup.h"
68 69
@@ -73,7 +74,7 @@
73#endif 74#endif
74 75
75int boot_cpuid = 0; 76int boot_cpuid = 0;
76int __initdata boot_cpu_count; 77int __initdata spinning_secondaries;
77u64 ppc64_pft_size; 78u64 ppc64_pft_size;
78 79
79/* Pick defaults since we might want to patch instructions 80/* Pick defaults since we might want to patch instructions
@@ -253,11 +254,11 @@ void smp_release_cpus(void)
253 for (i = 0; i < 100000; i++) { 254 for (i = 0; i < 100000; i++) {
254 mb(); 255 mb();
255 HMT_low(); 256 HMT_low();
256 if (boot_cpu_count == 0) 257 if (spinning_secondaries == 0)
257 break; 258 break;
258 udelay(1); 259 udelay(1);
259 } 260 }
260 DBG("boot_cpu_count = %d\n", boot_cpu_count); 261 DBG("spinning_secondaries = %d\n", spinning_secondaries);
261 262
262 DBG(" <- smp_release_cpus()\n"); 263 DBG(" <- smp_release_cpus()\n");
263} 264}
@@ -352,6 +353,7 @@ void __init setup_system(void)
352 &__start___fw_ftr_fixup, &__stop___fw_ftr_fixup); 353 &__start___fw_ftr_fixup, &__stop___fw_ftr_fixup);
353 do_lwsync_fixups(cur_cpu_spec->cpu_features, 354 do_lwsync_fixups(cur_cpu_spec->cpu_features,
354 &__start___lwsync_fixup, &__stop___lwsync_fixup); 355 &__start___lwsync_fixup, &__stop___lwsync_fixup);
356 do_final_fixups();
355 357
356 /* 358 /*
357 * Unflatten the device-tree passed by prom_init or kexec 359 * Unflatten the device-tree passed by prom_init or kexec
@@ -580,6 +582,8 @@ void __init setup_arch(char **cmdline_p)
580 /* Initialize the MMU context management stuff */ 582 /* Initialize the MMU context management stuff */
581 mmu_context_init(); 583 mmu_context_init();
582 584
585 kvm_rma_init();
586
583 ppc64_boot_msg(0x15, "Setup Done"); 587 ppc64_boot_msg(0x15, "Setup Done");
584} 588}
585 589
diff --git a/arch/powerpc/kernel/smp-tbsync.c b/arch/powerpc/kernel/smp-tbsync.c
index 03e45c4a9ef..640de836e46 100644
--- a/arch/powerpc/kernel/smp-tbsync.c
+++ b/arch/powerpc/kernel/smp-tbsync.c
@@ -11,7 +11,7 @@
11#include <linux/unistd.h> 11#include <linux/unistd.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <asm/atomic.h> 14#include <linux/atomic.h>
15#include <asm/smp.h> 15#include <asm/smp.h>
16#include <asm/time.h> 16#include <asm/time.h>
17 17
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 8ebc6700b98..7bf2187dfd9 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -33,7 +33,7 @@
33#include <linux/topology.h> 33#include <linux/topology.h>
34 34
35#include <asm/ptrace.h> 35#include <asm/ptrace.h>
36#include <asm/atomic.h> 36#include <linux/atomic.h>
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/page.h> 38#include <asm/page.h>
39#include <asm/pgtable.h> 39#include <asm/pgtable.h>
@@ -202,14 +202,6 @@ void smp_muxed_ipi_message_pass(int cpu, int msg)
202 smp_ops->cause_ipi(cpu, info->data); 202 smp_ops->cause_ipi(cpu, info->data);
203} 203}
204 204
205void smp_muxed_ipi_resend(void)
206{
207 struct cpu_messages *info = &__get_cpu_var(ipi_message);
208
209 if (info->messages)
210 smp_ops->cause_ipi(smp_processor_id(), info->data);
211}
212
213irqreturn_t smp_ipi_demux(void) 205irqreturn_t smp_ipi_demux(void)
214{ 206{
215 struct cpu_messages *info = &__get_cpu_var(ipi_message); 207 struct cpu_messages *info = &__get_cpu_var(ipi_message);
@@ -238,15 +230,26 @@ irqreturn_t smp_ipi_demux(void)
238} 230}
239#endif /* CONFIG_PPC_SMP_MUXED_IPI */ 231#endif /* CONFIG_PPC_SMP_MUXED_IPI */
240 232
233static inline void do_message_pass(int cpu, int msg)
234{
235 if (smp_ops->message_pass)
236 smp_ops->message_pass(cpu, msg);
237#ifdef CONFIG_PPC_SMP_MUXED_IPI
238 else
239 smp_muxed_ipi_message_pass(cpu, msg);
240#endif
241}
242
241void smp_send_reschedule(int cpu) 243void smp_send_reschedule(int cpu)
242{ 244{
243 if (likely(smp_ops)) 245 if (likely(smp_ops))
244 smp_ops->message_pass(cpu, PPC_MSG_RESCHEDULE); 246 do_message_pass(cpu, PPC_MSG_RESCHEDULE);
245} 247}
248EXPORT_SYMBOL_GPL(smp_send_reschedule);
246 249
247void arch_send_call_function_single_ipi(int cpu) 250void arch_send_call_function_single_ipi(int cpu)
248{ 251{
249 smp_ops->message_pass(cpu, PPC_MSG_CALL_FUNC_SINGLE); 252 do_message_pass(cpu, PPC_MSG_CALL_FUNC_SINGLE);
250} 253}
251 254
252void arch_send_call_function_ipi_mask(const struct cpumask *mask) 255void arch_send_call_function_ipi_mask(const struct cpumask *mask)
@@ -254,7 +257,7 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask)
254 unsigned int cpu; 257 unsigned int cpu;
255 258
256 for_each_cpu(cpu, mask) 259 for_each_cpu(cpu, mask)
257 smp_ops->message_pass(cpu, PPC_MSG_CALL_FUNCTION); 260 do_message_pass(cpu, PPC_MSG_CALL_FUNCTION);
258} 261}
259 262
260#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC) 263#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
@@ -268,7 +271,7 @@ void smp_send_debugger_break(void)
268 271
269 for_each_online_cpu(cpu) 272 for_each_online_cpu(cpu)
270 if (cpu != me) 273 if (cpu != me)
271 smp_ops->message_pass(cpu, PPC_MSG_DEBUGGER_BREAK); 274 do_message_pass(cpu, PPC_MSG_DEBUGGER_BREAK);
272} 275}
273#endif 276#endif
274 277
@@ -303,6 +306,10 @@ struct thread_info *current_set[NR_CPUS];
303static void __devinit smp_store_cpu_info(int id) 306static void __devinit smp_store_cpu_info(int id)
304{ 307{
305 per_cpu(cpu_pvr, id) = mfspr(SPRN_PVR); 308 per_cpu(cpu_pvr, id) = mfspr(SPRN_PVR);
309#ifdef CONFIG_PPC_FSL_BOOK3E
310 per_cpu(next_tlbcam_idx, id)
311 = (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1;
312#endif
306} 313}
307 314
308void __init smp_prepare_cpus(unsigned int max_cpus) 315void __init smp_prepare_cpus(unsigned int max_cpus)
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index f33acfd872a..2de304af07a 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -544,7 +544,7 @@ DEFINE_PER_CPU(u8, irq_work_pending);
544 544
545#endif /* 32 vs 64 bit */ 545#endif /* 32 vs 64 bit */
546 546
547void set_irq_work_pending(void) 547void arch_irq_work_raise(void)
548{ 548{
549 preempt_disable(); 549 preempt_disable();
550 set_irq_work_pending_flag(); 550 set_irq_work_pending_flag();
@@ -889,6 +889,15 @@ static void __init clocksource_init(void)
889 clock->name, clock->mult, clock->shift); 889 clock->name, clock->mult, clock->shift);
890} 890}
891 891
892void decrementer_check_overflow(void)
893{
894 u64 now = get_tb_or_rtc();
895 struct decrementer_clock *decrementer = &__get_cpu_var(decrementers);
896
897 if (now >= decrementer->next_tb)
898 set_dec(1);
899}
900
892static int decrementer_set_next_event(unsigned long evt, 901static int decrementer_set_next_event(unsigned long evt,
893 struct clock_event_device *dev) 902 struct clock_event_device *dev)
894{ 903{
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 1a0141426cd..f19d9777d3c 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1387,10 +1387,7 @@ void SPEFloatingPointException(struct pt_regs *regs)
1387 int code = 0; 1387 int code = 0;
1388 int err; 1388 int err;
1389 1389
1390 preempt_disable(); 1390 flush_spe_to_thread(current);
1391 if (regs->msr & MSR_SPE)
1392 giveup_spe(current);
1393 preempt_enable();
1394 1391
1395 spefscr = current->thread.spefscr; 1392 spefscr = current->thread.spefscr;
1396 fpexc_mode = current->thread.fpexc_mode; 1393 fpexc_mode = current->thread.fpexc_mode;
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index 23d65abbedc..faa82c1f3f6 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -31,6 +31,9 @@ void __init udbg_early_init(void)
31#if defined(CONFIG_PPC_EARLY_DEBUG_LPAR) 31#if defined(CONFIG_PPC_EARLY_DEBUG_LPAR)
32 /* For LPAR machines that have an HVC console on vterm 0 */ 32 /* For LPAR machines that have an HVC console on vterm 0 */
33 udbg_init_debug_lpar(); 33 udbg_init_debug_lpar();
34#elif defined(CONFIG_PPC_EARLY_DEBUG_LPAR_HVSI)
35 /* For LPAR machines that have an HVSI console on vterm 0 */
36 udbg_init_debug_lpar_hvsi();
34#elif defined(CONFIG_PPC_EARLY_DEBUG_G5) 37#elif defined(CONFIG_PPC_EARLY_DEBUG_G5)
35 /* For use on Apple G5 machines */ 38 /* For use on Apple G5 machines */
36 udbg_init_pmac_realmode(); 39 udbg_init_pmac_realmode();
@@ -68,6 +71,8 @@ void __init udbg_early_init(void)
68 71
69#ifdef CONFIG_PPC_EARLY_DEBUG 72#ifdef CONFIG_PPC_EARLY_DEBUG
70 console_loglevel = 10; 73 console_loglevel = 10;
74
75 register_early_udbg_console();
71#endif 76#endif
72} 77}
73 78