Skip to content

Commit 9c294ec

Browse files
committed
Merge tag 'powerpc-4.15-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "This is all fairly boring, except that there's two KVM fixes that you'd normally get via Paul's kvm-ppc tree. He's away so I picked them up. I was waiting to see if he would apply them, which is why they have only been in my tree since today. But they were on the list for a while and have been tested on the relevant hardware. Of note is two fixes for KVM XIVE (Power9 interrupt controller). These would normally go via the KVM tree but Paul is away so I've picked them up. Other than that, two fixes for error handling in the IMC driver, and one for a potential oops in the BHRB code if the hardware records a branch address that has subsequently been unmapped, and finally a s/%p/%px/ in our oops code. Thanks to: Anju T Sudhakar, Cédric Le Goater, Laurent Vivier, Madhavan Srinivasan, Naveen N. Rao, Ravi Bangoria" * tag 'powerpc-4.15-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: KVM: PPC: Book3S HV: Fix pending_pri value in kvmppc_xive_get_icp() KVM: PPC: Book3S: fix XIVE migration of pending interrupts powerpc/kernel: Print actual address of regs when oopsing powerpc/perf: Fix kfree memory allocated for nest pmus powerpc/perf/imc: Fix nest-imc cpuhotplug callback failure powerpc/perf: Dereference BHRB entries safely
2 parents 9ad95bd + 7333b5a commit 9c294ec

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

arch/powerpc/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ void show_regs(struct pt_regs * regs)
14031403

14041404
printk("NIP: "REG" LR: "REG" CTR: "REG"\n",
14051405
regs->nip, regs->link, regs->ctr);
1406-
printk("REGS: %p TRAP: %04lx %s (%s)\n",
1406+
printk("REGS: %px TRAP: %04lx %s (%s)\n",
14071407
regs, regs->trap, print_tainted(), init_utsname()->release);
14081408
printk("MSR: "REG" ", regs->msr);
14091409
print_msr_bits(regs->msr);

arch/powerpc/kvm/book3s_xive.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ u64 kvmppc_xive_get_icp(struct kvm_vcpu *vcpu)
725725

726726
/* Return the per-cpu state for state saving/migration */
727727
return (u64)xc->cppr << KVM_REG_PPC_ICP_CPPR_SHIFT |
728-
(u64)xc->mfrr << KVM_REG_PPC_ICP_MFRR_SHIFT;
728+
(u64)xc->mfrr << KVM_REG_PPC_ICP_MFRR_SHIFT |
729+
(u64)0xff << KVM_REG_PPC_ICP_PPRI_SHIFT;
729730
}
730731

731732
int kvmppc_xive_set_icp(struct kvm_vcpu *vcpu, u64 icpval)
@@ -1558,15 +1559,15 @@ static int xive_set_source(struct kvmppc_xive *xive, long irq, u64 addr)
15581559

15591560
/*
15601561
* Restore P and Q. If the interrupt was pending, we
1561-
* force both P and Q, which will trigger a resend.
1562+
* force Q and !P, which will trigger a resend.
15621563
*
15631564
* That means that a guest that had both an interrupt
15641565
* pending (queued) and Q set will restore with only
15651566
* one instance of that interrupt instead of 2, but that
15661567
* is perfectly fine as coalescing interrupts that haven't
15671568
* been presented yet is always allowed.
15681569
*/
1569-
if (val & KVM_XICS_PRESENTED || val & KVM_XICS_PENDING)
1570+
if (val & KVM_XICS_PRESENTED && !(val & KVM_XICS_PENDING))
15701571
state->old_p = true;
15711572
if (val & KVM_XICS_QUEUED || val & KVM_XICS_PENDING)
15721573
state->old_q = true;

arch/powerpc/perf/core-book3s.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,12 @@ static __u64 power_pmu_bhrb_to(u64 addr)
410410
int ret;
411411
__u64 target;
412412

413-
if (is_kernel_addr(addr))
414-
return branch_target((unsigned int *)addr);
413+
if (is_kernel_addr(addr)) {
414+
if (probe_kernel_read(&instr, (void *)addr, sizeof(instr)))
415+
return 0;
416+
417+
return branch_target(&instr);
418+
}
415419

416420
/* Userspace: need copy instruction here then translate it */
417421
pagefault_disable();

arch/powerpc/perf/imc-pmu.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,19 @@ static int ppc_nest_imc_cpu_offline(unsigned int cpu)
309309
if (!cpumask_test_and_clear_cpu(cpu, &nest_imc_cpumask))
310310
return 0;
311311

312+
/*
313+
* Check whether nest_imc is registered. We could end up here if the
314+
* cpuhotplug callback registration fails. i.e, callback invokes the
315+
* offline path for all successfully registered nodes. At this stage,
316+
* nest_imc pmu will not be registered and we should return here.
317+
*
318+
* We return with a zero since this is not an offline failure. And
319+
* cpuhp_setup_state() returns the actual failure reason to the caller,
320+
* which in turn will call the cleanup routine.
321+
*/
322+
if (!nest_pmus)
323+
return 0;
324+
312325
/*
313326
* Now that this cpu is one of the designated,
314327
* find a next cpu a) which is online and b) in same chip.
@@ -1171,6 +1184,7 @@ static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr)
11711184
if (nest_pmus == 1) {
11721185
cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE);
11731186
kfree(nest_imc_refc);
1187+
kfree(per_nest_pmu_arr);
11741188
}
11751189

11761190
if (nest_pmus > 0)
@@ -1195,7 +1209,6 @@ static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr)
11951209
kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]->attrs);
11961210
kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]);
11971211
kfree(pmu_ptr);
1198-
kfree(per_nest_pmu_arr);
11991212
return;
12001213
}
12011214

@@ -1309,6 +1322,8 @@ int init_imc_pmu(struct device_node *parent, struct imc_pmu *pmu_ptr, int pmu_id
13091322
ret = nest_pmu_cpumask_init();
13101323
if (ret) {
13111324
mutex_unlock(&nest_init_lock);
1325+
kfree(nest_imc_refc);
1326+
kfree(per_nest_pmu_arr);
13121327
goto err_free;
13131328
}
13141329
}

0 commit comments

Comments
 (0)