Re: [PATCH v3 00/20] SRSO fixes/cleanups

From: Ingo Molnar
Date: Tue Sep 05 2023 - 12:19:20 EST



* Borislav Petkov <bp@xxxxxxxxx> wrote:

> On Mon, Sep 04, 2023 at 10:04:44PM -0700, Josh Poimboeuf wrote:
> > 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(-)
>
> They all look good to me, thanks!
>
> Acked-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>

I've applied them to tip:x86/bugs, thanks guys!

Below is the delta diff from v2 to v3.

Thanks,

Ingo

diff --git a/Documentation/admin-guide/hw-vuln/srso.rst b/Documentation/admin-guide/hw-vuln/srso.rst
index 4516719e00b5..e715bfc09879 100644
--- a/Documentation/admin-guide/hw-vuln/srso.rst
+++ b/Documentation/admin-guide/hw-vuln/srso.rst
@@ -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
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index d538043c776d..016a32613259 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -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