Skip to content

Commit 474fcd6

Browse files
committed
KVM: PPC: Book3S HV: Sanitize special-purpose register values on guest exit
jira LE-1907 Rebuild_History Non-Buildable kernel-3.10.0-514.el7 Rebuild_CHGLOG: - [powerpc] kvm: book3s_hv: Sanitize special-purpose register values on guest exit (Thomas Huth) [1313725] Rebuild_FUZZ: 95.17% commit-author Paul Mackerras <[email protected]> commit ccec445 Thomas Huth discovered that a guest could cause a hard hang of a host CPU by setting the Instruction Authority Mask Register (IAMR) to a suitable value. It turns out that this is because when the code was added to context-switch the new special-purpose registers (SPRs) that were added in POWER8, we forgot to add code to ensure that they were restored to a sane value on guest exit. This adds code to set those registers where a bad value could compromise the execution of the host kernel to a suitable neutral value on guest exit. Cc: [email protected] # v3.14+ Fixes: b005255 Reported-by: Thomas Huth <[email protected]> Reviewed-by: David Gibson <[email protected]> Signed-off-by: Paul Mackerras <[email protected]> (cherry picked from commit ccec445) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 18626d7 commit 474fcd6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,20 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
14581458
std r6, VCPU_ACOP(r9)
14591459
stw r7, VCPU_GUEST_PID(r9)
14601460
std r8, VCPU_WORT(r9)
1461+
/*
1462+
* Restore various registers to 0, where non-zero values
1463+
* set by the guest could disrupt the host.
1464+
*/
1465+
li r0, 0
1466+
mtspr SPRN_IAMR, r0
1467+
mtspr SPRN_CIABR, r0
1468+
mtspr SPRN_DAWRX, r0
1469+
mtspr SPRN_TCSCR, r0
1470+
mtspr SPRN_WORT, r0
1471+
/* Set MMCRS to 1<<31 to freeze and disable the SPMC counters */
1472+
li r0, 1
1473+
sldi r0, r0, 31
1474+
mtspr SPRN_MMCRS, r0
14611475
8:
14621476

14631477
/* Save and reset AMR and UAMOR before turning on the MMU */

0 commit comments

Comments
 (0)