Skip to content

Commit a0651c7

Browse files
committed
Merge tag 'powerpc-4.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "Two fixes for nasty kexec/kdump crashes in certain configurations. A couple of minor fixes for the new TIDR code. A fix for an oops in a CXL error handling path. Thanks to: Andrew Donnellan, Christophe Lombard, David Gibson, Mahesh Salgaonkar, Vaibhav Jain" * tag 'powerpc-4.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc: Do not assign thread.tidr if already assigned powerpc: Avoid signed to unsigned conversion in set_thread_tidr() powerpc/kexec: Fix kexec/kdump in P9 guest kernels powerpc/powernv: Fix kexec crashes caused by tlbie tracing cxl: Check if vphb exists before iterating over AFU devices
2 parents ae753ee + 7e4d423 commit a0651c7

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

arch/powerpc/kernel/misc_64.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,9 @@ BEGIN_FTR_SECTION
623623
* NOTE, we rely on r0 being 0 from above.
624624
*/
625625
mtspr SPRN_IAMR,r0
626+
BEGIN_FTR_SECTION_NESTED(42)
626627
mtspr SPRN_AMOR,r0
628+
END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
627629
END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
628630

629631
/* save regs for local vars on new stack.

arch/powerpc/kernel/process.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,16 +1569,22 @@ void arch_release_task_struct(struct task_struct *t)
15691569
*/
15701570
int set_thread_tidr(struct task_struct *t)
15711571
{
1572+
int rc;
1573+
15721574
if (!cpu_has_feature(CPU_FTR_ARCH_300))
15731575
return -EINVAL;
15741576

15751577
if (t != current)
15761578
return -EINVAL;
15771579

1578-
t->thread.tidr = assign_thread_tidr();
1579-
if (t->thread.tidr < 0)
1580-
return t->thread.tidr;
1580+
if (t->thread.tidr)
1581+
return 0;
1582+
1583+
rc = assign_thread_tidr();
1584+
if (rc < 0)
1585+
return rc;
15811586

1587+
t->thread.tidr = rc;
15821588
mtspr(SPRN_TIDR, t->thread.tidr);
15831589

15841590
return 0;

arch/powerpc/mm/hash_native_64.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747

4848
DEFINE_RAW_SPINLOCK(native_tlbie_lock);
4949

50-
static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
50+
static inline unsigned long ___tlbie(unsigned long vpn, int psize,
51+
int apsize, int ssize)
5152
{
5253
unsigned long va;
5354
unsigned int penc;
@@ -100,7 +101,15 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
100101
: "memory");
101102
break;
102103
}
103-
trace_tlbie(0, 0, va, 0, 0, 0, 0);
104+
return va;
105+
}
106+
107+
static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
108+
{
109+
unsigned long rb;
110+
111+
rb = ___tlbie(vpn, psize, apsize, ssize);
112+
trace_tlbie(0, 0, rb, 0, 0, 0, 0);
104113
}
105114

106115
static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
@@ -652,7 +661,7 @@ static void native_hpte_clear(void)
652661
if (hpte_v & HPTE_V_VALID) {
653662
hpte_decode(hptep, slot, &psize, &apsize, &ssize, &vpn);
654663
hptep->v = 0;
655-
__tlbie(vpn, psize, apsize, ssize);
664+
___tlbie(vpn, psize, apsize, ssize);
656665
}
657666
}
658667

drivers/misc/cxl/pci.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,9 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
20832083
/* There should only be one entry, but go through the list
20842084
* anyway
20852085
*/
2086+
if (afu->phb == NULL)
2087+
return result;
2088+
20862089
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
20872090
if (!afu_dev->driver)
20882091
continue;
@@ -2124,8 +2127,7 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
21242127
* Tell the AFU drivers; but we don't care what they
21252128
* say, we're going away.
21262129
*/
2127-
if (afu->phb != NULL)
2128-
cxl_vphb_error_detected(afu, state);
2130+
cxl_vphb_error_detected(afu, state);
21292131
}
21302132
return PCI_ERS_RESULT_DISCONNECT;
21312133
}
@@ -2265,6 +2267,9 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
22652267
if (cxl_afu_select_best_mode(afu))
22662268
goto err;
22672269

2270+
if (afu->phb == NULL)
2271+
continue;
2272+
22682273
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
22692274
/* Reset the device context.
22702275
* TODO: make this less disruptive
@@ -2327,6 +2332,9 @@ static void cxl_pci_resume(struct pci_dev *pdev)
23272332
for (i = 0; i < adapter->slices; i++) {
23282333
afu = adapter->afu[i];
23292334

2335+
if (afu->phb == NULL)
2336+
continue;
2337+
23302338
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
23312339
if (afu_dev->driver && afu_dev->driver->err_handler &&
23322340
afu_dev->driver->err_handler->resume)

0 commit comments

Comments
 (0)