Skip to content

Commit 966d713

Browse files
maheshsalpaulusmack
authored andcommitted
KVM: PPC: Book3S HV: Deliver machine check with MSR(RI=0) to guest as MCE
For the machine check interrupt that happens while we are in the guest, kvm layer attempts the recovery, and then delivers the machine check interrupt directly to the guest if recovery fails. On successful recovery we go back to normal functioning of the guest. But there can be cases where a machine check interrupt can happen with MSR(RI=0) while we are in the guest. This means MC interrupt is unrecoverable and we have to deliver a machine check to the guest since the machine check interrupt might have trashed valid values in SRR0/1. The current implementation do not handle this case, causing guest to crash with Bad kernel stack pointer instead of machine check oops message. [26281.490060] Bad kernel stack pointer 3fff9ccce5b0 at c00000000000490c [26281.490434] Oops: Bad kernel stack pointer, sig: 6 [#1] [26281.490472] SMP NR_CPUS=2048 NUMA pSeries This patch fixes this issue by checking MSR(RI=0) in KVM layer and forwarding unrecoverable interrupt to guest which then panics with proper machine check Oops message. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Acked-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 224f363 commit 966d713

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,6 @@ machine_check_realmode:
23772377
mr r3, r9 /* get vcpu pointer */
23782378
bl kvmppc_realmode_machine_check
23792379
nop
2380-
cmpdi r3, 0 /* Did we handle MCE ? */
23812380
ld r9, HSTATE_KVM_VCPU(r13)
23822381
li r12, BOOK3S_INTERRUPT_MACHINE_CHECK
23832382
/*
@@ -2390,13 +2389,18 @@ machine_check_realmode:
23902389
* The old code used to return to host for unhandled errors which
23912390
* was causing guest to hang with soft lockups inside guest and
23922391
* makes it difficult to recover guest instance.
2392+
*
2393+
* if we receive machine check with MSR(RI=0) then deliver it to
2394+
* guest as machine check causing guest to crash.
23932395
*/
2394-
ld r10, VCPU_PC(r9)
23952396
ld r11, VCPU_MSR(r9)
2397+
andi. r10, r11, MSR_RI /* check for unrecoverable exception */
2398+
beq 1f /* Deliver a machine check to guest */
2399+
ld r10, VCPU_PC(r9)
2400+
cmpdi r3, 0 /* Did we handle MCE ? */
23962401
bne 2f /* Continue guest execution. */
23972402
/* If not, deliver a machine check. SRR0/1 are already set */
2398-
li r10, BOOK3S_INTERRUPT_MACHINE_CHECK
2399-
ld r11, VCPU_MSR(r9)
2403+
1: li r10, BOOK3S_INTERRUPT_MACHINE_CHECK
24002404
bl kvmppc_msr_interrupt
24012405
2: b fast_interrupt_c_return
24022406

0 commit comments

Comments
 (0)