Skip to content

Commit be9eb2f

Browse files
committed
Merge tag 'powerpc-5.15-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Fix a bug where guests on P9 with interrupts passed through could get stuck in synchronize_irq(). - Fix a bug in KVM on P8 where secondary threads entering a guest would write outside their allocated stack. - Fix a bug in KVM on P8 where secondary threads could confuse the host offline code and cause the guest or host to crash. Thanks to Cédric Le Goater. * tag 'powerpc-5.15-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: KVM: PPC: Book3S HV: Make idle_kvm_start_guest() return 0 if it went to guest KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest() powerpc/xive: Discard disabled interrupts in get_irqchip_state()
2 parents 6890aca + cdeb5d7 commit be9eb2f

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,16 @@ kvm_novcpu_exit:
255255
* r3 contains the SRR1 wakeup value, SRR1 is trashed.
256256
*/
257257
_GLOBAL(idle_kvm_start_guest)
258-
ld r4,PACAEMERGSP(r13)
259258
mfcr r5
260259
mflr r0
261-
std r1,0(r4)
262-
std r5,8(r4)
263-
std r0,16(r4)
264-
subi r1,r4,STACK_FRAME_OVERHEAD
260+
std r5, 8(r1) // Save CR in caller's frame
261+
std r0, 16(r1) // Save LR in caller's frame
262+
// Create frame on emergency stack
263+
ld r4, PACAEMERGSP(r13)
264+
stdu r1, -SWITCH_FRAME_SIZE(r4)
265+
// Switch to new frame on emergency stack
266+
mr r1, r4
267+
std r3, 32(r1) // Save SRR1 wakeup value
265268
SAVE_NVGPRS(r1)
266269

267270
/*
@@ -313,6 +316,10 @@ kvm_unsplit_wakeup:
313316

314317
kvm_secondary_got_guest:
315318

319+
// About to go to guest, clear saved SRR1
320+
li r0, 0
321+
std r0, 32(r1)
322+
316323
/* Set HSTATE_DSCR(r13) to something sensible */
317324
ld r6, PACA_DSCR_DEFAULT(r13)
318325
std r6, HSTATE_DSCR(r13)
@@ -392,13 +399,12 @@ kvm_no_guest:
392399
mfspr r4, SPRN_LPCR
393400
rlwimi r4, r3, 0, LPCR_PECE0 | LPCR_PECE1
394401
mtspr SPRN_LPCR, r4
395-
/* set up r3 for return */
396-
mfspr r3,SPRN_SRR1
402+
// Return SRR1 wakeup value, or 0 if we went into the guest
403+
ld r3, 32(r1)
397404
REST_NVGPRS(r1)
398-
addi r1, r1, STACK_FRAME_OVERHEAD
399-
ld r0, 16(r1)
400-
ld r5, 8(r1)
401-
ld r1, 0(r1)
405+
ld r1, 0(r1) // Switch back to caller stack
406+
ld r0, 16(r1) // Reload LR
407+
ld r5, 8(r1) // Reload CR
402408
mtlr r0
403409
mtcr r5
404410
blr

arch/powerpc/sysdev/xive/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,8 @@ static int xive_get_irqchip_state(struct irq_data *data,
945945
* interrupt to be inactive in that case.
946946
*/
947947
*state = (pq != XIVE_ESB_INVALID) && !xd->stale_p &&
948-
(xd->saved_p || !!(pq & XIVE_ESB_VAL_P));
948+
(xd->saved_p || (!!(pq & XIVE_ESB_VAL_P) &&
949+
!irqd_irq_disabled(data)));
949950
return 0;
950951
default:
951952
return -EINVAL;

0 commit comments

Comments
 (0)