Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc

Pull powerpc fixes from Ben Herrenschmidt:
"Here are a few more fixes for powerpc 3.10. It's a bit more than I
would have liked this late in the game but I suppose that's what
happens with a brand new chip generation coming out.

A few regression fixes, some last minute fixes for new P8 features
such as transactional memory,...

There's also one powerpc KVM patch that I requested that adds two
missing functions to our in-kernel interrupt controller support which
is itself a new 3.10 feature. These are defined by the base
hypervisor specification. We didn't implement them originally because
Linux doesn't use them but they are simple and I'm not comfortable
having a half-implemented interface in 3.10 and having to deal with
versionning etc... later when something starts needing those calls.
They cannot be emulated in qemu when using in-kernel interrupt
controller (not enough shared state).

Just added a last minute patch to fix a typo introducing a breakage in
our cputable for Power7+ processors, sorry about that, but the
regression it fixes just hurt me :-)"

* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc:
powerpc/cputable: Fix typo on P7+ cputable entry
powerpc/perf: Add missing SIER support
powerpc/perf: Revert to original NO_SIPR logic
powerpc/pci: Remove the unused variables in pci_process_bridge_OF_ranges
powerpc/pci: Remove the stale comments of pci_process_bridge_OF_ranges
powerpc/pseries: Always enable CONFIG_HOTPLUG_CPU on PSERIES SMP
powerpc/kvm/book3s: Add support for H_IPOLL and H_XIRR_X in XICS emulation
powerpc/32bit:Store temporary result in r0 instead of r8
powerpc/mm: Always invalidate tlb on hpte invalidate and update
powerpc/pseries: Improve stream generation comments in copypage/user
powerpc/pseries: Kill all prefetch streams on context switch
powerpc/cputable: Fix oprofile_cpu_type on power8
powerpc/mpic: Fix irq distribution problem when MPIC_SINGLE_DEST_CPU
powerpc/tm: Fix userspace stack corruption on signal delivery for active transactions
powerpc/tm: Move TM abort cause codes to uapi
powerpc/tm: Abort on emulation and alignment faults
powerpc/tm: Update cause codes documentation
powerpc/tm: Make room for hypervisor in abort cause codes

+25 -2
Documentation/powerpc/transactional_memory.txt
··· 147 147 fix_the_problem(ucp->dar); 148 148 } 149 149 150 + When in an active transaction that takes a signal, we need to be careful with 151 + the stack. It's possible that the stack has moved back up after the tbegin. 152 + The obvious case here is when the tbegin is called inside a function that 153 + returns before a tend. In this case, the stack is part of the checkpointed 154 + transactional memory state. If we write over this non transactionally or in 155 + suspend, we are in trouble because if we get a tm abort, the program counter and 156 + stack pointer will be back at the tbegin but our in memory stack won't be valid 157 + anymore. 158 + 159 + To avoid this, when taking a signal in an active transaction, we need to use 160 + the stack pointer from the checkpointed state, rather than the speculated 161 + state. This ensures that the signal context (written tm suspended) will be 162 + written below the stack required for the rollback. The transaction is aborted 163 + becuase of the treclaim, so any memory written between the tbegin and the 164 + signal will be rolled back anyway. 165 + 166 + For signals taken in non-TM or suspended mode, we use the 167 + normal/non-checkpointed stack pointer. 168 + 150 169 151 170 Failure cause codes used by kernel 152 171 ================================== ··· 174 155 kernel aborted a transaction: 175 156 176 157 TM_CAUSE_RESCHED Thread was rescheduled. 158 + TM_CAUSE_TLBI Software TLB invalide. 177 159 TM_CAUSE_FAC_UNAV FP/VEC/VSX unavailable trap. 178 160 TM_CAUSE_SYSCALL Currently unused; future syscalls that must abort 179 161 transactions for consistency will use this. 180 162 TM_CAUSE_SIGNAL Signal delivered. 181 163 TM_CAUSE_MISC Currently unused. 164 + TM_CAUSE_ALIGNMENT Alignment fault. 165 + TM_CAUSE_EMULATE Emulation that touched memory. 182 166 183 - These can be checked by the user program's abort handler as TEXASR[0:7]. 184 - 167 + These can be checked by the user program's abort handler as TEXASR[0:7]. If 168 + bit 7 is set, it indicates that the error is consider persistent. For example 169 + a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.q 185 170 186 171 GDB 187 172 ===
+1
arch/powerpc/include/asm/hvcall.h
··· 264 264 #define H_GET_MPP 0x2D4 265 265 #define H_HOME_NODE_ASSOCIATIVITY 0x2EC 266 266 #define H_BEST_ENERGY 0x2F4 267 + #define H_XIRR_X 0x2FC 267 268 #define H_RANDOM 0x300 268 269 #define H_COP 0x304 269 270 #define H_GET_MPP_X 0x314
+11
arch/powerpc/include/asm/ppc_asm.h
··· 523 523 #define PPC440EP_ERR42 524 524 #endif 525 525 526 + /* The following stops all load and store data streams associated with stream 527 + * ID (ie. streams created explicitly). The embedded and server mnemonics for 528 + * dcbt are different so we use machine "power4" here explicitly. 529 + */ 530 + #define DCBT_STOP_ALL_STREAM_IDS(scratch) \ 531 + .machine push ; \ 532 + .machine "power4" ; \ 533 + lis scratch,0x60000000@h; \ 534 + dcbt r0,scratch,0b01010; \ 535 + .machine pop 536 + 526 537 /* 527 538 * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them 528 539 * keep the address intact to be compatible with code shared with
+4 -9
arch/powerpc/include/asm/processor.h
··· 409 409 #endif 410 410 411 411 #ifdef CONFIG_PPC64 412 - static inline unsigned long get_clean_sp(struct pt_regs *regs, int is_32) 412 + static inline unsigned long get_clean_sp(unsigned long sp, int is_32) 413 413 { 414 - unsigned long sp; 415 - 416 414 if (is_32) 417 - sp = regs->gpr[1] & 0x0ffffffffUL; 418 - else 419 - sp = regs->gpr[1]; 420 - 415 + return sp & 0x0ffffffffUL; 421 416 return sp; 422 417 } 423 418 #else 424 - static inline unsigned long get_clean_sp(struct pt_regs *regs, int is_32) 419 + static inline unsigned long get_clean_sp(unsigned long sp, int is_32) 425 420 { 426 - return regs->gpr[1]; 421 + return sp; 427 422 } 428 423 #endif 429 424
-11
arch/powerpc/include/asm/reg.h
··· 111 111 #define MSR_TM_TRANSACTIONAL(x) (((x) & MSR_TS_MASK) == MSR_TS_T) 112 112 #define MSR_TM_SUSPENDED(x) (((x) & MSR_TS_MASK) == MSR_TS_S) 113 113 114 - /* Reason codes describing kernel causes for transaction aborts. By 115 - convention, bit0 is copied to TEXASR[56] (IBM bit 7) which is set if 116 - the failure is persistent. 117 - */ 118 - #define TM_CAUSE_RESCHED 0xfe 119 - #define TM_CAUSE_TLBI 0xfc 120 - #define TM_CAUSE_FAC_UNAV 0xfa 121 - #define TM_CAUSE_SYSCALL 0xf9 /* Persistent */ 122 - #define TM_CAUSE_MISC 0xf6 123 - #define TM_CAUSE_SIGNAL 0xf4 124 - 125 114 #if defined(CONFIG_PPC_BOOK3S_64) 126 115 #define MSR_64BIT MSR_SF 127 116
+3
arch/powerpc/include/asm/signal.h
··· 3 3 4 4 #define __ARCH_HAS_SA_RESTORER 5 5 #include <uapi/asm/signal.h> 6 + #include <uapi/asm/ptrace.h> 7 + 8 + extern unsigned long get_tm_stackpointer(struct pt_regs *regs); 6 9 7 10 #endif /* _ASM_POWERPC_SIGNAL_H */
+2
arch/powerpc/include/asm/tm.h
··· 5 5 * Copyright 2012 Matt Evans & Michael Neuling, IBM Corporation. 6 6 */ 7 7 8 + #include <uapi/asm/tm.h> 9 + 8 10 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 9 11 extern void do_load_up_transact_fpu(struct thread_struct *thread); 10 12 extern void do_load_up_transact_altivec(struct thread_struct *thread);
+1
arch/powerpc/include/uapi/asm/Kbuild
··· 40 40 header-y += swab.h 41 41 header-y += termbits.h 42 42 header-y += termios.h 43 + header-y += tm.h 43 44 header-y += types.h 44 45 header-y += ucontext.h 45 46 header-y += unistd.h
+18
arch/powerpc/include/uapi/asm/tm.h
··· 1 + #ifndef _ASM_POWERPC_TM_H 2 + #define _ASM_POWERPC_TM_H 3 + 4 + /* Reason codes describing kernel causes for transaction aborts. By 5 + * convention, bit0 is copied to TEXASR[56] (IBM bit 7) which is set if 6 + * the failure is persistent. PAPR saves 0xff-0xe0 for the hypervisor. 7 + */ 8 + #define TM_CAUSE_PERSISTENT 0x01 9 + #define TM_CAUSE_RESCHED 0xde 10 + #define TM_CAUSE_TLBI 0xdc 11 + #define TM_CAUSE_FAC_UNAV 0xda 12 + #define TM_CAUSE_SYSCALL 0xd8 /* future use */ 13 + #define TM_CAUSE_MISC 0xd6 /* future use */ 14 + #define TM_CAUSE_SIGNAL 0xd4 15 + #define TM_CAUSE_ALIGNMENT 0xd2 16 + #define TM_CAUSE_EMULATE 0xd0 17 + 18 + #endif
+3 -3
arch/powerpc/kernel/cputable.c
··· 453 453 .icache_bsize = 128, 454 454 .dcache_bsize = 128, 455 455 .oprofile_type = PPC_OPROFILE_POWER4, 456 - .oprofile_cpu_type = "ppc64/ibm-compat-v1", 456 + .oprofile_cpu_type = 0, 457 457 .cpu_setup = __setup_cpu_power8, 458 458 .cpu_restore = __restore_cpu_power8, 459 459 .platform = "power8", ··· 482 482 .cpu_name = "POWER7+ (raw)", 483 483 .cpu_features = CPU_FTRS_POWER7, 484 484 .cpu_user_features = COMMON_USER_POWER7, 485 - .cpu_user_features = COMMON_USER2_POWER7, 485 + .cpu_user_features2 = COMMON_USER2_POWER7, 486 486 .mmu_features = MMU_FTRS_POWER7, 487 487 .icache_bsize = 128, 488 488 .dcache_bsize = 128, ··· 506 506 .dcache_bsize = 128, 507 507 .num_pmcs = 6, 508 508 .pmc_type = PPC_PMC_IBM, 509 - .oprofile_cpu_type = "ppc64/power8", 509 + .oprofile_cpu_type = 0, 510 510 .oprofile_type = PPC_OPROFILE_POWER4, 511 511 .cpu_setup = __setup_cpu_power8, 512 512 .cpu_restore = __restore_cpu_power8,
+1 -1
arch/powerpc/kernel/entry_32.S
··· 849 849 /* check current_thread_info, _TIF_EMULATE_STACK_STORE */ 850 850 CURRENT_THREAD_INFO(r9, r1) 851 851 lwz r8,TI_FLAGS(r9) 852 - andis. r8,r8,_TIF_EMULATE_STACK_STORE@h 852 + andis. r0,r8,_TIF_EMULATE_STACK_STORE@h 853 853 beq+ 1f 854 854 855 855 addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */
+7
arch/powerpc/kernel/entry_64.S
··· 501 501 ldarx r6,0,r1 502 502 END_FTR_SECTION_IFSET(CPU_FTR_STCX_CHECKS_ADDRESS) 503 503 504 + #ifdef CONFIG_PPC_BOOK3S 505 + /* Cancel all explict user streams as they will have no use after context 506 + * switch and will stop the HW from creating streams itself 507 + */ 508 + DCBT_STOP_ALL_STREAM_IDS(r6) 509 + #endif 510 + 504 511 addi r6,r4,-THREAD /* Convert THREAD to 'current' */ 505 512 std r6,PACACURRENT(r13) /* Set new 'current' */ 506 513
+1 -13
arch/powerpc/kernel/pci-common.c
··· 657 657 * ranges. However, some machines (thanks Apple !) tend to split their 658 658 * space into lots of small contiguous ranges. So we have to coalesce. 659 659 * 660 - * - We can only cope with all memory ranges having the same offset 661 - * between CPU addresses and PCI addresses. Unfortunately, some bridges 662 - * are setup for a large 1:1 mapping along with a small "window" which 663 - * maps PCI address 0 to some arbitrary high address of the CPU space in 664 - * order to give access to the ISA memory hole. 665 - * The way out of here that I've chosen for now is to always set the 666 - * offset based on the first resource found, then override it if we 667 - * have a different offset and the previous was set by an ISA hole. 668 - * 669 660 * - Some busses have IO space not starting at 0, which causes trouble with 670 661 * the way we do our IO resource renumbering. The code somewhat deals with 671 662 * it for 64 bits but I would expect problems on 32 bits. ··· 671 680 int rlen; 672 681 int pna = of_n_addr_cells(dev); 673 682 int np = pna + 5; 674 - int memno = 0, isa_hole = -1; 683 + int memno = 0; 675 684 u32 pci_space; 676 685 unsigned long long pci_addr, cpu_addr, pci_next, cpu_next, size; 677 - unsigned long long isa_mb = 0; 678 686 struct resource *res; 679 687 680 688 printk(KERN_INFO "PCI host bridge %s %s ranges:\n", ··· 767 777 } 768 778 /* Handles ISA memory hole space here */ 769 779 if (pci_addr == 0) { 770 - isa_mb = cpu_addr; 771 - isa_hole = memno; 772 780 if (primary || isa_mem_base == 0) 773 781 isa_mem_base = cpu_addr; 774 782 hose->isa_mem_phys = cpu_addr;
+38 -2
arch/powerpc/kernel/signal.c
··· 18 18 #include <asm/uaccess.h> 19 19 #include <asm/unistd.h> 20 20 #include <asm/debug.h> 21 + #include <asm/tm.h> 21 22 22 23 #include "signal.h" 23 24 ··· 31 30 /* 32 31 * Allocate space for the signal frame 33 32 */ 34 - void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, 33 + void __user * get_sigframe(struct k_sigaction *ka, unsigned long sp, 35 34 size_t frame_size, int is_32) 36 35 { 37 36 unsigned long oldsp, newsp; 38 37 39 38 /* Default to using normal stack */ 40 - oldsp = get_clean_sp(regs, is_32); 39 + oldsp = get_clean_sp(sp, is_32); 41 40 42 41 /* Check for alt stack */ 43 42 if ((ka->sa.sa_flags & SA_ONSTACK) && ··· 175 174 } 176 175 177 176 user_enter(); 177 + } 178 + 179 + unsigned long get_tm_stackpointer(struct pt_regs *regs) 180 + { 181 + /* When in an active transaction that takes a signal, we need to be 182 + * careful with the stack. It's possible that the stack has moved back 183 + * up after the tbegin. The obvious case here is when the tbegin is 184 + * called inside a function that returns before a tend. In this case, 185 + * the stack is part of the checkpointed transactional memory state. 186 + * If we write over this non transactionally or in suspend, we are in 187 + * trouble because if we get a tm abort, the program counter and stack 188 + * pointer will be back at the tbegin but our in memory stack won't be 189 + * valid anymore. 190 + * 191 + * To avoid this, when taking a signal in an active transaction, we 192 + * need to use the stack pointer from the checkpointed state, rather 193 + * than the speculated state. This ensures that the signal context 194 + * (written tm suspended) will be written below the stack required for 195 + * the rollback. The transaction is aborted becuase of the treclaim, 196 + * so any memory written between the tbegin and the signal will be 197 + * rolled back anyway. 198 + * 199 + * For signals taken in non-TM or suspended mode, we use the 200 + * normal/non-checkpointed stack pointer. 201 + */ 202 + 203 + #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 204 + if (MSR_TM_ACTIVE(regs->msr)) { 205 + tm_enable(); 206 + tm_reclaim(&current->thread, regs->msr, TM_CAUSE_SIGNAL); 207 + if (MSR_TM_TRANSACTIONAL(regs->msr)) 208 + return current->thread.ckpt_regs.gpr[1]; 209 + } 210 + #endif 211 + return regs->gpr[1]; 178 212 }
+1 -1
arch/powerpc/kernel/signal.h
··· 12 12 13 13 extern void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags); 14 14 15 - extern void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, 15 + extern void __user * get_sigframe(struct k_sigaction *ka, unsigned long sp, 16 16 size_t frame_size, int is_32); 17 17 18 18 extern int handle_signal32(unsigned long sig, struct k_sigaction *ka,
+2 -8
arch/powerpc/kernel/signal_32.c
··· 503 503 { 504 504 unsigned long msr = regs->msr; 505 505 506 - /* tm_reclaim rolls back all reg states, updating thread.ckpt_regs, 507 - * thread.transact_fpr[], thread.transact_vr[], etc. 508 - */ 509 - tm_enable(); 510 - tm_reclaim(&current->thread, msr, TM_CAUSE_SIGNAL); 511 - 512 506 /* Make sure floating point registers are stored in regs */ 513 507 flush_fp_to_thread(current); 514 508 ··· 959 965 960 966 /* Set up Signal Frame */ 961 967 /* Put a Real Time Context onto stack */ 962 - rt_sf = get_sigframe(ka, regs, sizeof(*rt_sf), 1); 968 + rt_sf = get_sigframe(ka, get_tm_stackpointer(regs), sizeof(*rt_sf), 1); 963 969 addr = rt_sf; 964 970 if (unlikely(rt_sf == NULL)) 965 971 goto badframe; ··· 1397 1403 unsigned long tramp; 1398 1404 1399 1405 /* Set up Signal Frame */ 1400 - frame = get_sigframe(ka, regs, sizeof(*frame), 1); 1406 + frame = get_sigframe(ka, get_tm_stackpointer(regs), sizeof(*frame), 1); 1401 1407 if (unlikely(frame == NULL)) 1402 1408 goto badframe; 1403 1409 sc = (struct sigcontext __user *) &frame->sctx;
+7 -16
arch/powerpc/kernel/signal_64.c
··· 154 154 * As above, but Transactional Memory is in use, so deliver sigcontexts 155 155 * containing checkpointed and transactional register states. 156 156 * 157 - * To do this, we treclaim to gather both sets of registers and set up the 158 - * 'normal' sigcontext registers with rolled-back register values such that a 159 - * simple signal handler sees a correct checkpointed register state. 160 - * If interested, a TM-aware sighandler can examine the transactional registers 161 - * in the 2nd sigcontext to determine the real origin of the signal. 157 + * To do this, we treclaim (done before entering here) to gather both sets of 158 + * registers and set up the 'normal' sigcontext registers with rolled-back 159 + * register values such that a simple signal handler sees a correct 160 + * checkpointed register state. If interested, a TM-aware sighandler can 161 + * examine the transactional registers in the 2nd sigcontext to determine the 162 + * real origin of the signal. 162 163 */ 163 164 static long setup_tm_sigcontexts(struct sigcontext __user *sc, 164 165 struct sigcontext __user *tm_sc, ··· 184 183 long err = 0; 185 184 186 185 BUG_ON(!MSR_TM_ACTIVE(regs->msr)); 187 - 188 - /* tm_reclaim rolls back all reg states, saving checkpointed (older) 189 - * GPRs to thread.ckpt_regs and (if used) FPRs to (newer) 190 - * thread.transact_fp and/or VRs to (newer) thread.transact_vr. 191 - * THEN we save out FP/VRs, if necessary, to the checkpointed (older) 192 - * thread.fr[]/vr[]s. The transactional (newer) GPRs are on the 193 - * stack, in *regs. 194 - */ 195 - tm_enable(); 196 - tm_reclaim(&current->thread, msr, TM_CAUSE_SIGNAL); 197 186 198 187 flush_fp_to_thread(current); 199 188 ··· 702 711 unsigned long newsp = 0; 703 712 long err = 0; 704 713 705 - frame = get_sigframe(ka, regs, sizeof(*frame), 0); 714 + frame = get_sigframe(ka, get_tm_stackpointer(regs), sizeof(*frame), 0); 706 715 if (unlikely(frame == NULL)) 707 716 goto badframe; 708 717
+29
arch/powerpc/kernel/traps.c
··· 53 53 #ifdef CONFIG_PPC64 54 54 #include <asm/firmware.h> 55 55 #include <asm/processor.h> 56 + #include <asm/tm.h> 56 57 #endif 57 58 #include <asm/kexec.h> 58 59 #include <asm/ppc-opcode.h> ··· 933 932 return 0; 934 933 } 935 934 935 + #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 936 + static inline bool tm_abort_check(struct pt_regs *regs, int cause) 937 + { 938 + /* If we're emulating a load/store in an active transaction, we cannot 939 + * emulate it as the kernel operates in transaction suspended context. 940 + * We need to abort the transaction. This creates a persistent TM 941 + * abort so tell the user what caused it with a new code. 942 + */ 943 + if (MSR_TM_TRANSACTIONAL(regs->msr)) { 944 + tm_enable(); 945 + tm_abort(cause); 946 + return true; 947 + } 948 + return false; 949 + } 950 + #else 951 + static inline bool tm_abort_check(struct pt_regs *regs, int reason) 952 + { 953 + return false; 954 + } 955 + #endif 956 + 936 957 static int emulate_instruction(struct pt_regs *regs) 937 958 { 938 959 u32 instword; ··· 994 971 995 972 /* Emulate load/store string insn. */ 996 973 if ((instword & PPC_INST_STRING_GEN_MASK) == PPC_INST_STRING) { 974 + if (tm_abort_check(regs, 975 + TM_CAUSE_EMULATE | TM_CAUSE_PERSISTENT)) 976 + return -EINVAL; 997 977 PPC_WARN_EMULATED(string, regs); 998 978 return emulate_string_inst(regs, instword); 999 979 } ··· 1173 1147 /* We restore the interrupt state now */ 1174 1148 if (!arch_irq_disabled_regs(regs)) 1175 1149 local_irq_enable(); 1150 + 1151 + if (tm_abort_check(regs, TM_CAUSE_ALIGNMENT | TM_CAUSE_PERSISTENT)) 1152 + goto bail; 1176 1153 1177 1154 /* we don't implement logging of alignment exceptions */ 1178 1155 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
+2
arch/powerpc/kvm/book3s_hv.c
··· 562 562 case H_CPPR: 563 563 case H_EOI: 564 564 case H_IPI: 565 + case H_IPOLL: 566 + case H_XIRR_X: 565 567 if (kvmppc_xics_enabled(vcpu)) { 566 568 ret = kvmppc_xics_hcall(vcpu, req); 567 569 break;
+2
arch/powerpc/kvm/book3s_pr_papr.c
··· 257 257 case H_CPPR: 258 258 case H_EOI: 259 259 case H_IPI: 260 + case H_IPOLL: 261 + case H_XIRR_X: 260 262 if (kvmppc_xics_enabled(vcpu)) 261 263 return kvmppc_h_pr_xics_hcall(vcpu, cmd); 262 264 break;
+29
arch/powerpc/kvm/book3s_xics.c
··· 650 650 return H_SUCCESS; 651 651 } 652 652 653 + static int kvmppc_h_ipoll(struct kvm_vcpu *vcpu, unsigned long server) 654 + { 655 + union kvmppc_icp_state state; 656 + struct kvmppc_icp *icp; 657 + 658 + icp = vcpu->arch.icp; 659 + if (icp->server_num != server) { 660 + icp = kvmppc_xics_find_server(vcpu->kvm, server); 661 + if (!icp) 662 + return H_PARAMETER; 663 + } 664 + state = ACCESS_ONCE(icp->state); 665 + kvmppc_set_gpr(vcpu, 4, ((u32)state.cppr << 24) | state.xisr); 666 + kvmppc_set_gpr(vcpu, 5, state.mfrr); 667 + return H_SUCCESS; 668 + } 669 + 653 670 static noinline void kvmppc_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr) 654 671 { 655 672 union kvmppc_icp_state old_state, new_state; ··· 803 786 /* Check if we have an ICP */ 804 787 if (!xics || !vcpu->arch.icp) 805 788 return H_HARDWARE; 789 + 790 + /* These requests don't have real-mode implementations at present */ 791 + switch (req) { 792 + case H_XIRR_X: 793 + res = kvmppc_h_xirr(vcpu); 794 + kvmppc_set_gpr(vcpu, 4, res); 795 + kvmppc_set_gpr(vcpu, 5, get_tb()); 796 + return rc; 797 + case H_IPOLL: 798 + rc = kvmppc_h_ipoll(vcpu, kvmppc_get_gpr(vcpu, 4)); 799 + return rc; 800 + } 806 801 807 802 /* Check for real mode returning too hard */ 808 803 if (xics->real_mode)
+11 -8
arch/powerpc/lib/copypage_power7.S
··· 28 28 * aligned we don't need to clear the bottom 7 bits of either 29 29 * address. 30 30 */ 31 - ori r9,r3,1 /* stream=1 */ 31 + ori r9,r3,1 /* stream=1 => to */ 32 32 33 33 #ifdef CONFIG_PPC_64K_PAGES 34 - lis r7,0x0E01 /* depth=7, units=512 */ 34 + lis r7,0x0E01 /* depth=7 35 + * units/cachelines=512 */ 35 36 #else 36 37 lis r7,0x0E00 /* depth=7 */ 37 - ori r7,r7,0x1000 /* units=32 */ 38 + ori r7,r7,0x1000 /* units/cachelines=32 */ 38 39 #endif 39 40 ori r10,r7,1 /* stream=1 */ 40 41 ··· 44 43 45 44 .machine push 46 45 .machine "power4" 47 - dcbt r0,r4,0b01000 48 - dcbt r0,r7,0b01010 49 - dcbtst r0,r9,0b01000 50 - dcbtst r0,r10,0b01010 46 + /* setup read stream 0 */ 47 + dcbt r0,r4,0b01000 /* addr from */ 48 + dcbt r0,r7,0b01010 /* length and depth from */ 49 + /* setup write stream 1 */ 50 + dcbtst r0,r9,0b01000 /* addr to */ 51 + dcbtst r0,r10,0b01010 /* length and depth to */ 51 52 eieio 52 - dcbt r0,r8,0b01010 /* GO */ 53 + dcbt r0,r8,0b01010 /* all streams GO */ 53 54 .machine pop 54 55 55 56 #ifdef CONFIG_ALTIVEC
+7 -5
arch/powerpc/lib/copyuser_power7.S
··· 318 318 319 319 .machine push 320 320 .machine "power4" 321 - dcbt r0,r6,0b01000 322 - dcbt r0,r7,0b01010 323 - dcbtst r0,r9,0b01000 324 - dcbtst r0,r10,0b01010 321 + /* setup read stream 0 */ 322 + dcbt r0,r6,0b01000 /* addr from */ 323 + dcbt r0,r7,0b01010 /* length and depth from */ 324 + /* setup write stream 1 */ 325 + dcbtst r0,r9,0b01000 /* addr to */ 326 + dcbtst r0,r10,0b01010 /* length and depth to */ 325 327 eieio 326 - dcbt r0,r8,0b01010 /* GO */ 328 + dcbt r0,r8,0b01010 /* all streams GO */ 327 329 .machine pop 328 330 329 331 beq cr1,.Lunwind_stack_nonvmx_copy
+22 -8
arch/powerpc/mm/hash_native_64.c
··· 336 336 337 337 hpte_v = hptep->v; 338 338 actual_psize = hpte_actual_psize(hptep, psize); 339 + /* 340 + * We need to invalidate the TLB always because hpte_remove doesn't do 341 + * a tlb invalidate. If a hash bucket gets full, we "evict" a more/less 342 + * random entry from it. When we do that we don't invalidate the TLB 343 + * (hpte_remove) because we assume the old translation is still 344 + * technically "valid". 345 + */ 339 346 if (actual_psize < 0) { 340 - native_unlock_hpte(hptep); 341 - return -1; 347 + actual_psize = psize; 348 + ret = -1; 349 + goto err_out; 342 350 } 343 - /* Even if we miss, we need to invalidate the TLB */ 344 351 if (!HPTE_V_COMPARE(hpte_v, want_v)) { 345 352 DBG_LOW(" -> miss\n"); 346 353 ret = -1; ··· 357 350 hptep->r = (hptep->r & ~(HPTE_R_PP | HPTE_R_N)) | 358 351 (newpp & (HPTE_R_PP | HPTE_R_N | HPTE_R_C)); 359 352 } 353 + err_out: 360 354 native_unlock_hpte(hptep); 361 355 362 356 /* Ensure it is out of the tlb too. */ ··· 417 409 hptep = htab_address + slot; 418 410 actual_psize = hpte_actual_psize(hptep, psize); 419 411 if (actual_psize < 0) 420 - return; 412 + actual_psize = psize; 421 413 422 414 /* Update the HPTE */ 423 415 hptep->r = (hptep->r & ~(HPTE_R_PP | HPTE_R_N)) | ··· 445 437 hpte_v = hptep->v; 446 438 447 439 actual_psize = hpte_actual_psize(hptep, psize); 440 + /* 441 + * We need to invalidate the TLB always because hpte_remove doesn't do 442 + * a tlb invalidate. If a hash bucket gets full, we "evict" a more/less 443 + * random entry from it. When we do that we don't invalidate the TLB 444 + * (hpte_remove) because we assume the old translation is still 445 + * technically "valid". 446 + */ 448 447 if (actual_psize < 0) { 448 + actual_psize = psize; 449 449 native_unlock_hpte(hptep); 450 - local_irq_restore(flags); 451 - return; 450 + goto err_out; 452 451 } 453 - /* Even if we miss, we need to invalidate the TLB */ 454 452 if (!HPTE_V_COMPARE(hpte_v, want_v)) 455 453 native_unlock_hpte(hptep); 456 454 else 457 455 /* Invalidate the hpte. NOTE: this also unlocks it */ 458 456 hptep->v = 0; 459 457 458 + err_out: 460 459 /* Invalidate the TLB */ 461 460 tlbie(vpn, psize, actual_psize, ssize, local); 462 - 463 461 local_irq_restore(flags); 464 462 } 465 463
+31 -36
arch/powerpc/perf/core-book3s.c
··· 110 110 111 111 static bool regs_use_siar(struct pt_regs *regs) 112 112 { 113 - return !!(regs->result & 1); 113 + return !!regs->result; 114 114 } 115 115 116 116 /* ··· 136 136 * If we're not doing instruction sampling, give them the SDAR 137 137 * (sampled data address). If we are doing instruction sampling, then 138 138 * only give them the SDAR if it corresponds to the instruction 139 - * pointed to by SIAR; this is indicated by the [POWER6_]MMCRA_SDSYNC or 140 - * the [POWER7P_]MMCRA_SDAR_VALID bit in MMCRA. 139 + * pointed to by SIAR; this is indicated by the [POWER6_]MMCRA_SDSYNC, the 140 + * [POWER7P_]MMCRA_SDAR_VALID bit in MMCRA, or the SDAR_VALID bit in SIER. 141 141 */ 142 142 static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp) 143 143 { 144 144 unsigned long mmcra = regs->dsisr; 145 - unsigned long sdsync; 145 + bool sdar_valid; 146 146 147 - if (ppmu->flags & PPMU_SIAR_VALID) 148 - sdsync = POWER7P_MMCRA_SDAR_VALID; 149 - else if (ppmu->flags & PPMU_ALT_SIPR) 150 - sdsync = POWER6_MMCRA_SDSYNC; 151 - else 152 - sdsync = MMCRA_SDSYNC; 147 + if (ppmu->flags & PPMU_HAS_SIER) 148 + sdar_valid = regs->dar & SIER_SDAR_VALID; 149 + else { 150 + unsigned long sdsync; 153 151 154 - if (!(mmcra & MMCRA_SAMPLE_ENABLE) || (mmcra & sdsync)) 152 + if (ppmu->flags & PPMU_SIAR_VALID) 153 + sdsync = POWER7P_MMCRA_SDAR_VALID; 154 + else if (ppmu->flags & PPMU_ALT_SIPR) 155 + sdsync = POWER6_MMCRA_SDSYNC; 156 + else 157 + sdsync = MMCRA_SDSYNC; 158 + 159 + sdar_valid = mmcra & sdsync; 160 + } 161 + 162 + if (!(mmcra & MMCRA_SAMPLE_ENABLE) || sdar_valid) 155 163 *addrp = mfspr(SPRN_SDAR); 156 164 } 157 165 ··· 189 181 return !!(regs->dsisr & sipr); 190 182 } 191 183 192 - static bool regs_no_sipr(struct pt_regs *regs) 193 - { 194 - return !!(regs->result & 2); 195 - } 196 - 197 184 static inline u32 perf_flags_from_msr(struct pt_regs *regs) 198 185 { 199 186 if (regs->msr & MSR_PR) ··· 211 208 * SIAR which should give slightly more reliable 212 209 * results 213 210 */ 214 - if (regs_no_sipr(regs)) { 211 + if (ppmu->flags & PPMU_NO_SIPR) { 215 212 unsigned long siar = mfspr(SPRN_SIAR); 216 213 if (siar >= PAGE_OFFSET) 217 214 return PERF_RECORD_MISC_KERNEL; ··· 242 239 int use_siar; 243 240 244 241 regs->dsisr = mmcra; 245 - regs->result = 0; 246 242 247 - if (ppmu->flags & PPMU_NO_SIPR) 248 - regs->result |= 2; 249 - 250 - /* 251 - * On power8 if we're in random sampling mode, the SIER is updated. 252 - * If we're in continuous sampling mode, we don't have SIPR. 253 - */ 254 - if (ppmu->flags & PPMU_HAS_SIER) { 255 - if (marked) 256 - regs->dar = mfspr(SPRN_SIER); 257 - else 258 - regs->result |= 2; 259 - } 260 - 243 + if (ppmu->flags & PPMU_HAS_SIER) 244 + regs->dar = mfspr(SPRN_SIER); 261 245 262 246 /* 263 247 * If this isn't a PMU exception (eg a software event) the SIAR is ··· 269 279 use_siar = 1; 270 280 else if ((ppmu->flags & PPMU_NO_CONT_SAMPLING)) 271 281 use_siar = 0; 272 - else if (!regs_no_sipr(regs) && regs_sipr(regs)) 282 + else if (!(ppmu->flags & PPMU_NO_SIPR) && regs_sipr(regs)) 273 283 use_siar = 0; 274 284 else 275 285 use_siar = 1; 276 286 277 - regs->result |= use_siar; 287 + regs->result = use_siar; 278 288 } 279 289 280 290 /* ··· 298 308 unsigned long mmcra = regs->dsisr; 299 309 int marked = mmcra & MMCRA_SAMPLE_ENABLE; 300 310 301 - if ((ppmu->flags & PPMU_SIAR_VALID) && marked) 302 - return mmcra & POWER7P_MMCRA_SIAR_VALID; 311 + if (marked) { 312 + if (ppmu->flags & PPMU_HAS_SIER) 313 + return regs->dar & SIER_SIAR_VALID; 314 + 315 + if (ppmu->flags & PPMU_SIAR_VALID) 316 + return mmcra & POWER7P_MMCRA_SIAR_VALID; 317 + } 303 318 304 319 return 1; 305 320 }
+2
arch/powerpc/platforms/pseries/Kconfig
··· 19 19 select ZLIB_DEFLATE 20 20 select PPC_DOORBELL 21 21 select HAVE_CONTEXT_TRACKING 22 + select HOTPLUG if SMP 23 + select HOTPLUG_CPU if SMP 22 24 default y 23 25 24 26 config PPC_SPLPAR
+2 -2
arch/powerpc/sysdev/mpic.c
··· 54 54 55 55 #ifdef CONFIG_PPC32 /* XXX for now */ 56 56 #ifdef CONFIG_IRQ_ALL_CPUS 57 - #define distribute_irqs (!(mpic->flags & MPIC_SINGLE_DEST_CPU)) 57 + #define distribute_irqs (1) 58 58 #else 59 59 #define distribute_irqs (0) 60 60 #endif ··· 1703 1703 * it differently, then we should make sure we also change the default 1704 1704 * values of irq_desc[].affinity in irq.c. 1705 1705 */ 1706 - if (distribute_irqs) { 1706 + if (distribute_irqs && !(mpic->flags & MPIC_SINGLE_DEST_CPU)) { 1707 1707 for (i = 0; i < mpic->num_sources ; i++) 1708 1708 mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1709 1709 mpic_irq_read(i, MPIC_INFO(IRQ_DESTINATION)) | msk);