SRSO fixes/cleanups
Subsystems (5)
Josh Poimboeuf
maintainerv3 cover SRSO fixes/cleanups
v3:
- drop kvm patches (to be picked up by Sean)
- fix "no microcode, no microcode" printk
- fix "Safe Ret" capitalization in documentation
- fix chopped line in commit log
- drop "x86/srso: Remove redundant X86_FEATURE_ENTRY_IBPB check" patch
Josh Poimboeuf (20):
x86/srso: Fix srso_show_state() side effect
x86/srso: Set CPUID feature bits independently of bug or mitigation
status
x86/srso: Don't probe microcode in a guest
x86/srso: Fix SBPB enablement for spec_rstack_overflow=off x86/srso: Fix SBPB enablement for (possible) future fixed HW x86/srso: Print actual mitigation if requested mitigation isn't
possible
x86/srso: Print mitigation for retbleed IBPB case x86/srso: Fix vulnerability reporting for missing microcode x86/srso: Fix unret validation dependencies x86/alternatives: Remove faulty optimization
x86/srso: Improve i-cache locality for alias mitigation x86/srso: Unexport untraining functions
x86/srso: Remove 'pred_cmd' label
x86/bugs: Remove default case for fully switched enums x86/srso: Move retbleed IBPB check into existing 'has_microcode' code
block
x86/srso: Disentangle rethunk-dependent options x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros x86/retpoline: Remove .text..__x86.return_thunk section x86/nospec: Refactor UNTRAIN_RET[_*]
x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
Documentation/admin-guide/hw-vuln/srso.rst | 24 ++- arch/x86/include/asm/nospec-branch.h | 69 ++++----- arch/x86/include/asm/processor.h | 2 - arch/x86/kernel/alternative.c | 8 - arch/x86/kernel/cpu/amd.c | 28 ++-- arch/x86/kernel/cpu/bugs.c | 102 ++++++------ arch/x86/kernel/vmlinux.lds.S | 10 +- arch/x86/lib/retpoline.S | 171 +++++++++++---------- include/linux/objtool.h | 3 +- scripts/Makefile.vmlinux_o | 3 +- 10 files changed, 201 insertions(+), 219 deletions(-)
Signature · 1 line
2.41.0
Josh Poimboeuf
maintainerPATCH v3 1/20 x86/srso: Fix srso_show_state() side effect
Reading the 'spec_rstack_overflow' sysfs file can trigger an unnecessary MSR write, and possibly even a (handled) exception if the microcode hasn't been updated.
Avoid all that by just checking X86_FEATURE_IBPB_BRTYPE instead, which gets set by srso_select_mitigation() if the updated microcode exists.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2717,7 +2717,7 @@ static ssize_t srso_show_state(char *buf)return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], - (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" )); +boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); }static ssize_t gds_show_state (char *buf)
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Fix srso_show_state() side effect
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 272386dcbc4d775a0508dc8c185c248fec56c238 Gitweb: https://git.kernel.org/tip/272386dcbc4d775a0508dc8c185c248fec56c238 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:45 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Fix srso_show_state() side effect
Reading the 'spec_rstack_overflow' sysfs file can trigger an unnecessary MSR write, and possibly even a (handled) exception if the microcode hasn't been updated.
Avoid all that by just checking X86_FEATURE_IBPB_BRTYPE instead, which gets set by srso_select_mitigation() if the updated microcode exists.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2717,7 +2717,7 @@ static ssize_t srso_show_state(char *buf)return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], - (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" )); +boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); }static ssize_t gds_show_state (char *buf)
[tip: x86/urgent] x86/srso: Fix srso_show_state() side effect
In reply to Josh PoimboeufThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: a8cf700c17d9ca6cb8ee7dc5c9330dbac3948237 Gitweb: https://git.kernel.org/tip/a8cf700c17d9ca6cb8ee7dc5c9330dbac3948237 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:45 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 19 Sep 2023 10:53:34 +02:00
x86/srso: Fix srso_show_state() side effect
Reading the 'spec_rstack_overflow' sysfs file can trigger an unnecessary MSR write, and possibly even a (handled) exception if the microcode hasn't been updated.
Avoid all that by just checking X86_FEATURE_IBPB_BRTYPE instead, which gets set by srso_select_mitigation() if the updated microcode exists.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2717,7 +2717,7 @@ static ssize_t srso_show_state(char *buf)return sysfs_emit (buf,"%s%s\n" , srso_strings[srso_mitigation], - (cpu_has_ibpb_brtype_microcode () ?"" :", no microcode" )); +boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); }static ssize_t gds_show_state (char *buf)
Josh Poimboeuf
maintainerPATCH v3 2/20 x86/srso: Set CPUID feature bits independently of bug or mitigation status
In reply to Josh PoimboeufBooting with mitigations=off incorrectly prevents the X86_FEATURE_{IBPB_BRTYPE,SBPB} CPUID bits from getting set.
Also, future CPUs without X86_BUG_SRSO might still have IBPB with branch type prediction flushing, in which case SBPB should be used instead of IBPB. The current code doesn't allow for that.
Also, cpu_has_ibpb_brtype_microcode() has some surprising side effects and the setting of these feature bits really doesn't belong in the mitigation code anyway. Move it to earlier.
--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/cpu/amd.c | 28 +++++++++------------------- arch/x86/kernel/cpu/bugs.c | 13 +------------ 3 files changed, 10 insertions(+), 33 deletions(-)
arch/x86/include/asm/processor.h +0 -2
@@ -676,12 +676,10 @@ extern u16 get_llc_id(unsigned int cpu);#ifdef CONFIG_CPU_SUP_AMD extern u32 amd_get_nodes_per_socket (void );extern u32 amd_get_highest_perf (void ); -extern bool cpu_has_ibpb_brtype_microcode (void );extern void amd_clear_divider (void );#else static inline u32 amd_get_nodes_per_socket (void ) {return 0 ; }static inline u32 amd_get_highest_perf (void ) {return 0 ; } -static inline bool cpu_has_ibpb_brtype_microcode (void ) {return false; }static inline void amd_clear_divider (void ) { }#endif
arch/x86/kernel/cpu/amd.c +9 -19
@@ -766,6 +766,15 @@ static void early_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_TOPOEXT )) smp_num_siblings = ((cpuid_ebx (0x8000001e ) >>8 ) &0xff ) +1 ; + +if (!cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) { +if (c->x86 ==0x17 &&boot_cpu_has (X86_FEATURE_AMD_IBPB )) +setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); +else if (c->x86 >=0x19 && !wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) { +setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); +setup_force_cpu_cap (X86_FEATURE_SBPB ); + } + } }static void init_amd_k8 (struct cpuinfo_x86 *c)
@@ -1301,25 +1310,6 @@ void amd_check_microcode(void)on_each_cpu (zenbleed_check_cpu,NULL ,1 ); } -bool cpu_has_ibpb_brtype_microcode (void ) -{ -switch (boot_cpu_data.x86) { -/* Zen1/2 IBPB flushes branch type predictions too. */ -case 0x17 : -return boot_cpu_has (X86_FEATURE_AMD_IBPB ); -case 0x19 : -/* Poke the MSR bit on Zen3/4 to check its presence. */ -if (!wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) { -setup_force_cpu_cap (X86_FEATURE_SBPB ); -return true; - }else { -return false; - } -default : -return false; - } -} -/* * Issue a DIV 0/1 insn to clear any division data from previous DIV * operations.
arch/x86/kernel/cpu/bugs.c +1 -12
@@ -2404,26 +2404,15 @@ early_param("spec_rstack_overflow", srso_parse_cmdline);static void __init srso_select_mitigation (void ) { -bool has_microcode; +bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE );if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -/* -* The first check is for the kernel running as a guest in order -* for guests to verify whether IBPB is a viable mitigation. -*/ - has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ||cpu_has_ibpb_brtype_microcode ();if (!has_microcode) {pr_warn ("IBPB-extending microcode not applied!\n" );pr_warn (SRSO_NOTICE ); }else { -/* -* Enable the synthetic (even if in a real CPUID leaf) -* flags for guests. -*/ -setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); -/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied.
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Set CPUID feature bits independently of bug or mitigation status
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 2ab15814d800b8c4526eda2750bf33b58555b86b Gitweb: https://git.kernel.org/tip/2ab15814d800b8c4526eda2750bf33b58555b86b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:46 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Set CPUID feature bits independently of bug or mitigation status
Booting with mitigations=off incorrectly prevents the X86_FEATURE_{IBPB_BRTYPE,SBPB} CPUID bits from getting set.
Also, future CPUs without X86_BUG_SRSO might still have IBPB with branch type prediction flushing, in which case SBPB should be used instead of IBPB. The current code doesn't allow for that.
Also, cpu_has_ibpb_brtype_microcode() has some surprising side effects and the setting of these feature bits really doesn't belong in the mitigation code anyway. Move it to earlier.
--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/cpu/amd.c | 28 +++++++++------------------- arch/x86/kernel/cpu/bugs.c | 13 +------------ 3 files changed, 10 insertions(+), 33 deletions(-)
arch/x86/include/asm/processor.h +0 -2
@@ -683,13 +683,11 @@ extern u16 get_llc_id(unsigned int cpu);#ifdef CONFIG_CPU_SUP_AMD extern u32 amd_get_nodes_per_socket (void );extern u32 amd_get_highest_perf (void ); -extern bool cpu_has_ibpb_brtype_microcode (void );extern void amd_clear_divider (void );extern void amd_check_microcode (void );#else static inline u32 amd_get_nodes_per_socket (void ) {return 0 ; }static inline u32 amd_get_highest_perf (void ) {return 0 ; } -static inline bool cpu_has_ibpb_brtype_microcode (void ) {return false; }static inline void amd_clear_divider (void ) { }static inline void amd_check_microcode (void ) { }#endif
arch/x86/kernel/cpu/amd.c +9 -19
@@ -766,6 +766,15 @@ static void early_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_TOPOEXT )) smp_num_siblings = ((cpuid_ebx (0x8000001e ) >>8 ) &0xff ) +1 ; + +if (!cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) { +if (c->x86 ==0x17 &&boot_cpu_has (X86_FEATURE_AMD_IBPB )) +setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); +else if (c->x86 >=0x19 && !wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) { +setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); +setup_force_cpu_cap (X86_FEATURE_SBPB ); + } + } }static void init_amd_k8 (struct cpuinfo_x86 *c)
@@ -1301,25 +1310,6 @@ void amd_check_microcode(void)on_each_cpu (zenbleed_check_cpu,NULL ,1 ); } -bool cpu_has_ibpb_brtype_microcode (void ) -{ -switch (boot_cpu_data.x86) { -/* Zen1/2 IBPB flushes branch type predictions too. */ -case 0x17 : -return boot_cpu_has (X86_FEATURE_AMD_IBPB ); -case 0x19 : -/* Poke the MSR bit on Zen3/4 to check its presence. */ -if (!wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) { -setup_force_cpu_cap (X86_FEATURE_SBPB ); -return true; - }else { -return false; - } -default : -return false; - } -} -/* * Issue a DIV 0/1 insn to clear any division data from previous DIV * operations.
arch/x86/kernel/cpu/bugs.c +1 -12
@@ -2404,27 +2404,16 @@ early_param("spec_rstack_overflow", srso_parse_cmdline);static void __init srso_select_mitigation (void ) { -bool has_microcode; +bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE );if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -/* -* The first check is for the kernel running as a guest in order -* for guests to verify whether IBPB is a viable mitigation. -*/ - has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ||cpu_has_ibpb_brtype_microcode ();if (!has_microcode) {pr_warn ("IBPB-extending microcode not applied!\n" );pr_warn (SRSO_NOTICE ); }else {/* -* Enable the synthetic (even if in a real CPUID leaf) -* flags for guests. -*/ -setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); - -/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */
[tip: x86/urgent] x86/srso: Set CPUID feature bits independently of bug or mitigation status
In reply to Josh PoimboeufThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 91857ae20303cc98ed36720d9868fcd604a2ee75 Gitweb: https://git.kernel.org/tip/91857ae20303cc98ed36720d9868fcd604a2ee75 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:46 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 19 Sep 2023 10:54:07 +02:00
x86/srso: Set CPUID feature bits independently of bug or mitigation status
Booting with mitigations=off incorrectly prevents the X86_FEATURE_{IBPB_BRTYPE,SBPB} CPUID bits from getting set.
Also, future CPUs without X86_BUG_SRSO might still have IBPB with branch type prediction flushing, in which case SBPB should be used instead of IBPB. The current code doesn't allow for that.
Also, cpu_has_ibpb_brtype_microcode() has some surprising side effects and the setting of these feature bits really doesn't belong in the mitigation code anyway. Move it to earlier.
--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/cpu/amd.c | 28 +++++++++------------------- arch/x86/kernel/cpu/bugs.c | 13 +------------ 3 files changed, 10 insertions(+), 33 deletions(-)
arch/x86/include/asm/processor.h +0 -2
@@ -683,13 +683,11 @@ extern u16 get_llc_id(unsigned int cpu);#ifdef CONFIG_CPU_SUP_AMD extern u32 amd_get_nodes_per_socket (void );extern u32 amd_get_highest_perf (void ); -extern bool cpu_has_ibpb_brtype_microcode (void );extern void amd_clear_divider (void );extern void amd_check_microcode (void );#else static inline u32 amd_get_nodes_per_socket (void ) {return 0 ; }static inline u32 amd_get_highest_perf (void ) {return 0 ; } -static inline bool cpu_has_ibpb_brtype_microcode (void ) {return false; }static inline void amd_clear_divider (void ) { }static inline void amd_check_microcode (void ) { }#endif
arch/x86/kernel/cpu/amd.c +9 -19
@@ -766,6 +766,15 @@ static void early_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_TOPOEXT )) smp_num_siblings = ((cpuid_ebx (0x8000001e ) >>8 ) &0xff ) +1 ; + +if (!cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) { +if (c->x86 ==0x17 &&boot_cpu_has (X86_FEATURE_AMD_IBPB )) +setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); +else if (c->x86 >=0x19 && !wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) { +setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); +setup_force_cpu_cap (X86_FEATURE_SBPB ); + } + } }static void init_amd_k8 (struct cpuinfo_x86 *c)
@@ -1301,25 +1310,6 @@ void amd_check_microcode(void)on_each_cpu (zenbleed_check_cpu,NULL ,1 ); } -bool cpu_has_ibpb_brtype_microcode (void ) -{ -switch (boot_cpu_data.x86) { -/* Zen1/2 IBPB flushes branch type predictions too. */ -case 0x17 : -return boot_cpu_has (X86_FEATURE_AMD_IBPB ); -case 0x19 : -/* Poke the MSR bit on Zen3/4 to check its presence. */ -if (!wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) { -setup_force_cpu_cap (X86_FEATURE_SBPB ); -return true; - }else { -return false; - } -default : -return false; - } -} -/* * Issue a DIV 0/1 insn to clear any division data from previous DIV * operations.
arch/x86/kernel/cpu/bugs.c +1 -12
@@ -2404,27 +2404,16 @@ early_param("spec_rstack_overflow", srso_parse_cmdline);static void __init srso_select_mitigation (void ) { -bool has_microcode; +bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE );if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -/* -* The first check is for the kernel running as a guest in order -* for guests to verify whether IBPB is a viable mitigation. -*/ - has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ||cpu_has_ibpb_brtype_microcode ();if (!has_microcode) {pr_warn ("IBPB-extending microcode not applied!\n" );pr_warn (SRSO_NOTICE ); }else {/* -* Enable the synthetic (even if in a real CPUID leaf) -* flags for guests. -*/ -setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE ); - -/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. */
Josh Poimboeuf
maintainerPATCH v3 3/20 x86/srso: Don't probe microcode in a guest
In reply to Josh PoimboeufTo support live migration, the hypervisor sets the "lowest common denominator" of features. Probing the microcode isn't allowed because any detected features might go away after a migration.
As Andy Cooper states:
"Linux must not probe microcode when virtualised. What it may see instantaneously on boot (owing to MSR_PRED_CMD being fully passed through) is not accurate for the lifetime of the VM."
Rely on the hypervisor to set the needed IBPB_BRTYPE and SBPB bits.
--- arch/x86/kernel/cpu/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +1 -1
@@ -767,7 +767,7 @@ static void early_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_TOPOEXT )) smp_num_siblings = ((cpuid_ebx (0x8000001e ) >>8 ) &0xff ) +1 ; -if (!cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) { +if (!cpu_has (c,X86_FEATURE_HYPERVISOR ) && !cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) {if (c->x86 ==0x17 &&boot_cpu_has (X86_FEATURE_AMD_IBPB ))setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE );else if (c->x86 >=0x19 && !wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) {
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Don't probe microcode in a guest
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 7e0a668e6a292d4b47e638078a21736bb3a73ffb Gitweb: https://git.kernel.org/tip/7e0a668e6a292d4b47e638078a21736bb3a73ffb Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:47 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Don't probe microcode in a guest
To support live migration, the hypervisor sets the "lowest common denominator" of features. Probing the microcode isn't allowed because any detected features might go away after a migration.
As Andy Cooper states:
"Linux must not probe microcode when virtualised. What it may see instantaneously on boot (owing to MSR_PRED_CMD being fully passed through) is not accurate for the lifetime of the VM."
Rely on the hypervisor to set the needed IBPB_BRTYPE and SBPB bits.
--- arch/x86/kernel/cpu/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +1 -1
@@ -767,7 +767,7 @@ static void early_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_TOPOEXT )) smp_num_siblings = ((cpuid_ebx (0x8000001e ) >>8 ) &0xff ) +1 ; -if (!cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) { +if (!cpu_has (c,X86_FEATURE_HYPERVISOR ) && !cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) {if (c->x86 ==0x17 &&boot_cpu_has (X86_FEATURE_AMD_IBPB ))setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE );else if (c->x86 >=0x19 && !wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) {
[tip: x86/urgent] x86/srso: Don't probe microcode in a guest
In reply to Josh PoimboeufThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 02428d0366a27c2f33bc4361eb10467777804f29 Gitweb: https://git.kernel.org/tip/02428d0366a27c2f33bc4361eb10467777804f29 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:47 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 19 Sep 2023 10:54:23 +02:00
x86/srso: Don't probe microcode in a guest
To support live migration, the hypervisor sets the "lowest common denominator" of features. Probing the microcode isn't allowed because any detected features might go away after a migration.
As Andy Cooper states:
"Linux must not probe microcode when virtualised. What it may see instantaneously on boot (owing to MSR_PRED_CMD being fully passed through) is not accurate for the lifetime of the VM."
Rely on the hypervisor to set the needed IBPB_BRTYPE and SBPB bits.
--- arch/x86/kernel/cpu/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +1 -1
@@ -767,7 +767,7 @@ static void early_init_amd(struct cpuinfo_x86 *c)if (cpu_has (c,X86_FEATURE_TOPOEXT )) smp_num_siblings = ((cpuid_ebx (0x8000001e ) >>8 ) &0xff ) +1 ; -if (!cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) { +if (!cpu_has (c,X86_FEATURE_HYPERVISOR ) && !cpu_has (c,X86_FEATURE_IBPB_BRTYPE )) {if (c->x86 ==0x17 &&boot_cpu_has (X86_FEATURE_AMD_IBPB ))setup_force_cpu_cap (X86_FEATURE_IBPB_BRTYPE );else if (c->x86 >=0x19 && !wrmsrl_safe (MSR_IA32_PRED_CMD ,PRED_CMD_SBPB )) {
Josh Poimboeuf
maintainerPATCH v3 4/20 x86/srso: Fix SBPB enablement for spec_rstack_overflow=off
In reply to Josh PoimboeufIf the user has requested no SRSO mitigation, other mitigations can use the lighter-weight SBPB instead of IBPB.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2433,7 +2433,7 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : -return ; + goto pred_cmd;case SRSO_CMD_MICROCODE :if (has_microcode) {
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Fix SBPB enablement for spec_rstack_overflow=off
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: a9c7b944ff32243c248fb4a801ffac21635d7042 Gitweb: https://git.kernel.org/tip/a9c7b944ff32243c248fb4a801ffac21635d7042 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:48 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Fix SBPB enablement for spec_rstack_overflow=off
If the user has requested no SRSO mitigation, other mitigations can use the lighter-weight SBPB instead of IBPB.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2433,7 +2433,7 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : -return ; + goto pred_cmd;case SRSO_CMD_MICROCODE :if (has_microcode) {
[tip: x86/urgent] x86/srso: Fix SBPB enablement for spec_rstack_overflow=off
In reply to Josh PoimboeufThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 01b057b2f4cc2d905a0bd92195657dbd9a7005ab Gitweb: https://git.kernel.org/tip/01b057b2f4cc2d905a0bd92195657dbd9a7005ab Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:48 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 19 Sep 2023 10:54:39 +02:00
x86/srso: Fix SBPB enablement for spec_rstack_overflow=off
If the user has requested no SRSO mitigation, other mitigations can use the lighter-weight SBPB instead of IBPB.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2433,7 +2433,7 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : -return ; + goto pred_cmd;case SRSO_CMD_MICROCODE :if (has_microcode) {
Josh Poimboeuf
maintainerPATCH v3 5/20 x86/srso: Fix SBPB enablement for (possible) future fixed HW
In reply to Josh PoimboeufMake the SBPB check more robust against the (possible) case where future HW has SRSO fixed but doesn't have the SRSO_NO bit set.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2496,7 +2496,7 @@ static void __init srso_select_mitigation(void)pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); pred_cmd: -if ((boot_cpu_has (X86_FEATURE_SRSO_NO ) || srso_cmd ==SRSO_CMD_OFF ) && +if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) &&boot_cpu_has (X86_FEATURE_SBPB )) x86_pred_cmd =PRED_CMD_SBPB ; }
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Fix SBPB enablement for (possible) future fixed HW
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 94e07e94c7ea53757995b8702171f4cd1936fb8c Gitweb: https://git.kernel.org/tip/94e07e94c7ea53757995b8702171f4cd1936fb8c Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:49 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Fix SBPB enablement for (possible) future fixed HW
Make the SBPB check more robust against the (possible) case where future HW has SRSO fixed but doesn't have the SRSO_NO bit set.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2496,7 +2496,7 @@ static void __init srso_select_mitigation(void)pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); pred_cmd: -if ((boot_cpu_has (X86_FEATURE_SRSO_NO ) || srso_cmd ==SRSO_CMD_OFF ) && +if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) &&boot_cpu_has (X86_FEATURE_SBPB )) x86_pred_cmd =PRED_CMD_SBPB ; }
[tip: x86/bugs] x86/srso: Fix SBPB enablement for (possible) future fixed HW
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 01bba38f23ed7ae627442015332333191af37a5a Gitweb: https://git.kernel.org/tip/01bba38f23ed7ae627442015332333191af37a5a Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:49 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:46 +02:00
x86/srso: Fix SBPB enablement for (possible) future fixed HW
Make the SBPB check more robust against the (possible) case where future HW has SRSO fixed but doesn't have the SRSO_NO bit set.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2496,7 +2496,7 @@ static void __init srso_select_mitigation(void)pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); pred_cmd: -if ((boot_cpu_has (X86_FEATURE_SRSO_NO ) || srso_cmd ==SRSO_CMD_OFF ) && +if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) &&boot_cpu_has (X86_FEATURE_SBPB )) x86_pred_cmd =PRED_CMD_SBPB ; }
[tip: x86/bugs] x86/srso: Fix SBPB enablement for (possible) future fixed HW
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 06c8c5f9db4e6103294dd528c09568131c2f520a Gitweb: https://git.kernel.org/tip/06c8c5f9db4e6103294dd528c09568131c2f520a Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:49 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:02 +02:00
x86/srso: Fix SBPB enablement for (possible) future fixed HW
Make the SBPB check more robust against the (possible) case where future HW has SRSO fixed but doesn't have the SRSO_NO bit set.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2496,7 +2496,7 @@ static void __init srso_select_mitigation(void)pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); pred_cmd: -if ((boot_cpu_has (X86_FEATURE_SRSO_NO ) || srso_cmd ==SRSO_CMD_OFF ) && +if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) &&boot_cpu_has (X86_FEATURE_SBPB )) x86_pred_cmd =PRED_CMD_SBPB ; }
[tip: x86/bugs] x86/srso: Fix SBPB enablement for (possible) future fixed HW
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 1d1142ac51307145dbb256ac3535a1d43a1c9800 Gitweb: https://git.kernel.org/tip/1d1142ac51307145dbb256ac3535a1d43a1c9800 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:49 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 11:34:51 +02:00
x86/srso: Fix SBPB enablement for (possible) future fixed HW
Make the SBPB check more robust against the (possible) case where future HW has SRSO fixed but doesn't have the SRSO_NO bit set.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -2496,7 +2496,7 @@ static void __init srso_select_mitigation(void)pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); pred_cmd: -if ((boot_cpu_has (X86_FEATURE_SRSO_NO ) || srso_cmd ==SRSO_CMD_OFF ) && +if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) &&boot_cpu_has (X86_FEATURE_SBPB )) x86_pred_cmd =PRED_CMD_SBPB ; }
Josh Poimboeuf
maintainerPATCH v3 6/20 x86/srso: Print actual mitigation if requested mitigation isn't possible
In reply to Josh PoimboeufIf the kernel wasn't compiled to support the requested option, print the actual option that ends up getting used.
--- arch/x86/kernel/cpu/bugs.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +0 -3
@@ -2461,7 +2461,6 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_SAFE_RET ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
@@ -2473,7 +2472,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n" ); - goto pred_cmd; }break ;
@@ -2485,7 +2483,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Print actual mitigation if requested mitigation isn't possible
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 777145d26c8b1ca57b5ec031cab352439b3a081a Gitweb: https://git.kernel.org/tip/777145d26c8b1ca57b5ec031cab352439b3a081a Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:50 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Print actual mitigation if requested mitigation isn't possible
If the kernel wasn't compiled to support the requested option, print the actual option that ends up getting used.
--- arch/x86/kernel/cpu/bugs.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +0 -3
@@ -2461,7 +2461,6 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_SAFE_RET ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
@@ -2473,7 +2472,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n" ); - goto pred_cmd; }break ;
@@ -2485,7 +2483,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
[tip: x86/bugs] x86/srso: Print actual mitigation if requested mitigation isn't possible
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 8d1af58569b6b8541c3d6574ba6ef36016a07edb Gitweb: https://git.kernel.org/tip/8d1af58569b6b8541c3d6574ba6ef36016a07edb Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:50 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Print actual mitigation if requested mitigation isn't possible
If the kernel wasn't compiled to support the requested option, print the actual option that ends up getting used.
--- arch/x86/kernel/cpu/bugs.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +0 -3
@@ -2461,7 +2461,6 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_SAFE_RET ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
@@ -2473,7 +2472,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n" ); - goto pred_cmd; }break ;
@@ -2485,7 +2483,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
[tip: x86/bugs] x86/srso: Print actual mitigation if requested mitigation isn't possible
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: f9548addc12d02ee731ccd4a91ae55657e819d7d Gitweb: https://git.kernel.org/tip/f9548addc12d02ee731ccd4a91ae55657e819d7d Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:50 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:02 +02:00
x86/srso: Print actual mitigation if requested mitigation isn't possible
If the kernel wasn't compiled to support the requested option, print the actual option that ends up getting used.
--- arch/x86/kernel/cpu/bugs.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +0 -3
@@ -2461,7 +2461,6 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_SAFE_RET ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
@@ -2473,7 +2472,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n" ); - goto pred_cmd; }break ;
@@ -2485,7 +2483,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
[tip: x86/bugs] x86/srso: Print actual mitigation if requested mitigation isn't possible
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 3fc7b28e831f15274a5526197b54a73a88620584 Gitweb: https://git.kernel.org/tip/3fc7b28e831f15274a5526197b54a73a88620584 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:50 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 11:44:26 +02:00
x86/srso: Print actual mitigation if requested mitigation isn't possible
If the kernel wasn't compiled to support the requested option, print the actual option that ends up getting used.
--- arch/x86/kernel/cpu/bugs.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +0 -3
@@ -2461,7 +2461,6 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_SAFE_RET ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
@@ -2473,7 +2472,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n" ); - goto pred_cmd; }break ;
@@ -2485,7 +2483,6 @@ static void __init srso_select_mitigation(void) } }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); - goto pred_cmd; }break ;
Josh Poimboeuf
maintainerPATCH v3 7/20 x86/srso: Print mitigation for retbleed IBPB case
In reply to Josh PoimboeufWhen overriding the requested mitigation with IBPB due to retbleed=ibpb, print the mitigation in the usual format instead of a custom error message.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -2425,9 +2425,8 @@ static void __init srso_select_mitigation(void)if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (has_microcode) { -pr_err ("Retbleed IBPB mitigation enabled, using same for SRSO\n" ); srso_mitigation =SRSO_MITIGATION_IBPB ; - goto pred_cmd; + goto out; } }
@@ -2490,7 +2489,8 @@ static void __init srso_select_mitigation(void)break ; } -pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); +out: +pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Print mitigation for retbleed IBPB case
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 2294b77c2483ebc7a6c1cca2becf6b0164564a5b Gitweb: https://git.kernel.org/tip/2294b77c2483ebc7a6c1cca2becf6b0164564a5b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:51 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:06 +02:00
x86/srso: Print mitigation for retbleed IBPB case
When overriding the requested mitigation with IBPB due to retbleed=ibpb, print the mitigation in the usual format instead of a custom error message.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -2425,9 +2425,8 @@ static void __init srso_select_mitigation(void)if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (has_microcode) { -pr_err ("Retbleed IBPB mitigation enabled, using same for SRSO\n" ); srso_mitigation =SRSO_MITIGATION_IBPB ; - goto pred_cmd; + goto out; } }
@@ -2490,7 +2489,8 @@ static void __init srso_select_mitigation(void)break ; } -pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); +out: +pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
[tip: x86/bugs] x86/srso: Print mitigation for retbleed IBPB case
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 6988c6ceccb03bb29723bbf5645f7f5ab0658816 Gitweb: https://git.kernel.org/tip/6988c6ceccb03bb29723bbf5645f7f5ab0658816 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:51 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Print mitigation for retbleed IBPB case
When overriding the requested mitigation with IBPB due to retbleed=ibpb, print the mitigation in the usual format instead of a custom error message.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -2425,9 +2425,8 @@ static void __init srso_select_mitigation(void)if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (has_microcode) { -pr_err ("Retbleed IBPB mitigation enabled, using same for SRSO\n" ); srso_mitigation =SRSO_MITIGATION_IBPB ; - goto pred_cmd; + goto out; } }
@@ -2490,7 +2489,8 @@ static void __init srso_select_mitigation(void)break ; } -pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); +out: +pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
[tip: x86/bugs] x86/srso: Print mitigation for retbleed IBPB case
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 8e7f2ef76ed2360dabe3ccd253042f9f9054db65 Gitweb: https://git.kernel.org/tip/8e7f2ef76ed2360dabe3ccd253042f9f9054db65 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:51 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:02 +02:00
x86/srso: Print mitigation for retbleed IBPB case
When overriding the requested mitigation with IBPB due to retbleed=ibpb, print the mitigation in the usual format instead of a custom error message.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -2425,9 +2425,8 @@ static void __init srso_select_mitigation(void)if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (has_microcode) { -pr_err ("Retbleed IBPB mitigation enabled, using same for SRSO\n" ); srso_mitigation =SRSO_MITIGATION_IBPB ; - goto pred_cmd; + goto out; } }
@@ -2490,7 +2489,8 @@ static void __init srso_select_mitigation(void)break ; } -pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); +out: +pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
[tip: x86/bugs] x86/srso: Print mitigation for retbleed IBPB case
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: de9f5f7b06a5b7adbfdd8016f011120a4e928add Gitweb: https://git.kernel.org/tip/de9f5f7b06a5b7adbfdd8016f011120a4e928add Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:51 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 11:45:24 +02:00
x86/srso: Print mitigation for retbleed IBPB case
When overriding the requested mitigation with IBPB due to retbleed=ibpb, print the mitigation in the usual format instead of a custom error message.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -2425,9 +2425,8 @@ static void __init srso_select_mitigation(void)if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (has_microcode) { -pr_err ("Retbleed IBPB mitigation enabled, using same for SRSO\n" ); srso_mitigation =SRSO_MITIGATION_IBPB ; - goto pred_cmd; + goto out; } }
@@ -2490,7 +2489,8 @@ static void __init srso_select_mitigation(void)break ; } -pr_info ("%s%s\n" , srso_strings[srso_mitigation], (has_microcode ?"" :", no microcode" )); +out: +pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
Quoted 32 lines · Josh Poimboeuf
v3:
- drop kvm patches (to be picked up by Sean)
- fix "no microcode, no microcode" printk
- fix "Safe Ret" capitalization in documentation
- fix chopped line in commit log
- drop "x86/srso: Remove redundantX86_FEATURE_ENTRY_IBPBcheck" patchJosh Poimboeuf (20):
x86/srso: Fixsrso_show_state()side effect
x86/srso: Set CPUID feature bits independently of bug or mitigation
status
x86/srso: Don't probe microcode in a guest
x86/srso: Fix SBPB enablement for spec_rstack_overflow=off x86/srso: Fix SBPB enablement for (possible) future fixed HW x86/srso: Print actual mitigation if requested mitigation isn't
possible
x86/srso: Print mitigation for retbleed IBPB case x86/srso: Fix vulnerability reporting for missing microcode x86/srso: Fix unret validation dependencies x86/alternatives: Remove faulty optimization
x86/srso: Improve i-cache locality for alias mitigation x86/srso: Unexport untraining functions
x86/srso: Remove 'pred_cmd' label
x86/bugs: Remove default case for fully switched enums x86/srso: Move retbleed IBPB check into existing 'has_microcode' code
block
x86/srso: Disentangle rethunk-dependent options x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros x86/retpoline: Remove .text..__x86.return_thunk section x86/nospec: Refactor UNTRAIN_RET[_*]
x86/calldepth: Rename__x86_return_skl()tocall_depth_return_thunk()
Quoted 11 lines
Documentation/admin-guide/hw-vuln/srso.rst | 24 ++- arch/x86/include/asm/nospec-branch.h | 69 ++++----- arch/x86/include/asm/processor.h | 2 - arch/x86/kernel/alternative.c | 8 - arch/x86/kernel/cpu/amd.c | 28 ++-- arch/x86/kernel/cpu/bugs.c | 102 ++++++------ arch/x86/kernel/vmlinux.lds.S | 10 +- arch/x86/lib/retpoline.S | 171 +++++++++++---------- include/linux/objtool.h | 3 +- scripts/Makefile.vmlinux_o | 3 +- 10 files changed, 201 insertions(+), 219 deletions(-)
They all look good to me, thanks!
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteIngo Molnar
AppliedQuoted 45 lines · Borislav Petkov
Quoted 32 lines · Josh Poimboeuf
v3:
- drop kvm patches (to be picked up by Sean)
- fix "no microcode, no microcode" printk
- fix "Safe Ret" capitalization in documentation
- fix chopped line in commit log
- drop "x86/srso: Remove redundantX86_FEATURE_ENTRY_IBPBcheck" patchJosh Poimboeuf (20):
x86/srso: Fixsrso_show_state()side effect
x86/srso: Set CPUID feature bits independently of bug or mitigation
status
x86/srso: Don't probe microcode in a guest
x86/srso: Fix SBPB enablement for spec_rstack_overflow=off x86/srso: Fix SBPB enablement for (possible) future fixed HW x86/srso: Print actual mitigation if requested mitigation isn't
possible
x86/srso: Print mitigation for retbleed IBPB case x86/srso: Fix vulnerability reporting for missing microcode x86/srso: Fix unret validation dependencies x86/alternatives: Remove faulty optimization
x86/srso: Improve i-cache locality for alias mitigation x86/srso: Unexport untraining functions
x86/srso: Remove 'pred_cmd' label
x86/bugs: Remove default case for fully switched enums x86/srso: Move retbleed IBPB check into existing 'has_microcode' code
block
x86/srso: Disentangle rethunk-dependent options x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros x86/retpoline: Remove .text..__x86.return_thunk section x86/nospec: Refactor UNTRAIN_RET[_*]
x86/calldepth: Rename__x86_return_skl()tocall_depth_return_thunk()Quoted 11 lines
Documentation/admin-guide/hw-vuln/srso.rst | 24 ++- arch/x86/include/asm/nospec-branch.h | 69 ++++----- arch/x86/include/asm/processor.h | 2 - arch/x86/kernel/alternative.c | 8 - arch/x86/kernel/cpu/amd.c | 28 ++-- arch/x86/kernel/cpu/bugs.c | 102 ++++++------ arch/x86/kernel/vmlinux.lds.S | 10 +- arch/x86/lib/retpoline.S | 171 +++++++++++---------- include/linux/objtool.h | 3 +- scripts/Makefile.vmlinux_o | 3 +- 10 files changed, 201 insertions(+), 219 deletions(-)
Quoted 3 lines
They all look good to me, thanks!
I've applied them to tip:x86/bugs, thanks guys!
Below is the delta diff from v2 to v3.
Thanks,
Ingo
Documentation/admin-guide/hw-vuln/srso.rst +2 -2
@@ -57,7 +57,7 @@ The possible values in this file are: * 'Vulnerable: Safe RET, no microcode': - The "Safe Ret" mitigation (see below) has been applied to protect the + The "Safe RET" mitigation (see below) has been applied to protect the kernel, but the IBPB-extending microcode has not been applied. User space tasks may still be vulnerable.
@@ -139,7 +139,7 @@ an indrect branch prediction barrier after having applied the required microcode patch for one's system. This mitigation comes also at a performance cost. -Mitigation: safe RET +Mitigation: Safe RET -------------------- The mitigation works by ensuring all RET instructions speculate to
arch/x86/kernel/cpu/bugs.c +2 -2
@@ -2494,7 +2494,7 @@ static void __init srso_select_mitigation(void)case SRSO_CMD_IBPB_ON_VMEXIT :if (IS_ENABLED (CONFIG_CPU_SRSO )) { -if (has_microcode) { +if (!boot_cpu_has (X86_FEATURE_ENTRY_IBPB ) && has_microcode) {setup_force_cpu_cap (X86_FEATURE_IBPB_ON_VMEXIT ); srso_mitigation =SRSO_MITIGATION_IBPB_ON_VMEXIT ; }
@@ -2505,7 +2505,7 @@ static void __init srso_select_mitigation(void) } out: -pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); +pr_info ("%s\n" , srso_strings[srso_mitigation]); }#undef pr_fmt
Josh Poimboeuf
maintainerPATCH v3 8/20 x86/srso: Fix vulnerability reporting for missing microcode
In reply to Josh PoimboeufThe SRSO default safe-ret mitigation is reported as "mitigated" even if microcode hasn't been updated. That's wrong because userspace may still be vulnerable to SRSO attacks due to IBPB not flushing branch type predictions.
Report the safe-ret + !microcode case as vulnerable.
Also report the microcode-only case as vulnerable as it leaves the kernel open to attacks.
--- Documentation/admin-guide/hw-vuln/srso.rst | 24 ++++++++++----- arch/x86/kernel/cpu/bugs.c | 36 +++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-)
Documentation/admin-guide/hw-vuln/srso.rst +17 -7
@@ -46,12 +46,22 @@ The possible values in this file are: The processor is not vulnerable - * 'Vulnerable: no microcode': +* 'Vulnerable': + + The processor is vulnerable and no mitigations have been applied. + + * 'Vulnerable: No microcode': The processor is vulnerable, no microcode extending IBPB functionality to address the vulnerability has been applied. - * 'Mitigation: microcode': + * 'Vulnerable: Safe RET, no microcode': + + The "Safe RET" mitigation (see below) has been applied to protect the + kernel, but the IBPB-extending microcode has not been applied. User + space tasks may still be vulnerable. + + * 'Vulnerable: Microcode, no safe RET': Extended IBPB functionality microcode patch has been applied. It does not address User->Kernel and Guest->Host transitions protection but it
@@ -72,11 +82,11 @@ The possible values in this file are: (spec_rstack_overflow=microcode) - * 'Mitigation: safe RET': + * 'Mitigation: Safe RET': - Software-only mitigation. It complements the extended IBPB microcode - patch functionality by addressing User->Kernel and Guest->Host - transitions protection. + Combined microcode/software mitigation. It complements the + extended IBPB microcode patch functionality by addressing + User->Kernel and Guest->Host transitions protection. Selected by default or by spec_rstack_overflow=safe-ret
@@ -129,7 +139,7 @@ an indrect branch prediction barrier after having applied the required microcode patch for one's system. This mitigation comes also at a performance cost. -Mitigation: safe RET +Mitigation: Safe RET -------------------- The mitigation works by ensuring all RET instructions speculate to
arch/x86/kernel/cpu/bugs.c +22 -14
@@ -2353,6 +2353,8 @@ early_param("l1tf", l1tf_cmdline);enum srso_mitigation {SRSO_MITIGATION_NONE , +SRSO_MITIGATION_UCODE_NEEDED , +SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ,SRSO_MITIGATION_MICROCODE ,SRSO_MITIGATION_SAFE_RET ,SRSO_MITIGATION_IBPB ,
@@ -2368,11 +2370,13 @@ enum srso_mitigation_cmd { };static const char *const srso_strings[] = { - [SRSO_MITIGATION_NONE ] ="Vulnerable" , - [SRSO_MITIGATION_MICROCODE ] ="Mitigation: microcode" , - [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: safe RET" , - [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , - [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" + [SRSO_MITIGATION_NONE ] ="Vulnerable" , + [SRSO_MITIGATION_UCODE_NEEDED ] ="Vulnerable: No microcode" , + [SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ] ="Vulnerable: Safe RET, no microcode" , + [SRSO_MITIGATION_MICROCODE ] ="Vulnerable: Microcode, no safe RET" , + [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: Safe RET" , + [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , + [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" };static enum srso_mitigation srso_mitigation__ro_after_init =SRSO_MITIGATION_NONE ;
@@ -2409,10 +2413,7 @@ static void __init srso_select_mitigation(void)if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -if (!has_microcode) { -pr_warn ("IBPB-extending microcode not applied!\n" ); -pr_warn (SRSO_NOTICE ); - }else { +if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied.
@@ -2428,6 +2429,12 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; } + }else { +pr_warn ("IBPB-extending microcode not applied!\n" ); +pr_warn (SRSO_NOTICE ); + +/* may be overwritten by SRSO_CMD_SAFE_RET below */ + srso_mitigation =SRSO_MITIGATION_UCODE_NEEDED ; }switch (srso_cmd) {
@@ -2457,7 +2464,10 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO ); x86_return_thunk = srso_return_thunk; } - srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +if (has_microcode) + srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +else + srso_mitigation =SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }
@@ -2490,7 +2500,7 @@ static void __init srso_select_mitigation(void) } out: -pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); +pr_info ("%s\n" , srso_strings[srso_mitigation]); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
@@ -2701,9 +2711,7 @@ static ssize_t srso_show_state(char *buf)if (boot_cpu_has (X86_FEATURE_SRSO_NO ))return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); -return sysfs_emit (buf,"%s%s\n" , - srso_strings[srso_mitigation], -boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); +return sysfs_emit (buf,"%s\n" , srso_strings[srso_mitigation]); }static ssize_t gds_show_state (char *buf)
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Fix vulnerability reporting for missing microcode
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 534be1d0ecfa327cda06fd9e556b2f56062da3d7 Gitweb: https://git.kernel.org/tip/534be1d0ecfa327cda06fd9e556b2f56062da3d7 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:52 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Fix vulnerability reporting for missing microcode
The SRSO default safe-ret mitigation is reported as "mitigated" even if microcode hasn't been updated. That's wrong because userspace may still be vulnerable to SRSO attacks due to IBPB not flushing branch type predictions.
Report the safe-ret + !microcode case as vulnerable.
Also report the microcode-only case as vulnerable as it leaves the kernel open to attacks.
--- Documentation/admin-guide/hw-vuln/srso.rst | 24 +++++++++----- arch/x86/kernel/cpu/bugs.c | 36 ++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-)
Documentation/admin-guide/hw-vuln/srso.rst +17 -7
@@ -46,12 +46,22 @@ The possible values in this file are: The processor is not vulnerable - * 'Vulnerable: no microcode': +* 'Vulnerable': + + The processor is vulnerable and no mitigations have been applied. + + * 'Vulnerable: No microcode': The processor is vulnerable, no microcode extending IBPB functionality to address the vulnerability has been applied. - * 'Mitigation: microcode': + * 'Vulnerable: Safe RET, no microcode': + + The "Safe RET" mitigation (see below) has been applied to protect the + kernel, but the IBPB-extending microcode has not been applied. User + space tasks may still be vulnerable. + + * 'Vulnerable: Microcode, no safe RET': Extended IBPB functionality microcode patch has been applied. It does not address User->Kernel and Guest->Host transitions protection but it
@@ -72,11 +82,11 @@ The possible values in this file are: (spec_rstack_overflow=microcode) - * 'Mitigation: safe RET': + * 'Mitigation: Safe RET': - Software-only mitigation. It complements the extended IBPB microcode - patch functionality by addressing User->Kernel and Guest->Host - transitions protection. + Combined microcode/software mitigation. It complements the + extended IBPB microcode patch functionality by addressing + User->Kernel and Guest->Host transitions protection. Selected by default or by spec_rstack_overflow=safe-ret
@@ -129,7 +139,7 @@ an indrect branch prediction barrier after having applied the required microcode patch for one's system. This mitigation comes also at a performance cost. -Mitigation: safe RET +Mitigation: Safe RET -------------------- The mitigation works by ensuring all RET instructions speculate to
arch/x86/kernel/cpu/bugs.c +22 -14
@@ -2353,6 +2353,8 @@ early_param("l1tf", l1tf_cmdline);enum srso_mitigation {SRSO_MITIGATION_NONE , +SRSO_MITIGATION_UCODE_NEEDED , +SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ,SRSO_MITIGATION_MICROCODE ,SRSO_MITIGATION_SAFE_RET ,SRSO_MITIGATION_IBPB ,
@@ -2368,11 +2370,13 @@ enum srso_mitigation_cmd { };static const char *const srso_strings[] = { - [SRSO_MITIGATION_NONE ] ="Vulnerable" , - [SRSO_MITIGATION_MICROCODE ] ="Mitigation: microcode" , - [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: safe RET" , - [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , - [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" + [SRSO_MITIGATION_NONE ] ="Vulnerable" , + [SRSO_MITIGATION_UCODE_NEEDED ] ="Vulnerable: No microcode" , + [SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ] ="Vulnerable: Safe RET, no microcode" , + [SRSO_MITIGATION_MICROCODE ] ="Vulnerable: Microcode, no safe RET" , + [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: Safe RET" , + [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , + [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" };static enum srso_mitigation srso_mitigation__ro_after_init =SRSO_MITIGATION_NONE ;
@@ -2409,10 +2413,7 @@ static void __init srso_select_mitigation(void)if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -if (!has_microcode) { -pr_warn ("IBPB-extending microcode not applied!\n" ); -pr_warn (SRSO_NOTICE ); - }else { +if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied.
@@ -2428,6 +2429,12 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; } + }else { +pr_warn ("IBPB-extending microcode not applied!\n" ); +pr_warn (SRSO_NOTICE ); + +/* may be overwritten by SRSO_CMD_SAFE_RET below */ + srso_mitigation =SRSO_MITIGATION_UCODE_NEEDED ; }switch (srso_cmd) {
@@ -2457,7 +2464,10 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO ); x86_return_thunk = srso_return_thunk; } - srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +if (has_microcode) + srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +else + srso_mitigation =SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }
@@ -2490,7 +2500,7 @@ static void __init srso_select_mitigation(void) } out: -pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); +pr_info ("%s\n" , srso_strings[srso_mitigation]); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
@@ -2701,9 +2711,7 @@ static ssize_t srso_show_state(char *buf)if (boot_cpu_has (X86_FEATURE_SRSO_NO ))return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); -return sysfs_emit (buf,"%s%s\n" , - srso_strings[srso_mitigation], -boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); +return sysfs_emit (buf,"%s\n" , srso_strings[srso_mitigation]); }static ssize_t gds_show_state (char *buf)
[tip: x86/bugs] x86/srso: Fix vulnerability reporting for missing microcode
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 3f0659662ac8e0b76e715c904ccbf2ca9bf64d74 Gitweb: https://git.kernel.org/tip/3f0659662ac8e0b76e715c904ccbf2ca9bf64d74 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:52 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Fix vulnerability reporting for missing microcode
The SRSO default safe-ret mitigation is reported as "mitigated" even if microcode hasn't been updated. That's wrong because userspace may still be vulnerable to SRSO attacks due to IBPB not flushing branch type predictions.
Report the safe-ret + !microcode case as vulnerable.
Also report the microcode-only case as vulnerable as it leaves the kernel open to attacks.
--- Documentation/admin-guide/hw-vuln/srso.rst | 24 +++++++++----- arch/x86/kernel/cpu/bugs.c | 36 ++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-)
Documentation/admin-guide/hw-vuln/srso.rst +17 -7
@@ -46,12 +46,22 @@ The possible values in this file are: The processor is not vulnerable - * 'Vulnerable: no microcode': +* 'Vulnerable': + + The processor is vulnerable and no mitigations have been applied. + + * 'Vulnerable: No microcode': The processor is vulnerable, no microcode extending IBPB functionality to address the vulnerability has been applied. - * 'Mitigation: microcode': + * 'Vulnerable: Safe RET, no microcode': + + The "Safe RET" mitigation (see below) has been applied to protect the + kernel, but the IBPB-extending microcode has not been applied. User + space tasks may still be vulnerable. + + * 'Vulnerable: Microcode, no safe RET': Extended IBPB functionality microcode patch has been applied. It does not address User->Kernel and Guest->Host transitions protection but it
@@ -72,11 +82,11 @@ The possible values in this file are: (spec_rstack_overflow=microcode) - * 'Mitigation: safe RET': + * 'Mitigation: Safe RET': - Software-only mitigation. It complements the extended IBPB microcode - patch functionality by addressing User->Kernel and Guest->Host - transitions protection. + Combined microcode/software mitigation. It complements the + extended IBPB microcode patch functionality by addressing + User->Kernel and Guest->Host transitions protection. Selected by default or by spec_rstack_overflow=safe-ret
@@ -129,7 +139,7 @@ an indrect branch prediction barrier after having applied the required microcode patch for one's system. This mitigation comes also at a performance cost. -Mitigation: safe RET +Mitigation: Safe RET -------------------- The mitigation works by ensuring all RET instructions speculate to
arch/x86/kernel/cpu/bugs.c +22 -14
@@ -2353,6 +2353,8 @@ early_param("l1tf", l1tf_cmdline);enum srso_mitigation {SRSO_MITIGATION_NONE , +SRSO_MITIGATION_UCODE_NEEDED , +SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ,SRSO_MITIGATION_MICROCODE ,SRSO_MITIGATION_SAFE_RET ,SRSO_MITIGATION_IBPB ,
@@ -2368,11 +2370,13 @@ enum srso_mitigation_cmd { };static const char *const srso_strings[] = { - [SRSO_MITIGATION_NONE ] ="Vulnerable" , - [SRSO_MITIGATION_MICROCODE ] ="Mitigation: microcode" , - [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: safe RET" , - [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , - [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" + [SRSO_MITIGATION_NONE ] ="Vulnerable" , + [SRSO_MITIGATION_UCODE_NEEDED ] ="Vulnerable: No microcode" , + [SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ] ="Vulnerable: Safe RET, no microcode" , + [SRSO_MITIGATION_MICROCODE ] ="Vulnerable: Microcode, no safe RET" , + [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: Safe RET" , + [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , + [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" };static enum srso_mitigation srso_mitigation__ro_after_init =SRSO_MITIGATION_NONE ;
@@ -2409,10 +2413,7 @@ static void __init srso_select_mitigation(void)if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -if (!has_microcode) { -pr_warn ("IBPB-extending microcode not applied!\n" ); -pr_warn (SRSO_NOTICE ); - }else { +if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied.
@@ -2428,6 +2429,12 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; } + }else { +pr_warn ("IBPB-extending microcode not applied!\n" ); +pr_warn (SRSO_NOTICE ); + +/* may be overwritten by SRSO_CMD_SAFE_RET below */ + srso_mitigation =SRSO_MITIGATION_UCODE_NEEDED ; }switch (srso_cmd) {
@@ -2457,7 +2464,10 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO ); x86_return_thunk = srso_return_thunk; } - srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +if (has_microcode) + srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +else + srso_mitigation =SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }
@@ -2490,7 +2500,7 @@ static void __init srso_select_mitigation(void) } out: -pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); +pr_info ("%s\n" , srso_strings[srso_mitigation]); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
@@ -2701,9 +2711,7 @@ static ssize_t srso_show_state(char *buf)if (boot_cpu_has (X86_FEATURE_SRSO_NO ))return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); -return sysfs_emit (buf,"%s%s\n" , - srso_strings[srso_mitigation], -boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); +return sysfs_emit (buf,"%s\n" , srso_strings[srso_mitigation]); }static ssize_t gds_show_state (char *buf)
[tip: x86/bugs] x86/srso: Fix vulnerability reporting for missing microcode
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 8caca8ceaae016329eb055f39bb0c95246bcc5b1 Gitweb: https://git.kernel.org/tip/8caca8ceaae016329eb055f39bb0c95246bcc5b1 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:52 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:02 +02:00
x86/srso: Fix vulnerability reporting for missing microcode
The SRSO default safe-ret mitigation is reported as "mitigated" even if microcode hasn't been updated. That's wrong because userspace may still be vulnerable to SRSO attacks due to IBPB not flushing branch type predictions.
Report the safe-ret + !microcode case as vulnerable.
Also report the microcode-only case as vulnerable as it leaves the kernel open to attacks.
--- Documentation/admin-guide/hw-vuln/srso.rst | 24 +++++++++----- arch/x86/kernel/cpu/bugs.c | 36 ++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-)
Documentation/admin-guide/hw-vuln/srso.rst +17 -7
@@ -46,12 +46,22 @@ The possible values in this file are: The processor is not vulnerable - * 'Vulnerable: no microcode': +* 'Vulnerable': + + The processor is vulnerable and no mitigations have been applied. + + * 'Vulnerable: No microcode': The processor is vulnerable, no microcode extending IBPB functionality to address the vulnerability has been applied. - * 'Mitigation: microcode': + * 'Vulnerable: Safe RET, no microcode': + + The "Safe RET" mitigation (see below) has been applied to protect the + kernel, but the IBPB-extending microcode has not been applied. User + space tasks may still be vulnerable. + + * 'Vulnerable: Microcode, no safe RET': Extended IBPB functionality microcode patch has been applied. It does not address User->Kernel and Guest->Host transitions protection but it
@@ -72,11 +82,11 @@ The possible values in this file are: (spec_rstack_overflow=microcode) - * 'Mitigation: safe RET': + * 'Mitigation: Safe RET': - Software-only mitigation. It complements the extended IBPB microcode - patch functionality by addressing User->Kernel and Guest->Host - transitions protection. + Combined microcode/software mitigation. It complements the + extended IBPB microcode patch functionality by addressing + User->Kernel and Guest->Host transitions protection. Selected by default or by spec_rstack_overflow=safe-ret
@@ -129,7 +139,7 @@ an indrect branch prediction barrier after having applied the required microcode patch for one's system. This mitigation comes also at a performance cost. -Mitigation: safe RET +Mitigation: Safe RET -------------------- The mitigation works by ensuring all RET instructions speculate to
arch/x86/kernel/cpu/bugs.c +22 -14
@@ -2353,6 +2353,8 @@ early_param("l1tf", l1tf_cmdline);enum srso_mitigation {SRSO_MITIGATION_NONE , +SRSO_MITIGATION_UCODE_NEEDED , +SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ,SRSO_MITIGATION_MICROCODE ,SRSO_MITIGATION_SAFE_RET ,SRSO_MITIGATION_IBPB ,
@@ -2368,11 +2370,13 @@ enum srso_mitigation_cmd { };static const char *const srso_strings[] = { - [SRSO_MITIGATION_NONE ] ="Vulnerable" , - [SRSO_MITIGATION_MICROCODE ] ="Mitigation: microcode" , - [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: safe RET" , - [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , - [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" + [SRSO_MITIGATION_NONE ] ="Vulnerable" , + [SRSO_MITIGATION_UCODE_NEEDED ] ="Vulnerable: No microcode" , + [SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ] ="Vulnerable: Safe RET, no microcode" , + [SRSO_MITIGATION_MICROCODE ] ="Vulnerable: Microcode, no safe RET" , + [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: Safe RET" , + [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , + [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" };static enum srso_mitigation srso_mitigation__ro_after_init =SRSO_MITIGATION_NONE ;
@@ -2409,10 +2413,7 @@ static void __init srso_select_mitigation(void)if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -if (!has_microcode) { -pr_warn ("IBPB-extending microcode not applied!\n" ); -pr_warn (SRSO_NOTICE ); - }else { +if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied.
@@ -2428,6 +2429,12 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; } + }else { +pr_warn ("IBPB-extending microcode not applied!\n" ); +pr_warn (SRSO_NOTICE ); + +/* may be overwritten by SRSO_CMD_SAFE_RET below */ + srso_mitigation =SRSO_MITIGATION_UCODE_NEEDED ; }switch (srso_cmd) {
@@ -2457,7 +2464,10 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO ); x86_return_thunk = srso_return_thunk; } - srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +if (has_microcode) + srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +else + srso_mitigation =SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }
@@ -2490,7 +2500,7 @@ static void __init srso_select_mitigation(void) } out: -pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); +pr_info ("%s\n" , srso_strings[srso_mitigation]); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
@@ -2701,9 +2711,7 @@ static ssize_t srso_show_state(char *buf)if (boot_cpu_has (X86_FEATURE_SRSO_NO ))return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); -return sysfs_emit (buf,"%s%s\n" , - srso_strings[srso_mitigation], -boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); +return sysfs_emit (buf,"%s\n" , srso_strings[srso_mitigation]); }static ssize_t gds_show_state (char *buf)
[tip: x86/bugs] x86/srso: Fix vulnerability reporting for missing microcode
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: dc6306ad5b0dda040baf1fde3cfd458e6abfc4da Gitweb: https://git.kernel.org/tip/dc6306ad5b0dda040baf1fde3cfd458e6abfc4da Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:52 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 11:46:09 +02:00
x86/srso: Fix vulnerability reporting for missing microcode
The SRSO default safe-ret mitigation is reported as "mitigated" even if microcode hasn't been updated. That's wrong because userspace may still be vulnerable to SRSO attacks due to IBPB not flushing branch type predictions.
Report the safe-ret + !microcode case as vulnerable.
Also report the microcode-only case as vulnerable as it leaves the kernel open to attacks.
--- Documentation/admin-guide/hw-vuln/srso.rst | 24 +++++++++----- arch/x86/kernel/cpu/bugs.c | 36 ++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-)
Documentation/admin-guide/hw-vuln/srso.rst +17 -7
@@ -46,12 +46,22 @@ The possible values in this file are: The processor is not vulnerable - * 'Vulnerable: no microcode': +* 'Vulnerable': + + The processor is vulnerable and no mitigations have been applied. + + * 'Vulnerable: No microcode': The processor is vulnerable, no microcode extending IBPB functionality to address the vulnerability has been applied. - * 'Mitigation: microcode': + * 'Vulnerable: Safe RET, no microcode': + + The "Safe RET" mitigation (see below) has been applied to protect the + kernel, but the IBPB-extending microcode has not been applied. User + space tasks may still be vulnerable. + + * 'Vulnerable: Microcode, no safe RET': Extended IBPB functionality microcode patch has been applied. It does not address User->Kernel and Guest->Host transitions protection but it
@@ -72,11 +82,11 @@ The possible values in this file are: (spec_rstack_overflow=microcode) - * 'Mitigation: safe RET': + * 'Mitigation: Safe RET': - Software-only mitigation. It complements the extended IBPB microcode - patch functionality by addressing User->Kernel and Guest->Host - transitions protection. + Combined microcode/software mitigation. It complements the + extended IBPB microcode patch functionality by addressing + User->Kernel and Guest->Host transitions protection. Selected by default or by spec_rstack_overflow=safe-ret
@@ -129,7 +139,7 @@ an indrect branch prediction barrier after having applied the required microcode patch for one's system. This mitigation comes also at a performance cost. -Mitigation: safe RET +Mitigation: Safe RET -------------------- The mitigation works by ensuring all RET instructions speculate to
arch/x86/kernel/cpu/bugs.c +22 -14
@@ -2353,6 +2353,8 @@ early_param("l1tf", l1tf_cmdline);enum srso_mitigation {SRSO_MITIGATION_NONE , +SRSO_MITIGATION_UCODE_NEEDED , +SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ,SRSO_MITIGATION_MICROCODE ,SRSO_MITIGATION_SAFE_RET ,SRSO_MITIGATION_IBPB ,
@@ -2368,11 +2370,13 @@ enum srso_mitigation_cmd { };static const char *const srso_strings[] = { - [SRSO_MITIGATION_NONE ] ="Vulnerable" , - [SRSO_MITIGATION_MICROCODE ] ="Mitigation: microcode" , - [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: safe RET" , - [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , - [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" + [SRSO_MITIGATION_NONE ] ="Vulnerable" , + [SRSO_MITIGATION_UCODE_NEEDED ] ="Vulnerable: No microcode" , + [SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ] ="Vulnerable: Safe RET, no microcode" , + [SRSO_MITIGATION_MICROCODE ] ="Vulnerable: Microcode, no safe RET" , + [SRSO_MITIGATION_SAFE_RET ] ="Mitigation: Safe RET" , + [SRSO_MITIGATION_IBPB ] ="Mitigation: IBPB" , + [SRSO_MITIGATION_IBPB_ON_VMEXIT ] ="Mitigation: IBPB on VMEXIT only" };static enum srso_mitigation srso_mitigation__ro_after_init =SRSO_MITIGATION_NONE ;
@@ -2409,10 +2413,7 @@ static void __init srso_select_mitigation(void)if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) goto pred_cmd; -if (!has_microcode) { -pr_warn ("IBPB-extending microcode not applied!\n" ); -pr_warn (SRSO_NOTICE ); - }else { +if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied.
@@ -2428,6 +2429,12 @@ static void __init srso_select_mitigation(void) srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; } + }else { +pr_warn ("IBPB-extending microcode not applied!\n" ); +pr_warn (SRSO_NOTICE ); + +/* may be overwritten by SRSO_CMD_SAFE_RET below */ + srso_mitigation =SRSO_MITIGATION_UCODE_NEEDED ; }switch (srso_cmd) {
@@ -2457,7 +2464,10 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO ); x86_return_thunk = srso_return_thunk; } - srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +if (has_microcode) + srso_mitigation =SRSO_MITIGATION_SAFE_RET ; +else + srso_mitigation =SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED ; }else {pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }
@@ -2490,7 +2500,7 @@ static void __init srso_select_mitigation(void) } out: -pr_info ("%s%s\n" , srso_strings[srso_mitigation], has_microcode ?"" :", no microcode" ); +pr_info ("%s\n" , srso_strings[srso_mitigation]); pred_cmd: if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
@@ -2701,9 +2711,7 @@ static ssize_t srso_show_state(char *buf)if (boot_cpu_has (X86_FEATURE_SRSO_NO ))return sysfs_emit (buf,"Mitigation: SMT disabled\n" ); -return sysfs_emit (buf,"%s%s\n" , - srso_strings[srso_mitigation], -boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ) ?"" :", no microcode" ); +return sysfs_emit (buf,"%s\n" , srso_strings[srso_mitigation]); }static ssize_t gds_show_state (char *buf)
Josh Poimboeuf
maintainerPATCH v3 9/20 x86/srso: Fix unret validation dependencies
In reply to Josh PoimboeufCONFIG_CPU_SRSO isn't dependent on CONFIG_CPU_UNRET_ENTRY (AMD Retbleed), so the two features are independently configurable. Fix several issues for the (presumably rare) case where CONFIG_CPU_SRSO is enabled but CONFIG_CPU_UNRET_ENTRY isn't.
--- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 3 ++- scripts/Makefile.vmlinux_o | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -271,7 +271,7 @@ .Lskip_rsb_\@: .endm -#ifdef CONFIG_CPU_UNRET_ENTRY +#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )#define CALL_UNTRAIN_RET "call entry_untrain_ret"#else #define CALL_UNTRAIN_RET ""
@@ -312,7 +312,7 @@ .macro UNTRAIN_RET_FROM_CALL#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) + defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
include/linux/objtool.h +2 -1
@@ -130,7 +130,8 @@* it will be ignored. */ .macro VALIDATE_UNRET_BEGIN -#if defined(CONFIG_NOINSTR_VALIDATION ) && defined(CONFIG_CPU_UNRET_ENTRY ) +#if defined(CONFIG_NOINSTR_VALIDATION ) && \ + (defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )) .Lhere_\@: .pushsection .discard.validate_unret .long .Lhere_\@ - .
scripts/Makefile.vmlinux_o +2 -1
@@ -37,7 +37,8 @@ objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret) +vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ + $(if $(or $(CONFIG_CPU_UNRET_ENTRY),$(CONFIG_CPU_SRSO)), --unret) objtool-args = $(vmlinux-objtool-args-y) --link
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Fix unret validation dependencies
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 96d660f35790646f15b69010f767b6b7948fb723 Gitweb: https://git.kernel.org/tip/96d660f35790646f15b69010f767b6b7948fb723 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:53 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Fix unret validation dependencies
CONFIG_CPU_SRSO isn't dependent on CONFIG_CPU_UNRET_ENTRY (AMD Retbleed), so the two features are independently configurable. Fix several issues for the (presumably rare) case where CONFIG_CPU_SRSO is enabled but CONFIG_CPU_UNRET_ENTRY isn't.
--- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 3 ++- scripts/Makefile.vmlinux_o | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -271,7 +271,7 @@ .Lskip_rsb_\@: .endm -#ifdef CONFIG_CPU_UNRET_ENTRY +#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )#define CALL_UNTRAIN_RET "call entry_untrain_ret"#else #define CALL_UNTRAIN_RET ""
@@ -312,7 +312,7 @@ .macro UNTRAIN_RET_FROM_CALL#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) + defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
include/linux/objtool.h +2 -1
@@ -130,7 +130,8 @@* it will be ignored. */ .macro VALIDATE_UNRET_BEGIN -#if defined(CONFIG_NOINSTR_VALIDATION ) && defined(CONFIG_CPU_UNRET_ENTRY ) +#if defined(CONFIG_NOINSTR_VALIDATION ) && \ + (defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )) .Lhere_\@: .pushsection .discard.validate_unret .long .Lhere_\@ - .
scripts/Makefile.vmlinux_o +2 -1
@@ -37,7 +37,8 @@ objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret) +vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ + $(if $(or $(CONFIG_CPU_UNRET_ENTRY),$(CONFIG_CPU_SRSO)), --unret) objtool-args = $(vmlinux-objtool-args-y) --link
[tip: x86/bugs] x86/srso: Fix unret validation dependencies
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: adc5517ec8157084ba978b25241fc398207d05dd Gitweb: https://git.kernel.org/tip/adc5517ec8157084ba978b25241fc398207d05dd Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:53 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Fix unret validation dependencies
CONFIG_CPU_SRSO isn't dependent on CONFIG_CPU_UNRET_ENTRY (AMD Retbleed), so the two features are independently configurable. Fix several issues for the (presumably rare) case where CONFIG_CPU_SRSO is enabled but CONFIG_CPU_UNRET_ENTRY isn't.
--- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 3 ++- scripts/Makefile.vmlinux_o | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -271,7 +271,7 @@ .Lskip_rsb_\@: .endm -#ifdef CONFIG_CPU_UNRET_ENTRY +#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )#define CALL_UNTRAIN_RET "call entry_untrain_ret"#else #define CALL_UNTRAIN_RET ""
@@ -312,7 +312,7 @@ .macro UNTRAIN_RET_FROM_CALL#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) + defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
include/linux/objtool.h +2 -1
@@ -130,7 +130,8 @@* it will be ignored. */ .macro VALIDATE_UNRET_BEGIN -#if defined(CONFIG_NOINSTR_VALIDATION ) && defined(CONFIG_CPU_UNRET_ENTRY ) +#if defined(CONFIG_NOINSTR_VALIDATION ) && \ + (defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )) .Lhere_\@: .pushsection .discard.validate_unret .long .Lhere_\@ - .
scripts/Makefile.vmlinux_o +2 -1
@@ -37,7 +37,8 @@ objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret) +vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ + $(if $(or $(CONFIG_CPU_UNRET_ENTRY),$(CONFIG_CPU_SRSO)), --unret) objtool-args = $(vmlinux-objtool-args-y) --link
[tip: x86/bugs] x86/srso: Fix unret validation dependencies
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ae56e67426368016b4ff9083842210d5e0a09015 Gitweb: https://git.kernel.org/tip/ae56e67426368016b4ff9083842210d5e0a09015 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:53 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:02 +02:00
x86/srso: Fix unret validation dependencies
CONFIG_CPU_SRSO isn't dependent on CONFIG_CPU_UNRET_ENTRY (AMD Retbleed), so the two features are independently configurable. Fix several issues for the (presumably rare) case where CONFIG_CPU_SRSO is enabled but CONFIG_CPU_UNRET_ENTRY isn't.
--- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 3 ++- scripts/Makefile.vmlinux_o | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -271,7 +271,7 @@ .Lskip_rsb_\@: .endm -#ifdef CONFIG_CPU_UNRET_ENTRY +#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )#define CALL_UNTRAIN_RET "call entry_untrain_ret"#else #define CALL_UNTRAIN_RET ""
@@ -312,7 +312,7 @@ .macro UNTRAIN_RET_FROM_CALL#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) + defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
include/linux/objtool.h +2 -1
@@ -130,7 +130,8 @@* it will be ignored. */ .macro VALIDATE_UNRET_BEGIN -#if defined(CONFIG_NOINSTR_VALIDATION ) && defined(CONFIG_CPU_UNRET_ENTRY ) +#if defined(CONFIG_NOINSTR_VALIDATION ) && \ + (defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )) .Lhere_\@: .pushsection .discard.validate_unret .long .Lhere_\@ - .
scripts/Makefile.vmlinux_o +2 -1
@@ -37,7 +37,8 @@ objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret) +vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ + $(if $(or $(CONFIG_CPU_UNRET_ENTRY),$(CONFIG_CPU_SRSO)), --unret) objtool-args = $(vmlinux-objtool-args-y) --link
[tip: x86/bugs] x86/srso: Fix unret validation dependencies
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: eeb9f34df065f42f0c9195b322ba6df420c9fc92 Gitweb: https://git.kernel.org/tip/eeb9f34df065f42f0c9195b322ba6df420c9fc92 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:53 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 11:46:59 +02:00
x86/srso: Fix unret validation dependencies
CONFIG_CPU_SRSO isn't dependent on CONFIG_CPU_UNRET_ENTRY (AMD Retbleed), so the two features are independently configurable. Fix several issues for the (presumably rare) case where CONFIG_CPU_SRSO is enabled but CONFIG_CPU_UNRET_ENTRY isn't.
--- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 3 ++- scripts/Makefile.vmlinux_o | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/nospec-branch.h +2 -2
@@ -271,7 +271,7 @@ .Lskip_rsb_\@: .endm -#ifdef CONFIG_CPU_UNRET_ENTRY +#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )#define CALL_UNTRAIN_RET "call entry_untrain_ret"#else #define CALL_UNTRAIN_RET ""
@@ -312,7 +312,7 @@ .macro UNTRAIN_RET_FROM_CALL#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) + defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
include/linux/objtool.h +2 -1
@@ -130,7 +130,8 @@* it will be ignored. */ .macro VALIDATE_UNRET_BEGIN -#if defined(CONFIG_NOINSTR_VALIDATION ) && defined(CONFIG_CPU_UNRET_ENTRY ) +#if defined(CONFIG_NOINSTR_VALIDATION ) && \ + (defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_SRSO )) .Lhere_\@: .pushsection .discard.validate_unret .long .Lhere_\@ - .
scripts/Makefile.vmlinux_o +2 -1
@@ -37,7 +37,8 @@ objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret) +vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ + $(if $(or $(CONFIG_CPU_UNRET_ENTRY),$(CONFIG_CPU_SRSO)), --unret) objtool-args = $(vmlinux-objtool-args-y) --link
Josh Poimboeuf
maintainerPATCH v3 10/20 x86/alternatives: Remove faulty optimization
In reply to Josh PoimboeufThe following commit
095b8303f383 ("x86/alternative: Make custom return thunk unconditional")
made '__x86_return_thunk' a placeholder value. All code setting X86_FEATURE_RETHUNK also changes the value of 'x86_return_thunk'. So the optimization at the beginning of apply_returns() is dead code.
Also, before the above-mentioned commit, the optimization actually had a bug It bypassed __static_call_fixup(), causing some raw returns to remain unpatched in static call trampolines. Thus the 'Fixes' tag.
--- arch/x86/kernel/alternative.c | 8 -------- 1 file changed, 8 deletions(-)
arch/x86/kernel/alternative.c +0 -8
@@ -720,14 +720,6 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end) {s32 *s; -/* -* Do not patch out the default return thunks if those needed are the -* ones generated by the compiler. -*/ -if (cpu_feature_enabled (X86_FEATURE_RETHUNK ) && - (x86_return_thunk == __x86_return_thunk)) -return ; -for (s = start; s < end; s++) {void *dest =NULL , *addr = (void *)s + *s;struct insn insn;
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/alternatives: Remove faulty optimization
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 85d5fbfb7deaf3a5b4666e741bb72a68866439e6 Gitweb: https://git.kernel.org/tip/85d5fbfb7deaf3a5b4666e741bb72a68866439e6 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:54 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/alternatives: Remove faulty optimization
The following commit
095b8303f383 ("x86/alternative: Make custom return thunk unconditional")
made '__x86_return_thunk' a placeholder value. All code setting X86_FEATURE_RETHUNK also changes the value of 'x86_return_thunk'. So the optimization at the beginning of apply_returns() is dead code.
Also, before the above-mentioned commit, the optimization actually had a bug It bypassed __static_call_fixup(), causing some raw returns to remain unpatched in static call trampolines. Thus the 'Fixes' tag.
--- arch/x86/kernel/alternative.c | 8 -------- 1 file changed, 8 deletions(-)
arch/x86/kernel/alternative.c +0 -8
@@ -720,14 +720,6 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end) {s32 *s; -/* -* Do not patch out the default return thunks if those needed are the -* ones generated by the compiler. -*/ -if (cpu_feature_enabled (X86_FEATURE_RETHUNK ) && - (x86_return_thunk == __x86_return_thunk)) -return ; -for (s = start; s < end; s++) {void *dest =NULL , *addr = (void *)s + *s;struct insn insn;
[tip: x86/bugs] x86/alternatives: Remove faulty optimization
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: eae1a2bb7dd350195c18f1788f5d687684d8d92d Gitweb: https://git.kernel.org/tip/eae1a2bb7dd350195c18f1788f5d687684d8d92d Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:54 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/alternatives: Remove faulty optimization
The following commit
095b8303f383 ("x86/alternative: Make custom return thunk unconditional")
made '__x86_return_thunk' a placeholder value. All code setting X86_FEATURE_RETHUNK also changes the value of 'x86_return_thunk'. So the optimization at the beginning of apply_returns() is dead code.
Also, before the above-mentioned commit, the optimization actually had a bug It bypassed __static_call_fixup(), causing some raw returns to remain unpatched in static call trampolines. Thus the 'Fixes' tag.
--- arch/x86/kernel/alternative.c | 8 -------- 1 file changed, 8 deletions(-)
arch/x86/kernel/alternative.c +0 -8
@@ -720,14 +720,6 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end) {s32 *s; -/* -* Do not patch out the default return thunks if those needed are the -* ones generated by the compiler. -*/ -if (cpu_feature_enabled (X86_FEATURE_RETHUNK ) && - (x86_return_thunk == __x86_return_thunk)) -return ; -for (s = start; s < end; s++) {void *dest =NULL , *addr = (void *)s + *s;struct insn insn;
Josh Poimboeuf
maintainerPATCH v3 11/20 x86/srso: Improve i-cache locality for alias mitigation
In reply to Josh PoimboeufMove srso_alias_return_thunk() to the same section as srso_alias_safe_ret() so they can share a cache line.
--- arch/x86/lib/retpoline.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/lib/retpoline.S +2 -3
@@ -177,15 +177,14 @@ SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) int3 SYM_FUNC_END(srso_alias_safe_ret) - .section .text..__x86.return_thunk - -SYM_CODE_START(srso_alias_return_thunk) +SYM_CODE_START_NOALIGN(srso_alias_return_thunk) UNWIND_HINT_FUNC ANNOTATE_NOENDBR call srso_alias_safe_ret ud2 SYM_CODE_END(srso_alias_return_thunk) + .section .text..__x86.return_thunk /* * Some generic notes on the untraining sequences: *
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Improve i-cache locality for alias mitigation
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 001c04b48252282f3045acbdc4e91fb6f4142085 Gitweb: https://git.kernel.org/tip/001c04b48252282f3045acbdc4e91fb6f4142085 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:55 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Improve i-cache locality for alias mitigation
Move srso_alias_return_thunk() to the same section as srso_alias_safe_ret() so they can share a cache line.
--- arch/x86/lib/retpoline.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/lib/retpoline.S +2 -3
@@ -177,15 +177,14 @@ SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) int3 SYM_FUNC_END(srso_alias_safe_ret) - .section .text..__x86.return_thunk - -SYM_CODE_START(srso_alias_return_thunk) +SYM_CODE_START_NOALIGN(srso_alias_return_thunk) UNWIND_HINT_FUNC ANNOTATE_NOENDBR call srso_alias_safe_ret ud2 SYM_CODE_END(srso_alias_return_thunk) + .section .text..__x86.return_thunk /* * Some generic notes on the untraining sequences: *
[tip: x86/bugs] x86/srso: Improve i-cache locality for alias mitigation
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: da3bd8872ee00f23b58c7f62dfd403dcc83e074b Gitweb: https://git.kernel.org/tip/da3bd8872ee00f23b58c7f62dfd403dcc83e074b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:55 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Improve i-cache locality for alias mitigation
Move srso_alias_return_thunk() to the same section as srso_alias_safe_ret() so they can share a cache line.
--- arch/x86/lib/retpoline.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/lib/retpoline.S +2 -3
@@ -177,15 +177,14 @@ SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) int3 SYM_FUNC_END(srso_alias_safe_ret) - .section .text..__x86.return_thunk - -SYM_CODE_START(srso_alias_return_thunk) +SYM_CODE_START_NOALIGN(srso_alias_return_thunk) UNWIND_HINT_FUNC ANNOTATE_NOENDBR call srso_alias_safe_ret ud2 SYM_CODE_END(srso_alias_return_thunk) + .section .text..__x86.return_thunk /* * Some generic notes on the untraining sequences: *
[tip: x86/bugs] x86/srso: Improve i-cache locality for alias mitigation
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 01c032b1b11620232f0405d477d33acb7870388c Gitweb: https://git.kernel.org/tip/01c032b1b11620232f0405d477d33acb7870388c Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:55 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:02 +02:00
x86/srso: Improve i-cache locality for alias mitigation
Move srso_alias_return_thunk() to the same section as srso_alias_safe_ret() so they can share a cache line.
--- arch/x86/lib/retpoline.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/lib/retpoline.S +2 -3
@@ -177,15 +177,14 @@ SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) int3 SYM_FUNC_END(srso_alias_safe_ret) - .section .text..__x86.return_thunk - -SYM_CODE_START(srso_alias_return_thunk) +SYM_CODE_START_NOALIGN(srso_alias_return_thunk) UNWIND_HINT_FUNC ANNOTATE_NOENDBR call srso_alias_safe_ret ud2 SYM_CODE_END(srso_alias_return_thunk) + .section .text..__x86.return_thunk /* * Some generic notes on the untraining sequences: *
[tip: x86/bugs] x86/srso: Improve i-cache locality for alias mitigation
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: aa730cff0c26244e88066b5b461a9f5fbac13823 Gitweb: https://git.kernel.org/tip/aa730cff0c26244e88066b5b461a9f5fbac13823 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:55 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:04:18 +02:00
x86/srso: Improve i-cache locality for alias mitigation
Move srso_alias_return_thunk() to the same section as srso_alias_safe_ret() so they can share a cache line.
--- arch/x86/lib/retpoline.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/lib/retpoline.S +2 -3
@@ -177,15 +177,14 @@ SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) int3 SYM_FUNC_END(srso_alias_safe_ret) - .section .text..__x86.return_thunk - -SYM_CODE_START(srso_alias_return_thunk) +SYM_CODE_START_NOALIGN(srso_alias_return_thunk) UNWIND_HINT_FUNC ANNOTATE_NOENDBR call srso_alias_safe_ret ud2 SYM_CODE_END(srso_alias_return_thunk) + .section .text..__x86.return_thunk /* * Some generic notes on the untraining sequences: *
Josh Poimboeuf
maintainerPATCH v3 12/20 x86/srso: Unexport untraining functions
In reply to Josh PoimboeufThese functions aren't called outside of retpoline.S.
--- arch/x86/include/asm/nospec-branch.h | 4 ---- arch/x86/lib/retpoline.S | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/include/asm/nospec-branch.h +0 -4
@@ -352,10 +352,6 @@ extern void retbleed_return_thunk(void);extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void ); -extern void retbleed_untrain_ret (void ); -extern void srso_untrain_ret (void ); -extern void srso_alias_untrain_ret (void ); -extern void entry_untrain_ret (void );extern void entry_ibpb (void );
arch/x86/lib/retpoline.S +2 -5
@@ -157,7 +157,6 @@ SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) lfence jmp srso_alias_return_thunk SYM_FUNC_END(srso_alias_untrain_ret) -__EXPORT_THUNK(srso_alias_untrain_ret) .section .text..__x86.rethunk_safe #else
@@ -215,7 +214,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
@@ -263,7 +262,6 @@ SYM_CODE_END(retbleed_return_thunk) jmp retbleed_return_thunk int3 SYM_FUNC_END(retbleed_untrain_ret) -__EXPORT_THUNK(retbleed_untrain_ret) /* * SRSO untraining sequence for Zen1/2, similar to retbleed_untrain_ret()
@@ -277,7 +275,7 @@ __EXPORT_THUNK(retbleed_untrain_ret) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -298,7 +296,6 @@ SYM_INNER_LABEL(srso_safe_ret, SYM_L_GLOBAL) ud2 SYM_CODE_END(srso_safe_ret) SYM_FUNC_END(srso_untrain_ret) -__EXPORT_THUNK(srso_untrain_ret) SYM_CODE_START(srso_return_thunk) UNWIND_HINT_FUNC
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Unexport untraining functions
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 253553c3364c20d4ff8f61ae53456a7429c5261b Gitweb: https://git.kernel.org/tip/253553c3364c20d4ff8f61ae53456a7429c5261b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:56 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Unexport untraining functions
These functions aren't called outside of retpoline.S.
--- arch/x86/include/asm/nospec-branch.h | 4 ---- arch/x86/lib/retpoline.S | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/include/asm/nospec-branch.h +0 -4
@@ -352,10 +352,6 @@ extern void retbleed_return_thunk(void);extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void ); -extern void retbleed_untrain_ret (void ); -extern void srso_untrain_ret (void ); -extern void srso_alias_untrain_ret (void ); -extern void entry_untrain_ret (void );extern void entry_ibpb (void );
arch/x86/lib/retpoline.S +2 -5
@@ -157,7 +157,6 @@ SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) lfence jmp srso_alias_return_thunk SYM_FUNC_END(srso_alias_untrain_ret) -__EXPORT_THUNK(srso_alias_untrain_ret) .section .text..__x86.rethunk_safe #else
@@ -215,7 +214,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
@@ -263,7 +262,6 @@ SYM_CODE_END(retbleed_return_thunk) jmp retbleed_return_thunk int3 SYM_FUNC_END(retbleed_untrain_ret) -__EXPORT_THUNK(retbleed_untrain_ret) /* * SRSO untraining sequence for Zen1/2, similar to retbleed_untrain_ret()
@@ -277,7 +275,7 @@ __EXPORT_THUNK(retbleed_untrain_ret) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -298,7 +296,6 @@ SYM_INNER_LABEL(srso_safe_ret, SYM_L_GLOBAL) ud2 SYM_CODE_END(srso_safe_ret) SYM_FUNC_END(srso_untrain_ret) -__EXPORT_THUNK(srso_untrain_ret) SYM_CODE_START(srso_return_thunk) UNWIND_HINT_FUNC
[tip: x86/bugs] x86/srso: Unexport untraining functions
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: d1a8e4d9929989ffd74da6b340acf6a4ce03e299 Gitweb: https://git.kernel.org/tip/d1a8e4d9929989ffd74da6b340acf6a4ce03e299 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:56 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Unexport untraining functions
These functions aren't called outside of retpoline.S.
--- arch/x86/include/asm/nospec-branch.h | 4 ---- arch/x86/lib/retpoline.S | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/include/asm/nospec-branch.h +0 -4
@@ -352,10 +352,6 @@ extern void retbleed_return_thunk(void);extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void ); -extern void retbleed_untrain_ret (void ); -extern void srso_untrain_ret (void ); -extern void srso_alias_untrain_ret (void ); -extern void entry_untrain_ret (void );extern void entry_ibpb (void );
arch/x86/lib/retpoline.S +2 -5
@@ -157,7 +157,6 @@ SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) lfence jmp srso_alias_return_thunk SYM_FUNC_END(srso_alias_untrain_ret) -__EXPORT_THUNK(srso_alias_untrain_ret) .section .text..__x86.rethunk_safe #else
@@ -215,7 +214,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
@@ -263,7 +262,6 @@ SYM_CODE_END(retbleed_return_thunk) jmp retbleed_return_thunk int3 SYM_FUNC_END(retbleed_untrain_ret) -__EXPORT_THUNK(retbleed_untrain_ret) /* * SRSO untraining sequence for Zen1/2, similar to retbleed_untrain_ret()
@@ -277,7 +275,7 @@ __EXPORT_THUNK(retbleed_untrain_ret) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -298,7 +296,6 @@ SYM_INNER_LABEL(srso_safe_ret, SYM_L_GLOBAL) ud2 SYM_CODE_END(srso_safe_ret) SYM_FUNC_END(srso_untrain_ret) -__EXPORT_THUNK(srso_untrain_ret) SYM_CODE_START(srso_return_thunk) UNWIND_HINT_FUNC
[tip: x86/bugs] x86/srso: Unexport untraining functions
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ee35f33f13f094151794a02fdb0204ce8ca89af9 Gitweb: https://git.kernel.org/tip/ee35f33f13f094151794a02fdb0204ce8ca89af9 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:56 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/srso: Unexport untraining functions
These functions aren't called outside of retpoline.S.
--- arch/x86/include/asm/nospec-branch.h | 4 ---- arch/x86/lib/retpoline.S | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/include/asm/nospec-branch.h +0 -4
@@ -352,10 +352,6 @@ extern void retbleed_return_thunk(void);extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void ); -extern void retbleed_untrain_ret (void ); -extern void srso_untrain_ret (void ); -extern void srso_alias_untrain_ret (void ); -extern void entry_untrain_ret (void );extern void entry_ibpb (void );
arch/x86/lib/retpoline.S +2 -5
@@ -157,7 +157,6 @@ SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) lfence jmp srso_alias_return_thunk SYM_FUNC_END(srso_alias_untrain_ret) -__EXPORT_THUNK(srso_alias_untrain_ret) .section .text..__x86.rethunk_safe #else
@@ -215,7 +214,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
@@ -263,7 +262,6 @@ SYM_CODE_END(retbleed_return_thunk) jmp retbleed_return_thunk int3 SYM_FUNC_END(retbleed_untrain_ret) -__EXPORT_THUNK(retbleed_untrain_ret) /* * SRSO untraining sequence for Zen1/2, similar to retbleed_untrain_ret()
@@ -277,7 +275,7 @@ __EXPORT_THUNK(retbleed_untrain_ret) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -298,7 +296,6 @@ SYM_INNER_LABEL(srso_safe_ret, SYM_L_GLOBAL) ud2 SYM_CODE_END(srso_safe_ret) SYM_FUNC_END(srso_untrain_ret) -__EXPORT_THUNK(srso_untrain_ret) SYM_CODE_START(srso_return_thunk) UNWIND_HINT_FUNC
[tip: x86/bugs] x86/srso: Unexport untraining functions
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: eb54be26b0d25222809b16f335fe13756ff4a206 Gitweb: https://git.kernel.org/tip/eb54be26b0d25222809b16f335fe13756ff4a206 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:56 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:21:59 +02:00
x86/srso: Unexport untraining functions
These functions aren't called outside of retpoline.S.
--- arch/x86/include/asm/nospec-branch.h | 4 ---- arch/x86/lib/retpoline.S | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/x86/include/asm/nospec-branch.h +0 -4
@@ -352,10 +352,6 @@ extern void retbleed_return_thunk(void);extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void ); -extern void retbleed_untrain_ret (void ); -extern void srso_untrain_ret (void ); -extern void srso_alias_untrain_ret (void ); -extern void entry_untrain_ret (void );extern void entry_ibpb (void );
arch/x86/lib/retpoline.S +2 -5
@@ -157,7 +157,6 @@ SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) lfence jmp srso_alias_return_thunk SYM_FUNC_END(srso_alias_untrain_ret) -__EXPORT_THUNK(srso_alias_untrain_ret) .section .text..__x86.rethunk_safe #else
@@ -215,7 +214,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
@@ -263,7 +262,6 @@ SYM_CODE_END(retbleed_return_thunk) jmp retbleed_return_thunk int3 SYM_FUNC_END(retbleed_untrain_ret) -__EXPORT_THUNK(retbleed_untrain_ret) /* * SRSO untraining sequence for Zen1/2, similar to retbleed_untrain_ret()
@@ -277,7 +275,7 @@ __EXPORT_THUNK(retbleed_untrain_ret) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -298,7 +296,6 @@ SYM_INNER_LABEL(srso_safe_ret, SYM_L_GLOBAL) ud2 SYM_CODE_END(srso_safe_ret) SYM_FUNC_END(srso_untrain_ret) -__EXPORT_THUNK(srso_untrain_ret) SYM_CODE_START(srso_return_thunk) UNWIND_HINT_FUNC
Josh Poimboeuf
maintainerPATCH v3 13/20 x86/srso: Remove 'pred_cmd' label
In reply to Josh PoimboeufSBPB is only enabled in two distinct cases:
1) when SRSO has been disabled with srso=off
2) when SRSO has been fixed (in future HW)
Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled.
--- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +13 -8
@@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void) {bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ); -if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) - goto pred_cmd; +if (cpu_mitigations_off ()) +return ; + +if (!boot_cpu_has_bug (X86_BUG_SRSO )) { +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ; + }if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. +* +* Zen1/2 don't have SBPB, no need to try to enable it here. */ if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );
@@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : - goto pred_cmd; +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ;case SRSO_CMD_MICROCODE :if (has_microcode) {
@@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void) out:pr_info ("%s\n" , srso_strings[srso_mitigation]); - -pred_cmd: -if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) && -boot_cpu_has (X86_FEATURE_SBPB )) - x86_pred_cmd =PRED_CMD_SBPB ; }#undef pr_fmt
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Remove 'pred_cmd' label
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 7a7b33e7a36b13e0032f77406461bd0fed68f55c Gitweb: https://git.kernel.org/tip/7a7b33e7a36b13e0032f77406461bd0fed68f55c Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:57 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Remove 'pred_cmd' label
SBPB is only enabled in two distinct cases:
1) when SRSO has been disabled with srso=off
2) when SRSO has been fixed (in future HW)
Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled.
--- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +13 -8
@@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void) {bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ); -if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) - goto pred_cmd; +if (cpu_mitigations_off ()) +return ; + +if (!boot_cpu_has_bug (X86_BUG_SRSO )) { +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ; + }if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. +* +* Zen1/2 don't have SBPB, no need to try to enable it here. */ if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );
@@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : - goto pred_cmd; +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ;case SRSO_CMD_MICROCODE :if (has_microcode) {
@@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void) out:pr_info ("%s\n" , srso_strings[srso_mitigation]); - -pred_cmd: -if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) && -boot_cpu_has (X86_FEATURE_SBPB )) - x86_pred_cmd =PRED_CMD_SBPB ; }#undef pr_fmt
[tip: x86/bugs] x86/srso: Remove 'pred_cmd' label
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 73163764dd8d117f2ffa14c0bc816bf1bf8a0e27 Gitweb: https://git.kernel.org/tip/73163764dd8d117f2ffa14c0bc816bf1bf8a0e27 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:57 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:47 +02:00
x86/srso: Remove 'pred_cmd' label
SBPB is only enabled in two distinct cases:
1) when SRSO has been disabled with srso=off
2) when SRSO has been fixed (in future HW)
Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled.
--- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +13 -8
@@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void) {bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ); -if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) - goto pred_cmd; +if (cpu_mitigations_off ()) +return ; + +if (!boot_cpu_has_bug (X86_BUG_SRSO )) { +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ; + }if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. +* +* Zen1/2 don't have SBPB, no need to try to enable it here. */ if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );
@@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : - goto pred_cmd; +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ;case SRSO_CMD_MICROCODE :if (has_microcode) {
@@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void) out:pr_info ("%s\n" , srso_strings[srso_mitigation]); - -pred_cmd: -if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) && -boot_cpu_has (X86_FEATURE_SBPB )) - x86_pred_cmd =PRED_CMD_SBPB ; }#undef pr_fmt
[tip: x86/bugs] x86/srso: Remove 'pred_cmd' label
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e2ea4bea46ad9b71ab0c9617d8f4e09310973344 Gitweb: https://git.kernel.org/tip/e2ea4bea46ad9b71ab0c9617d8f4e09310973344 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:57 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/srso: Remove 'pred_cmd' label
SBPB is only enabled in two distinct cases:
1) when SRSO has been disabled with srso=off
2) when SRSO has been fixed (in future HW)
Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled.
--- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +13 -8
@@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void) {bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ); -if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) - goto pred_cmd; +if (cpu_mitigations_off ()) +return ; + +if (!boot_cpu_has_bug (X86_BUG_SRSO )) { +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ; + }if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. +* +* Zen1/2 don't have SBPB, no need to try to enable it here. */ if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );
@@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : - goto pred_cmd; +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ;case SRSO_CMD_MICROCODE :if (has_microcode) {
@@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void) out:pr_info ("%s\n" , srso_strings[srso_mitigation]); - -pred_cmd: -if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) && -boot_cpu_has (X86_FEATURE_SBPB )) - x86_pred_cmd =PRED_CMD_SBPB ; }#undef pr_fmt
[tip: x86/bugs] x86/srso: Remove 'pred_cmd' label
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 55ca9010c4a988b48278f81ae4129deea52d2488 Gitweb: https://git.kernel.org/tip/55ca9010c4a988b48278f81ae4129deea52d2488 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:57 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:26:59 +02:00
x86/srso: Remove 'pred_cmd' label
SBPB is only enabled in two distinct cases:
1) when SRSO has been disabled with srso=off
2) when SRSO has been fixed (in future HW)
Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled.
--- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +13 -8
@@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void) {bool has_microcode =boot_cpu_has (X86_FEATURE_IBPB_BRTYPE ); -if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||cpu_mitigations_off ()) - goto pred_cmd; +if (cpu_mitigations_off ()) +return ; + +if (!boot_cpu_has_bug (X86_BUG_SRSO )) { +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ; + }if (has_microcode) {/* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. +* +* Zen1/2 don't have SBPB, no need to try to enable it here. */ if (boot_cpu_data.x86 <0x19 && !cpu_smt_possible ()) {setup_force_cpu_cap (X86_FEATURE_SRSO_NO );
@@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void)switch (srso_cmd) {case SRSO_CMD_OFF : - goto pred_cmd; +if (boot_cpu_has (X86_FEATURE_SBPB )) + x86_pred_cmd =PRED_CMD_SBPB ; +return ;case SRSO_CMD_MICROCODE :if (has_microcode) {
@@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void) out:pr_info ("%s\n" , srso_strings[srso_mitigation]); - -pred_cmd: -if ((!boot_cpu_has_bug (X86_BUG_SRSO ) || srso_cmd ==SRSO_CMD_OFF ) && -boot_cpu_has (X86_FEATURE_SBPB )) - x86_pred_cmd =PRED_CMD_SBPB ; }#undef pr_fmt
Josh Poimboeuf
maintainerPATCH v3 14/20 x86/bugs: Remove default case for fully switched enums
In reply to Josh PoimboeufFor enum switch statements which handle all possible cases, remove the default case so a compiler warning gets printed if one of the enums gets accidentally omitted from the switch statement.
--- arch/x86/kernel/cpu/bugs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/bugs.c +7 -10
@@ -1019,7 +1019,6 @@ static void __init retbleed_select_mitigation(void) do_cmd_auto:case RETBLEED_CMD_AUTO : -default :if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD || boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) {if (IS_ENABLED (CONFIG_CPU_UNRET_ENTRY ))
@@ -1290,6 +1289,8 @@ spectre_v2_user_select_mitigation(void) spectre_v2_user_ibpb = mode;switch (cmd) { +case SPECTRE_V2_USER_CMD_NONE : +break ;case SPECTRE_V2_USER_CMD_FORCE :case SPECTRE_V2_USER_CMD_PRCTL_IBPB :case SPECTRE_V2_USER_CMD_SECCOMP_IBPB :
@@ -1301,8 +1302,6 @@ spectre_v2_user_select_mitigation(void)case SPECTRE_V2_USER_CMD_SECCOMP :static_branch_enable (&switch_mm_cond_ibpb);break ; -default : -break ; } pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n",
@@ -2160,6 +2159,10 @@ static int l1d_flush_prctl_get(struct task_struct *task)static int ssb_prctl_get (struct task_struct *task) {switch (ssb_mode) { +case SPEC_STORE_BYPASS_NONE : +if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) +return PR_SPEC_ENABLE ; +return PR_SPEC_NOT_AFFECTED ;case SPEC_STORE_BYPASS_DISABLE :return PR_SPEC_DISABLE ;case SPEC_STORE_BYPASS_SECCOMP :
@@ -2171,11 +2174,8 @@ static int ssb_prctl_get(struct task_struct *task)if (task_spec_ssb_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -default : -if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) -return PR_SPEC_ENABLE ; -return PR_SPEC_NOT_AFFECTED ; } +BUG (); }static int ib_prctl_get (struct task_struct *task)
@@ -2504,9 +2504,6 @@ static void __init srso_select_mitigation(void)pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }break ; - -default : -break ; } out:
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/bugs: Remove default case for fully switched enums
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 3cd8bc46c3e4147551c89a38ca0ffc5ff7915e52 Gitweb: https://git.kernel.org/tip/3cd8bc46c3e4147551c89a38ca0ffc5ff7915e52 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/bugs: Remove default case for fully switched enums
For enum switch statements which handle all possible cases, remove the default case so a compiler warning gets printed if one of the enums gets accidentally omitted from the switch statement.
--- arch/x86/kernel/cpu/bugs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/bugs.c +7 -10
@@ -1019,7 +1019,6 @@ static void __init retbleed_select_mitigation(void) do_cmd_auto:case RETBLEED_CMD_AUTO : -default :if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD || boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) {if (IS_ENABLED (CONFIG_CPU_UNRET_ENTRY ))
@@ -1290,6 +1289,8 @@ spectre_v2_user_select_mitigation(void) spectre_v2_user_ibpb = mode;switch (cmd) { +case SPECTRE_V2_USER_CMD_NONE : +break ;case SPECTRE_V2_USER_CMD_FORCE :case SPECTRE_V2_USER_CMD_PRCTL_IBPB :case SPECTRE_V2_USER_CMD_SECCOMP_IBPB :
@@ -1301,8 +1302,6 @@ spectre_v2_user_select_mitigation(void)case SPECTRE_V2_USER_CMD_SECCOMP :static_branch_enable (&switch_mm_cond_ibpb);break ; -default : -break ; } pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n",
@@ -2160,6 +2159,10 @@ static int l1d_flush_prctl_get(struct task_struct *task)static int ssb_prctl_get (struct task_struct *task) {switch (ssb_mode) { +case SPEC_STORE_BYPASS_NONE : +if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) +return PR_SPEC_ENABLE ; +return PR_SPEC_NOT_AFFECTED ;case SPEC_STORE_BYPASS_DISABLE :return PR_SPEC_DISABLE ;case SPEC_STORE_BYPASS_SECCOMP :
@@ -2171,11 +2174,8 @@ static int ssb_prctl_get(struct task_struct *task)if (task_spec_ssb_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -default : -if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) -return PR_SPEC_ENABLE ; -return PR_SPEC_NOT_AFFECTED ; } +BUG (); }static int ib_prctl_get (struct task_struct *task)
@@ -2504,9 +2504,6 @@ static void __init srso_select_mitigation(void)pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }break ; - -default : -break ; } out:
[tip: x86/bugs] x86/bugs: Remove default case for fully switched enums
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 44bd14590309118cb0103b51f7681f369cfca6d9 Gitweb: https://git.kernel.org/tip/44bd14590309118cb0103b51f7681f369cfca6d9 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/bugs: Remove default case for fully switched enums
For enum switch statements which handle all possible cases, remove the default case so a compiler warning gets printed if one of the enums gets accidentally omitted from the switch statement.
--- arch/x86/kernel/cpu/bugs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/bugs.c +7 -10
@@ -1019,7 +1019,6 @@ static void __init retbleed_select_mitigation(void) do_cmd_auto:case RETBLEED_CMD_AUTO : -default :if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD || boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) {if (IS_ENABLED (CONFIG_CPU_UNRET_ENTRY ))
@@ -1290,6 +1289,8 @@ spectre_v2_user_select_mitigation(void) spectre_v2_user_ibpb = mode;switch (cmd) { +case SPECTRE_V2_USER_CMD_NONE : +break ;case SPECTRE_V2_USER_CMD_FORCE :case SPECTRE_V2_USER_CMD_PRCTL_IBPB :case SPECTRE_V2_USER_CMD_SECCOMP_IBPB :
@@ -1301,8 +1302,6 @@ spectre_v2_user_select_mitigation(void)case SPECTRE_V2_USER_CMD_SECCOMP :static_branch_enable (&switch_mm_cond_ibpb);break ; -default : -break ; } pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n",
@@ -2160,6 +2159,10 @@ static int l1d_flush_prctl_get(struct task_struct *task)static int ssb_prctl_get (struct task_struct *task) {switch (ssb_mode) { +case SPEC_STORE_BYPASS_NONE : +if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) +return PR_SPEC_ENABLE ; +return PR_SPEC_NOT_AFFECTED ;case SPEC_STORE_BYPASS_DISABLE :return PR_SPEC_DISABLE ;case SPEC_STORE_BYPASS_SECCOMP :
@@ -2171,11 +2174,8 @@ static int ssb_prctl_get(struct task_struct *task)if (task_spec_ssb_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -default : -if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) -return PR_SPEC_ENABLE ; -return PR_SPEC_NOT_AFFECTED ; } +BUG (); }static int ib_prctl_get (struct task_struct *task)
@@ -2504,9 +2504,6 @@ static void __init srso_select_mitigation(void)pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }break ; - -default : -break ; } out:
[tip: x86/bugs] x86/bugs: Remove default case for fully switched enums
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 365d8a5f4fe4faa88a813b849ea8eac58645289b Gitweb: https://git.kernel.org/tip/365d8a5f4fe4faa88a813b849ea8eac58645289b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/bugs: Remove default case for fully switched enums
For enum switch statements which handle all possible cases, remove the default case so a compiler warning gets printed if one of the enums gets accidentally omitted from the switch statement.
--- arch/x86/kernel/cpu/bugs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/bugs.c +7 -10
@@ -1019,7 +1019,6 @@ static void __init retbleed_select_mitigation(void) do_cmd_auto:case RETBLEED_CMD_AUTO : -default :if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD || boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) {if (IS_ENABLED (CONFIG_CPU_UNRET_ENTRY ))
@@ -1290,6 +1289,8 @@ spectre_v2_user_select_mitigation(void) spectre_v2_user_ibpb = mode;switch (cmd) { +case SPECTRE_V2_USER_CMD_NONE : +break ;case SPECTRE_V2_USER_CMD_FORCE :case SPECTRE_V2_USER_CMD_PRCTL_IBPB :case SPECTRE_V2_USER_CMD_SECCOMP_IBPB :
@@ -1301,8 +1302,6 @@ spectre_v2_user_select_mitigation(void)case SPECTRE_V2_USER_CMD_SECCOMP :static_branch_enable (&switch_mm_cond_ibpb);break ; -default : -break ; } pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n",
@@ -2160,6 +2159,10 @@ static int l1d_flush_prctl_get(struct task_struct *task)static int ssb_prctl_get (struct task_struct *task) {switch (ssb_mode) { +case SPEC_STORE_BYPASS_NONE : +if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) +return PR_SPEC_ENABLE ; +return PR_SPEC_NOT_AFFECTED ;case SPEC_STORE_BYPASS_DISABLE :return PR_SPEC_DISABLE ;case SPEC_STORE_BYPASS_SECCOMP :
@@ -2171,11 +2174,8 @@ static int ssb_prctl_get(struct task_struct *task)if (task_spec_ssb_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -default : -if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) -return PR_SPEC_ENABLE ; -return PR_SPEC_NOT_AFFECTED ; } +BUG (); }static int ib_prctl_get (struct task_struct *task)
@@ -2504,9 +2504,6 @@ static void __init srso_select_mitigation(void)pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }break ; - -default : -break ; } out:
[tip: x86/bugs] x86/bugs: Remove default case for fully switched enums
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 0a0ce0da7fe66d54e497fb4e97d101b478f57e00 Gitweb: https://git.kernel.org/tip/0a0ce0da7fe66d54e497fb4e97d101b478f57e00 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:28:44 +02:00
x86/bugs: Remove default case for fully switched enums
For enum switch statements which handle all possible cases, remove the default case so a compiler warning gets printed if one of the enums gets accidentally omitted from the switch statement.
--- arch/x86/kernel/cpu/bugs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/bugs.c +7 -10
@@ -1019,7 +1019,6 @@ static void __init retbleed_select_mitigation(void) do_cmd_auto:case RETBLEED_CMD_AUTO : -default :if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD || boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) {if (IS_ENABLED (CONFIG_CPU_UNRET_ENTRY ))
@@ -1290,6 +1289,8 @@ spectre_v2_user_select_mitigation(void) spectre_v2_user_ibpb = mode;switch (cmd) { +case SPECTRE_V2_USER_CMD_NONE : +break ;case SPECTRE_V2_USER_CMD_FORCE :case SPECTRE_V2_USER_CMD_PRCTL_IBPB :case SPECTRE_V2_USER_CMD_SECCOMP_IBPB :
@@ -1301,8 +1302,6 @@ spectre_v2_user_select_mitigation(void)case SPECTRE_V2_USER_CMD_SECCOMP :static_branch_enable (&switch_mm_cond_ibpb);break ; -default : -break ; } pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n",
@@ -2160,6 +2159,10 @@ static int l1d_flush_prctl_get(struct task_struct *task)static int ssb_prctl_get (struct task_struct *task) {switch (ssb_mode) { +case SPEC_STORE_BYPASS_NONE : +if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) +return PR_SPEC_ENABLE ; +return PR_SPEC_NOT_AFFECTED ;case SPEC_STORE_BYPASS_DISABLE :return PR_SPEC_DISABLE ;case SPEC_STORE_BYPASS_SECCOMP :
@@ -2171,11 +2174,8 @@ static int ssb_prctl_get(struct task_struct *task)if (task_spec_ssb_disable (task))return PR_SPEC_PRCTL |PR_SPEC_DISABLE ;return PR_SPEC_PRCTL |PR_SPEC_ENABLE ; -default : -if (boot_cpu_has_bug (X86_BUG_SPEC_STORE_BYPASS )) -return PR_SPEC_ENABLE ; -return PR_SPEC_NOT_AFFECTED ; } +BUG (); }static int ib_prctl_get (struct task_struct *task)
@@ -2504,9 +2504,6 @@ static void __init srso_select_mitigation(void)pr_err ("WARNING: kernel not compiled with CPU_SRSO.\n" ); }break ; - -default : -break ; } out:
Josh Poimboeuf
maintainerPATCH v3 15/20 x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
In reply to Josh PoimboeufSimplify the code flow a bit by moving the retbleed IBPB check into the existing 'has_microcode' block.
--- arch/x86/kernel/cpu/bugs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -3
@@ -2430,10 +2430,8 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; } - } -if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { -if (has_microcode) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; }
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: a94be9ae24d2e1580cf68fb58e14369ae6a4846b Gitweb: https://git.kernel.org/tip/a94be9ae24d2e1580cf68fb58e14369ae6a4846b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:59 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
Simplify the code flow a bit by moving the retbleed IBPB check into the existing 'has_microcode' block.
--- arch/x86/kernel/cpu/bugs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -3
@@ -2430,10 +2430,8 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; } - } -if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { -if (has_microcode) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; }
[tip: x86/bugs] x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 27ee0600912c8a02fd6901bc4413709282d7b3f8 Gitweb: https://git.kernel.org/tip/27ee0600912c8a02fd6901bc4413709282d7b3f8 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:59 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
Simplify the code flow a bit by moving the retbleed IBPB check into the existing 'has_microcode' block.
--- arch/x86/kernel/cpu/bugs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -3
@@ -2430,10 +2430,8 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; } - } -if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { -if (has_microcode) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; }
[tip: x86/bugs] x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 074c9666d42211d0f70d5c156d377a4881b2a98c Gitweb: https://git.kernel.org/tip/074c9666d42211d0f70d5c156d377a4881b2a98c Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:59 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
Simplify the code flow a bit by moving the retbleed IBPB check into the existing 'has_microcode' block.
--- arch/x86/kernel/cpu/bugs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -3
@@ -2430,10 +2430,8 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; } - } -if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { -if (has_microcode) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; }
[tip: x86/bugs] x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 351236947a45a512c517153bbe109fe868d05e6d Gitweb: https://git.kernel.org/tip/351236947a45a512c517153bbe109fe868d05e6d Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:04:59 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:29:25 +02:00
x86/srso: Move retbleed IBPB check into existing 'has_microcode' code block
Simplify the code flow a bit by moving the retbleed IBPB check into the existing 'has_microcode' block.
--- arch/x86/kernel/cpu/bugs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -3
@@ -2430,10 +2430,8 @@ static void __init srso_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; } - } -if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { -if (has_microcode) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; }
Josh Poimboeuf
maintainerPATCH v3 16/20 x86/srso: Disentangle rethunk-dependent options
In reply to Josh PoimboeufCONFIG_RETHUNK, CONFIG_CPU_UNRET_ENTRY and CONFIG_CPU_SRSO are all tangled up. De-spaghettify the code a bit.
Some of the rethunk-related code has been shuffled around within the '.text..__x86.return_thunk' section, but otherwise there are no functional changes. srso_alias_untrain_ret() and srso_alias_safe_ret() ((which are very address-sensitive) haven't moved.
--- arch/x86/include/asm/nospec-branch.h | 25 +++-- arch/x86/kernel/cpu/bugs.c | 5 +- arch/x86/kernel/vmlinux.lds.S | 7 +- arch/x86/lib/retpoline.S | 157 +++++++++++++++------------ 4 files changed, 109 insertions(+), 85 deletions(-)
arch/x86/include/asm/nospec-branch.h +18 -7
@@ -289,19 +289,17 @@* where we have a stack but before any RET instruction. */ .macro UNTRAIN_RET -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH #endif .endm .macro UNTRAIN_RET_VM -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -311,8 +309,7 @@ .endm .macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -348,6 +345,20 @@ extern void __x86_return_thunk(void);static inline void __x86_return_thunk (void ) {}#endif +#ifdef CONFIG_CPU_UNRET_ENTRY +extern void retbleed_return_thunk (void ); +#else +static inline void retbleed_return_thunk (void ) {} +#endif + +#ifdef CONFIG_CPU_SRSO +extern void srso_return_thunk (void ); +extern void srso_alias_return_thunk (void ); +#else +static inline void srso_return_thunk (void ) {} +static inline void srso_alias_return_thunk (void ) {} +#endif +extern void retbleed_return_thunk (void );extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void );
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(x86_pred_cmd);static DEFINE_MUTEX (spec_ctrl_mutex); -void (*x86_return_thunk)(void )__ro_after_init = &__x86_return_thunk; +void (*x86_return_thunk)(void )__ro_after_init = __x86_return_thunk;/* Update SPEC_CTRL MSR and its cached copy unconditionally */ static void update_spec_ctrl (u64 val)
@@ -1041,8 +1041,7 @@ static void __init retbleed_select_mitigation(void)setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_UNRET ); -if (IS_ENABLED (CONFIG_RETHUNK )) - x86_return_thunk = retbleed_return_thunk; + x86_return_thunk = retbleed_return_thunk;if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON )
arch/x86/kernel/vmlinux.lds.S +2 -5
@@ -139,10 +139,7 @@ SECTIONS STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN -#ifdef CONFIG_CPU_SRSO *(.text..__x86.rethunk_untrain) -#endif - ENTRY_TEXT #ifdef CONFIG_CPU_SRSO
@@ -520,12 +517,12 @@ INIT_PER_CPU(irq_stack_backing_store); "fixed_percpu_data is not at start of per-cpu area"); #endif -#ifdef CONFIG_RETHUNK +#ifdef CONFIG_CPU_UNRET_ENTRY . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned"); -. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); #endif #ifdef CONFIG_CPU_SRSO +. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); /* * GNU ld cannot do XOR until 2.41. * https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
arch/x86/lib/retpoline.S +87 -70
200 lines not on this page · raw message
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/srso: Disentangle rethunk-dependent options
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: da5a1ae1877b9a455bab096869cec2d6bd33ddd6 Gitweb: https://git.kernel.org/tip/da5a1ae1877b9a455bab096869cec2d6bd33ddd6 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:00 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/srso: Disentangle rethunk-dependent options
CONFIG_RETHUNK, CONFIG_CPU_UNRET_ENTRY and CONFIG_CPU_SRSO are all tangled up. De-spaghettify the code a bit.
Some of the rethunk-related code has been shuffled around within the '.text..__x86.return_thunk' section, but otherwise there are no functional changes. srso_alias_untrain_ret() and srso_alias_safe_ret() ((which are very address-sensitive) haven't moved.
--- arch/x86/include/asm/nospec-branch.h | 25 ++-- arch/x86/kernel/cpu/bugs.c | 5 +- arch/x86/kernel/vmlinux.lds.S | 7 +- arch/x86/lib/retpoline.S | 157 ++++++++++++++------------ 4 files changed, 109 insertions(+), 85 deletions(-)
arch/x86/include/asm/nospec-branch.h +18 -7
@@ -289,19 +289,17 @@* where we have a stack but before any RET instruction. */ .macro UNTRAIN_RET -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH #endif .endm .macro UNTRAIN_RET_VM -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -311,8 +309,7 @@ .endm .macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -348,6 +345,20 @@ extern void __x86_return_thunk(void);static inline void __x86_return_thunk (void ) {}#endif +#ifdef CONFIG_CPU_UNRET_ENTRY +extern void retbleed_return_thunk (void ); +#else +static inline void retbleed_return_thunk (void ) {} +#endif + +#ifdef CONFIG_CPU_SRSO +extern void srso_return_thunk (void ); +extern void srso_alias_return_thunk (void ); +#else +static inline void srso_return_thunk (void ) {} +static inline void srso_alias_return_thunk (void ) {} +#endif +extern void retbleed_return_thunk (void );extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void );
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(x86_pred_cmd);static DEFINE_MUTEX (spec_ctrl_mutex); -void (*x86_return_thunk)(void )__ro_after_init = &__x86_return_thunk; +void (*x86_return_thunk)(void )__ro_after_init = __x86_return_thunk;/* Update SPEC_CTRL MSR and its cached copy unconditionally */ static void update_spec_ctrl (u64 val)
@@ -1041,8 +1041,7 @@ do_cmd_auto:setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_UNRET ); -if (IS_ENABLED (CONFIG_RETHUNK )) - x86_return_thunk = retbleed_return_thunk; + x86_return_thunk = retbleed_return_thunk;if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON )
arch/x86/kernel/vmlinux.lds.S +2 -5
@@ -139,10 +139,7 @@ SECTIONS STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN -#ifdef CONFIG_CPU_SRSO *(.text..__x86.rethunk_untrain) -#endif - ENTRY_TEXT #ifdef CONFIG_CPU_SRSO
@@ -520,12 +517,12 @@ INIT_PER_CPU(irq_stack_backing_store); "fixed_percpu_data is not at start of per-cpu area"); #endif -#ifdef CONFIG_RETHUNK +#ifdef CONFIG_CPU_UNRET_ENTRY . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned"); -. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); #endif #ifdef CONFIG_CPU_SRSO +. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); /* * GNU ld cannot do XOR until 2.41. * https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
arch/x86/lib/retpoline.S +87 -70
200 lines not on this page · raw message
[tip: x86/bugs] x86/srso: Disentangle rethunk-dependent options
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 8976895617cd0d212f90cb55557ec735db632b96 Gitweb: https://git.kernel.org/tip/8976895617cd0d212f90cb55557ec735db632b96 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:00 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/srso: Disentangle rethunk-dependent options
CONFIG_RETHUNK, CONFIG_CPU_UNRET_ENTRY and CONFIG_CPU_SRSO are all tangled up. De-spaghettify the code a bit.
Some of the rethunk-related code has been shuffled around within the '.text..__x86.return_thunk' section, but otherwise there are no functional changes. srso_alias_untrain_ret() and srso_alias_safe_ret() ((which are very address-sensitive) haven't moved.
--- arch/x86/include/asm/nospec-branch.h | 25 ++-- arch/x86/kernel/cpu/bugs.c | 5 +- arch/x86/kernel/vmlinux.lds.S | 7 +- arch/x86/lib/retpoline.S | 157 ++++++++++++++------------ 4 files changed, 109 insertions(+), 85 deletions(-)
arch/x86/include/asm/nospec-branch.h +18 -7
@@ -289,19 +289,17 @@* where we have a stack but before any RET instruction. */ .macro UNTRAIN_RET -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH #endif .endm .macro UNTRAIN_RET_VM -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -311,8 +309,7 @@ .endm .macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -348,6 +345,20 @@ extern void __x86_return_thunk(void);static inline void __x86_return_thunk (void ) {}#endif +#ifdef CONFIG_CPU_UNRET_ENTRY +extern void retbleed_return_thunk (void ); +#else +static inline void retbleed_return_thunk (void ) {} +#endif + +#ifdef CONFIG_CPU_SRSO +extern void srso_return_thunk (void ); +extern void srso_alias_return_thunk (void ); +#else +static inline void srso_return_thunk (void ) {} +static inline void srso_alias_return_thunk (void ) {} +#endif +extern void retbleed_return_thunk (void );extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void );
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(x86_pred_cmd);static DEFINE_MUTEX (spec_ctrl_mutex); -void (*x86_return_thunk)(void )__ro_after_init = &__x86_return_thunk; +void (*x86_return_thunk)(void )__ro_after_init = __x86_return_thunk;/* Update SPEC_CTRL MSR and its cached copy unconditionally */ static void update_spec_ctrl (u64 val)
@@ -1041,8 +1041,7 @@ do_cmd_auto:setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_UNRET ); -if (IS_ENABLED (CONFIG_RETHUNK )) - x86_return_thunk = retbleed_return_thunk; + x86_return_thunk = retbleed_return_thunk;if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON )
arch/x86/kernel/vmlinux.lds.S +2 -5
@@ -139,10 +139,7 @@ SECTIONS STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN -#ifdef CONFIG_CPU_SRSO *(.text..__x86.rethunk_untrain) -#endif - ENTRY_TEXT #ifdef CONFIG_CPU_SRSO
@@ -520,12 +517,12 @@ INIT_PER_CPU(irq_stack_backing_store); "fixed_percpu_data is not at start of per-cpu area"); #endif -#ifdef CONFIG_RETHUNK +#ifdef CONFIG_CPU_UNRET_ENTRY . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned"); -. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); #endif #ifdef CONFIG_CPU_SRSO +. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); /* * GNU ld cannot do XOR until 2.41. * https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
arch/x86/lib/retpoline.S +87 -70
200 lines not on this page · raw message
[tip: x86/bugs] x86/srso: Disentangle rethunk-dependent options
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 670bf81b24ed688fe77d8cc1ff3a66b409bf6e08 Gitweb: https://git.kernel.org/tip/670bf81b24ed688fe77d8cc1ff3a66b409bf6e08 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:00 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/srso: Disentangle rethunk-dependent options
CONFIG_RETHUNK, CONFIG_CPU_UNRET_ENTRY and CONFIG_CPU_SRSO are all tangled up. De-spaghettify the code a bit.
Some of the rethunk-related code has been shuffled around within the '.text..__x86.return_thunk' section, but otherwise there are no functional changes. srso_alias_untrain_ret() and srso_alias_safe_ret() ((which are very address-sensitive) haven't moved.
--- arch/x86/include/asm/nospec-branch.h | 25 ++-- arch/x86/kernel/cpu/bugs.c | 5 +- arch/x86/kernel/vmlinux.lds.S | 7 +- arch/x86/lib/retpoline.S | 157 ++++++++++++++------------ 4 files changed, 109 insertions(+), 85 deletions(-)
arch/x86/include/asm/nospec-branch.h +18 -7
@@ -289,19 +289,17 @@* where we have a stack but before any RET instruction. */ .macro UNTRAIN_RET -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH #endif .endm .macro UNTRAIN_RET_VM -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -311,8 +309,7 @@ .endm .macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -348,6 +345,20 @@ extern void __x86_return_thunk(void);static inline void __x86_return_thunk (void ) {}#endif +#ifdef CONFIG_CPU_UNRET_ENTRY +extern void retbleed_return_thunk (void ); +#else +static inline void retbleed_return_thunk (void ) {} +#endif + +#ifdef CONFIG_CPU_SRSO +extern void srso_return_thunk (void ); +extern void srso_alias_return_thunk (void ); +#else +static inline void srso_return_thunk (void ) {} +static inline void srso_alias_return_thunk (void ) {} +#endif +extern void retbleed_return_thunk (void );extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void );
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(x86_pred_cmd);static DEFINE_MUTEX (spec_ctrl_mutex); -void (*x86_return_thunk)(void )__ro_after_init = &__x86_return_thunk; +void (*x86_return_thunk)(void )__ro_after_init = __x86_return_thunk;/* Update SPEC_CTRL MSR and its cached copy unconditionally */ static void update_spec_ctrl (u64 val)
@@ -1041,8 +1041,7 @@ do_cmd_auto:setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_UNRET ); -if (IS_ENABLED (CONFIG_RETHUNK )) - x86_return_thunk = retbleed_return_thunk; + x86_return_thunk = retbleed_return_thunk;if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON )
arch/x86/kernel/vmlinux.lds.S +2 -5
@@ -139,10 +139,7 @@ SECTIONS STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN -#ifdef CONFIG_CPU_SRSO *(.text..__x86.rethunk_untrain) -#endif - ENTRY_TEXT #ifdef CONFIG_CPU_SRSO
@@ -520,12 +517,12 @@ INIT_PER_CPU(irq_stack_backing_store); "fixed_percpu_data is not at start of per-cpu area"); #endif -#ifdef CONFIG_RETHUNK +#ifdef CONFIG_CPU_UNRET_ENTRY . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned"); -. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); #endif #ifdef CONFIG_CPU_SRSO +. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); /* * GNU ld cannot do XOR until 2.41. * https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
arch/x86/lib/retpoline.S +87 -70
200 lines not on this page · raw message
[tip: x86/bugs] x86/srso: Disentangle rethunk-dependent options
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 34a3cae7474c6e6f4a85aad4a7b8191b8b35cdcd Gitweb: https://git.kernel.org/tip/34a3cae7474c6e6f4a85aad4a7b8191b8b35cdcd Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:00 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:30:50 +02:00
x86/srso: Disentangle rethunk-dependent options
CONFIG_RETHUNK, CONFIG_CPU_UNRET_ENTRY and CONFIG_CPU_SRSO are all tangled up. De-spaghettify the code a bit.
Some of the rethunk-related code has been shuffled around within the '.text..__x86.return_thunk' section, but otherwise there are no functional changes. srso_alias_untrain_ret() and srso_alias_safe_ret() ((which are very address-sensitive) haven't moved.
--- arch/x86/include/asm/nospec-branch.h | 25 ++-- arch/x86/kernel/cpu/bugs.c | 5 +- arch/x86/kernel/vmlinux.lds.S | 7 +- arch/x86/lib/retpoline.S | 157 ++++++++++++++------------ 4 files changed, 109 insertions(+), 85 deletions(-)
arch/x86/include/asm/nospec-branch.h +18 -7
@@ -289,19 +289,17 @@* where we have a stack but before any RET instruction. */ .macro UNTRAIN_RET -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH #endif .endm .macro UNTRAIN_RET_VM -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -311,8 +309,7 @@ .endm .macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY ) || \ - defined(CONFIG_CALL_DEPTH_TRACKING ) || defined(CONFIG_CPU_SRSO ) +#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \
@@ -348,6 +345,20 @@ extern void __x86_return_thunk(void);static inline void __x86_return_thunk (void ) {}#endif +#ifdef CONFIG_CPU_UNRET_ENTRY +extern void retbleed_return_thunk (void ); +#else +static inline void retbleed_return_thunk (void ) {} +#endif + +#ifdef CONFIG_CPU_SRSO +extern void srso_return_thunk (void ); +extern void srso_alias_return_thunk (void ); +#else +static inline void srso_return_thunk (void ) {} +static inline void srso_alias_return_thunk (void ) {} +#endif +extern void retbleed_return_thunk (void );extern void srso_return_thunk (void );extern void srso_alias_return_thunk (void );
arch/x86/kernel/cpu/bugs.c +2 -3
@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(x86_pred_cmd);static DEFINE_MUTEX (spec_ctrl_mutex); -void (*x86_return_thunk)(void )__ro_after_init = &__x86_return_thunk; +void (*x86_return_thunk)(void )__ro_after_init = __x86_return_thunk;/* Update SPEC_CTRL MSR and its cached copy unconditionally */ static void update_spec_ctrl (u64 val)
@@ -1041,8 +1041,7 @@ do_cmd_auto:setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_UNRET ); -if (IS_ENABLED (CONFIG_RETHUNK )) - x86_return_thunk = retbleed_return_thunk; + x86_return_thunk = retbleed_return_thunk;if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON )
arch/x86/kernel/vmlinux.lds.S +2 -5
@@ -139,10 +139,7 @@ SECTIONS STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN -#ifdef CONFIG_CPU_SRSO *(.text..__x86.rethunk_untrain) -#endif - ENTRY_TEXT #ifdef CONFIG_CPU_SRSO
@@ -520,12 +517,12 @@ INIT_PER_CPU(irq_stack_backing_store); "fixed_percpu_data is not at start of per-cpu area"); #endif -#ifdef CONFIG_RETHUNK +#ifdef CONFIG_CPU_UNRET_ENTRY . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned"); -. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); #endif #ifdef CONFIG_CPU_SRSO +. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned"); /* * GNU ld cannot do XOR until 2.41. * https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f6f78318fca803c4907fb8d7f6ded8295f1947b1
arch/x86/lib/retpoline.S +87 -70
200 lines not on this page · raw message
Josh Poimboeuf
maintainerPATCH v3 17/20 x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
In reply to Josh PoimboeufMacros already exist for unaligned code block symbols. Use them.
--- arch/x86/lib/retpoline.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/retpoline.S +4 -4
@@ -149,7 +149,7 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) * As a result, srso_alias_safe_ret() becomes a safe return. */ .pushsection .text..__x86.rethunk_untrain -SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_untrain_ret) UNWIND_HINT_FUNC ANNOTATE_NOENDBR ASM_NOP2
@@ -159,7 +159,7 @@ SYM_FUNC_END(srso_alias_untrain_ret) .popsection .pushsection .text..__x86.rethunk_safe -SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_safe_ret) lea 8(%_ASM_SP), %_ASM_SP UNWIND_HINT_FUNC ANNOTATE_UNRET_SAFE
@@ -187,7 +187,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(srso_untrain_ret) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -255,7 +255,7 @@ SYM_CODE_END(srso_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(retbleed_untrain_ret) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ba6ee6dfa046653621d57209873094962174ae6c Gitweb: https://git.kernel.org/tip/ba6ee6dfa046653621d57209873094962174ae6c Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:01 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
Macros already exist for unaligned code block symbols. Use them.
--- arch/x86/lib/retpoline.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/retpoline.S +4 -4
@@ -149,7 +149,7 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) * As a result, srso_alias_safe_ret() becomes a safe return. */ .pushsection .text..__x86.rethunk_untrain -SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_untrain_ret) UNWIND_HINT_FUNC ANNOTATE_NOENDBR ASM_NOP2
@@ -159,7 +159,7 @@ SYM_FUNC_END(srso_alias_untrain_ret) .popsection .pushsection .text..__x86.rethunk_safe -SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_safe_ret) lea 8(%_ASM_SP), %_ASM_SP UNWIND_HINT_FUNC ANNOTATE_UNRET_SAFE
@@ -187,7 +187,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(srso_untrain_ret) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -255,7 +255,7 @@ SYM_CODE_END(srso_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(retbleed_untrain_ret) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
[tip: x86/bugs] x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ff72a720fbaef33896043fa66043772d0cc3142b Gitweb: https://git.kernel.org/tip/ff72a720fbaef33896043fa66043772d0cc3142b Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:01 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
Macros already exist for unaligned code block symbols. Use them.
--- arch/x86/lib/retpoline.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/retpoline.S +4 -4
@@ -149,7 +149,7 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) * As a result, srso_alias_safe_ret() becomes a safe return. */ .pushsection .text..__x86.rethunk_untrain -SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_untrain_ret) UNWIND_HINT_FUNC ANNOTATE_NOENDBR ASM_NOP2
@@ -159,7 +159,7 @@ SYM_FUNC_END(srso_alias_untrain_ret) .popsection .pushsection .text..__x86.rethunk_safe -SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_safe_ret) lea 8(%_ASM_SP), %_ASM_SP UNWIND_HINT_FUNC ANNOTATE_UNRET_SAFE
@@ -187,7 +187,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(srso_untrain_ret) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -255,7 +255,7 @@ SYM_CODE_END(srso_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(retbleed_untrain_ret) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
[tip: x86/bugs] x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 642ff448c87d176aaf923597a70cb55baf2706ef Gitweb: https://git.kernel.org/tip/642ff448c87d176aaf923597a70cb55baf2706ef Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:01 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
Macros already exist for unaligned code block symbols. Use them.
--- arch/x86/lib/retpoline.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/retpoline.S +4 -4
@@ -149,7 +149,7 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) * As a result, srso_alias_safe_ret() becomes a safe return. */ .pushsection .text..__x86.rethunk_untrain -SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_untrain_ret) UNWIND_HINT_FUNC ANNOTATE_NOENDBR ASM_NOP2
@@ -159,7 +159,7 @@ SYM_FUNC_END(srso_alias_untrain_ret) .popsection .pushsection .text..__x86.rethunk_safe -SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_safe_ret) lea 8(%_ASM_SP), %_ASM_SP UNWIND_HINT_FUNC ANNOTATE_UNRET_SAFE
@@ -187,7 +187,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(srso_untrain_ret) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -255,7 +255,7 @@ SYM_CODE_END(srso_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(retbleed_untrain_ret) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
[tip: x86/bugs] x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 0a3c49178c3c3e6f29280567ccb549826dd3a3f1 Gitweb: https://git.kernel.org/tip/0a3c49178c3c3e6f29280567ccb549826dd3a3f1 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:01 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:40:42 +02:00
x86/rethunk: Use SYM_CODE_START[_LOCAL]_NOALIGN macros
Macros already exist for unaligned code block symbols. Use them.
--- arch/x86/lib/retpoline.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/lib/retpoline.S +4 -4
@@ -149,7 +149,7 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) * As a result, srso_alias_safe_ret() becomes a safe return. */ .pushsection .text..__x86.rethunk_untrain -SYM_START(srso_alias_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_untrain_ret) UNWIND_HINT_FUNC ANNOTATE_NOENDBR ASM_NOP2
@@ -159,7 +159,7 @@ SYM_FUNC_END(srso_alias_untrain_ret) .popsection .pushsection .text..__x86.rethunk_safe -SYM_START(srso_alias_safe_ret, SYM_L_GLOBAL, SYM_A_NONE) +SYM_CODE_START_NOALIGN(srso_alias_safe_ret) lea 8(%_ASM_SP), %_ASM_SP UNWIND_HINT_FUNC ANNOTATE_UNRET_SAFE
@@ -187,7 +187,7 @@ SYM_CODE_END(srso_alias_return_thunk) */ .align 64 .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc -SYM_START(srso_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(srso_untrain_ret) ANNOTATE_NOENDBR .byte 0x48, 0xb8
@@ -255,7 +255,7 @@ SYM_CODE_END(srso_return_thunk) */ .align 64 .skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc -SYM_START(retbleed_untrain_ret, SYM_L_LOCAL, SYM_A_NONE) +SYM_CODE_START_LOCAL_NOALIGN(retbleed_untrain_ret) ANNOTATE_NOENDBR /* * As executed from retbleed_untrain_ret, this is:
Josh Poimboeuf
maintainerPATCH v3 18/20 x86/retpoline: Remove .text..__x86.return_thunk section
In reply to Josh PoimboeufThe '.text..__x86.return_thunk' section has no purpose. Remove it and let the return thunk code live in '.text..__x86.indirect_thunk'.
--- arch/x86/kernel/vmlinux.lds.S | 3 --- arch/x86/lib/retpoline.S | 2 -- 2 files changed, 5 deletions(-)
arch/x86/kernel/vmlinux.lds.S +0 -3
@@ -132,10 +132,7 @@ SECTIONS LOCK_TEXT KPROBES_TEXT SOFTIRQENTRY_TEXT -#ifdef CONFIG_RETPOLINE *(.text..__x86.indirect_thunk) - *(.text..__x86.return_thunk) -#endif STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN
arch/x86/lib/retpoline.S +0 -2
@@ -129,8 +129,6 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) #ifdef CONFIG_RETHUNK - .section .text..__x86.return_thunk - #ifdef CONFIG_CPU_SRSO /*
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/retpoline: Remove .text..__x86.return_thunk section
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 6cb0ce310bad46ba9bc20ca906ff2ca40f170462 Gitweb: https://git.kernel.org/tip/6cb0ce310bad46ba9bc20ca906ff2ca40f170462 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:02 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:07 +02:00
x86/retpoline: Remove .text..__x86.return_thunk section
The '.text..__x86.return_thunk' section has no purpose. Remove it and let the return thunk code live in '.text..__x86.indirect_thunk'.
--- arch/x86/kernel/vmlinux.lds.S | 3 --- arch/x86/lib/retpoline.S | 2 -- 2 files changed, 5 deletions(-)
arch/x86/kernel/vmlinux.lds.S +0 -3
@@ -132,10 +132,7 @@ SECTIONS LOCK_TEXT KPROBES_TEXT SOFTIRQENTRY_TEXT -#ifdef CONFIG_RETPOLINE *(.text..__x86.indirect_thunk) - *(.text..__x86.return_thunk) -#endif STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN
arch/x86/lib/retpoline.S +0 -2
@@ -129,8 +129,6 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) #ifdef CONFIG_RETHUNK - .section .text..__x86.return_thunk - #ifdef CONFIG_CPU_SRSO /*
[tip: x86/bugs] x86/retpoline: Remove .text..__x86.return_thunk section
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: c8b840f7767b3178cc5fd92b70cc4c06c37943ac Gitweb: https://git.kernel.org/tip/c8b840f7767b3178cc5fd92b70cc4c06c37943ac Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:02 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/retpoline: Remove .text..__x86.return_thunk section
The '.text..__x86.return_thunk' section has no purpose. Remove it and let the return thunk code live in '.text..__x86.indirect_thunk'.
--- arch/x86/kernel/vmlinux.lds.S | 3 --- arch/x86/lib/retpoline.S | 2 -- 2 files changed, 5 deletions(-)
arch/x86/kernel/vmlinux.lds.S +0 -3
@@ -132,10 +132,7 @@ SECTIONS LOCK_TEXT KPROBES_TEXT SOFTIRQENTRY_TEXT -#ifdef CONFIG_RETPOLINE *(.text..__x86.indirect_thunk) - *(.text..__x86.return_thunk) -#endif STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN
arch/x86/lib/retpoline.S +0 -2
@@ -129,8 +129,6 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) #ifdef CONFIG_RETHUNK - .section .text..__x86.return_thunk - #ifdef CONFIG_CPU_SRSO /*
[tip: x86/bugs] x86/retpoline: Remove .text..__x86.return_thunk section
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e92626af3234708fe30f53b269d210d202b95206 Gitweb: https://git.kernel.org/tip/e92626af3234708fe30f53b269d210d202b95206 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:02 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/retpoline: Remove .text..__x86.return_thunk section
The '.text..__x86.return_thunk' section has no purpose. Remove it and let the return thunk code live in '.text..__x86.indirect_thunk'.
--- arch/x86/kernel/vmlinux.lds.S | 3 --- arch/x86/lib/retpoline.S | 2 -- 2 files changed, 5 deletions(-)
arch/x86/kernel/vmlinux.lds.S +0 -3
@@ -132,10 +132,7 @@ SECTIONS LOCK_TEXT KPROBES_TEXT SOFTIRQENTRY_TEXT -#ifdef CONFIG_RETPOLINE *(.text..__x86.indirect_thunk) - *(.text..__x86.return_thunk) -#endif STATIC_CALL_TEXT ALIGN_ENTRY_TEXT_BEGIN
arch/x86/lib/retpoline.S +0 -2
@@ -129,8 +129,6 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array) #ifdef CONFIG_RETHUNK - .section .text..__x86.return_thunk - #ifdef CONFIG_CPU_SRSO /*
Josh Poimboeuf
maintainerPATCH v3 19/20 x86/nospec: Refactor UNTRAIN_RET[_*]
In reply to Josh PoimboeufFactor out the UNTRAIN_RET[_*] common bits into a helper macro.
--- arch/x86/include/asm/nospec-branch.h | 31 +++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
arch/x86/include/asm/nospec-branch.h +10 -21
@@ -288,35 +288,24 @@* As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a point * where we have a stack but before any RET instruction. */ -.macro UNTRAIN_RET +.macro __UNTRAIN_RET ibpb_feature, call_depth_insns#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + "call entry_ibpb", \ibpb_feature, \ + __stringify(\call_depth_insns), X86_FEATURE_CALL_DEPTH #endif .endm -.macro UNTRAIN_RET_VM -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_IBPB_ON_VMEXIT, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH) -.macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH_FROM_CALL), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET_VM \ + __UNTRAIN_RET X86_FEATURE_IBPB_ON_VMEXIT, __stringify(RESET_CALL_DEPTH) + +#define UNTRAIN_RET_FROM_CALL \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH_FROM_CALL) .macro CALL_DEPTH_ACCOUNT
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/nospec: Refactor UNTRAIN_RET[_*]
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ef96daae49597e76a99f3db00dfc2c1559fe2443 Gitweb: https://git.kernel.org/tip/ef96daae49597e76a99f3db00dfc2c1559fe2443 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:03 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:08 +02:00
x86/nospec: Refactor UNTRAIN_RET[_*]
Factor out the UNTRAIN_RET[_*] common bits into a helper macro.
--- arch/x86/include/asm/nospec-branch.h | 31 ++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
arch/x86/include/asm/nospec-branch.h +10 -21
@@ -288,35 +288,24 @@* As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a point * where we have a stack but before any RET instruction. */ -.macro UNTRAIN_RET +.macro __UNTRAIN_RET ibpb_feature, call_depth_insns#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + "call entry_ibpb", \ibpb_feature, \ + __stringify(\call_depth_insns), X86_FEATURE_CALL_DEPTH #endif .endm -.macro UNTRAIN_RET_VM -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_IBPB_ON_VMEXIT, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH) -.macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH_FROM_CALL), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET_VM \ + __UNTRAIN_RET X86_FEATURE_IBPB_ON_VMEXIT, __stringify(RESET_CALL_DEPTH) + +#define UNTRAIN_RET_FROM_CALL \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH_FROM_CALL) .macro CALL_DEPTH_ACCOUNT
[tip: x86/bugs] x86/nospec: Refactor UNTRAIN_RET[_*]
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 82c6462008641aed2f213e7c51394cb8c7c1fce7 Gitweb: https://git.kernel.org/tip/82c6462008641aed2f213e7c51394cb8c7c1fce7 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:03 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/nospec: Refactor UNTRAIN_RET[_*]
Factor out the UNTRAIN_RET[_*] common bits into a helper macro.
--- arch/x86/include/asm/nospec-branch.h | 31 ++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
arch/x86/include/asm/nospec-branch.h +10 -21
@@ -288,35 +288,24 @@* As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a point * where we have a stack but before any RET instruction. */ -.macro UNTRAIN_RET +.macro __UNTRAIN_RET ibpb_feature, call_depth_insns#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + "call entry_ibpb", \ibpb_feature, \ + __stringify(\call_depth_insns), X86_FEATURE_CALL_DEPTH #endif .endm -.macro UNTRAIN_RET_VM -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_IBPB_ON_VMEXIT, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH) -.macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH_FROM_CALL), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET_VM \ + __UNTRAIN_RET X86_FEATURE_IBPB_ON_VMEXIT, __stringify(RESET_CALL_DEPTH) + +#define UNTRAIN_RET_FROM_CALL \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH_FROM_CALL) .macro CALL_DEPTH_ACCOUNT
[tip: x86/bugs] x86/nospec: Refactor UNTRAIN_RET[_*]
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e653cf101de2ac99d92049c38735cebc537fa2fb Gitweb: https://git.kernel.org/tip/e653cf101de2ac99d92049c38735cebc537fa2fb Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:03 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/nospec: Refactor UNTRAIN_RET[_*]
Factor out the UNTRAIN_RET[_*] common bits into a helper macro.
--- arch/x86/include/asm/nospec-branch.h | 31 ++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
arch/x86/include/asm/nospec-branch.h +10 -21
@@ -288,35 +288,24 @@* As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a point * where we have a stack but before any RET instruction. */ -.macro UNTRAIN_RET +.macro __UNTRAIN_RET ibpb_feature, call_depth_insns#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + "call entry_ibpb", \ibpb_feature, \ + __stringify(\call_depth_insns), X86_FEATURE_CALL_DEPTH #endif .endm -.macro UNTRAIN_RET_VM -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_IBPB_ON_VMEXIT, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH) -.macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH_FROM_CALL), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET_VM \ + __UNTRAIN_RET X86_FEATURE_IBPB_ON_VMEXIT, __stringify(RESET_CALL_DEPTH) + +#define UNTRAIN_RET_FROM_CALL \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH_FROM_CALL) .macro CALL_DEPTH_ACCOUNT
[tip: x86/bugs] x86/nospec: Refactor UNTRAIN_RET[_*]
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e8efc0800b8b5045ba8c0d1256bfbb47e92e192a Gitweb: https://git.kernel.org/tip/e8efc0800b8b5045ba8c0d1256bfbb47e92e192a Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:03 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:41:57 +02:00
x86/nospec: Refactor UNTRAIN_RET[_*]
Factor out the UNTRAIN_RET[_*] common bits into a helper macro.
--- arch/x86/include/asm/nospec-branch.h | 31 ++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
arch/x86/include/asm/nospec-branch.h +10 -21
@@ -288,35 +288,24 @@* As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a point * where we have a stack but before any RET instruction. */ -.macro UNTRAIN_RET +.macro __UNTRAIN_RET ibpb_feature, call_depth_insns#if defined(CONFIG_RETHUNK ) || defined(CONFIG_CPU_IBPB_ENTRY )VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH + "call entry_ibpb", \ibpb_feature, \ + __stringify(\call_depth_insns), X86_FEATURE_CALL_DEPTH #endif .endm -.macro UNTRAIN_RET_VM -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_IBPB_ON_VMEXIT, \ - __stringify(RESET_CALL_DEPTH), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH) -.macro UNTRAIN_RET_FROM_CALL -#if defined(CONFIG_RETHUNK) || defined(CONFIG_CPU_IBPB_ENTRY) - VALIDATE_UNRET_END - ALTERNATIVE_3 "", \ - CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ - "call entry_ibpb", X86_FEATURE_ENTRY_IBPB, \ - __stringify(RESET_CALL_DEPTH_FROM_CALL), X86_FEATURE_CALL_DEPTH -#endif -.endm +#define UNTRAIN_RET_VM \ + __UNTRAIN_RET X86_FEATURE_IBPB_ON_VMEXIT, __stringify(RESET_CALL_DEPTH) + +#define UNTRAIN_RET_FROM_CALL \ + __UNTRAIN_RET X86_FEATURE_ENTRY_IBPB, __stringify(RESET_CALL_DEPTH_FROM_CALL) .macro CALL_DEPTH_ACCOUNT
Josh Poimboeuf
maintainerPATCH v3 20/20 x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
In reply to Josh PoimboeufFor consistency with the other return thunks, rename __x86_return_skl() to call_depth_return_thunk().
--- arch/x86/include/asm/nospec-branch.h | 13 ++++--------- arch/x86/kernel/cpu/bugs.c | 3 ++- arch/x86/lib/retpoline.S | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/include/asm/nospec-branch.h +4 -9
@@ -358,12 +358,7 @@ extern void entry_ibpb(void);extern void (*x86_return_thunk)(void );#ifdef CONFIG_CALL_DEPTH_TRACKING -extern void __x86_return_skl (void ); - -static inline void x86_set_skl_return_thunk (void ) -{ - x86_return_thunk = &__x86_return_skl; -} +extern void call_depth_return_thunk (void );#define CALL_DEPTH_ACCOUNT \ ALTERNATIVE("", \
@@ -376,12 +371,12 @@ DECLARE_PER_CPU(u64, __x86_ret_count);DECLARE_PER_CPU (u64, __x86_stuffs_count);DECLARE_PER_CPU (u64, __x86_ctxsw_count);#endif -#else -static inline void x86_set_skl_return_thunk (void ) {} +#else /* !CONFIG_CALL_DEPTH_TRACKING */ +static inline void call_depth_return_thunk (void ) {}#define CALL_DEPTH_ACCOUNT "" -#endif +#endif /* CONFIG_CALL_DEPTH_TRACKING */ #ifdef CONFIG_RETPOLINE
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -1059,7 +1059,8 @@ static void __init retbleed_select_mitigation(void)case RETBLEED_MITIGATION_STUFF :setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_CALL_DEPTH ); -x86_set_skl_return_thunk (); + + x86_return_thunk = call_depth_return_thunk;break ;default :
arch/x86/lib/retpoline.S +2 -2
@@ -321,7 +321,7 @@ __EXPORT_THUNK(entry_untrain_ret) #ifdef CONFIG_CALL_DEPTH_TRACKING .align 64 -SYM_FUNC_START(__x86_return_skl) +SYM_FUNC_START(call_depth_return_thunk) ANNOTATE_NOENDBR /* * Keep the hotpath in a 16byte I-fetch for the non-debug
@@ -348,7 +348,7 @@ SYM_FUNC_START(__x86_return_skl) ANNOTATE_UNRET_SAFE ret int3 -SYM_FUNC_END(__x86_return_skl) +SYM_FUNC_END(call_depth_return_thunk) #endif /* CONFIG_CALL_DEPTH_TRACKING */
Signature · 1 line
2.41.0
[tip: x86/bugs] x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
The following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 423a4484b9235af31b1fd60d6049b820586e57d2 Gitweb: https://git.kernel.org/tip/423a4484b9235af31b1fd60d6049b820586e57d2 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:04 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 05 Sep 2023 12:05:08 +02:00
x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
For consistency with the other return thunks, rename __x86_return_skl() to call_depth_return_thunk().
--- arch/x86/include/asm/nospec-branch.h | 13 ++++--------- arch/x86/kernel/cpu/bugs.c | 3 ++- arch/x86/lib/retpoline.S | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/include/asm/nospec-branch.h +4 -9
@@ -358,12 +358,7 @@ extern void entry_ibpb(void);extern void (*x86_return_thunk)(void );#ifdef CONFIG_CALL_DEPTH_TRACKING -extern void __x86_return_skl (void ); - -static inline void x86_set_skl_return_thunk (void ) -{ - x86_return_thunk = &__x86_return_skl; -} +extern void call_depth_return_thunk (void );#define CALL_DEPTH_ACCOUNT \ ALTERNATIVE("", \
@@ -376,12 +371,12 @@ DECLARE_PER_CPU(u64, __x86_ret_count);DECLARE_PER_CPU (u64, __x86_stuffs_count);DECLARE_PER_CPU (u64, __x86_ctxsw_count);#endif -#else -static inline void x86_set_skl_return_thunk (void ) {} +#else /* !CONFIG_CALL_DEPTH_TRACKING */ +static inline void call_depth_return_thunk (void ) {}#define CALL_DEPTH_ACCOUNT "" -#endif +#endif /* CONFIG_CALL_DEPTH_TRACKING */ #ifdef CONFIG_RETPOLINE
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -1059,7 +1059,8 @@ do_cmd_auto:case RETBLEED_MITIGATION_STUFF :setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_CALL_DEPTH ); -x86_set_skl_return_thunk (); + + x86_return_thunk = call_depth_return_thunk;break ;default :
arch/x86/lib/retpoline.S +2 -2
@@ -321,7 +321,7 @@ __EXPORT_THUNK(entry_untrain_ret) #ifdef CONFIG_CALL_DEPTH_TRACKING .align 64 -SYM_FUNC_START(__x86_return_skl) +SYM_FUNC_START(call_depth_return_thunk) ANNOTATE_NOENDBR /* * Keep the hotpath in a 16byte I-fetch for the non-debug
@@ -348,7 +348,7 @@ SYM_FUNC_START(__x86_return_skl) ANNOTATE_UNRET_SAFE ret int3 -SYM_FUNC_END(__x86_return_skl) +SYM_FUNC_END(call_depth_return_thunk) #endif /* CONFIG_CALL_DEPTH_TRACKING */
[tip: x86/bugs] x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 01e1e86d8d206c2e34e66ff03d0bd5ce49675265 Gitweb: https://git.kernel.org/tip/01e1e86d8d206c2e34e66ff03d0bd5ce49675265 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:04 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 19 Sep 2023 11:42:48 +02:00
x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
For consistency with the other return thunks, rename __x86_return_skl() to call_depth_return_thunk().
--- arch/x86/include/asm/nospec-branch.h | 13 ++++--------- arch/x86/kernel/cpu/bugs.c | 3 ++- arch/x86/lib/retpoline.S | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/include/asm/nospec-branch.h +4 -9
@@ -358,12 +358,7 @@ extern void entry_ibpb(void);extern void (*x86_return_thunk)(void );#ifdef CONFIG_CALL_DEPTH_TRACKING -extern void __x86_return_skl (void ); - -static inline void x86_set_skl_return_thunk (void ) -{ - x86_return_thunk = &__x86_return_skl; -} +extern void call_depth_return_thunk (void );#define CALL_DEPTH_ACCOUNT \ ALTERNATIVE("", \
@@ -376,12 +371,12 @@ DECLARE_PER_CPU(u64, __x86_ret_count);DECLARE_PER_CPU (u64, __x86_stuffs_count);DECLARE_PER_CPU (u64, __x86_ctxsw_count);#endif -#else -static inline void x86_set_skl_return_thunk (void ) {} +#else /* !CONFIG_CALL_DEPTH_TRACKING */ +static inline void call_depth_return_thunk (void ) {}#define CALL_DEPTH_ACCOUNT "" -#endif +#endif /* CONFIG_CALL_DEPTH_TRACKING */ #ifdef CONFIG_RETPOLINE
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -1059,7 +1059,8 @@ do_cmd_auto:case RETBLEED_MITIGATION_STUFF :setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_CALL_DEPTH ); -x86_set_skl_return_thunk (); + + x86_return_thunk = call_depth_return_thunk;break ;default :
arch/x86/lib/retpoline.S +2 -2
@@ -321,7 +321,7 @@ __EXPORT_THUNK(entry_untrain_ret) #ifdef CONFIG_CALL_DEPTH_TRACKING .align 64 -SYM_FUNC_START(__x86_return_skl) +SYM_FUNC_START(call_depth_return_thunk) ANNOTATE_NOENDBR /* * Keep the hotpath in a 16byte I-fetch for the non-debug
@@ -348,7 +348,7 @@ SYM_FUNC_START(__x86_return_skl) ANNOTATE_UNRET_SAFE ret int3 -SYM_FUNC_END(__x86_return_skl) +SYM_FUNC_END(call_depth_return_thunk) #endif /* CONFIG_CALL_DEPTH_TRACKING */
[tip: x86/bugs] x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 88494339b5bccf0abea5660228fd066ec2e91dea Gitweb: https://git.kernel.org/tip/88494339b5bccf0abea5660228fd066ec2e91dea Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:04 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Sep 2023 14:13:03 +02:00
x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
For consistency with the other return thunks, rename __x86_return_skl() to call_depth_return_thunk().
--- arch/x86/include/asm/nospec-branch.h | 13 ++++--------- arch/x86/kernel/cpu/bugs.c | 3 ++- arch/x86/lib/retpoline.S | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/include/asm/nospec-branch.h +4 -9
@@ -358,12 +358,7 @@ extern void entry_ibpb(void);extern void (*x86_return_thunk)(void );#ifdef CONFIG_CALL_DEPTH_TRACKING -extern void __x86_return_skl (void ); - -static inline void x86_set_skl_return_thunk (void ) -{ - x86_return_thunk = &__x86_return_skl; -} +extern void call_depth_return_thunk (void );#define CALL_DEPTH_ACCOUNT \ ALTERNATIVE("", \
@@ -376,12 +371,12 @@ DECLARE_PER_CPU(u64, __x86_ret_count);DECLARE_PER_CPU (u64, __x86_stuffs_count);DECLARE_PER_CPU (u64, __x86_ctxsw_count);#endif -#else -static inline void x86_set_skl_return_thunk (void ) {} +#else /* !CONFIG_CALL_DEPTH_TRACKING */ +static inline void call_depth_return_thunk (void ) {}#define CALL_DEPTH_ACCOUNT "" -#endif +#endif /* CONFIG_CALL_DEPTH_TRACKING */ #ifdef CONFIG_RETPOLINE
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -1059,7 +1059,8 @@ do_cmd_auto:case RETBLEED_MITIGATION_STUFF :setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_CALL_DEPTH ); -x86_set_skl_return_thunk (); + + x86_return_thunk = call_depth_return_thunk;break ;default :
arch/x86/lib/retpoline.S +2 -2
@@ -321,7 +321,7 @@ __EXPORT_THUNK(entry_untrain_ret) #ifdef CONFIG_CALL_DEPTH_TRACKING .align 64 -SYM_FUNC_START(__x86_return_skl) +SYM_FUNC_START(call_depth_return_thunk) ANNOTATE_NOENDBR /* * Keep the hotpath in a 16byte I-fetch for the non-debug
@@ -348,7 +348,7 @@ SYM_FUNC_START(__x86_return_skl) ANNOTATE_UNRET_SAFE ret int3 -SYM_FUNC_END(__x86_return_skl) +SYM_FUNC_END(call_depth_return_thunk) #endif /* CONFIG_CALL_DEPTH_TRACKING */
[tip: x86/bugs] x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
In reply to Josh PoimboeufThe following commit has been merged into the x86/bugs branch of tip:
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 99ee56c7657f939eecc4e8ac96e0aa0cd6ea7cbd Gitweb: https://git.kernel.org/tip/99ee56c7657f939eecc4e8ac96e0aa0cd6ea7cbd Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 04 Sep 2023 22:05:04 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 20 Oct 2023 12:45:48 +02:00
x86/calldepth: Rename __x86_return_skl() to call_depth_return_thunk()
For consistency with the other return thunks, rename __x86_return_skl() to call_depth_return_thunk().
--- arch/x86/include/asm/nospec-branch.h | 13 ++++--------- arch/x86/kernel/cpu/bugs.c | 3 ++- arch/x86/lib/retpoline.S | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/include/asm/nospec-branch.h +4 -9
@@ -358,12 +358,7 @@ extern void entry_ibpb(void);extern void (*x86_return_thunk)(void );#ifdef CONFIG_CALL_DEPTH_TRACKING -extern void __x86_return_skl (void ); - -static inline void x86_set_skl_return_thunk (void ) -{ - x86_return_thunk = &__x86_return_skl; -} +extern void call_depth_return_thunk (void );#define CALL_DEPTH_ACCOUNT \ ALTERNATIVE("", \
@@ -376,12 +371,12 @@ DECLARE_PER_CPU(u64, __x86_ret_count);DECLARE_PER_CPU (u64, __x86_stuffs_count);DECLARE_PER_CPU (u64, __x86_ctxsw_count);#endif -#else -static inline void x86_set_skl_return_thunk (void ) {} +#else /* !CONFIG_CALL_DEPTH_TRACKING */ +static inline void call_depth_return_thunk (void ) {}#define CALL_DEPTH_ACCOUNT "" -#endif +#endif /* CONFIG_CALL_DEPTH_TRACKING */ #ifdef CONFIG_RETPOLINE
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -1059,7 +1059,8 @@ do_cmd_auto:case RETBLEED_MITIGATION_STUFF :setup_force_cpu_cap (X86_FEATURE_RETHUNK );setup_force_cpu_cap (X86_FEATURE_CALL_DEPTH ); -x86_set_skl_return_thunk (); + + x86_return_thunk = call_depth_return_thunk;break ;default :
arch/x86/lib/retpoline.S +2 -2
@@ -323,7 +323,7 @@ __EXPORT_THUNK(entry_untrain_ret) #ifdef CONFIG_CALL_DEPTH_TRACKING .align 64 -SYM_FUNC_START(__x86_return_skl) +SYM_FUNC_START(call_depth_return_thunk) ANNOTATE_NOENDBR /* * Keep the hotpath in a 16byte I-fetch for the non-debug
@@ -350,7 +350,7 @@ SYM_FUNC_START(__x86_return_skl) ANNOTATE_UNRET_SAFE ret int3 -SYM_FUNC_END(__x86_return_skl) +SYM_FUNC_END(call_depth_return_thunk) #endif /* CONFIG_CALL_DEPTH_TRACKING */