Skip to content

Commit c83e35f

Browse files
Ingo Molnargregkh
authored andcommitted
x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr'
commit d048573 upstream. So we are using the 'ia32_cap' value in a number of places, which got its name from MSR_IA32_ARCH_CAPABILITIES MSR register. But there's very little 'IA32' about it - this isn't 32-bit only code, nor does it originate from there, it's just a historic quirk that many Intel MSR names are prefixed with IA32_. This is already clear from the helper method around the MSR: x86_read_arch_cap_msr(), which doesn't have the IA32 prefix. So rename 'ia32_cap' to 'x86_arch_cap_msr' to be consistent with its role and with the naming of the helper function. Signed-off-by: Ingo Molnar <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Nikolay Borisov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/9592a18a814368e75f8f4b9d74d3883aa4fd1eaf.1712813475.git.jpoimboe@kernel.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bdbbe95 commit c83e35f

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,11 +1724,11 @@ static int x2apic_state;
17241724

17251725
static bool x2apic_hw_locked(void)
17261726
{
1727-
u64 ia32_cap;
1727+
u64 x86_arch_cap_msr;
17281728
u64 msr;
17291729

1730-
ia32_cap = x86_read_arch_cap_msr();
1731-
if (ia32_cap & ARCH_CAP_XAPIC_DISABLE) {
1730+
x86_arch_cap_msr = x86_read_arch_cap_msr();
1731+
if (x86_arch_cap_msr & ARCH_CAP_XAPIC_DISABLE) {
17321732
rdmsrl(MSR_IA32_XAPIC_DISABLE_STATUS, msr);
17331733
return (msr & LEGACY_XAPIC_DISABLED);
17341734
}

arch/x86/kernel/cpu/bugs.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(x86_spec_ctrl_current);
6161
u64 x86_pred_cmd __ro_after_init = PRED_CMD_IBPB;
6262
EXPORT_SYMBOL_GPL(x86_pred_cmd);
6363

64-
static u64 __ro_after_init ia32_cap;
64+
static u64 __ro_after_init x86_arch_cap_msr;
6565

6666
static DEFINE_MUTEX(spec_ctrl_mutex);
6767

@@ -146,7 +146,7 @@ void __init cpu_select_mitigations(void)
146146
x86_spec_ctrl_base &= ~SPEC_CTRL_MITIGATIONS_MASK;
147147
}
148148

149-
ia32_cap = x86_read_arch_cap_msr();
149+
x86_arch_cap_msr = x86_read_arch_cap_msr();
150150

151151
/* Select the proper CPU mitigations before patching alternatives: */
152152
spectre_v1_select_mitigation();
@@ -343,8 +343,8 @@ static void __init taa_select_mitigation(void)
343343
* On MDS_NO=1 CPUs if ARCH_CAP_TSX_CTRL_MSR is not set, microcode
344344
* update is required.
345345
*/
346-
if ( (ia32_cap & ARCH_CAP_MDS_NO) &&
347-
!(ia32_cap & ARCH_CAP_TSX_CTRL_MSR))
346+
if ( (x86_arch_cap_msr & ARCH_CAP_MDS_NO) &&
347+
!(x86_arch_cap_msr & ARCH_CAP_TSX_CTRL_MSR))
348348
taa_mitigation = TAA_MITIGATION_UCODE_NEEDED;
349349

350350
/*
@@ -434,7 +434,7 @@ static void __init mmio_select_mitigation(void)
434434
* be propagated to uncore buffers, clearing the Fill buffers on idle
435435
* is required irrespective of SMT state.
436436
*/
437-
if (!(ia32_cap & ARCH_CAP_FBSDP_NO))
437+
if (!(x86_arch_cap_msr & ARCH_CAP_FBSDP_NO))
438438
static_branch_enable(&mds_idle_clear);
439439

440440
/*
@@ -444,10 +444,10 @@ static void __init mmio_select_mitigation(void)
444444
* FB_CLEAR or by the presence of both MD_CLEAR and L1D_FLUSH on MDS
445445
* affected systems.
446446
*/
447-
if ((ia32_cap & ARCH_CAP_FB_CLEAR) ||
447+
if ((x86_arch_cap_msr & ARCH_CAP_FB_CLEAR) ||
448448
(boot_cpu_has(X86_FEATURE_MD_CLEAR) &&
449449
boot_cpu_has(X86_FEATURE_FLUSH_L1D) &&
450-
!(ia32_cap & ARCH_CAP_MDS_NO)))
450+
!(x86_arch_cap_msr & ARCH_CAP_MDS_NO)))
451451
mmio_mitigation = MMIO_MITIGATION_VERW;
452452
else
453453
mmio_mitigation = MMIO_MITIGATION_UCODE_NEEDED;
@@ -505,7 +505,7 @@ static void __init rfds_select_mitigation(void)
505505
if (rfds_mitigation == RFDS_MITIGATION_OFF)
506506
return;
507507

508-
if (ia32_cap & ARCH_CAP_RFDS_CLEAR)
508+
if (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR)
509509
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
510510
else
511511
rfds_mitigation = RFDS_MITIGATION_UCODE_NEEDED;
@@ -664,7 +664,7 @@ static void __init srbds_select_mitigation(void)
664664
* are only exposed to SRBDS when TSX is enabled or when CPU is affected
665665
* by Processor MMIO Stale Data vulnerability.
666666
*/
667-
if ((ia32_cap & ARCH_CAP_MDS_NO) && !boot_cpu_has(X86_FEATURE_RTM) &&
667+
if ((x86_arch_cap_msr & ARCH_CAP_MDS_NO) && !boot_cpu_has(X86_FEATURE_RTM) &&
668668
!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))
669669
srbds_mitigation = SRBDS_MITIGATION_TSX_OFF;
670670
else if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
@@ -807,7 +807,7 @@ static void __init gds_select_mitigation(void)
807807
/* Will verify below that mitigation _can_ be disabled */
808808

809809
/* No microcode */
810-
if (!(ia32_cap & ARCH_CAP_GDS_CTRL)) {
810+
if (!(x86_arch_cap_msr & ARCH_CAP_GDS_CTRL)) {
811811
if (gds_mitigation == GDS_MITIGATION_FORCE) {
812812
/*
813813
* This only needs to be done on the boot CPU so do it
@@ -1540,14 +1540,14 @@ static enum spectre_v2_mitigation __init spectre_v2_select_retpoline(void)
15401540
/* Disable in-kernel use of non-RSB RET predictors */
15411541
static void __init spec_ctrl_disable_kernel_rrsba(void)
15421542
{
1543-
u64 ia32_cap;
1543+
u64 x86_arch_cap_msr;
15441544

15451545
if (!boot_cpu_has(X86_FEATURE_RRSBA_CTRL))
15461546
return;
15471547

1548-
ia32_cap = x86_read_arch_cap_msr();
1548+
x86_arch_cap_msr = x86_read_arch_cap_msr();
15491549

1550-
if (ia32_cap & ARCH_CAP_RRSBA) {
1550+
if (x86_arch_cap_msr & ARCH_CAP_RRSBA) {
15511551
x86_spec_ctrl_base |= SPEC_CTRL_RRSBA_DIS_S;
15521552
update_spec_ctrl(x86_spec_ctrl_base);
15531553
}
@@ -1915,7 +1915,7 @@ static void update_mds_branch_idle(void)
19151915
if (sched_smt_active()) {
19161916
static_branch_enable(&mds_idle_clear);
19171917
} else if (mmio_mitigation == MMIO_MITIGATION_OFF ||
1918-
(ia32_cap & ARCH_CAP_FBSDP_NO)) {
1918+
(x86_arch_cap_msr & ARCH_CAP_FBSDP_NO)) {
19191919
static_branch_disable(&mds_idle_clear);
19201920
}
19211921
}
@@ -2809,7 +2809,7 @@ static const char *spectre_bhi_state(void)
28092809
else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_LOOP))
28102810
return "; BHI: SW loop, KVM: SW loop";
28112811
else if (boot_cpu_has(X86_FEATURE_RETPOLINE) &&
2812-
!(ia32_cap & ARCH_CAP_RRSBA))
2812+
!(x86_arch_cap_msr & ARCH_CAP_RRSBA))
28132813
return "; BHI: Retpoline";
28142814
else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT))
28152815
return "; BHI: Syscall hardening, KVM: SW loop";

arch/x86/kernel/cpu/common.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,33 +1329,33 @@ static bool __init cpu_matches(const struct x86_cpu_id *table, unsigned long whi
13291329

13301330
u64 x86_read_arch_cap_msr(void)
13311331
{
1332-
u64 ia32_cap = 0;
1332+
u64 x86_arch_cap_msr = 0;
13331333

13341334
if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES))
1335-
rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap);
1335+
rdmsrl(MSR_IA32_ARCH_CAPABILITIES, x86_arch_cap_msr);
13361336

1337-
return ia32_cap;
1337+
return x86_arch_cap_msr;
13381338
}
13391339

1340-
static bool arch_cap_mmio_immune(u64 ia32_cap)
1340+
static bool arch_cap_mmio_immune(u64 x86_arch_cap_msr)
13411341
{
1342-
return (ia32_cap & ARCH_CAP_FBSDP_NO &&
1343-
ia32_cap & ARCH_CAP_PSDP_NO &&
1344-
ia32_cap & ARCH_CAP_SBDR_SSDP_NO);
1342+
return (x86_arch_cap_msr & ARCH_CAP_FBSDP_NO &&
1343+
x86_arch_cap_msr & ARCH_CAP_PSDP_NO &&
1344+
x86_arch_cap_msr & ARCH_CAP_SBDR_SSDP_NO);
13451345
}
13461346

1347-
static bool __init vulnerable_to_rfds(u64 ia32_cap)
1347+
static bool __init vulnerable_to_rfds(u64 x86_arch_cap_msr)
13481348
{
13491349
/* The "immunity" bit trumps everything else: */
1350-
if (ia32_cap & ARCH_CAP_RFDS_NO)
1350+
if (x86_arch_cap_msr & ARCH_CAP_RFDS_NO)
13511351
return false;
13521352

13531353
/*
13541354
* VMMs set ARCH_CAP_RFDS_CLEAR for processors not in the blacklist to
13551355
* indicate that mitigation is needed because guest is running on a
13561356
* vulnerable hardware or may migrate to such hardware:
13571357
*/
1358-
if (ia32_cap & ARCH_CAP_RFDS_CLEAR)
1358+
if (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR)
13591359
return true;
13601360

13611361
/* Only consult the blacklist when there is no enumeration: */
@@ -1364,11 +1364,11 @@ static bool __init vulnerable_to_rfds(u64 ia32_cap)
13641364

13651365
static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
13661366
{
1367-
u64 ia32_cap = x86_read_arch_cap_msr();
1367+
u64 x86_arch_cap_msr = x86_read_arch_cap_msr();
13681368

13691369
/* Set ITLB_MULTIHIT bug if cpu is not in the whitelist and not mitigated */
13701370
if (!cpu_matches(cpu_vuln_whitelist, NO_ITLB_MULTIHIT) &&
1371-
!(ia32_cap & ARCH_CAP_PSCHANGE_MC_NO))
1371+
!(x86_arch_cap_msr & ARCH_CAP_PSCHANGE_MC_NO))
13721372
setup_force_cpu_bug(X86_BUG_ITLB_MULTIHIT);
13731373

13741374
if (cpu_matches(cpu_vuln_whitelist, NO_SPECULATION))
@@ -1380,23 +1380,23 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
13801380
setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
13811381

13821382
if (!cpu_matches(cpu_vuln_whitelist, NO_SSB) &&
1383-
!(ia32_cap & ARCH_CAP_SSB_NO) &&
1383+
!(x86_arch_cap_msr & ARCH_CAP_SSB_NO) &&
13841384
!cpu_has(c, X86_FEATURE_AMD_SSB_NO))
13851385
setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
13861386

13871387
/*
13881388
* AMD's AutoIBRS is equivalent to Intel's eIBRS - use the Intel feature
13891389
* flag and protect from vendor-specific bugs via the whitelist.
13901390
*/
1391-
if ((ia32_cap & ARCH_CAP_IBRS_ALL) || cpu_has(c, X86_FEATURE_AUTOIBRS)) {
1391+
if ((x86_arch_cap_msr & ARCH_CAP_IBRS_ALL) || cpu_has(c, X86_FEATURE_AUTOIBRS)) {
13921392
setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
13931393
if (!cpu_matches(cpu_vuln_whitelist, NO_EIBRS_PBRSB) &&
1394-
!(ia32_cap & ARCH_CAP_PBRSB_NO))
1394+
!(x86_arch_cap_msr & ARCH_CAP_PBRSB_NO))
13951395
setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB);
13961396
}
13971397

13981398
if (!cpu_matches(cpu_vuln_whitelist, NO_MDS) &&
1399-
!(ia32_cap & ARCH_CAP_MDS_NO)) {
1399+
!(x86_arch_cap_msr & ARCH_CAP_MDS_NO)) {
14001400
setup_force_cpu_bug(X86_BUG_MDS);
14011401
if (cpu_matches(cpu_vuln_whitelist, MSBDS_ONLY))
14021402
setup_force_cpu_bug(X86_BUG_MSBDS_ONLY);
@@ -1415,9 +1415,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14151415
* TSX_CTRL check alone is not sufficient for cases when the microcode
14161416
* update is not present or running as guest that don't get TSX_CTRL.
14171417
*/
1418-
if (!(ia32_cap & ARCH_CAP_TAA_NO) &&
1418+
if (!(x86_arch_cap_msr & ARCH_CAP_TAA_NO) &&
14191419
(cpu_has(c, X86_FEATURE_RTM) ||
1420-
(ia32_cap & ARCH_CAP_TSX_CTRL_MSR)))
1420+
(x86_arch_cap_msr & ARCH_CAP_TSX_CTRL_MSR)))
14211421
setup_force_cpu_bug(X86_BUG_TAA);
14221422

14231423
/*
@@ -1443,15 +1443,15 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14431443
* Set X86_BUG_MMIO_UNKNOWN for CPUs that are neither in the blacklist,
14441444
* nor in the whitelist and also don't enumerate MSR ARCH_CAP MMIO bits.
14451445
*/
1446-
if (!arch_cap_mmio_immune(ia32_cap)) {
1446+
if (!arch_cap_mmio_immune(x86_arch_cap_msr)) {
14471447
if (cpu_matches(cpu_vuln_blacklist, MMIO))
14481448
setup_force_cpu_bug(X86_BUG_MMIO_STALE_DATA);
14491449
else if (!cpu_matches(cpu_vuln_whitelist, NO_MMIO))
14501450
setup_force_cpu_bug(X86_BUG_MMIO_UNKNOWN);
14511451
}
14521452

14531453
if (!cpu_has(c, X86_FEATURE_BTC_NO)) {
1454-
if (cpu_matches(cpu_vuln_blacklist, RETBLEED) || (ia32_cap & ARCH_CAP_RSBA))
1454+
if (cpu_matches(cpu_vuln_blacklist, RETBLEED) || (x86_arch_cap_msr & ARCH_CAP_RSBA))
14551455
setup_force_cpu_bug(X86_BUG_RETBLEED);
14561456
}
14571457

@@ -1469,15 +1469,15 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14691469
* disabling AVX2. The only way to do this in HW is to clear XCR0[2],
14701470
* which means that AVX will be disabled.
14711471
*/
1472-
if (cpu_matches(cpu_vuln_blacklist, GDS) && !(ia32_cap & ARCH_CAP_GDS_NO) &&
1472+
if (cpu_matches(cpu_vuln_blacklist, GDS) && !(x86_arch_cap_msr & ARCH_CAP_GDS_NO) &&
14731473
boot_cpu_has(X86_FEATURE_AVX))
14741474
setup_force_cpu_bug(X86_BUG_GDS);
14751475

1476-
if (vulnerable_to_rfds(ia32_cap))
1476+
if (vulnerable_to_rfds(x86_arch_cap_msr))
14771477
setup_force_cpu_bug(X86_BUG_RFDS);
14781478

14791479
/* When virtualized, eIBRS could be hidden, assume vulnerable */
1480-
if (!(ia32_cap & ARCH_CAP_BHI_NO) &&
1480+
if (!(x86_arch_cap_msr & ARCH_CAP_BHI_NO) &&
14811481
!cpu_matches(cpu_vuln_whitelist, NO_BHI) &&
14821482
(boot_cpu_has(X86_FEATURE_IBRS_ENHANCED) ||
14831483
boot_cpu_has(X86_FEATURE_HYPERVISOR)))
@@ -1487,7 +1487,7 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14871487
return;
14881488

14891489
/* Rogue Data Cache Load? No! */
1490-
if (ia32_cap & ARCH_CAP_RDCL_NO)
1490+
if (x86_arch_cap_msr & ARCH_CAP_RDCL_NO)
14911491
return;
14921492

14931493
setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);

0 commit comments

Comments
 (0)