aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/mcheck/mce.c
diff options
context:
space:
mode:
authorJesse Larrew <jesse.larrew@amd.com>2015-03-13 12:03:39 -0400
committerIngo Molnar <mingo@kernel.org>2015-03-23 05:16:43 -0400
commitf77ac507f893fc00c1b9ea0076f3c9e664b0f9ab (patch)
tree746da99d0fb1efe66fc2061f34d51dfb71a3a51f /arch/x86/kernel/cpu/mcheck/mce.c
parentfa45a45ca34891614789e68dfbf7ce344c9013ac (diff)
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: Jesse Larrew <jesse.larrew@amd.com> [ Drop {} braces around loop ] Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Joel Schopp <joel.schopp@amd.com> Acked-by: Tony 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.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/cpu/mcheck/mce.c')
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d760931a4546..196a1e34fe39 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1541,7 +1541,7 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
1541 if (c->x86 == 0x15 && 1541 if (c->x86 == 0x15 &&
1542 (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) { 1542 (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) {
1543 int i; 1543 int i;
1544 u64 val, hwcr; 1544 u64 hwcr;
1545 bool need_toggle; 1545 bool need_toggle;
1546 u32 msrs[] = { 1546 u32 msrs[] = {
1547 0x00000413, /* MC4_MISC0 */ 1547 0x00000413, /* MC4_MISC0 */
@@ -1556,15 +1556,9 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
1556 if (need_toggle) 1556 if (need_toggle)
1557 wrmsrl(MSR_K7_HWCR, hwcr | BIT(18)); 1557 wrmsrl(MSR_K7_HWCR, hwcr | BIT(18));
1558 1558
1559 for (i = 0; i < ARRAY_SIZE(msrs); i++) { 1559 /* Clear CntP bit safely */
1560 rdmsrl(msrs[i], val); 1560 for (i = 0; i < ARRAY_SIZE(msrs); i++)
1561 1561 msr_clear_bit(msrs[i], 62);
1562 /* CntP bit set? */
1563 if (val & BIT_64(62)) {
1564 val &= ~BIT_64(62);
1565 wrmsrl(msrs[i], val);
1566 }
1567 }
1568 1562
1569 /* restore old settings */ 1563 /* restore old settings */
1570 if (need_toggle) 1564 if (need_toggle)