Skip to content

Commit 27fd808

Browse files
committed
Merge tag 'x86-urgent-2024-04-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 fixes from Ingo Molnar: - Follow up fixes for the BHI mitigations code - Fix !SPECULATION_MITIGATIONS bug not turning off mitigations as expected - Work around an APIC emulation bug when the kernel is built with Clang and run as a SEV guest - Follow up x86 topology fixes * tag 'x86-urgent-2024-04-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpu/amd: Move TOPOEXT enablement into the topology parser x86/cpu/amd: Make the NODEID_MSR union actually work x86/cpu/amd: Make the CPUID 0x80000008 parser correct x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with CONFIG_MITIGATION_SPECTRE_BHI x86/bugs: Remove CONFIG_BHI_MITIGATION_AUTO and spectre_bhi=auto x86/bugs: Clarify that syscall hardening isn't a BHI mitigation x86/bugs: Fix BHI handling of RRSBA x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr' x86/bugs: Cache the value of MSR_IA32_ARCH_CAPABILITIES x86/bugs: Fix BHI documentation x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n x86/topology: Don't update cpu_possible_map in topo_set_cpuids() x86/bugs: Fix return type of spectre_bhi_state() x86/apic: Force native_apic_mem_read() to use the MOV instruction
2 parents c748fc3 + 7211274 commit 27fd808

File tree

11 files changed

+131
-140
lines changed

11 files changed

+131
-140
lines changed

Documentation/admin-guide/hw-vuln/spectre.rst

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,12 @@ The possible values in this file are:
439439
- System is protected by retpoline
440440
* - BHI: BHI_DIS_S
441441
- System is protected by BHI_DIS_S
442-
* - BHI: SW loop; KVM SW loop
442+
* - BHI: SW loop, KVM SW loop
443443
- System is protected by software clearing sequence
444-
* - BHI: Syscall hardening
445-
- Syscalls are hardened against BHI
446-
* - BHI: Syscall hardening; KVM: SW loop
447-
- System is protected from userspace attacks by syscall hardening; KVM is protected by software clearing sequence
444+
* - BHI: Vulnerable
445+
- System is vulnerable to BHI
446+
* - BHI: Vulnerable, KVM: SW loop
447+
- System is vulnerable; KVM is protected by software clearing sequence
448448

449449
Full mitigation might require a microcode update from the CPU
450450
vendor. When the necessary microcode is not available, the kernel will
@@ -661,18 +661,14 @@ kernel command line.
661661
spectre_bhi=
662662

663663
[X86] Control mitigation of Branch History Injection
664-
(BHI) vulnerability. Syscalls are hardened against BHI
665-
regardless of this setting. This setting affects the deployment
664+
(BHI) vulnerability. This setting affects the deployment
666665
of the HW BHI control and the SW BHB clearing sequence.
667666

668667
on
669-
unconditionally enable.
668+
(default) Enable the HW or SW mitigation as
669+
needed.
670670
off
671-
unconditionally disable.
672-
auto
673-
enable if hardware mitigation
674-
control(BHI_DIS_S) is available, otherwise
675-
enable alternate mitigation in KVM.
671+
Disable the mitigation.
676672

677673
For spectre_v2_user see Documentation/admin-guide/kernel-parameters.txt
678674

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,6 +3444,7 @@
34443444
retbleed=off [X86]
34453445
spec_rstack_overflow=off [X86]
34463446
spec_store_bypass_disable=off [X86,PPC]
3447+
spectre_bhi=off [X86]
34473448
spectre_v2_user=off [X86]
34483449
srbds=off [X86,INTEL]
34493450
ssbd=force-off [ARM64]
@@ -6064,16 +6065,13 @@
60646065
See Documentation/admin-guide/laptops/sonypi.rst
60656066

60666067
spectre_bhi= [X86] Control mitigation of Branch History Injection
6067-
(BHI) vulnerability. Syscalls are hardened against BHI
6068-
reglardless of this setting. This setting affects the
6068+
(BHI) vulnerability. This setting affects the
60696069
deployment of the HW BHI control and the SW BHB
60706070
clearing sequence.
60716071

6072-
on - unconditionally enable.
6073-
off - unconditionally disable.
6074-
auto - (default) enable hardware mitigation
6075-
(BHI_DIS_S) if available, otherwise enable
6076-
alternate mitigation in KVM.
6072+
on - (default) Enable the HW or SW mitigation
6073+
as needed.
6074+
off - Disable the mitigation.
60776075

60786076
spectre_v2= [X86,EARLY] Control mitigation of Spectre variant 2
60796077
(indirect branch speculation) vulnerability.

arch/x86/Kconfig

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,32 +2633,16 @@ config MITIGATION_RFDS
26332633
stored in floating point, vector and integer registers.
26342634
See also <file:Documentation/admin-guide/hw-vuln/reg-file-data-sampling.rst>
26352635

2636-
choice
2637-
prompt "Clear branch history"
2636+
config MITIGATION_SPECTRE_BHI
2637+
bool "Mitigate Spectre-BHB (Branch History Injection)"
26382638
depends on CPU_SUP_INTEL
2639-
default SPECTRE_BHI_ON
2639+
default y
26402640
help
26412641
Enable BHI mitigations. BHI attacks are a form of Spectre V2 attacks
26422642
where the branch history buffer is poisoned to speculatively steer
26432643
indirect branches.
26442644
See <file:Documentation/admin-guide/hw-vuln/spectre.rst>
26452645

2646-
config SPECTRE_BHI_ON
2647-
bool "on"
2648-
help
2649-
Equivalent to setting spectre_bhi=on command line parameter.
2650-
config SPECTRE_BHI_OFF
2651-
bool "off"
2652-
help
2653-
Equivalent to setting spectre_bhi=off command line parameter.
2654-
config SPECTRE_BHI_AUTO
2655-
bool "auto"
2656-
depends on BROKEN
2657-
help
2658-
Equivalent to setting spectre_bhi=auto command line parameter.
2659-
2660-
endchoice
2661-
26622646
endif
26632647

26642648
config ARCH_HAS_ADD_PAGES

arch/x86/include/asm/apic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/mpspec.h>
1414
#include <asm/msr.h>
1515
#include <asm/hardirq.h>
16+
#include <asm/io.h>
1617

1718
#define ARCH_APICTIMER_STOPS_ON_C3 1
1819

@@ -98,7 +99,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v)
9899

99100
static inline u32 native_apic_mem_read(u32 reg)
100101
{
101-
return *((volatile u32 *)(APIC_BASE + reg));
102+
return readl((void __iomem *)(APIC_BASE + reg));
102103
}
103104

104105
static inline void native_apic_mem_eoi(void)

arch/x86/kernel/apic/apic.c

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

16881688
static bool x2apic_hw_locked(void)
16891689
{
1690-
u64 ia32_cap;
1690+
u64 x86_arch_cap_msr;
16911691
u64 msr;
16921692

1693-
ia32_cap = x86_read_arch_cap_msr();
1694-
if (ia32_cap & ARCH_CAP_XAPIC_DISABLE) {
1693+
x86_arch_cap_msr = x86_read_arch_cap_msr();
1694+
if (x86_arch_cap_msr & ARCH_CAP_XAPIC_DISABLE) {
16951695
rdmsrl(MSR_IA32_XAPIC_DISABLE_STATUS, msr);
16961696
return (msr & LEGACY_XAPIC_DISABLED);
16971697
}

arch/x86/kernel/cpu/amd.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c)
535535

536536
static void early_init_amd(struct cpuinfo_x86 *c)
537537
{
538-
u64 value;
539538
u32 dummy;
540539

541540
if (c->x86 >= 0xf)
@@ -603,20 +602,6 @@ static void early_init_amd(struct cpuinfo_x86 *c)
603602

604603
early_detect_mem_encrypt(c);
605604

606-
/* Re-enable TopologyExtensions if switched off by BIOS */
607-
if (c->x86 == 0x15 &&
608-
(c->x86_model >= 0x10 && c->x86_model <= 0x6f) &&
609-
!cpu_has(c, X86_FEATURE_TOPOEXT)) {
610-
611-
if (msr_set_bit(0xc0011005, 54) > 0) {
612-
rdmsrl(0xc0011005, value);
613-
if (value & BIT_64(54)) {
614-
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
615-
pr_info_once(FW_INFO "CPU: Re-enabling disabled Topology Extensions Support.\n");
616-
}
617-
}
618-
}
619-
620605
if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_IBPB_BRTYPE)) {
621606
if (c->x86 == 0x17 && boot_cpu_has(X86_FEATURE_AMD_IBPB))
622607
setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE);

0 commit comments

Comments
 (0)