Skip to content

Commit 7ed23e1

Browse files
ozbenhmpe
authored andcommitted
powerpc: Disable HFSCR[TM] if TM is not supported
On Power8 & Power9 the early CPU inititialisation in __init_HFSCR() turns on HFSCR[TM] (Hypervisor Facility Status and Control Register [Transactional Memory]), but that doesn't take into account that TM might be disabled by CPU features, or disabled by the kernel being built with CONFIG_PPC_TRANSACTIONAL_MEM=n. So later in boot, when we have setup the CPU features, clear HSCR[TM] if the TM CPU feature has been disabled. We use CPU_FTR_TM_COMP to account for the CONFIG_PPC_TRANSACTIONAL_MEM=n case. Without this a KVM guest might try use TM, even if told not to, and cause an oops in the host kernel. Typically the oops is seen in __kvmppc_vcore_entry() and may or may not be fatal to the host, but is always bad news. In practice all shipping CPU revisions do support TM, and all host kernels we are aware of build with TM support enabled, so no one should actually be able to hit this in the wild. Fixes: 2a3563b ("powerpc: Setup in HFSCR for POWER8") Cc: [email protected] # v3.10+ Signed-off-by: Benjamin Herrenschmidt <[email protected]> Tested-by: Sam Bobroff <[email protected]> [mpe: Rewrite change log with input from Sam, add Fixes/stable] Signed-off-by: Michael Ellerman <[email protected]>
1 parent 2db2c25 commit 7ed23e1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/powerpc/kernel/setup_64.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ static void cpu_ready_for_interrupts(void)
236236
mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3);
237237
}
238238

239+
/*
240+
* Fixup HFSCR:TM based on CPU features. The bit is set by our
241+
* early asm init because at that point we haven't updated our
242+
* CPU features from firmware and device-tree. Here we have,
243+
* so let's do it.
244+
*/
245+
if (cpu_has_feature(CPU_FTR_HVMODE) && !cpu_has_feature(CPU_FTR_TM_COMP))
246+
mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) & ~HFSCR_TM);
247+
239248
/* Set IR and DR in PACA MSR */
240249
get_paca()->kernel_msr = MSR_KERNEL;
241250
}

0 commit comments

Comments
 (0)