提交 f77ac507 编写于 作者: J Jesse Larrew 提交者: Ingo Molnar

x86/mce: Use safe MSR accesses for AMD quirk

Certain MSRs are only relevant to a kernel in host mode, and kvm had
chosen not to implement these MSRs at all for guests. If a guest kernel
ever tried to access these MSRs, the result was a general protection
fault.

KVM will be separately patched to return 0 when these MSRs are read,
and this patch ensures that MSR accesses are tolerant of exceptions.
Signed-off-by: NJesse Larrew <jesse.larrew@amd.com>
[ Drop {} braces around loop ]
Signed-off-by: NBorislav Petkov <bp@suse.de>
Reviewed-by: NJoel Schopp <joel.schopp@amd.com>
Acked-by: NTony Luck <tony.luck@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-edac@vger.kernel.org
Link: http://lkml.kernel.org/r/1426262619-5016-1-git-send-email-jesse.larrew@amd.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 fa45a45c
...@@ -1541,7 +1541,7 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) ...@@ -1541,7 +1541,7 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
if (c->x86 == 0x15 && if (c->x86 == 0x15 &&
(c->x86_model >= 0x10 && c->x86_model <= 0x1f)) { (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) {
int i; int i;
u64 val, hwcr; u64 hwcr;
bool need_toggle; bool need_toggle;
u32 msrs[] = { u32 msrs[] = {
0x00000413, /* MC4_MISC0 */ 0x00000413, /* MC4_MISC0 */
...@@ -1556,15 +1556,9 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) ...@@ -1556,15 +1556,9 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
if (need_toggle) if (need_toggle)
wrmsrl(MSR_K7_HWCR, hwcr | BIT(18)); wrmsrl(MSR_K7_HWCR, hwcr | BIT(18));
for (i = 0; i < ARRAY_SIZE(msrs); i++) { /* Clear CntP bit safely */
rdmsrl(msrs[i], val); for (i = 0; i < ARRAY_SIZE(msrs); i++)
msr_clear_bit(msrs[i], 62);
/* CntP bit set? */
if (val & BIT_64(62)) {
val &= ~BIT_64(62);
wrmsrl(msrs[i], val);
}
}
/* restore old settings */ /* restore old settings */
if (need_toggle) if (need_toggle)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册