aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2014-03-09 13:05:24 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-03-13 18:35:03 -0400
commit8f86a7373a1c8ee52d3cc64adf7f2ace13fd24ed (patch)
tree0957b3ec9695bdfd9965c916cdba9bf21810540e /arch
parent22085a66c2fab6cf9b9393c056a3600a6b4735de (diff)
x86, AMD: Convert to the new bit access MSR accessors
... and save us a bunch of code. Signed-off-by: Borislav Petkov <bp@suse.de> Link: http://lkml.kernel.org/r/1394384725-10796-3-git-send-email-bp@alien8.de Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/cpu/amd.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index c67ffa686064..b85e43a5a462 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -233,9 +233,7 @@ static void init_amd_k7(struct cpuinfo_x86 *c)
233 if (c->x86_model >= 6 && c->x86_model <= 10) { 233 if (c->x86_model >= 6 && c->x86_model <= 10) {
234 if (!cpu_has(c, X86_FEATURE_XMM)) { 234 if (!cpu_has(c, X86_FEATURE_XMM)) {
235 printk(KERN_INFO "Enabling disabled K7/SSE Support.\n"); 235 printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
236 rdmsr(MSR_K7_HWCR, l, h); 236 msr_clear_bit(MSR_K7_HWCR, 15);
237 l &= ~0x00008000;
238 wrmsr(MSR_K7_HWCR, l, h);
239 set_cpu_cap(c, X86_FEATURE_XMM); 237 set_cpu_cap(c, X86_FEATURE_XMM);
240 } 238 }
241 } 239 }
@@ -509,14 +507,8 @@ static void early_init_amd(struct cpuinfo_x86 *c)
509#endif 507#endif
510 508
511 /* F16h erratum 793, CVE-2013-6885 */ 509 /* F16h erratum 793, CVE-2013-6885 */
512 if (c->x86 == 0x16 && c->x86_model <= 0xf) { 510 if (c->x86 == 0x16 && c->x86_model <= 0xf)
513 u64 val; 511 msr_set_bit(MSR_AMD64_LS_CFG, 15);
514
515 rdmsrl(MSR_AMD64_LS_CFG, val);
516 if (!(val & BIT(15)))
517 wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
518 }
519
520} 512}
521 513
522static const int amd_erratum_383[]; 514static const int amd_erratum_383[];
@@ -536,11 +528,8 @@ static void init_amd(struct cpuinfo_x86 *c)
536 * Errata 63 for SH-B3 steppings 528 * Errata 63 for SH-B3 steppings
537 * Errata 122 for all steppings (F+ have it disabled by default) 529 * Errata 122 for all steppings (F+ have it disabled by default)
538 */ 530 */
539 if (c->x86 == 0xf) { 531 if (c->x86 == 0xf)
540 rdmsrl(MSR_K7_HWCR, value); 532 msr_set_bit(MSR_K7_HWCR, 6);
541 value |= 1 << 6;
542 wrmsrl(MSR_K7_HWCR, value);
543 }
544#endif 533#endif
545 534
546 early_init_amd(c); 535 early_init_amd(c);
@@ -623,14 +612,11 @@ static void init_amd(struct cpuinfo_x86 *c)
623 (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) && 612 (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
624 !cpu_has(c, X86_FEATURE_TOPOEXT)) { 613 !cpu_has(c, X86_FEATURE_TOPOEXT)) {
625 614
626 if (!rdmsrl_safe(0xc0011005, &value)) { 615 if (msr_set_bit(0xc0011005, 54) > 0) {
627 value |= 1ULL << 54;
628 wrmsrl_safe(0xc0011005, value);
629 rdmsrl(0xc0011005, value); 616 rdmsrl(0xc0011005, value);
630 if (value & (1ULL << 54)) { 617 if (value & BIT_64(54)) {
631 set_cpu_cap(c, X86_FEATURE_TOPOEXT); 618 set_cpu_cap(c, X86_FEATURE_TOPOEXT);
632 printk(KERN_INFO FW_INFO "CPU: Re-enabling " 619 pr_info(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n");
633 "disabled Topology Extensions Support\n");
634 } 620 }
635 } 621 }
636 } 622 }
@@ -709,19 +695,12 @@ static void init_amd(struct cpuinfo_x86 *c)
709 * Disable GART TLB Walk Errors on Fam10h. We do this here 695 * Disable GART TLB Walk Errors on Fam10h. We do this here
710 * because this is always needed when GART is enabled, even in a 696 * because this is always needed when GART is enabled, even in a
711 * kernel which has no MCE support built in. 697 * kernel which has no MCE support built in.
712 * BIOS should disable GartTlbWlk Errors themself. If 698 * BIOS should disable GartTlbWlk Errors already. If
713 * it doesn't do it here as suggested by the BKDG. 699 * it doesn't, do it here as suggested by the BKDG.
714 * 700 *
715 * Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=33012 701 * Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=33012
716 */ 702 */
717 u64 mask; 703 msr_set_bit(MSR_AMD64_MCx_MASK(4), 10);
718 int err;
719
720 err = rdmsrl_safe(MSR_AMD64_MCx_MASK(4), &mask);
721 if (err == 0) {
722 mask |= (1 << 10);
723 wrmsrl_safe(MSR_AMD64_MCx_MASK(4), mask);
724 }
725 704
726 /* 705 /*
727 * On family 10h BIOS may not have properly enabled WC+ support, 706 * On family 10h BIOS may not have properly enabled WC+ support,
@@ -733,10 +712,7 @@ static void init_amd(struct cpuinfo_x86 *c)
733 * NOTE: we want to use the _safe accessors so as not to #GP kvm 712 * NOTE: we want to use the _safe accessors so as not to #GP kvm
734 * guests on older kvm hosts. 713 * guests on older kvm hosts.
735 */ 714 */
736 715 msr_clear_bit(MSR_AMD64_BU_CFG2, 24);
737 rdmsrl_safe(MSR_AMD64_BU_CFG2, &value);
738 value &= ~(1ULL << 24);
739 wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
740 716
741 if (cpu_has_amd_erratum(c, amd_erratum_383)) 717 if (cpu_has_amd_erratum(c, amd_erratum_383))
742 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); 718 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);