Skip to content

Commit 8f86a73

Browse files
suryasaimadhuH. Peter Anvin
authored andcommitted
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>
1 parent 22085a6 commit 8f86a73

1 file changed

Lines changed: 12 additions & 36 deletions

File tree

‎arch/x86/kernel/cpu/amd.c‎

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ static void init_amd_k7(struct cpuinfo_x86 *c)
233233
if (c->x86_model >= 6 && c->x86_model <= 10) {
234234
if (!cpu_has(c, X86_FEATURE_XMM)) {
235235
printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
236-
rdmsr(MSR_K7_HWCR, l, h);
237-
l &= ~0x00008000;
238-
wrmsr(MSR_K7_HWCR, l, h);
236+
msr_clear_bit(MSR_K7_HWCR, 15);
239237
set_cpu_cap(c, X86_FEATURE_XMM);
240238
}
241239
}
@@ -509,14 +507,8 @@ static void early_init_amd(struct cpuinfo_x86 *c)
509507
#endif
510508

511509
/* F16h erratum 793, CVE-2013-6885 */
512-
if (c->x86 == 0x16 && c->x86_model <= 0xf) {
513-
u64 val;
514-
515-
rdmsrl(MSR_AMD64_LS_CFG, val);
516-
if (!(val & BIT(15)))
517-
wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15));
518-
}
519-
510+
if (c->x86 == 0x16 && c->x86_model <= 0xf)
511+
msr_set_bit(MSR_AMD64_LS_CFG, 15);
520512
}
521513

522514
static const int amd_erratum_383[];
@@ -536,11 +528,8 @@ static void init_amd(struct cpuinfo_x86 *c)
536528
* Errata 63 for SH-B3 steppings
537529
* Errata 122 for all steppings (F+ have it disabled by default)
538530
*/
539-
if (c->x86 == 0xf) {
540-
rdmsrl(MSR_K7_HWCR, value);
541-
value |= 1 << 6;
542-
wrmsrl(MSR_K7_HWCR, value);
543-
}
531+
if (c->x86 == 0xf)
532+
msr_set_bit(MSR_K7_HWCR, 6);
544533
#endif
545534

546535
early_init_amd(c);
@@ -623,14 +612,11 @@ static void init_amd(struct cpuinfo_x86 *c)
623612
(c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
624613
!cpu_has(c, X86_FEATURE_TOPOEXT)) {
625614

626-
if (!rdmsrl_safe(0xc0011005, &value)) {
627-
value |= 1ULL << 54;
628-
wrmsrl_safe(0xc0011005, value);
615+
if (msr_set_bit(0xc0011005, 54) > 0) {
629616
rdmsrl(0xc0011005, value);
630-
if (value & (1ULL << 54)) {
617+
if (value & BIT_64(54)) {
631618
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
632-
printk(KERN_INFO FW_INFO "CPU: Re-enabling "
633-
"disabled Topology Extensions Support\n");
619+
pr_info(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n");
634620
}
635621
}
636622
}
@@ -709,19 +695,12 @@ static void init_amd(struct cpuinfo_x86 *c)
709695
* Disable GART TLB Walk Errors on Fam10h. We do this here
710696
* because this is always needed when GART is enabled, even in a
711697
* kernel which has no MCE support built in.
712-
* BIOS should disable GartTlbWlk Errors themself. If
713-
* it doesn't do it here as suggested by the BKDG.
698+
* BIOS should disable GartTlbWlk Errors already. If
699+
* it doesn't, do it here as suggested by the BKDG.
714700
*
715701
* Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=33012
716702
*/
717-
u64 mask;
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-
}
703+
msr_set_bit(MSR_AMD64_MCx_MASK(4), 10);
725704

726705
/*
727706
* On family 10h BIOS may not have properly enabled WC+ support,
@@ -733,10 +712,7 @@ static void init_amd(struct cpuinfo_x86 *c)
733712
* NOTE: we want to use the _safe accessors so as not to #GP kvm
734713
* guests on older kvm hosts.
735714
*/
736-
737-
rdmsrl_safe(MSR_AMD64_BU_CFG2, &value);
738-
value &= ~(1ULL << 24);
739-
wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
715+
msr_clear_bit(MSR_AMD64_BU_CFG2, 24);
740716

741717
if (cpu_has_amd_erratum(c, amd_erratum_383))
742718
set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);

0 commit comments

Comments
 (0)