Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'powerpc-4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
"Fixes marked for stable:
- Convert cmp to cmpd in idle enter sequence (Segher Boessenkool)
- cxl: Fix leaking pid refs in some error paths (Vaibhav Jain)
- Re-fix race condition between going idle and entering guest (Paul Mackerras)
- Fix race condition in setting lock bit in idle/wakeup code (Paul Mackerras)
- radix: Use tlbiel only if we ever ran on the current cpu (Aneesh Kumar K.V)
- relocation, register save fixes for system reset interrupt (Nicholas Piggin)

Fixes for code merged this cycle:
- Fix CONFIG_ALIVEC typo in restore_tm_state() (Valentin Rothberg)
- KVM: PPC: Book3S HV: Fix build error when SMP=n (Michael Ellerman)"

* tag 'powerpc-4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/64s: relocation, register save fixes for system reset interrupt
powerpc/mm/radix: Use tlbiel only if we ever ran on the current cpu
powerpc/process: Fix CONFIG_ALIVEC typo in restore_tm_state()
powerpc/64: Fix race condition in setting lock bit in idle/wakeup code
powerpc/64: Re-fix race condition between going idle and entering guest
cxl: Fix leaking pid refs in some error paths
powerpc: Convert cmp to cmpd in idle enter sequence
KVM: PPC: Book3S HV: Fix build error when SMP=n

+108 -42
+1 -1
arch/powerpc/include/asm/cpuidle.h
··· 26 26 std r0,0(r1); \ 27 27 ptesync; \ 28 28 ld r0,0(r1); \ 29 - 1: cmp cr0,r0,r0; \ 29 + 1: cmpd cr0,r0,r0; \ 30 30 bne 1b; \ 31 31 IDLE_INST; \ 32 32 b .
+16
arch/powerpc/include/asm/exception-64s.h
··· 93 93 ld reg,PACAKBASE(r13); /* get high part of &label */ \ 94 94 ori reg,reg,(FIXED_SYMBOL_ABS_ADDR(label))@l; 95 95 96 + #define __LOAD_HANDLER(reg, label) \ 97 + ld reg,PACAKBASE(r13); \ 98 + ori reg,reg,(ABS_ADDR(label))@l; 99 + 96 100 /* Exception register prefixes */ 97 101 #define EXC_HV H 98 102 #define EXC_STD ··· 210 206 #define kvmppc_interrupt kvmppc_interrupt_hv 211 207 #else 212 208 #define kvmppc_interrupt kvmppc_interrupt_pr 209 + #endif 210 + 211 + #ifdef CONFIG_RELOCATABLE 212 + #define BRANCH_TO_COMMON(reg, label) \ 213 + __LOAD_HANDLER(reg, label); \ 214 + mtctr reg; \ 215 + bctr 216 + 217 + #else 218 + #define BRANCH_TO_COMMON(reg, label) \ 219 + b label 220 + 213 221 #endif 214 222 215 223 #define __KVM_HANDLER_PROLOG(area, n) \
+12
arch/powerpc/include/asm/tlb.h
··· 52 52 return cpumask_subset(mm_cpumask(mm), 53 53 topology_sibling_cpumask(smp_processor_id())); 54 54 } 55 + 56 + static inline int mm_is_thread_local(struct mm_struct *mm) 57 + { 58 + return cpumask_equal(mm_cpumask(mm), 59 + cpumask_of(smp_processor_id())); 60 + } 61 + 55 62 #else 56 63 static inline int mm_is_core_local(struct mm_struct *mm) 64 + { 65 + return 1; 66 + } 67 + 68 + static inline int mm_is_thread_local(struct mm_struct *mm) 57 69 { 58 70 return 1; 59 71 }
+29 -21
arch/powerpc/kernel/exceptions-64s.S
··· 95 95 /* No virt vectors corresponding with 0x0..0x100 */ 96 96 EXC_VIRT_NONE(0x4000, 0x4100) 97 97 98 + 99 + #ifdef CONFIG_PPC_P7_NAP 100 + /* 101 + * If running native on arch 2.06 or later, check if we are waking up 102 + * from nap/sleep/winkle, and branch to idle handler. 103 + */ 104 + #define IDLETEST(n) \ 105 + BEGIN_FTR_SECTION ; \ 106 + mfspr r10,SPRN_SRR1 ; \ 107 + rlwinm. r10,r10,47-31,30,31 ; \ 108 + beq- 1f ; \ 109 + cmpwi cr3,r10,2 ; \ 110 + BRANCH_TO_COMMON(r10, system_reset_idle_common) ; \ 111 + 1: \ 112 + END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) 113 + #else 114 + #define IDLETEST NOTEST 115 + #endif 116 + 98 117 EXC_REAL_BEGIN(system_reset, 0x100, 0x200) 99 118 SET_SCRATCH0(r13) 100 - #ifdef CONFIG_PPC_P7_NAP 101 - BEGIN_FTR_SECTION 102 - /* Running native on arch 2.06 or later, check if we are 103 - * waking up from nap/sleep/winkle. 104 - */ 105 - mfspr r13,SPRN_SRR1 106 - rlwinm. r13,r13,47-31,30,31 107 - beq 9f 119 + EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, 120 + IDLETEST, 0x100) 108 121 109 - cmpwi cr3,r13,2 110 - GET_PACA(r13) 122 + EXC_REAL_END(system_reset, 0x100, 0x200) 123 + EXC_VIRT_NONE(0x4100, 0x4200) 124 + 125 + #ifdef CONFIG_PPC_P7_NAP 126 + EXC_COMMON_BEGIN(system_reset_idle_common) 111 127 bl pnv_restore_hyp_resource 112 128 113 129 li r0,PNV_THREAD_RUNNING ··· 146 130 blt cr3,2f 147 131 b pnv_wakeup_loss 148 132 2: b pnv_wakeup_noloss 133 + #endif 149 134 150 - 9: 151 - END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) 152 - #endif /* CONFIG_PPC_P7_NAP */ 153 - EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, 154 - NOTEST, 0x100) 155 - EXC_REAL_END(system_reset, 0x100, 0x200) 156 - EXC_VIRT_NONE(0x4100, 0x4200) 157 135 EXC_COMMON(system_reset_common, 0x100, system_reset_exception) 158 136 159 137 #ifdef CONFIG_PPC_PSERIES ··· 827 817 TRAMP_KVM(PACA_EXGEN, 0xb00) 828 818 EXC_COMMON(trap_0b_common, 0xb00, unknown_exception) 829 819 830 - 831 - #define LOAD_SYSCALL_HANDLER(reg) \ 832 - ld reg,PACAKBASE(r13); \ 833 - ori reg,reg,(ABS_ADDR(system_call_common))@l; 820 + #define LOAD_SYSCALL_HANDLER(reg) \ 821 + __LOAD_HANDLER(reg, system_call_common) 834 822 835 823 /* Syscall routine is used twice, in reloc-off and reloc-on paths */ 836 824 #define SYSCALL_PSERIES_1 \
+29 -6
arch/powerpc/kernel/idle_book3s.S
··· 90 90 * Threads will spin in HMT_LOW until the lock bit is cleared. 91 91 * r14 - pointer to core_idle_state 92 92 * r15 - used to load contents of core_idle_state 93 + * r9 - used as a temporary variable 93 94 */ 94 95 95 96 core_idle_lock_held: ··· 100 99 bne 3b 101 100 HMT_MEDIUM 102 101 lwarx r15,0,r14 102 + andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT 103 + bne core_idle_lock_held 103 104 blr 104 105 105 106 /* ··· 166 163 std r9,_MSR(r1) 167 164 std r1,PACAR1(r13) 168 165 169 - #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 170 - /* Tell KVM we're entering idle */ 171 - li r4,KVM_HWTHREAD_IN_IDLE 172 - stb r4,HSTATE_HWTHREAD_STATE(r13) 173 - #endif 174 - 175 166 /* 176 167 * Go to real mode to do the nap, as required by the architecture. 177 168 * Also, we need to be in real mode before setting hwthread_state, ··· 182 185 183 186 .globl pnv_enter_arch207_idle_mode 184 187 pnv_enter_arch207_idle_mode: 188 + #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 189 + /* Tell KVM we're entering idle */ 190 + li r4,KVM_HWTHREAD_IN_IDLE 191 + /******************************************************/ 192 + /* N O T E W E L L ! ! ! N O T E W E L L */ 193 + /* The following store to HSTATE_HWTHREAD_STATE(r13) */ 194 + /* MUST occur in real mode, i.e. with the MMU off, */ 195 + /* and the MMU must stay off until we clear this flag */ 196 + /* and test HSTATE_HWTHREAD_REQ(r13) in the system */ 197 + /* reset interrupt vector in exceptions-64s.S. */ 198 + /* The reason is that another thread can switch the */ 199 + /* MMU to a guest context whenever this flag is set */ 200 + /* to KVM_HWTHREAD_IN_IDLE, and if the MMU was on, */ 201 + /* that would potentially cause this thread to start */ 202 + /* executing instructions from guest memory in */ 203 + /* hypervisor mode, leading to a host crash or data */ 204 + /* corruption, or worse. */ 205 + /******************************************************/ 206 + stb r4,HSTATE_HWTHREAD_STATE(r13) 207 + #endif 185 208 stb r3,PACA_THREAD_IDLE_STATE(r13) 186 209 cmpwi cr3,r3,PNV_THREAD_SLEEP 187 210 bge cr3,2f ··· 267 250 * r3 - requested stop state 268 251 */ 269 252 power_enter_stop: 253 + #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 254 + /* Tell KVM we're entering idle */ 255 + li r4,KVM_HWTHREAD_IN_IDLE 256 + /* DO THIS IN REAL MODE! See comment above. */ 257 + stb r4,HSTATE_HWTHREAD_STATE(r13) 258 + #endif 270 259 /* 271 260 * Check if the requested state is a deep idle state. 272 261 */
+1 -1
arch/powerpc/kernel/process.c
··· 1012 1012 /* Ensure that restore_math() will restore */ 1013 1013 if (msr_diff & MSR_FP) 1014 1014 current->thread.load_fp = 1; 1015 - #ifdef CONFIG_ALIVEC 1015 + #ifdef CONFIG_ALTIVEC 1016 1016 if (cpu_has_feature(CPU_FTR_ALTIVEC) && msr_diff & MSR_VEC) 1017 1017 current->thread.load_vec = 1; 1018 1018 #endif
+1
arch/powerpc/kvm/book3s_hv_rm_xics.c
··· 23 23 #include <asm/ppc-opcode.h> 24 24 #include <asm/pnv-pci.h> 25 25 #include <asm/opal.h> 26 + #include <asm/smp.h> 26 27 27 28 #include "book3s_xics.h" 28 29
+4 -4
arch/powerpc/mm/tlb-radix.c
··· 175 175 if (unlikely(pid == MMU_NO_CONTEXT)) 176 176 goto no_context; 177 177 178 - if (!mm_is_core_local(mm)) { 178 + if (!mm_is_thread_local(mm)) { 179 179 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 180 180 181 181 if (lock_tlbie) ··· 201 201 if (unlikely(pid == MMU_NO_CONTEXT)) 202 202 goto no_context; 203 203 204 - if (!mm_is_core_local(mm)) { 204 + if (!mm_is_thread_local(mm)) { 205 205 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 206 206 207 207 if (lock_tlbie) ··· 226 226 pid = mm ? mm->context.id : 0; 227 227 if (unlikely(pid == MMU_NO_CONTEXT)) 228 228 goto bail; 229 - if (!mm_is_core_local(mm)) { 229 + if (!mm_is_thread_local(mm)) { 230 230 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 231 231 232 232 if (lock_tlbie) ··· 321 321 { 322 322 unsigned long pid; 323 323 unsigned long addr; 324 - int local = mm_is_core_local(mm); 324 + int local = mm_is_thread_local(mm); 325 325 unsigned long ap = mmu_get_ap(psize); 326 326 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 327 327 unsigned long page_size = 1UL << mmu_psize_defs[psize].shift;
+2
drivers/misc/cxl/api.c
··· 247 247 cxl_ctx_get(); 248 248 249 249 if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { 250 + put_pid(ctx->glpid); 250 251 put_pid(ctx->pid); 252 + ctx->glpid = ctx->pid = NULL; 251 253 cxl_adapter_context_put(ctx->afu->adapter); 252 254 cxl_ctx_put(); 253 255 goto out;
+13 -9
drivers/misc/cxl/file.c
··· 194 194 ctx->mmio_err_ff = !!(work.flags & CXL_START_WORK_ERR_FF); 195 195 196 196 /* 197 + * Increment the mapped context count for adapter. This also checks 198 + * if adapter_context_lock is taken. 199 + */ 200 + rc = cxl_adapter_context_get(ctx->afu->adapter); 201 + if (rc) { 202 + afu_release_irqs(ctx, ctx); 203 + goto out; 204 + } 205 + 206 + /* 197 207 * We grab the PID here and not in the file open to allow for the case 198 208 * where a process (master, some daemon, etc) has opened the chardev on 199 209 * behalf of another process, so the AFU's mm gets bound to the process ··· 215 205 ctx->pid = get_task_pid(current, PIDTYPE_PID); 216 206 ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID); 217 207 218 - /* 219 - * Increment the mapped context count for adapter. This also checks 220 - * if adapter_context_lock is taken. 221 - */ 222 - rc = cxl_adapter_context_get(ctx->afu->adapter); 223 - if (rc) { 224 - afu_release_irqs(ctx, ctx); 225 - goto out; 226 - } 227 208 228 209 trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr); 229 210 ··· 222 221 amr))) { 223 222 afu_release_irqs(ctx, ctx); 224 223 cxl_adapter_context_put(ctx->afu->adapter); 224 + put_pid(ctx->glpid); 225 + put_pid(ctx->pid); 226 + ctx->glpid = ctx->pid = NULL; 225 227 goto out; 226 228 } 227 229