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.14-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
"A fix for a bad bug (written by me) in our livepatch handler. Removal
of an over-zealous lockdep_assert_cpus_held() in our topology code. A
fix to the recently added emulation of cntlz[wd]. And three small
fixes to the recently added IMC PMU driver.

Thanks to: Anju T Sudhakar, Balbir Singh, Kamalesh Babulal, Naveen N.
Rao, Sandipan Das, Santosh Sivaraj, Thiago Jung Bauermann"

* tag 'powerpc-4.14-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/perf: Fix IMC initialization crash
powerpc/perf: Add ___GFP_NOWARN flag to alloc_pages_node()
powerpc/perf: Fix for core/nest imc call trace on cpuhotplug
powerpc: Don't call lockdep_assert_cpus_held() from arch_update_cpu_topology()
powerpc/lib/sstep: Fix count leading zeros instructions
powerpc/livepatch: Fix livepatch stack access

+53 -38
+15 -30
arch/powerpc/kernel/trace/ftrace_64_mprofile.S
··· 181 181 * - we have no stack frame and can not allocate one 182 182 * - LR points back to the original caller (in A) 183 183 * - CTR holds the new NIP in C 184 - * - r0 & r12 are free 185 - * 186 - * r0 can't be used as the base register for a DS-form load or store, so 187 - * we temporarily shuffle r1 (stack pointer) into r0 and then put it back. 184 + * - r0, r11 & r12 are free 188 185 */ 189 186 livepatch_handler: 190 187 CURRENT_THREAD_INFO(r12, r1) 191 188 192 - /* Save stack pointer into r0 */ 193 - mr r0, r1 194 - 195 189 /* Allocate 3 x 8 bytes */ 196 - ld r1, TI_livepatch_sp(r12) 197 - addi r1, r1, 24 198 - std r1, TI_livepatch_sp(r12) 190 + ld r11, TI_livepatch_sp(r12) 191 + addi r11, r11, 24 192 + std r11, TI_livepatch_sp(r12) 199 193 200 194 /* Save toc & real LR on livepatch stack */ 201 - std r2, -24(r1) 195 + std r2, -24(r11) 202 196 mflr r12 203 - std r12, -16(r1) 197 + std r12, -16(r11) 204 198 205 199 /* Store stack end marker */ 206 200 lis r12, STACK_END_MAGIC@h 207 201 ori r12, r12, STACK_END_MAGIC@l 208 - std r12, -8(r1) 209 - 210 - /* Restore real stack pointer */ 211 - mr r1, r0 202 + std r12, -8(r11) 212 203 213 204 /* Put ctr in r12 for global entry and branch there */ 214 205 mfctr r12 ··· 207 216 208 217 /* 209 218 * Now we are returning from the patched function to the original 210 - * caller A. We are free to use r0 and r12, and we can use r2 until we 219 + * caller A. We are free to use r11, r12 and we can use r2 until we 211 220 * restore it. 212 221 */ 213 222 214 223 CURRENT_THREAD_INFO(r12, r1) 215 224 216 - /* Save stack pointer into r0 */ 217 - mr r0, r1 218 - 219 - ld r1, TI_livepatch_sp(r12) 225 + ld r11, TI_livepatch_sp(r12) 220 226 221 227 /* Check stack marker hasn't been trashed */ 222 228 lis r2, STACK_END_MAGIC@h 223 229 ori r2, r2, STACK_END_MAGIC@l 224 - ld r12, -8(r1) 230 + ld r12, -8(r11) 225 231 1: tdne r12, r2 226 232 EMIT_BUG_ENTRY 1b, __FILE__, __LINE__ - 1, 0 227 233 228 234 /* Restore LR & toc from livepatch stack */ 229 - ld r12, -16(r1) 235 + ld r12, -16(r11) 230 236 mtlr r12 231 - ld r2, -24(r1) 237 + ld r2, -24(r11) 232 238 233 239 /* Pop livepatch stack frame */ 234 - CURRENT_THREAD_INFO(r12, r0) 235 - subi r1, r1, 24 236 - std r1, TI_livepatch_sp(r12) 237 - 238 - /* Restore real stack pointer */ 239 - mr r1, r0 240 + CURRENT_THREAD_INFO(r12, r1) 241 + subi r11, r11, 24 242 + std r11, TI_livepatch_sp(r12) 240 243 241 244 /* Return to original caller of live patched function */ 242 245 blr
+4 -2
arch/powerpc/lib/sstep.c
··· 1684 1684 * Logical instructions 1685 1685 */ 1686 1686 case 26: /* cntlzw */ 1687 - op->val = __builtin_clz((unsigned int) regs->gpr[rd]); 1687 + val = (unsigned int) regs->gpr[rd]; 1688 + op->val = ( val ? __builtin_clz(val) : 32 ); 1688 1689 goto logical_done; 1689 1690 #ifdef __powerpc64__ 1690 1691 case 58: /* cntlzd */ 1691 - op->val = __builtin_clzl(regs->gpr[rd]); 1692 + val = regs->gpr[rd]; 1693 + op->val = ( val ? __builtin_clzl(val) : 64 ); 1692 1694 goto logical_done; 1693 1695 #endif 1694 1696 case 28: /* and */
-1
arch/powerpc/mm/numa.c
··· 1438 1438 1439 1439 int arch_update_cpu_topology(void) 1440 1440 { 1441 - lockdep_assert_cpus_held(); 1442 1441 return numa_update_cpu_topology(true); 1443 1442 } 1444 1443
+34 -5
arch/powerpc/perf/imc-pmu.c
··· 399 399 400 400 /* Take the mutex lock for this node and then decrement the reference count */ 401 401 mutex_lock(&ref->lock); 402 + if (ref->refc == 0) { 403 + /* 404 + * The scenario where this is true is, when perf session is 405 + * started, followed by offlining of all cpus in a given node. 406 + * 407 + * In the cpuhotplug offline path, ppc_nest_imc_cpu_offline() 408 + * function set the ref->count to zero, if the cpu which is 409 + * about to offline is the last cpu in a given node and make 410 + * an OPAL call to disable the engine in that node. 411 + * 412 + */ 413 + mutex_unlock(&ref->lock); 414 + return; 415 + } 402 416 ref->refc--; 403 417 if (ref->refc == 0) { 404 418 rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST, ··· 537 523 538 524 /* We need only vbase for core counters */ 539 525 mem_info->vbase = page_address(alloc_pages_node(phys_id, 540 - GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE, 541 - get_order(size))); 526 + GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | 527 + __GFP_NOWARN, get_order(size))); 542 528 if (!mem_info->vbase) 543 529 return -ENOMEM; 544 530 ··· 660 646 return; 661 647 662 648 mutex_lock(&ref->lock); 649 + if (ref->refc == 0) { 650 + /* 651 + * The scenario where this is true is, when perf session is 652 + * started, followed by offlining of all cpus in a given core. 653 + * 654 + * In the cpuhotplug offline path, ppc_core_imc_cpu_offline() 655 + * function set the ref->count to zero, if the cpu which is 656 + * about to offline is the last cpu in a given core and make 657 + * an OPAL call to disable the engine in that core. 658 + * 659 + */ 660 + mutex_unlock(&ref->lock); 661 + return; 662 + } 663 663 ref->refc--; 664 664 if (ref->refc == 0) { 665 665 rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_CORE, ··· 791 763 * free the memory in cpu offline path. 792 764 */ 793 765 local_mem = page_address(alloc_pages_node(phys_id, 794 - GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE, 795 - get_order(size))); 766 + GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | 767 + __GFP_NOWARN, get_order(size))); 796 768 if (!local_mem) 797 769 return -ENOMEM; 798 770 ··· 1176 1148 } 1177 1149 1178 1150 /* Only free the attr_groups which are dynamically allocated */ 1179 - kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]->attrs); 1151 + if (pmu_ptr->attr_groups[IMC_EVENT_ATTR]) 1152 + kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]->attrs); 1180 1153 kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]); 1181 1154 kfree(pmu_ptr); 1182 1155 return;