5.10.133-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 95/148 x86: Add magic AMD return-thunk
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit a149180fbcf336e97ce4eb2cdc13672727feb94d upstream.
Note: needs to be in a section distinct from Retpolines such that the Retpoline RET substitution cannot possibly use immediate jumps.
ORC unwinding for zen_untrain_ret() and __x86_return_thunk() is a little tricky but works due to the fact that zen_untrain_ret() doesn't have any stack ops and as such will emit a single ORC entry at the start (+0x3f).
Meanwhile, unwinding an IP, including the __x86_return_thunk() one (+0x40) will search for the largest ORC entry smaller or equal to the IP, these will find the one ORC entry (+0x3f) and all works.
[ Alexandre: SVM part. ]
[ bp: Build fix, massages. ]
[bwh: Backported to 5.10: SEV-ES is not supported, so drop the change
in arch/x86/kvm/svm/vmenter.S]
--- arch/x86/entry/entry_64.S | 6 ++ arch/x86/entry/entry_64_compat.S | 4 + arch/x86/include/asm/cpufeatures.h | 1 arch/x86/include/asm/disabled-features.h | 3 - arch/x86/include/asm/nospec-branch.h | 17 ++++++++ arch/x86/kernel/vmlinux.lds.S | 2 arch/x86/kvm/svm/vmenter.S | 9 ++++ arch/x86/lib/retpoline.S | 63 +++++++++++++++++++++++++++++-- tools/objtool/check.c | 20 ++++++++- 9 files changed, 117 insertions(+), 8 deletions(-)
arch/x86/entry/entry_64.S +6 -0
@@ -102,6 +102,7 @@ SYM_CODE_START(entry_SYSCALL_64) movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp SYM_INNER_LABEL(entry_SYSCALL_64_safe_stack, SYM_L_GLOBAL) + UNTRAIN_RET /* Construct struct pt_regs on stack */ pushq $__USER_DS /* pt_regs->ss */
@@ -675,6 +676,7 @@ native_irq_return_ldt: pushq %rdi /* Stash user RDI */ swapgs /* to kernel GS */ SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi /* to kernel CR3 */ + UNTRAIN_RET movq PER_CPU_VAR(espfix_waddr), %rdi movq %rax, (0*8)(%rdi) /* user RAX */
@@ -910,6 +912,7 @@ SYM_CODE_START_LOCAL(paranoid_entry) * be retrieved from a kernel internal table. */ SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg=%rax save_reg=%r14 + UNTRAIN_RET /* * Handling GSBASE depends on the availability of FSGSBASE.
@@ -1022,6 +1025,7 @@ SYM_CODE_START_LOCAL(error_entry) FENCE_SWAPGS_USER_ENTRY /* We have user CR3. Change to kernel CR3. */ SWITCH_TO_KERNEL_CR3 scratch_reg=%rax + UNTRAIN_RET .Lerror_entry_from_usermode_after_swapgs: /* Put us onto the real thread stack. */
@@ -1077,6 +1081,7 @@ SYM_CODE_START_LOCAL(error_entry) SWAPGS FENCE_SWAPGS_USER_ENTRY SWITCH_TO_KERNEL_CR3 scratch_reg=%rax + UNTRAIN_RET /* * Pretend that the exception came from user mode: set up pt_regs
@@ -1171,6 +1176,7 @@ SYM_CODE_START(asm_exc_nmi) movq %rsp, %rdx movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp UNWIND_HINT_IRET_REGS base=%rdx offset=8 + UNTRAIN_RET pushq 5*8(%rdx) /* pt_regs->ss */ pushq 4*8(%rdx) /* pt_regs->rsp */ pushq 3*8(%rdx) /* pt_regs->flags */
arch/x86/entry/entry_64_compat.S +4 -0
@@ -14,6 +14,7 @@ #include <asm/irqflags.h> #include <asm/asm.h> #include <asm/smap.h> +#include <asm/nospec-branch.h> #include <linux/linkage.h> #include <linux/err.h>
@@ -71,6 +72,7 @@ SYM_CODE_START(entry_SYSENTER_compat) pushq $__USER32_CS /* pt_regs->cs */ pushq $0 /* pt_regs->ip = 0 (placeholder) */ SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) + UNTRAIN_RET /* * User tracing code (ptrace or signal handlers) might assume that
@@ -211,6 +213,7 @@ SYM_CODE_START(entry_SYSCALL_compat) movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp SYM_INNER_LABEL(entry_SYSCALL_compat_safe_stack, SYM_L_GLOBAL) + UNTRAIN_RET /* Construct struct pt_regs on stack */ pushq $__USER32_DS /* pt_regs->ss */
@@ -377,6 +380,7 @@ SYM_CODE_START(entry_INT80_compat) pushq (%rdi) /* pt_regs->di */ .Lint80_keep_stack: + UNTRAIN_RET pushq %rsi /* pt_regs->si */ xorl %esi, %esi /* nospec si */ pushq %rdx /* pt_regs->dx */
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -297,6 +297,7 @@#define X86_FEATURE_RETPOLINE (11*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ #define X86_FEATURE_RETPOLINE_LFENCE (11*32+13)/* "" Use LFENCE for Spectre variant 2 */ #define X86_FEATURE_RETHUNK (11*32+14)/* "" Use REturn THUNK */ +#define X86_FEATURE_UNRET (11*32+15)/* "" AMD BTB untrain return */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5)/* AVX512 BFLOAT16 instructions */
arch/x86/include/asm/disabled-features.h +2 -1
@@ -61,7 +61,8 @@#else # define DISABLE_RETPOLINE ((1 << (X86_FEATURE_RETPOLINE & 31)) | \ (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31)) | \ - (1 << (X86_FEATURE_RETHUNK & 31))) + (1 << (X86_FEATURE_RETHUNK & 31)) | \ + (1 << (X86_FEATURE_UNRET & 31)))#endif /* Force disable because it's broken beyond repair */
arch/x86/include/asm/nospec-branch.h +17 -0
@@ -112,6 +112,22 @@#endif .endm +/* + * Mitigate RETBleed for AMD/Hygon Zen uarch. Requires KERNEL CR3 because the + * return thunk isn't mapped into the userspace tables (then again, AMD + * typically has NO_MELTDOWN). + * + * Doesn't clobber any registers but does require a stable stack. + * + * 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 +#ifdef CONFIG_RETPOLINE +ALTERNATIVE "" ,"call zen_untrain_ret" ,X86_FEATURE_UNRET +#endif +.endm +#else /* __ASSEMBLY__ */ #define ANNOTATE_RETPOLINE_SAFE \
@@ -121,6 +137,7 @@".popsection\n\t" extern void __x86_return_thunk(void); +extern void zen_untrain_ret (void );#ifdef CONFIG_RETPOLINE
arch/x86/kernel/vmlinux.lds.S +1 -1
@@ -142,7 +142,7 @@ SECTIONS #ifdef CONFIG_RETPOLINE __indirect_thunk_start = .; - *(.text.__x86.indirect_thunk) + *(.text.__x86.*) __indirect_thunk_end = .; #endif } :text =0xcccc
arch/x86/kvm/svm/vmenter.S +9 -0
@@ -129,6 +129,15 @@ SYM_FUNC_START(__svm_vcpu_run) #endif /* + * Mitigate RETBleed for AMD/Hygon Zen uarch. RET should be + * untrained as soon as we exit the VM and are back to the + * kernel. This should be done before re-enabling interrupts + * because interrupt handlers won't sanitize 'ret' if the return is + * from the kernel. + */ + UNTRAIN_RET + + /* * Clear all general purpose registers except RSP and RAX to prevent * speculative use of the guest's values, even those that are reloaded * via the stack. In theory, an L1 cache miss when restoring registers
arch/x86/lib/retpoline.S +60 -3
70 lines not on this page · raw message
tools/objtool/check.c +17 -3
@@ -1082,7 +1082,7 @@ static void add_retpoline_call(struct obannotate_call_site (file, insn, false); } -static void add_return_call (struct objtool_file *file,struct instruction *insn) +static void add_return_call (struct objtool_file *file,struct instruction *insn,bool add) {/* * Return thunk tail calls are really just returns in disguise,
@@ -1092,7 +1092,7 @@ static void add_return_call(struct objto insn->retpoline_safe = true;/* Skip the non-text sections, specially .discard ones */ -if (insn->sec->text) +if (add && insn->sec->text)list_add_tail (&insn->call_node, &file->return_thunk_list); }
@@ -1121,7 +1121,7 @@ static int add_jump_destinations(structadd_retpoline_call (file, insn);continue ; }else if (reloc->sym->return_thunk) { -add_return_call (file, insn); +add_return_call (file, insn, true);continue ; }else if (insn->func) {/* internal or external sibling call (with reloc) */
@@ -1138,6 +1138,7 @@ static int add_jump_destinations(struct insn->jump_dest =find_insn (file, dest_sec, dest_off);if (!insn->jump_dest) { +struct symbol *sym =find_symbol_by_offset (dest_sec, dest_off);/* * This is a special case where an alt instruction
@@ -1147,6 +1148,19 @@ static int add_jump_destinations(structif (!strcmp (insn->sec->name,".altinstr_replacement" ))continue ; +/* +* This is a special case for zen_untrain_ret(). +* It jumps to __x86_return_thunk(), but objtool +* can't find the thunk's starting RET +* instruction, because the RET is also in the +* middle of another instruction. Objtool only +* knows about the outer instruction. +*/ +if (sym && sym->return_thunk) { +add_return_call (file, insn, false); +continue ; + } +WARN_FUNC ("can't find jump dest instruction at %s+0x%lx" , insn->sec, insn->offset, dest_sec->name, dest_off);
Greg Kroah-Hartman
maintainerPATCH 96/148 x86/bugs: Report AMD retbleed vulnerability
In reply to Greg Kroah-HartmanFrom: Alexandre Chartre <[email protected]>
commit 6b80b59b3555706508008f1f127b5412c89c7fd8 upstream.
Report that AMD x86 CPUs are vulnerable to the RETBleed (Arbitrary Speculative Code Execution with Return Instructions) attack.
[peterz: add hygon]
[kim: invert parity; fam15h]
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/bugs.c | 13 +++++++++++++ arch/x86/kernel/cpu/common.c | 19 +++++++++++++++++++ drivers/base/cpu.c | 8 ++++++++ include/linux/cpu.h | 2 ++ 5 files changed, 43 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -426,5 +426,6 @@#define X86_BUG_ITLB_MULTIHIT X86_BUG(23)/* CPU may incur MCE during certain page attribute changes */ #define X86_BUG_SRBDS X86_BUG(24)/* CPU may leak RNG bits if not mitigated */ #define X86_BUG_MMIO_STALE_DATA X86_BUG(25)/* CPU is affected by Processor MMIO Stale Data vulnerabilities */ +#define X86_BUG_RETBLEED X86_BUG(26)/* CPU is affected by RETBleed */ #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/kernel/cpu/bugs.c +13 -0
@@ -1917,6 +1917,11 @@ static ssize_t srbds_show_state(char *bureturn sprintf (buf,"%s\n" , srbds_strings[srbds_mitigation]); } +static ssize_t retbleed_show_state (char *buf) +{ +return sprintf (buf,"Vulnerable\n" ); +} +static ssize_t cpu_show_common (struct device *dev,struct device_attribute *attr,char *buf,unsigned int bug) {
@@ -1962,6 +1967,9 @@ static ssize_t cpu_show_common(struct decase X86_BUG_MMIO_STALE_DATA :return mmio_stale_data_show_state (buf); +case X86_BUG_RETBLEED : +return retbleed_show_state (buf); +default :break ; }
@@ -2018,4 +2026,9 @@ ssize_t cpu_show_mmio_stale_data(struct {return cpu_show_common (dev, attr, buf,X86_BUG_MMIO_STALE_DATA ); } + +ssize_t cpu_show_retbleed (struct device *dev,struct device_attribute *attr,char *buf) +{ +return cpu_show_common (dev, attr, buf,X86_BUG_RETBLEED ); +}#endif
arch/x86/kernel/cpu/common.c +19 -0
@@ -1092,16 +1092,27 @@ static const __initconst struct x86_cpu_ {} }; +#define VULNBL (vendor, family, model, blacklist) \ + X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, blacklist) +#define VULNBL_INTEL_STEPPINGS (model, steppings, issues) \ X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, \ INTEL_FAM6_##model, steppings, \ X86_FEATURE_ANY, issues) +#define VULNBL_AMD (family, blacklist) \ + VULNBL(AMD, family, X86_MODEL_ANY, blacklist) + +#define VULNBL_HYGON (family, blacklist) \ + VULNBL(HYGON, family, X86_MODEL_ANY, blacklist) +#define SRBDS BIT(0)/* CPU is affected by X86_BUG_MMIO_STALE_DATA */ #define MMIO BIT(1)/* CPU is affected by Shared Buffers Data Sampling (SBDS), a variant of X86_BUG_MMIO_STALE_DATA */ #define MMIO_SBDS BIT(2) +/* CPU is affected by RETbleed, speculating where you would not expect it */ +#define RETBLEED BIT(3)static const struct x86_cpu_id cpu_vuln_blacklist[]__initconst = {VULNBL_INTEL_STEPPINGS (IVYBRIDGE ,X86_STEPPING_ANY ,SRBDS ),
@@ -1134,6 +1145,11 @@ static const struct x86_cpu_id cpu_vuln_VULNBL_INTEL_STEPPINGS (ATOM_TREMONT ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS ),VULNBL_INTEL_STEPPINGS (ATOM_TREMONT_D ,X86_STEPPING_ANY ,MMIO ),VULNBL_INTEL_STEPPINGS (ATOM_TREMONT_L ,X86_STEPPINGS (0x0 ,0x0 ),MMIO |MMIO_SBDS ), + +VULNBL_AMD (0x15 ,RETBLEED ), +VULNBL_AMD (0x16 ,RETBLEED ), +VULNBL_AMD (0x17 ,RETBLEED ), + VULNBL_HYGON(0x18, RETBLEED), {} };
@@ -1235,6 +1251,9 @@ static void __init cpu_set_bug_bits(stru !arch_cap_mmio_immune(ia32_cap))setup_force_cpu_bug (X86_BUG_MMIO_STALE_DATA ); +if (cpu_matches (cpu_vuln_blacklist,RETBLEED )) +setup_force_cpu_bug (X86_BUG_RETBLEED ); +if (cpu_matches (cpu_vuln_whitelist,NO_MELTDOWN ))return ;
drivers/base/cpu.c +8 -0
@@ -572,6 +572,12 @@ ssize_t __weak cpu_show_mmio_stale_data(return sysfs_emit (buf,"Not affected\n" ); } +ssize_t __weak cpu_show_retbleed (struct device *dev, +struct device_attribute *attr,char *buf) +{ +return sysfs_emit (buf,"Not affected\n" ); +} + static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL); static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL); static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
@@ -582,6 +588,7 @@ static DEVICE_ATTR(tsx_async_abort, 0444 static DEVICE_ATTR(itlb_multihit, 0444, cpu_show_itlb_multihit, NULL); static DEVICE_ATTR(srbds, 0444, cpu_show_srbds, NULL); static DEVICE_ATTR(mmio_stale_data, 0444, cpu_show_mmio_stale_data, NULL); +static DEVICE_ATTR(retbleed, 0444, cpu_show_retbleed, NULL);static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_meltdown.attr,
@@ -594,6 +601,7 @@ static struct attribute *cpu_root_vulner &dev_attr_itlb_multihit.attr, &dev_attr_srbds.attr, &dev_attr_mmio_stale_data.attr, + &dev_attr_retbleed.attr, NULL };
include/linux/cpu.h +2 -0
@@ -68,6 +68,8 @@ extern ssize_t cpu_show_srbds(struct devextern ssize_t cpu_show_mmio_stale_data (struct device *dev,struct device_attribute *attr,char *buf); +extern ssize_t cpu_show_retbleed (struct device *dev, +struct device_attribute *attr,char *buf); extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata,
Greg Kroah-Hartman
maintainerPATCH 97/148 x86/bugs: Add AMD retbleed= boot parameter
In reply to Greg Kroah-HartmanFrom: Alexandre Chartre <[email protected]>
commit 7fbf47c7ce50b38a64576b150e7011ae73d54669 upstream.
Add the "retbleed=<value>" boot parameter to select a mitigation for RETBleed. Possible values are "off", "auto" and "unret" (JMP2RET mitigation). The default value is "auto".
Currently, "retbleed=auto" will select the unret mitigation on AMD and Hygon and no mitigation on Intel (JMP2RET is not effective on Intel).
[peterz: rebase; add hygon]
[jpoimboe: cleanups]
--- Documentation/admin-guide/kernel-parameters.txt | 15 +++ arch/x86/Kconfig | 3 arch/x86/kernel/cpu/bugs.c | 108 +++++++++++++++++++++++- 3 files changed, 125 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +15 -0
@@ -4656,6 +4656,21 @@ retain_initrd [RAM] Keep initrd memory after extraction + retbleed= [X86] Control mitigation of RETBleed (Arbitrary + Speculative Code Execution with Return Instructions) + vulnerability. + + off - unconditionally disable + auto - automatically select a migitation + unret - force enable untrained return thunks, + only effective on AMD Zen {1,2} + based systems. + + Selecting 'auto' will choose a mitigation method at run + time according to the CPU. + + Not specifying this option is equivalent to retbleed=auto. + rfkill.default_state= 0 "airplane mode". All wifi, bluetooth, wimax, gps, fm, etc. communication is blocked by default.
arch/x86/Kconfig +3 -0
@@ -465,6 +465,9 @@ config RETPOLINE config CC_HAS_SLS def_bool $(cc-option,-mharden-sls=all) +config CC_HAS_RETURN_THUNK + def_bool $(cc-option,-mfunction-return=thunk-extern) + config SLS bool "Mitigate Straight-Line-Speculation" depends on CC_HAS_SLS && X86_64
arch/x86/kernel/cpu/bugs.c +107 -1
132 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 98/148 x86/bugs: Enable STIBP for JMP2RET
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit e8ec1b6e08a2102d8755ccb06fa26d540f26a2fa upstream.
For untrained return thunks to be fully effective, STIBP must be enabled or SMT disabled.
--- Documentation/admin-guide/kernel-parameters.txt | 16 ++++-- arch/x86/kernel/cpu/bugs.c | 58 +++++++++++++++++++----- 2 files changed, 57 insertions(+), 17 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +11 -5
@@ -4660,11 +4660,17 @@ Speculative Code Execution with Return Instructions) vulnerability. - off - unconditionally disable - auto - automatically select a migitation - unret - force enable untrained return thunks, - only effective on AMD Zen {1,2} - based systems. + off - no mitigation + auto - automatically select a migitation + auto,nosmt - automatically select a mitigation, + disabling SMT if necessary for + the full mitigation (only on Zen1 + and older without STIBP). + unret - force enable untrained return thunks, + only effective on AMD f15h-f17h + based systems. + unret,nosmt - like unret, will disable SMT when STIBP + is not available. Selecting 'auto' will choose a mitigation method at run time according to the CPU.
arch/x86/kernel/cpu/bugs.c +46 -12
87 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 99/148 x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit caa0ff24d5d0e02abce5e65c3d2b7f20a6617be5 upstream.
Due to TIF_SSBD and TIF_SPEC_IB the actual IA32_SPEC_CTRL value can differ from x86_spec_ctrl_base. As such, keep a per-CPU value reflecting the current task's MSR content.
[jpoimboe: rename]
--- arch/x86/include/asm/nospec-branch.h | 1 + arch/x86/kernel/cpu/bugs.c | 28 +++++++++++++++++++++++----- arch/x86/kernel/process.c | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-)
arch/x86/include/asm/nospec-branch.h +1 -0
@@ -254,6 +254,7 @@ static inline void indirect_branch_predi/* The Intel SPEC CTRL MSR base value cache */ extern u64 x86_spec_ctrl_base; +extern void write_spec_ctrl_current (u64 val);/* * With retpoline, we must use IBRS to restrict branch prediction
arch/x86/kernel/cpu/bugs.c +23 -5
@@ -48,12 +48,30 @@ static void __init taa_select_mitigationstatic void __init mmio_select_mitigation (void );static void __init srbds_select_mitigation (void ); -/* The base value of the SPEC_CTRL MSR that always has to be preserved. */ +/* The base value of the SPEC_CTRL MSR without task-specific bits set */ u64 x86_spec_ctrl_base;EXPORT_SYMBOL_GPL (x86_spec_ctrl_base); + +/* The current value of the SPEC_CTRL MSR with task-specific bits set */ +DEFINE_PER_CPU (u64, x86_spec_ctrl_current); +EXPORT_SYMBOL_GPL (x86_spec_ctrl_current); +static DEFINE_MUTEX (spec_ctrl_mutex);/* +* Keep track of the SPEC_CTRL MSR value for the current task, which may differ +* from x86_spec_ctrl_base due to STIBP/SSB in __speculation_ctrl_update(). +*/ +void write_spec_ctrl_current (u64 val) +{ +if (this_cpu_read (x86_spec_ctrl_current) == val) +return ; + +this_cpu_write (x86_spec_ctrl_current, val); +wrmsrl (MSR_IA32_SPEC_CTRL , val); +} + +/* * The vendor and possibly platform specific bits which can be modified in * x86_spec_ctrl_base. */
@@ -1235,7 +1253,7 @@ static void __init spectre_v2_select_mitif (spectre_v2_in_eibrs_mode (mode)) {/* Force it so VMEXIT will restore correctly */ x86_spec_ctrl_base |=SPEC_CTRL_IBRS ; -wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base); }switch (mode) {
@@ -1290,7 +1308,7 @@ static void __init spectre_v2_select_mitstatic void update_stibp_msr (void * __unused) { -wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base); }/* Update x86_spec_ctrl_base in case SMT state changed. */
@@ -1533,7 +1551,7 @@ static enum ssb_mitigation __init __ssb_x86_amd_ssb_disable (); }else { x86_spec_ctrl_base |=SPEC_CTRL_SSBD ; -wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base); } }
@@ -1751,7 +1769,7 @@ int arch_prctl_spec_ctrl_get(struct taskvoid x86_spec_ctrl_setup_ap (void ) {if (boot_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) -wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base);if (ssb_mode ==SPEC_STORE_BYPASS_DISABLE )x86_amd_ssb_disable ();
arch/x86/kernel/process.c +1 -1
@@ -556,7 +556,7 @@ static __always_inline void __speculatio }if (updmsr) -wrmsrl (MSR_IA32_SPEC_CTRL , msr); +write_spec_ctrl_current (msr); }static unsigned long speculation_ctrl_update_tif (struct task_struct *tsk)
Greg Kroah-Hartman
maintainerPATCH 100/148 x86/entry: Add kernel IBRS implementation
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 2dbb887e875b1de3ca8f40ddf26bcfe55798c609 upstream.
Implement Kernel IBRS - currently the only known option to mitigate RSB underflow speculation issues on Skylake hardware.
Note: since IBRS_ENTER requires fuller context established than UNTRAIN_RET, it must be placed after it. However, since UNTRAIN_RET itself implies a RET, it must come after IBRS_ENTER. This means IBRS_ENTER needs to also move UNTRAIN_RET.
Note 2: KERNEL_IBRS is sub-optimal for XenPV.
--- arch/x86/entry/calling.h | 58 +++++++++++++++++++++++++++++++++++++ arch/x86/entry/entry_64.S | 44 ++++++++++++++++++++++++---- arch/x86/entry/entry_64_compat.S | 17 ++++++++-- arch/x86/include/asm/cpufeatures.h | 2 - 4 files changed, 111 insertions(+), 10 deletions(-)
arch/x86/entry/calling.h +58 -0
@@ -6,6 +6,8 @@#include <asm/percpu.h> #include <asm/asm-offsets.h> #include <asm/processor-flags.h> +#include <asm/msr.h> +#include <asm/nospec-branch.h> /*
@@ -309,6 +311,62 @@ For 32-bit we have the following convent#endif /* +* IBRS kernel mitigation for Spectre_v2. +* +* Assumes full context is established (PUSH_REGS, CR3 and GS) and it clobbers +* the regs it uses (AX, CX, DX). Must be called before the first RET +* instruction (NOTE! UNTRAIN_RET includes a RET instruction) +* +* The optional argument is used to save/restore the current value, +* which is used on the paranoid paths. +* +* Assumes x86_spec_ctrl_{base,current} to have SPEC_CTRL_IBRS set. +*/ +.macro IBRS_ENTER save_reg + ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_KERNEL_IBRS + movl $MSR_IA32_SPEC_CTRL, %ecx + +.ifnb \save_reg + rdmsr + shl $32, %rdx + or %rdx, %rax + mov %rax, \save_reg + test $SPEC_CTRL_IBRS, %eax + jz .Ldo_wrmsr_\@ + lfence + jmp .Lend_\@ +.Ldo_wrmsr_\@: +.endif + + movq PER_CPU_VAR(x86_spec_ctrl_current), %rdx + movl %edx, %eax + shr $32, %rdx + wrmsr +.Lend_\@: +.endm + +/* + * Similar to IBRS_ENTER, requires KERNEL GS,CR3 and clobbers (AX, CX, DX) + * regs. Must be called after the last RET. + */ +.macro IBRS_EXIT save_reg + ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_KERNEL_IBRS + movl $MSR_IA32_SPEC_CTRL, %ecx + +.ifnb \save_reg + mov \save_reg, %rdx +.else + movq PER_CPU_VAR(x86_spec_ctrl_current), %rdx + andl $(~SPEC_CTRL_IBRS), %edx +.endif + + movl %edx, %eax + shr $32, %rdx + wrmsr +.Lend_\@: +.endm + +/* * Mitigate Spectre v1 for conditional swapgs code paths. * * FENCE_SWAPGS_USER_ENTRY is used in the user entry swapgs code path, to
arch/x86/entry/entry_64.S +39 -5
135 lines not on this page · raw message
arch/x86/entry/entry_64_compat.S +13 -4
@@ -4,7 +4,6 @@ * * Copyright 2000-2002 Andi Kleen, SuSE Labs. */ -#include "calling.h" #include <asm/asm-offsets.h> #include <asm/current.h> #include <asm/errno.h>
@@ -18,6 +17,8 @@ #include <linux/linkage.h> #include <linux/err.h> +#include "calling.h" + .section .entry.text, "ax" /*
@@ -72,7 +73,6 @@ SYM_CODE_START(entry_SYSENTER_compat) pushq $__USER32_CS /* pt_regs->cs */ pushq $0 /* pt_regs->ip = 0 (placeholder) */ SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) - UNTRAIN_RET /* * User tracing code (ptrace or signal handlers) might assume that
@@ -114,6 +114,9 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_af cld + IBRS_ENTER + UNTRAIN_RET + /* * SYSENTER doesn't filter flags, so we need to clear NT and AC * ourselves. To save a few cycles, we can check whether
@@ -213,7 +216,6 @@ SYM_CODE_START(entry_SYSCALL_compat) movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp SYM_INNER_LABEL(entry_SYSCALL_compat_safe_stack, SYM_L_GLOBAL) - UNTRAIN_RET /* Construct struct pt_regs on stack */ pushq $__USER32_DS /* pt_regs->ss */
@@ -255,6 +257,9 @@ SYM_INNER_LABEL(entry_SYSCALL_compat_aft UNWIND_HINT_REGS + IBRS_ENTER + UNTRAIN_RET + movq %rsp, %rdi call do_fast_syscall_32 /* XEN PV guests always use IRET path */
@@ -269,6 +274,8 @@ sysret32_from_system_call: */ STACKLEAK_ERASE + IBRS_EXIT + movq RBX(%rsp), %rbx /* pt_regs->rbx */ movq RBP(%rsp), %rbp /* pt_regs->rbp */ movq EFLAGS(%rsp), %r11 /* pt_regs->flags (in r11) */
@@ -380,7 +387,6 @@ SYM_CODE_START(entry_INT80_compat) pushq (%rdi) /* pt_regs->di */ .Lint80_keep_stack: - UNTRAIN_RET pushq %rsi /* pt_regs->si */ xorl %esi, %esi /* nospec si */ pushq %rdx /* pt_regs->dx */
@@ -413,6 +419,9 @@ SYM_CODE_START(entry_INT80_compat) cld + IBRS_ENTER + UNTRAIN_RET + movq %rsp, %rdi call do_int80_syscall_32 jmp swapgs_restore_regs_and_return_to_usermode
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -203,7 +203,7 @@#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ #define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ -/* FREE! ( 7*32+12) */ +#define X86_FEATURE_KERNEL_IBRS ( 7*32+12)/* "" Set/clear IBRS on kernel entry/exit */ /* FREE! ( 7*32+13) */ #define X86_FEATURE_INTEL_PPIN ( 7*32+14)/* Intel Processor Inventory Number */ #define X86_FEATURE_CDP_L2 ( 7*32+15)/* Code and Data Prioritization L2 */
Greg Kroah-Hartman
maintainerPATCH 101/148 x86/bugs: Optimize SPEC_CTRL MSR writes
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit c779bc1a9002fa474175b80e72b85c9bf628abb0 upstream.
When changing SPEC_CTRL for user control, the WRMSR can be delayed until return-to-user when KERNEL_IBRS has been enabled.
This avoids an MSR write during context switch.
--- arch/x86/include/asm/nospec-branch.h | 2 +- arch/x86/kernel/cpu/bugs.c | 18 ++++++++++++------ arch/x86/kernel/process.c | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-)
arch/x86/include/asm/nospec-branch.h +1 -1
@@ -254,7 +254,7 @@ static inline void indirect_branch_predi/* The Intel SPEC CTRL MSR base value cache */ extern u64 x86_spec_ctrl_base; -extern void write_spec_ctrl_current (u64 val); +extern void write_spec_ctrl_current (u64 val,bool force);/* * With retpoline, we must use IBRS to restrict branch prediction
arch/x86/kernel/cpu/bugs.c +12 -6
@@ -62,13 +62,19 @@ static DEFINE_MUTEX(spec_ctrl_mutex);* Keep track of the SPEC_CTRL MSR value for the current task, which may differ * from x86_spec_ctrl_base due to STIBP/SSB in __speculation_ctrl_update(). */ -void write_spec_ctrl_current (u64 val) +void write_spec_ctrl_current (u64 val,bool force) {if (this_cpu_read (x86_spec_ctrl_current) == val)return ;this_cpu_write (x86_spec_ctrl_current, val); -wrmsrl (MSR_IA32_SPEC_CTRL , val); + +/* +* When KERNEL_IBRS this MSR is written on return-to-user, unless +* forced the update can be delayed until that time. +*/ +if (force || !cpu_feature_enabled (X86_FEATURE_KERNEL_IBRS )) +wrmsrl (MSR_IA32_SPEC_CTRL , val); }/*
@@ -1253,7 +1259,7 @@ static void __init spectre_v2_select_mitif (spectre_v2_in_eibrs_mode (mode)) {/* Force it so VMEXIT will restore correctly */ x86_spec_ctrl_base |=SPEC_CTRL_IBRS ; -write_spec_ctrl_current (x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base, true); }switch (mode) {
@@ -1308,7 +1314,7 @@ static void __init spectre_v2_select_mitstatic void update_stibp_msr (void * __unused) { -write_spec_ctrl_current (x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base, true); }/* Update x86_spec_ctrl_base in case SMT state changed. */
@@ -1551,7 +1557,7 @@ static enum ssb_mitigation __init __ssb_x86_amd_ssb_disable (); }else { x86_spec_ctrl_base |=SPEC_CTRL_SSBD ; -write_spec_ctrl_current (x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base, true); } }
@@ -1769,7 +1775,7 @@ int arch_prctl_spec_ctrl_get(struct taskvoid x86_spec_ctrl_setup_ap (void ) {if (boot_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) -write_spec_ctrl_current (x86_spec_ctrl_base); +write_spec_ctrl_current (x86_spec_ctrl_base, true);if (ssb_mode ==SPEC_STORE_BYPASS_DISABLE )x86_amd_ssb_disable ();
arch/x86/kernel/process.c +1 -1
@@ -556,7 +556,7 @@ static __always_inline void __speculatio }if (updmsr) -write_spec_ctrl_current (msr); +write_spec_ctrl_current (msr, false); }static unsigned long speculation_ctrl_update_tif (struct task_struct *tsk)
Greg Kroah-Hartman
maintainerPATCH 102/148 x86/speculation: Add spectre_v2=ibrs option to support Kernel IBRS
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 7c693f54c873691a4b7da05c7e0f74e67745d144 upstream.
Extend spectre_v2= boot option with Kernel IBRS.
[jpoimboe: no STIBP with IBRS]
--- Documentation/admin-guide/kernel-parameters.txt | 1 arch/x86/include/asm/nospec-branch.h | 1 arch/x86/kernel/cpu/bugs.c | 66 ++++++++++++++++++------ 3 files changed, 54 insertions(+), 14 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -0
@@ -5026,6 +5026,7 @@ eibrs - enhanced IBRS eibrs,retpoline - enhanced IBRS + Retpolines eibrs,lfence - enhanced IBRS + LFENCE + ibrs - use IBRS to protect kernel Not specifying this option is equivalent to spectre_v2=auto.
arch/x86/include/asm/nospec-branch.h +1 -0
@@ -212,6 +212,7 @@ enum spectre_v2_mitigation {SPECTRE_V2_EIBRS ,SPECTRE_V2_EIBRS_RETPOLINE ,SPECTRE_V2_EIBRS_LFENCE , + SPECTRE_V2_IBRS, };/* The indirect branch speculation control variants */
arch/x86/kernel/cpu/bugs.c +52 -14
148 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 103/148 x86/bugs: Split spectre_v2_select_mitigation() and spectre_v2_user_select_mitigation()
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 166115c08a9b0b846b783088808a27d739be6e8d upstream.
retbleed will depend on spectre_v2, while spectre_v2_user depends on retbleed. Break this cycle.
--- arch/x86/kernel/cpu/bugs.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +17 -8
@@ -37,8 +37,9 @@#include "cpu.h" static void __init spectre_v1_select_mitigation (void ); -static void __init retbleed_select_mitigation (void );static void __init spectre_v2_select_mitigation (void ); +static void __init retbleed_select_mitigation (void ); +static void __init spectre_v2_user_select_mitigation (void );static void __init ssb_select_mitigation (void );static void __init l1tf_select_mitigation (void );static void __init mds_select_mitigation (void );
@@ -137,13 +138,19 @@ void __init check_bugs(void)/* Select the proper CPU mitigations before patching alternatives: */ spectre_v1_select_mitigation (); +spectre_v2_select_mitigation (); +/* +* retbleed_select_mitigation() relies on the state set by +* spectre_v2_select_mitigation(); specifically it wants to know about +* spectre_v2=ibrs. +*/ retbleed_select_mitigation ();/* -* spectre_v2_select_mitigation() relies on the state set by +* spectre_v2_user_select_mitigation() relies on the state set by * retbleed_select_mitigation(); specifically the STIBP selection is * forced for UNRET. */ -spectre_v2_select_mitigation (); +spectre_v2_user_select_mitigation ();ssb_select_mitigation ();l1tf_select_mitigation ();md_clear_select_mitigation ();
@@ -969,13 +976,15 @@ static void __init spec_v2_user_print_copr_info ("spectre_v2_user=%s forced on command line.\n" , reason); } +static __ro_after_init enum spectre_v2_mitigation_cmd spectre_v2_cmd; +static enum spectre_v2_user_cmd __init -spectre_v2_parse_user_cmdline (enum spectre_v2_mitigation_cmd v2_cmd) +spectre_v2_parse_user_cmdline (void ) {char arg[20 ];int ret, i; -switch (v2_cmd) { +switch (spectre_v2_cmd) {case SPECTRE_V2_CMD_NONE :return SPECTRE_V2_USER_CMD_NONE ;case SPECTRE_V2_CMD_FORCE :
@@ -1010,7 +1019,7 @@ static inline bool spectre_v2_in_ibrs_mo }static void __init -spectre_v2_user_select_mitigation (enum spectre_v2_mitigation_cmd v2_cmd) +spectre_v2_user_select_mitigation (void ) {enum spectre_v2_user_mitigation mode =SPECTRE_V2_USER_NONE ;bool smt_possible =IS_ENABLED (CONFIG_SMP );
@@ -1023,7 +1032,7 @@ spectre_v2_user_select_mitigation(enum s cpu_smt_control == CPU_SMT_NOT_SUPPORTED) smt_possible = false; - cmd =spectre_v2_parse_user_cmdline (v2_cmd); + cmd =spectre_v2_parse_user_cmdline ();switch (cmd) {case SPECTRE_V2_USER_CMD_NONE : goto set_mode;
@@ -1347,7 +1356,7 @@ static void __init spectre_v2_select_mit }/* Set up IBPB and STIBP depending on the general spectre V2 command */ -spectre_v2_user_select_mitigation (cmd); + spectre_v2_cmd = cmd; }static void update_stibp_msr (void * __unused)
Greg Kroah-Hartman
maintainerPATCH 104/148 x86/bugs: Report Intel retbleed vulnerability
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 6ad0ad2bf8a67e27d1f9d006a1dabb0e1c360cc3 upstream.
Skylake suffers from RSB underflow speculation issues; report this vulnerability and it's mitigation (spectre_v2=ibrs).
[jpoimboe: cleanups, eibrs]
--- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/bugs.c | 39 +++++++++++++++++++++++++++++++++------ arch/x86/kernel/cpu/common.c | 24 ++++++++++++------------ 3 files changed, 46 insertions(+), 18 deletions(-)
arch/x86/include/asm/msr-index.h +1 -0
@@ -91,6 +91,7 @@#define MSR_IA32_ARCH_CAPABILITIES 0x0000010a#define ARCH_CAP_RDCL_NO BIT(0)/* Not susceptible to Meltdown */ #define ARCH_CAP_IBRS_ALL BIT(1)/* Enhanced IBRS support */ +#define ARCH_CAP_RSBA BIT(2)/* RET may use alternative branch predictors */ #define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH BIT(3)/* Skip L1D flush on vmentry */ #define ARCH_CAP_SSB_NO BIT(4)/* * Not susceptible to Speculative Store Bypass
arch/x86/kernel/cpu/bugs.c +33 -6
@@ -746,12 +746,17 @@ static int __init nospectre_v1_cmdline(c }early_param ("nospectre_v1" , nospectre_v1_cmdline); +static enum spectre_v2_mitigation spectre_v2_enabled__ro_after_init = +SPECTRE_V2_NONE ; +#undef pr_fmt#define pr_fmt (fmt) "RETBleed: " fmtenum retbleed_mitigation {RETBLEED_MITIGATION_NONE ,RETBLEED_MITIGATION_UNRET , +RETBLEED_MITIGATION_IBRS , +RETBLEED_MITIGATION_EIBRS , };enum retbleed_mitigation_cmd {
@@ -763,6 +768,8 @@ enum retbleed_mitigation_cmd {const char *const retbleed_strings[] = { [RETBLEED_MITIGATION_NONE ] ="Vulnerable" , [RETBLEED_MITIGATION_UNRET ] ="Mitigation: untrained return thunk" , + [RETBLEED_MITIGATION_IBRS ] ="Mitigation: IBRS" , + [RETBLEED_MITIGATION_EIBRS ] ="Mitigation: Enhanced IBRS" , }; static enum retbleed_mitigation retbleed_mitigation __ro_after_init =
@@ -805,6 +812,7 @@ early_param("retbleed", retbleed_parse_c#define RETBLEED_UNTRAIN_MSG "WARNING: BTB untrained return thunk mitigation is only effective on AMD/Hygon!\n"#define RETBLEED_COMPILER_MSG "WARNING: kernel not compiled with RETPOLINE or -mfunction-return capable compiler!\n" +#define RETBLEED_INTEL_MSG "WARNING: Spectre v2 mitigation leaves CPU vulnerable to RETBleed attacks, data leaks possible!\n"static void __init retbleed_select_mitigation (void ) {
@@ -821,12 +829,15 @@ static void __init retbleed_select_mitigcase RETBLEED_CMD_AUTO :default : -if (!boot_cpu_has_bug (X86_BUG_RETBLEED )) -break ; -if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD || boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) retbleed_mitigation =RETBLEED_MITIGATION_UNRET ; + +/* +* The Intel mitigation (IBRS) was already selected in +* spectre_v2_select_mitigation(). +*/ +break ; }
@@ -856,15 +867,31 @@ static void __init retbleed_select_mitigbreak ; } +/* +* Let IBRS trump all on Intel without affecting the effects of the +* retbleed= cmdline option. +*/ +if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) { +switch (spectre_v2_enabled) { +case SPECTRE_V2_IBRS : + retbleed_mitigation =RETBLEED_MITIGATION_IBRS ; +break ; +case SPECTRE_V2_EIBRS : +case SPECTRE_V2_EIBRS_RETPOLINE : +case SPECTRE_V2_EIBRS_LFENCE : + retbleed_mitigation =RETBLEED_MITIGATION_EIBRS ; +break ; +default : +pr_err (RETBLEED_INTEL_MSG ); + } + } +pr_info ("%s\n" , retbleed_strings[retbleed_mitigation]); }#undef pr_fmt#define pr_fmt (fmt) "Spectre V2 : " fmt -static enum spectre_v2_mitigation spectre_v2_enabled__ro_after_init = -SPECTRE_V2_NONE ; -static enum spectre_v2_user_mitigation spectre_v2_user_stibp__ro_after_init =SPECTRE_V2_USER_NONE ; static enum spectre_v2_user_mitigation spectre_v2_user_ibpb __ro_after_init =
arch/x86/kernel/cpu/common.c +12 -12
@@ -1124,24 +1124,24 @@ static const struct x86_cpu_id cpu_vuln_VULNBL_INTEL_STEPPINGS (BROADWELL_G ,X86_STEPPING_ANY ,SRBDS ),VULNBL_INTEL_STEPPINGS (BROADWELL_X ,X86_STEPPING_ANY ,MMIO ),VULNBL_INTEL_STEPPINGS (BROADWELL ,X86_STEPPING_ANY ,SRBDS ), -VULNBL_INTEL_STEPPINGS (SKYLAKE_L ,X86_STEPPINGS (0x3 ,0x3 ),SRBDS |MMIO ), +VULNBL_INTEL_STEPPINGS (SKYLAKE_L ,X86_STEPPINGS (0x3 ,0x3 ),SRBDS |MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (SKYLAKE_L ,X86_STEPPING_ANY ,SRBDS ),VULNBL_INTEL_STEPPINGS (SKYLAKE_X ,BIT (3 ) |BIT (4 ) |BIT (6 ) | -BIT (7 ) |BIT (0xB ),MMIO ), -VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPINGS (0x3 ,0x3 ),SRBDS |MMIO ), +BIT (7 ) |BIT (0xB ),MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPINGS (0x3 ,0x3 ),SRBDS |MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPING_ANY ,SRBDS ), -VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPINGS (0x9 ,0xC ),SRBDS |MMIO ), +VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPINGS (0x9 ,0xC ),SRBDS |MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPINGS (0x0 ,0x8 ),SRBDS ), -VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPINGS (0x9 ,0xD ),SRBDS |MMIO ), +VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPINGS (0x9 ,0xD ),SRBDS |MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPINGS (0x0 ,0x8 ),SRBDS ), -VULNBL_INTEL_STEPPINGS (ICELAKE_L ,X86_STEPPINGS (0x5 ,0x5 ),MMIO |MMIO_SBDS ), +VULNBL_INTEL_STEPPINGS (ICELAKE_L ,X86_STEPPINGS (0x5 ,0x5 ),MMIO |MMIO_SBDS |RETBLEED ),VULNBL_INTEL_STEPPINGS (ICELAKE_D ,X86_STEPPINGS (0x1 ,0x1 ),MMIO ),VULNBL_INTEL_STEPPINGS (ICELAKE_X ,X86_STEPPINGS (0x4 ,0x6 ),MMIO ), -VULNBL_INTEL_STEPPINGS (COMETLAKE ,BIT (2 ) |BIT (3 ) |BIT (5 ),MMIO |MMIO_SBDS ), -VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS ), -VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPINGS (0x0 ,0x0 ),MMIO ), -VULNBL_INTEL_STEPPINGS (LAKEFIELD ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS ), -VULNBL_INTEL_STEPPINGS (ROCKETLAKE ,X86_STEPPINGS (0x1 ,0x1 ),MMIO ), +VULNBL_INTEL_STEPPINGS (COMETLAKE ,BIT (2 ) |BIT (3 ) |BIT (5 ),MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPINGS (0x0 ,0x0 ),MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (LAKEFIELD ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (ROCKETLAKE ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (ATOM_TREMONT ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS ),VULNBL_INTEL_STEPPINGS (ATOM_TREMONT_D ,X86_STEPPING_ANY ,MMIO ), VULNBL_INTEL_STEPPINGS(ATOM_TREMONT_L, X86_STEPPINGS(0x0, 0x0), MMIO | MMIO_SBDS),
@@ -1251,7 +1251,7 @@ static void __init cpu_set_bug_bits(stru !arch_cap_mmio_immune(ia32_cap))setup_force_cpu_bug (X86_BUG_MMIO_STALE_DATA ); -if (cpu_matches (cpu_vuln_blacklist,RETBLEED )) +if ((cpu_matches (cpu_vuln_blacklist,RETBLEED ) || (ia32_cap &ARCH_CAP_RSBA )))setup_force_cpu_bug (X86_BUG_RETBLEED );if (cpu_matches (cpu_vuln_whitelist,NO_MELTDOWN ))
Greg Kroah-Hartman
maintainerPATCH 105/148 intel_idle: Disable IBRS during long idle
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit bf5835bcdb9635c97f85120dba9bfa21e111130f upstream.
Having IBRS enabled while the SMT sibling is idle unnecessarily slows down the running sibling. OTOH, disabling IBRS around idle takes two MSR writes, which will increase the idle latency.
Therefore, only disable IBRS around deeper idle states. Shallow idle states are bounded by the tick in duration, since NOHZ is not allowed for them by virtue of their short target residency.
Only do this for mwait-driven idle, since that keeps interrupts disabled across idle, which makes disabling IBRS vs IRQ-entry a non-issue.
Note: C6 is a random threshold, most importantly C1 probably shouldn't disable IBRS, benchmarking needed.
--- arch/x86/include/asm/nospec-branch.h | 1 arch/x86/kernel/cpu/bugs.c | 6 ++++ drivers/idle/intel_idle.c | 43 ++++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 6 deletions(-)
arch/x86/include/asm/nospec-branch.h +1 -0
@@ -256,6 +256,7 @@ static inline void indirect_branch_predi/* The Intel SPEC CTRL MSR base value cache */ extern u64 x86_spec_ctrl_base;extern void write_spec_ctrl_current (u64 val,bool force); +extern u64 spec_ctrl_current (void );/* * With retpoline, we must use IBRS to restrict branch prediction
arch/x86/kernel/cpu/bugs.c +6 -0
@@ -78,6 +78,12 @@ void write_spec_ctrl_current(u64 val, bowrmsrl (MSR_IA32_SPEC_CTRL , val); } +u64 spec_ctrl_current (void ) +{ +return this_cpu_read (x86_spec_ctrl_current); +} +EXPORT_SYMBOL_GPL (spec_ctrl_current); +/* * The vendor and possibly platform specific bits which can be modified in * x86_spec_ctrl_base.
drivers/idle/intel_idle.c +37 -6
108 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 106/148 objtool: Update Retpoline validation
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 9bb2ec608a209018080ca262f771e6a9ff203b6f upstream.
Update retpoline validation with the new CONFIG_RETPOLINE requirement of not having bare naked RET instructions.
--- arch/x86/include/asm/nospec-branch.h | 6 ++++++ arch/x86/mm/mem_encrypt_boot.S | 2 ++ arch/x86/xen/xen-head.S | 1 + tools/objtool/check.c | 19 +++++++++++++------ 4 files changed, 22 insertions(+), 6 deletions(-)
arch/x86/include/asm/nospec-branch.h +6 -0
@@ -76,6 +76,12 @@ .endm/* +* (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions +* vs RETBleed validation. +*/ +#define ANNOTATE_UNRET_SAFE ANNOTATE_RETPOLINE_SAFE + +/* * JMP_NOSPEC and CALL_NOSPEC macros can be used instead of a simple * indirect jmp/call which may be susceptible to the Spectre variant 2 * attack.
arch/x86/mm/mem_encrypt_boot.S +2 -0
@@ -66,6 +66,7 @@ SYM_FUNC_START(sme_encrypt_execute) pop %rbp /* Offset to __x86_return_thunk would be wrong here */ + ANNOTATE_UNRET_SAFE ret int3 SYM_FUNC_END(sme_encrypt_execute)
@@ -154,6 +155,7 @@ SYM_FUNC_START(__enc_copy) pop %r15 /* Offset to __x86_return_thunk would be wrong here */ + ANNOTATE_UNRET_SAFE ret int3 .L__enc_copy_end:
arch/x86/xen/xen-head.S +1 -0
@@ -70,6 +70,7 @@ SYM_CODE_START(hypercall_page) .rept (PAGE_SIZE / 32) UNWIND_HINT_FUNC .skip 31, 0x90 + ANNOTATE_UNRET_SAFE RET .endr
tools/objtool/check.c +13 -6
@@ -1799,8 +1799,9 @@ static int read_retpoline_hints(struct o }if (insn->type !=INSN_JUMP_DYNAMIC && - insn->type !=INSN_CALL_DYNAMIC ) { -WARN_FUNC ("retpoline_safe hint not an indirect jump/call" , + insn->type !=INSN_CALL_DYNAMIC && + insn->type !=INSN_RETURN ) { +WARN_FUNC ("retpoline_safe hint not an indirect jump/call/ret" , insn->sec, insn->offset);return -1 ; }
@@ -3051,7 +3052,8 @@ static int validate_retpoline(struct objfor_each_insn (file, insn) {if (insn->type !=INSN_JUMP_DYNAMIC && - insn->type !=INSN_CALL_DYNAMIC ) + insn->type !=INSN_CALL_DYNAMIC && + insn->type !=INSN_RETURN )continue ;if (insn->retpoline_safe)
@@ -3066,9 +3068,14 @@ static int validate_retpoline(struct objif (!strcmp (insn->sec->name,".init.text" ) && !module)continue ; -WARN_FUNC ("indirect %s found in RETPOLINE build" , - insn->sec, insn->offset, - insn->type ==INSN_JUMP_DYNAMIC ?"jump" :"call" ); +if (insn->type ==INSN_RETURN ) { +WARN_FUNC ("'naked' return found in RETPOLINE build" , + insn->sec, insn->offset); + }else { +WARN_FUNC ("indirect %s found in RETPOLINE build" , + insn->sec, insn->offset, + insn->type ==INSN_JUMP_DYNAMIC ?"jump" :"call" ); + } warnings++; }
Greg Kroah-Hartman
maintainerPATCH 107/148 x86/xen: Rename SYS* entry points
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit b75b7f8ef1148be1b9321ffc2f6c19238904b438 upstream.
Native SYS{CALL,ENTER} entry points are called entry_SYS{CALL,ENTER}_{64,compat}, make sure the Xen versions are named consistently.
--- arch/x86/xen/setup.c | 6 +++--- arch/x86/xen/xen-asm.S | 20 ++++++++++---------- arch/x86/xen/xen-ops.h | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/xen/setup.c +3 -3
@@ -922,7 +922,7 @@ void xen_enable_sysenter(void)if (!boot_cpu_has (sysenter_feature))return ; - ret =register_callback (CALLBACKTYPE_sysenter, xen_sysenter_target); + ret =register_callback (CALLBACKTYPE_sysenter, xen_entry_SYSENTER_compat);if (ret !=0 )setup_clear_cpu_cap (sysenter_feature); }
@@ -931,7 +931,7 @@ void xen_enable_syscall(void) {int ret; - ret =register_callback (CALLBACKTYPE_syscall, xen_syscall_target); + ret =register_callback (CALLBACKTYPE_syscall, xen_entry_SYSCALL_64);if (ret !=0 ) {printk (KERN_ERR "Failed to set syscall callback: %d\n" , ret);/* Pretty fatal; 64-bit userspace has no other
@@ -940,7 +940,7 @@ void xen_enable_syscall(void)if (boot_cpu_has (X86_FEATURE_SYSCALL32 )) { ret =register_callback (CALLBACKTYPE_syscall32, - xen_syscall32_target); + xen_entry_SYSCALL_compat);if (ret !=0 )setup_clear_cpu_cap (X86_FEATURE_SYSCALL32 ); }
arch/x86/xen/xen-asm.S +10 -10
@@ -276,7 +276,7 @@ SYM_CODE_END(xenpv_restore_regs_and_retu */ /* Normal 64-bit system call target */ -SYM_CODE_START(xen_syscall_target) +SYM_CODE_START(xen_entry_SYSCALL_64) UNWIND_HINT_EMPTY popq %rcx popq %r11
@@ -290,12 +290,12 @@ SYM_CODE_START(xen_syscall_target) movq $__USER_CS, 1*8(%rsp) jmp entry_SYSCALL_64_after_hwframe -SYM_CODE_END(xen_syscall_target) +SYM_CODE_END(xen_entry_SYSCALL_64) #ifdef CONFIG_IA32_EMULATION /* 32-bit compat syscall target */ -SYM_CODE_START(xen_syscall32_target) +SYM_CODE_START(xen_entry_SYSCALL_compat) UNWIND_HINT_EMPTY popq %rcx popq %r11
@@ -309,10 +309,10 @@ SYM_CODE_START(xen_syscall32_target) movq $__USER32_CS, 1*8(%rsp) jmp entry_SYSCALL_compat_after_hwframe -SYM_CODE_END(xen_syscall32_target) +SYM_CODE_END(xen_entry_SYSCALL_compat) /* 32-bit compat sysenter target */ -SYM_CODE_START(xen_sysenter_target) +SYM_CODE_START(xen_entry_SYSENTER_compat) UNWIND_HINT_EMPTY /* * NB: Xen is polite and clears TF from EFLAGS for us. This means
@@ -330,18 +330,18 @@ SYM_CODE_START(xen_sysenter_target) movq $__USER32_CS, 1*8(%rsp) jmp entry_SYSENTER_compat_after_hwframe -SYM_CODE_END(xen_sysenter_target) +SYM_CODE_END(xen_entry_SYSENTER_compat) #else /* !CONFIG_IA32_EMULATION */ -SYM_CODE_START(xen_syscall32_target) -SYM_CODE_START(xen_sysenter_target) +SYM_CODE_START(xen_entry_SYSCALL_compat) +SYM_CODE_START(xen_entry_SYSENTER_compat) UNWIND_HINT_EMPTY lea 16(%rsp), %rsp /* strip %rcx, %r11 */ mov $-ENOSYS, %rax pushq $0 jmp hypercall_iret -SYM_CODE_END(xen_sysenter_target) -SYM_CODE_END(xen_syscall32_target) +SYM_CODE_END(xen_entry_SYSENTER_compat) +SYM_CODE_END(xen_entry_SYSCALL_compat) #endif /* CONFIG_IA32_EMULATION */
arch/x86/xen/xen-ops.h +3 -3
@@ -10,10 +10,10 @@/* These are code, but not functions. Defined in entry.S */ extern const char xen_failsafe_callback[]; -void xen_sysenter_target (void ); +void xen_entry_SYSENTER_compat (void );#ifdef CONFIG_X86_64 -void xen_syscall_target (void ); -void xen_syscall32_target (void ); +void xen_entry_SYSCALL_64 (void ); +void xen_entry_SYSCALL_compat (void );#endif extern void *xen_initial_gdt;
Greg Kroah-Hartman
maintainerPATCH 108/148 x86/bugs: Add retbleed=ibpb
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 3ebc170068885b6fc7bedda6c667bb2c4d533159 upstream.
jmp2ret mitigates the easy-to-attack case at relatively low overhead. It mitigates the long speculation windows after a mispredicted RET, but it does not mitigate the short speculation window from arbitrary instruction boundaries.
On Zen2, there is a chicken bit which needs setting, which mitigates "arbitrary instruction boundaries" down to just "basic block boundaries".
But there is no fix for the short speculation window on basic block boundaries, other than to flush the entire BTB to evict all attacker predictions.
On the spectrum of "fast & blurry" -> "safe", there is (on top of STIBP or no-SMT):
1) Nothing System wide open
2) jmp2ret May stop a script kiddy
3) jmp2ret+chickenbit Raises the bar rather further
4) IBPB Only thing which can count as "safe".
Tentative numbers put IBPB-on-entry at a 2.5x hit on Zen2, and a 10x hit on Zen1 according to lmbench.
[ bp: Fixup feature bit comments, document option, 32-bit build fix. ]
--- Documentation/admin-guide/kernel-parameters.txt | 3 + arch/x86/entry/Makefile | 2 - arch/x86/entry/entry.S | 22 ++++++++++++ arch/x86/include/asm/cpufeatures.h | 2 - arch/x86/include/asm/nospec-branch.h | 8 +++- arch/x86/kernel/cpu/bugs.c | 43 ++++++++++++++++++------ 6 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 arch/x86/entry/entry.S
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -4666,6 +4666,9 @@ disabling SMT if necessary for the full mitigation (only on Zen1 and older without STIBP). + ibpb - mitigate short speculation windows on + basic block boundaries too. Safe, highest + perf impact. unret - force enable untrained return thunks, only effective on AMD f15h-f17h based systems.
arch/x86/entry/Makefile +1 -1
@@ -21,7 +21,7 @@ CFLAGS_syscall_64.o += $(call cc-option CFLAGS_syscall_32.o += $(call cc-option,-Wno-override-init,) CFLAGS_syscall_x32.o += $(call cc-option,-Wno-override-init,) -obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o +obj-y := entry.o entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o obj-y += common.o obj-y += vdso/
arch/x86/entry/entry.S new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Common place for both 32- and 64-bit entry routines. + */ + +#include <linux/linkage.h> +#include <asm/export.h> +#include <asm/msr-index.h> + +.pushsection .noinstr.text, "ax" + +SYM_FUNC_START(entry_ibpb) + movl $MSR_IA32_PRED_CMD, %ecx + movl $PRED_CMD_IBPB, %eax + xorl %edx, %edx + wrmsr + RET +SYM_FUNC_END(entry_ibpb) +/* For KVM */ +EXPORT_SYMBOL_GPL(entry_ibpb); + +.popsection
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -292,7 +292,7 @@#define X86_FEATURE_PER_THREAD_MBA (11*32+ 7)/* "" Per-thread Memory Bandwidth Allocation */ /* FREE! (11*32+ 8) */ /* FREE! (11*32+ 9) */ -/* FREE! (11*32+10) */ +#define X86_FEATURE_ENTRY_IBPB (11*32+10)/* "" Issue an IBPB on kernel entry */ /* FREE! (11*32+11) */ #define X86_FEATURE_RETPOLINE (11*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ #define X86_FEATURE_RETPOLINE_LFENCE (11*32+13)/* "" Use LFENCE for Spectre variant 2 */
arch/x86/include/asm/nospec-branch.h +6 -2
@@ -123,14 +123,17 @@* return thunk isn't mapped into the userspace tables (then again, AMD * typically has NO_MELTDOWN). * -* Doesn't clobber any registers but does require a stable stack. +* While zen_untrain_ret() doesn't clobber anything but requires stack, +* entry_ibpb() will clobber AX, CX, DX. * * 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#ifdef CONFIG_RETPOLINE -ALTERNATIVE "" ,"call zen_untrain_ret" ,X86_FEATURE_UNRET +ALTERNATIVE_2 "" , \ +"call zen_untrain_ret" ,X86_FEATURE_UNRET , \ +"call entry_ibpb" ,X86_FEATURE_ENTRY_IBPB #endif .endm
@@ -144,6 +147,7 @@extern void __x86_return_thunk (void );extern void zen_untrain_ret (void ); +extern void entry_ibpb (void );#ifdef CONFIG_RETPOLINE
arch/x86/kernel/cpu/bugs.c +34 -9
105 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 109/148 x86/bugs: Do IBPB fallback check only once
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 0fe4aeea9c01baabecc8c3afc7889c809d939bc2 upstream.
When booting with retbleed=auto, if the kernel wasn't built with CONFIG_CC_HAS_RETURN_THUNK, the mitigation falls back to IBPB. Make sure a warning is printed in that case. The IBPB fallback check is done twice, but it really only needs to be done once.
--- arch/x86/kernel/cpu/bugs.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -10
@@ -847,18 +847,13 @@ static void __init retbleed_select_mitigcase 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_RETPOLINE ) && -IS_ENABLED (CONFIG_CC_HAS_RETURN_THUNK )) - retbleed_mitigation =RETBLEED_MITIGATION_UNRET ; -else - retbleed_mitigation =RETBLEED_MITIGATION_IBPB ; - } + boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) + retbleed_mitigation =RETBLEED_MITIGATION_UNRET ;/* -* The Intel mitigation (IBRS) was already selected in -* spectre_v2_select_mitigation(). +* The Intel mitigation (IBRS or eIBRS) was already selected in +* spectre_v2_select_mitigation(). 'retbleed_mitigation' will +* be set accordingly below. */ break ;
Greg Kroah-Hartman
maintainerPATCH 110/148 objtool: Add entry UNRET validation
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit a09a6e2399ba0595c3042b3164f3ca68a3cff33e upstream.
Since entry asm is tricky, add a validation pass that ensures the retbleed mitigation has been done before the first actual RET instruction.
Entry points are those that either have UNWIND_HINT_ENTRY, which acts as UNWIND_HINT_EMPTY but marks the instruction as an entry point, or those that have UWIND_HINT_IRET_REGS at +0.
This is basically a variant of validate_branch() that is intra-function and it will simply follow all branches from marked entry points and ensures that all paths lead to ANNOTATE_UNRET_END.
If a path hits RET or an indirection the path is a fail and will be reported.
There are 3 ANNOTATE_UNRET_END instances:
- UNTRAIN_RET itself
- exception from-kernel; this path doesn't need UNTRAIN_RET
- all early exceptions; these also don't need UNTRAIN_RET
[bwh: Backported to 5.10:
- In scripts/link-vmlinux.sh, use "test -n" instead of is_enabled
- Adjust context]
--- arch/x86/entry/entry_64.S | 3 arch/x86/entry/entry_64_compat.S | 6 - arch/x86/include/asm/nospec-branch.h | 12 ++ arch/x86/include/asm/unwind_hints.h | 4 arch/x86/kernel/head_64.S | 5 + arch/x86/xen/xen-asm.S | 10 +- include/linux/objtool.h | 3 scripts/link-vmlinux.sh | 3 tools/include/linux/objtool.h | 3 tools/objtool/builtin-check.c | 3 tools/objtool/builtin.h | 2 tools/objtool/check.c | 172 ++++++++++++++++++++++++++++++++++- tools/objtool/check.h | 6 + 13 files changed, 217 insertions(+), 15 deletions(-)
arch/x86/entry/entry_64.S +2 -1
@@ -93,7 +93,7 @@ SYM_CODE_END(native_usergs_sysret64) */ SYM_CODE_START(entry_SYSCALL_64) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY swapgs /* tss.sp2 is scratch space. */
@@ -1094,6 +1094,7 @@ SYM_CODE_START_LOCAL(error_entry) */ .Lerror_entry_done_lfence: FENCE_SWAPGS_KERNEL_ENTRY + ANNOTATE_UNRET_END RET .Lbstep_iret:
arch/x86/entry/entry_64_compat.S +3 -3
@@ -49,7 +49,7 @@ * 0(%ebp) arg6 */ SYM_CODE_START(entry_SYSENTER_compat) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY /* Interrupts are off on entry. */ SWAPGS
@@ -202,7 +202,7 @@ SYM_CODE_END(entry_SYSENTER_compat) * 0(%esp) arg6 */ SYM_CODE_START(entry_SYSCALL_compat) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY /* Interrupts are off on entry. */ swapgs
@@ -349,7 +349,7 @@ SYM_CODE_END(entry_SYSCALL_compat) * ebp arg6 */ SYM_CODE_START(entry_INT80_compat) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY /* * Interrupts are off on entry. */
arch/x86/include/asm/nospec-branch.h +12 -0
@@ -82,6 +82,17 @@#define ANNOTATE_UNRET_SAFE ANNOTATE_RETPOLINE_SAFE/* +* Abuse ANNOTATE_RETPOLINE_SAFE on a NOP to indicate UNRET_END, should +* eventually turn into it's own annotation. +*/ +.macro ANNOTATE_UNRET_END +#ifdef CONFIG_DEBUG_ENTRY +ANNOTATE_RETPOLINE_SAFE + nop +#endif +.endm + +/* * JMP_NOSPEC and CALL_NOSPEC macros can be used instead of a simple * indirect jmp/call which may be susceptible to the Spectre variant 2 * attack.
@@ -131,6 +142,7 @@*/ .macro UNTRAIN_RET#ifdef CONFIG_RETPOLINE +ANNOTATE_UNRET_END ALTERNATIVE_2 "", \"call zen_untrain_ret" ,X86_FEATURE_UNRET , \"call entry_ibpb" ,X86_FEATURE_ENTRY_IBPB
arch/x86/include/asm/unwind_hints.h +4 -0
@@ -11,6 +11,10 @@ UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_CALL end=1 .endm +.macro UNWIND_HINT_ENTRY + UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_ENTRY end=1 +.endm + .macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0 .if \base == %rsp .if \indirect
arch/x86/kernel/head_64.S +5 -0
@@ -321,6 +321,8 @@ SYM_CODE_END(start_cpu0) SYM_CODE_START_NOALIGN(vc_boot_ghcb) UNWIND_HINT_IRET_REGS offset=8 + ANNOTATE_UNRET_END + /* Build pt_regs */ PUSH_AND_CLEAR_REGS
@@ -378,6 +380,7 @@ SYM_CODE_START(early_idt_handler_array) SYM_CODE_END(early_idt_handler_array) SYM_CODE_START_LOCAL(early_idt_handler_common) + ANNOTATE_UNRET_END /* * The stack is the hardware frame, an error code or zero, and the * vector number.
@@ -424,6 +427,8 @@ SYM_CODE_END(early_idt_handler_common) SYM_CODE_START_NOALIGN(vc_no_ghcb) UNWIND_HINT_IRET_REGS offset=8 + ANNOTATE_UNRET_END + /* Build pt_regs */ PUSH_AND_CLEAR_REGS
arch/x86/xen/xen-asm.S +5 -5
@@ -148,7 +148,7 @@ SYM_FUNC_END(xen_read_cr2_direct); .macro xen_pv_trap name SYM_CODE_START(xen_\name) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY pop %rcx pop %r11 jmp \name
@@ -277,7 +277,7 @@ SYM_CODE_END(xenpv_restore_regs_and_retu /* Normal 64-bit system call target */ SYM_CODE_START(xen_entry_SYSCALL_64) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY popq %rcx popq %r11
@@ -296,7 +296,7 @@ SYM_CODE_END(xen_entry_SYSCALL_64) /* 32-bit compat syscall target */ SYM_CODE_START(xen_entry_SYSCALL_compat) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY popq %rcx popq %r11
@@ -313,7 +313,7 @@ SYM_CODE_END(xen_entry_SYSCALL_compat) /* 32-bit compat sysenter target */ SYM_CODE_START(xen_entry_SYSENTER_compat) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY /* * NB: Xen is polite and clears TF from EFLAGS for us. This means * that we don't need to guard against single step exceptions here.
@@ -336,7 +336,7 @@ SYM_CODE_END(xen_entry_SYSENTER_compat) SYM_CODE_START(xen_entry_SYSCALL_compat) SYM_CODE_START(xen_entry_SYSENTER_compat) - UNWIND_HINT_EMPTY + UNWIND_HINT_ENTRY lea 16(%rsp), %rsp /* strip %rcx, %r11 */ mov $-ENOSYS, %rax pushq $0
include/linux/objtool.h +3 -0
@@ -32,11 +32,14 @@ struct unwind_hint {* * UNWIND_HINT_FUNC: Generate the unwind metadata of a callable function. * Useful for code which doesn't have an ELF function annotation. +* +* UNWIND_HINT_ENTRY: machine entry without stack, SYSCALL/SYSENTER etc. */ #define UNWIND_HINT_TYPE_CALL 0#define UNWIND_HINT_TYPE_REGS 1#define UNWIND_HINT_TYPE_REGS_PARTIAL 2#define UNWIND_HINT_TYPE_FUNC 3 +#define UNWIND_HINT_TYPE_ENTRY 4#ifdef CONFIG_STACK_VALIDATION
scripts/link-vmlinux.sh +3 -0
@@ -65,6 +65,9 @@ objtool_link() if [ -n "${CONFIG_VMLINUX_VALIDATION}" ]; then objtoolopt="check" + if [ -n "${CONFIG_RETPOLINE}" ]; then + objtoolopt="${objtoolopt} --unret" + fi if [ -z "${CONFIG_FRAME_POINTER}" ]; then objtoolopt="${objtoolopt} --no-fp" fi
tools/include/linux/objtool.h +3 -0
@@ -32,11 +32,14 @@ struct unwind_hint {* * UNWIND_HINT_FUNC: Generate the unwind metadata of a callable function. * Useful for code which doesn't have an ELF function annotation. +* +* UNWIND_HINT_ENTRY: machine entry without stack, SYSCALL/SYSENTER etc. */ #define UNWIND_HINT_TYPE_CALL 0#define UNWIND_HINT_TYPE_REGS 1#define UNWIND_HINT_TYPE_REGS_PARTIAL 2#define UNWIND_HINT_TYPE_FUNC 3 +#define UNWIND_HINT_TYPE_ENTRY 4#ifdef CONFIG_STACK_VALIDATION
tools/objtool/builtin-check.c +2 -1
@@ -19,7 +19,7 @@#include "objtool.h" bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, - validate_dup, vmlinux, sls; + validate_dup, vmlinux, sls, unret;static const char *const check_usage[] = {"objtool check [<options>] file.o" ,
@@ -30,6 +30,7 @@ const struct option check_options[] = {OPT_BOOLEAN ('f' ,"no-fp" , &no_fp,"Skip frame pointer validation" ),OPT_BOOLEAN ('u' ,"no-unreachable" , &no_unreachable,"Skip 'unreachable instruction' warnings" ),OPT_BOOLEAN ('r' ,"retpoline" , &retpoline,"Validate retpoline assumptions" ), +OPT_BOOLEAN (0 ,"unret" , &unret,"validate entry unret placement" ),OPT_BOOLEAN ('m' ,"module" , &module,"Indicates the object will be part of a kernel module" ),OPT_BOOLEAN ('b' ,"backtrace" , &backtrace,"unwind on error" ), OPT_BOOLEAN('a', "uaccess", &uaccess, "enable uaccess checking"),
tools/objtool/builtin.h +1 -1
@@ -9,7 +9,7 @@extern const struct option check_options[];extern bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, - validate_dup, vmlinux, sls; + validate_dup, vmlinux, sls, unret;extern int cmd_check (int argc,const char **argv);extern int cmd_orc (int argc,const char **argv);
tools/objtool/check.c +168 -4
202 lines not on this page · raw message
tools/objtool/check.h +6 -0
@@ -48,6 +48,7 @@ struct instruction {bool dead_end, ignore, ignore_alts;bool hint;bool retpoline_safe; +bool entry;s8 instr;u8 visited;struct alt_group *alt_group;
@@ -62,6 +63,11 @@ struct instruction {struct cfi_state *cfi; }; +#define VISITED_BRANCH 0x01 +#define VISITED_BRANCH_UACCESS 0x02 +#define VISITED_BRANCH_MASK 0x03 +#define VISITED_ENTRY 0x04 +static inline bool is_static_jump (struct instruction *insn) { return insn->type == INSN_JUMP_CONDITIONAL ||
Greg Kroah-Hartman
maintainerPATCH 111/148 x86/cpu/amd: Add Spectral Chicken
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit d7caac991feeef1b871ee6988fd2c9725df09039 upstream.
Zen2 uarchs have an undocumented, unnamed, MSR that contains a chicken bit for some speculation behaviour. It needs setting.
Note: very belatedly AMD released naming; it's now officially called
MSR_AMD64_DE_CFG2 and MSR_AMD64_DE_CFG2_SUPPRESS_NOBR_PRED_BIT but shall remain the SPECTRAL CHICKEN.
--- arch/x86/include/asm/msr-index.h | 3 +++ arch/x86/kernel/cpu/amd.c | 23 ++++++++++++++++++++++- arch/x86/kernel/cpu/cpu.h | 2 ++ arch/x86/kernel/cpu/hygon.c | 6 ++++++ 4 files changed, 33 insertions(+), 1 deletion(-)
arch/x86/include/asm/msr-index.h +3 -0
@@ -508,6 +508,9 @@/* Fam 17h MSRs */ #define MSR_F17H_IRPERF 0xc00000e9 +#define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3 +#define MSR_ZEN2_SPECTRAL_CHICKEN_BIT BIT_ULL(1) +/* Fam 16h MSRs */ #define MSR_F16H_L2I_PERF_CTL 0xc0010230#define MSR_F16H_L2I_PERF_CTR 0xc0010231
arch/x86/kernel/cpu/amd.c +22 -1
@@ -914,6 +914,26 @@ static void init_amd_bd(struct cpuinfo_xclear_rdrand_cpuid_bit (c); } +void init_spectral_chicken (struct cpuinfo_x86 *c) +{ +u64 value; + +/* +* On Zen2 we offer this chicken (bit) on the altar of Speculation. +* +* This suppresses speculation from the middle of a basic block, i.e. it +* suppresses non-branch predictions. +* +* We use STIBP as a heuristic to filter out Zen2 from the rest of F17H +*/ +if (!cpu_has (c,X86_FEATURE_HYPERVISOR ) &&cpu_has (c,X86_FEATURE_AMD_STIBP )) { +if (!rdmsrl_safe (MSR_ZEN2_SPECTRAL_CHICKEN , &value)) { + value |=MSR_ZEN2_SPECTRAL_CHICKEN_BIT ; +wrmsrl_safe (MSR_ZEN2_SPECTRAL_CHICKEN , value); + } + } +} +static void init_amd_zn (struct cpuinfo_x86 *c) {set_cpu_cap (c,X86_FEATURE_ZEN );
@@ -959,7 +979,8 @@ static void init_amd(struct cpuinfo_x86case 0x12 :init_amd_ln (c);break ;case 0x15 :init_amd_bd (c);break ;case 0x16 :init_amd_jg (c);break ; -case 0x17 : fallthrough; +case 0x17 :init_spectral_chicken (c); + fallthrough;case 0x19 :init_amd_zn (c);break ; }
arch/x86/kernel/cpu/cpu.h +2 -0
@@ -60,6 +60,8 @@ extern void tsx_disable(void);static inline void tsx_init (void ) { }#endif /* CONFIG_CPU_SUP_INTEL */ +extern void init_spectral_chicken (struct cpuinfo_x86 *c); +extern void get_cpu_cap (struct cpuinfo_x86 *c);extern void get_cpu_address_sizes (struct cpuinfo_x86 *c);extern void cpu_detect_cache_sizes (struct cpuinfo_x86 *c);
arch/x86/kernel/cpu/hygon.c +6 -0
@@ -318,6 +318,12 @@ static void init_hygon(struct cpuinfo_x8/* get apicid instead of initial apic id from cpuid */ c->apicid =hard_smp_processor_id (); +/* +* XXX someone from Hygon needs to confirm this DTRT +* +init_spectral_chicken(c); +*/ +set_cpu_cap (c,X86_FEATURE_ZEN );set_cpu_cap (c,X86_FEATURE_CPB );
Greg Kroah-Hartman
maintainerPATCH 112/148 x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit b2620facef4889fefcbf2e87284f34dcd4189bce upstream.
If a kernel is built with CONFIG_RETPOLINE=n, but the user still wants to mitigate Spectre v2 using IBRS or eIBRS, the RSB filling will be silently disabled.
There's nothing retpoline-specific about RSB buffer filling. Remove the CONFIG_RETPOLINE guards around it.
--- arch/x86/entry/entry_32.S | 2 -- arch/x86/entry/entry_64.S | 2 -- arch/x86/include/asm/nospec-branch.h | 2 -- 3 files changed, 6 deletions(-)
arch/x86/entry/entry_32.S +0 -2
@@ -782,7 +782,6 @@ SYM_CODE_START(__switch_to_asm) movl %ebx, PER_CPU_VAR(stack_canary)+stack_canary_offset #endif -#ifdef CONFIG_RETPOLINE /* * When switching from a shallower to a deeper call stack * the RSB may either underflow or use entries populated
@@ -791,7 +790,6 @@ SYM_CODE_START(__switch_to_asm) * speculative execution to prevent attack. */ FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW -#endif /* Restore flags or the incoming task to restore AC state. */ popfl
arch/x86/entry/entry_64.S +0 -2
@@ -249,7 +249,6 @@ SYM_FUNC_START(__switch_to_asm) movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset #endif -#ifdef CONFIG_RETPOLINE /* * When switching from a shallower to a deeper call stack * the RSB may either underflow or use entries populated
@@ -258,7 +257,6 @@ SYM_FUNC_START(__switch_to_asm) * speculative execution to prevent attack. */ FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW -#endif /* restore callee-saved registers */ popq %r15
arch/x86/include/asm/nospec-branch.h +0 -2
@@ -122,11 +122,9 @@* monstrosity above, manually. */ .macro FILL_RETURN_BUFFER reg:req nr:req ftr:req -#ifdef CONFIG_RETPOLINE ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP) .Lskip_rsb_\@: -#endif .endm/*
Greg Kroah-Hartman
maintainerPATCH 113/148 x86/speculation: Fix firmware entry SPEC_CTRL handling
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit e6aa13622ea8283cc699cac5d018cc40a2ba2010 upstream.
The firmware entry code may accidentally clear STIBP or SSBD. Fix that.
--- arch/x86/include/asm/nospec-branch.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/include/asm/nospec-branch.h +4 -6
@@ -286,18 +286,16 @@ extern u64 spec_ctrl_current(void);*/ #define firmware_restrict_branch_speculation_start () \ do { \ - u64 val = x86_spec_ctrl_base | SPEC_CTRL_IBRS; \ - \ preempt_disable(); \ - alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ + alternative_msr_write(MSR_IA32_SPEC_CTRL, \ + spec_ctrl_current() | SPEC_CTRL_IBRS, \ X86_FEATURE_USE_IBRS_FW); \ } while (0)#define firmware_restrict_branch_speculation_end () \ do { \ - u64 val = x86_spec_ctrl_base; \ - \ - alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ + alternative_msr_write(MSR_IA32_SPEC_CTRL, \ + spec_ctrl_current(), \ X86_FEATURE_USE_IBRS_FW); \ preempt_enable(); \ } while (0)
Greg Kroah-Hartman
maintainerPATCH 114/148 x86/speculation: Fix SPEC_CTRL write on SMT state change
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 56aa4d221f1ee2c3a49b45b800778ec6e0ab73c5 upstream.
If the SMT state changes, SSBD might get accidentally disabled. Fix that.
--- arch/x86/kernel/cpu/bugs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -1414,7 +1414,8 @@ static void __init spectre_v2_select_mitstatic void update_stibp_msr (void * __unused) { -write_spec_ctrl_current (x86_spec_ctrl_base, true); +u64 val =spec_ctrl_current () | (x86_spec_ctrl_base &SPEC_CTRL_STIBP ); +write_spec_ctrl_current (val, true); }/* Update x86_spec_ctrl_base in case SMT state changed. */
Greg Kroah-Hartman
maintainerPATCH 115/148 x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit bbb69e8bee1bd882784947095ffb2bfe0f7c9470 upstream.
There's no need to recalculate the host value for every entry/exit. Just use the cached value in spec_ctrl_current().
--- arch/x86/kernel/cpu/bugs.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -11
@@ -199,7 +199,7 @@ void __init check_bugs(void)void x86_virt_spec_ctrl (u64 guest_spec_ctrl,u64 guest_virt_spec_ctrl,bool setguest) { -u64 msrval, guestval, hostval = x86_spec_ctrl_base; +u64 msrval, guestval, hostval =spec_ctrl_current ();struct thread_info *ti =current_thread_info ();/* Is MSR_SPEC_CTRL implemented ? */
@@ -212,15 +212,6 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, guestval = hostval & ~x86_spec_ctrl_mask; guestval |= guest_spec_ctrl & x86_spec_ctrl_mask; -/* SSBD controlled in MSR_SPEC_CTRL */ -if (static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD ) || -static_cpu_has (X86_FEATURE_AMD_SSBD )) - hostval |=ssbd_tif_to_spec_ctrl (ti->flags); - -/* Conditional STIBP enabled? */ -if (static_branch_unlikely (&switch_to_cond_stibp)) - hostval |=stibp_tif_to_spec_ctrl (ti->flags); -if (hostval != guestval) { msrval = setguest ? guestval : hostval;wrmsrl (MSR_IA32_SPEC_CTRL , msrval);
@@ -1353,7 +1344,6 @@ static void __init spectre_v2_select_mitpr_err (SPECTRE_V2_EIBRS_EBPF_MSG );if (spectre_v2_in_ibrs_mode (mode)) { -/* Force it so VMEXIT will restore correctly */ x86_spec_ctrl_base |=SPEC_CTRL_IBRS ;write_spec_ctrl_current (x86_spec_ctrl_base, true); }
Greg Kroah-Hartman
maintainerPATCH 116/148 x86/speculation: Remove x86_spec_ctrl_mask
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit acac5e98ef8d638a411cfa2ee676c87e1973f126 upstream.
This mask has been made redundant by kvm_spec_ctrl_test_value(). And it doesn't even work when MSR interception is disabled, as the guest can just write to SPEC_CTRL directly.
--- arch/x86/kernel/cpu/bugs.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -30
@@ -85,12 +85,6 @@ u64 spec_ctrl_current(void)EXPORT_SYMBOL_GPL (spec_ctrl_current);/* -* The vendor and possibly platform specific bits which can be modified in -* x86_spec_ctrl_base. -*/ -static u64 __ro_after_init x86_spec_ctrl_mask =SPEC_CTRL_IBRS ; - -/* * AMD specific MSR info for Speculative Store Bypass control. * x86_amd_ls_cfg_ssbd_mask is initialized in identify_boot_cpu(). */
@@ -138,10 +132,6 @@ void __init check_bugs(void)if (boot_cpu_has (X86_FEATURE_MSR_SPEC_CTRL ))rdmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); -/* Allow STIBP in MSR_SPEC_CTRL if supported */ -if (boot_cpu_has (X86_FEATURE_STIBP )) - x86_spec_ctrl_mask |=SPEC_CTRL_STIBP ; -/* Select the proper CPU mitigations before patching alternatives: */ spectre_v1_select_mitigation ();spectre_v2_select_mitigation ();
@@ -199,19 +189,10 @@ void __init check_bugs(void)void x86_virt_spec_ctrl (u64 guest_spec_ctrl,u64 guest_virt_spec_ctrl,bool setguest) { -u64 msrval, guestval, hostval =spec_ctrl_current (); +u64 msrval, guestval = guest_spec_ctrl, hostval =spec_ctrl_current ();struct thread_info *ti =current_thread_info (); -/* Is MSR_SPEC_CTRL implemented ? */ if (static_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) { -/* -* Restrict guest_spec_ctrl to supported values. Clear the -* modifiable bits in the host base value and or the -* modifiable bits from the guest value. -*/ - guestval = hostval & ~x86_spec_ctrl_mask; - guestval |= guest_spec_ctrl & x86_spec_ctrl_mask; -if (hostval != guestval) { msrval = setguest ? guestval : hostval;wrmsrl (MSR_IA32_SPEC_CTRL , msrval);
@@ -1622,16 +1603,6 @@ static enum ssb_mitigation __init __ssb_ }/* -* If SSBD is controlled by the SPEC_CTRL MSR, then set the proper -* bit in the mask to allow guests to use the mitigation even in the -* case where the host does not enable it. -*/ -if (static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD ) || -static_cpu_has (X86_FEATURE_AMD_SSBD )) { - x86_spec_ctrl_mask |=SPEC_CTRL_SSBD ; - } - -/* * We have three CPU feature flags that are in play here: * - X86_BUG_SPEC_STORE_BYPASS - CPU is susceptible. * - X86_FEATURE_SSBD - CPU is able to turn off speculative store bypass
Greg Kroah-Hartman
maintainerPATCH 117/148 objtool: Re-add UNWIND_HINT_{SAVE_RESTORE}
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 8faea26e611189e933ea2281975ff4dc7c1106b6 upstream.
Commit
c536ed2fffd5 ("objtool: Remove SAVE/RESTORE hints")
removed the save/restore unwind hints because they were no longer needed. Now they're going to be needed again so re-add them.
--- arch/x86/include/asm/unwind_hints.h | 12 +++++++++- include/linux/objtool.h | 6 +++-- tools/include/linux/objtool.h | 6 +++-- tools/objtool/check.c | 40 ++++++++++++++++++++++++++++++++++++ tools/objtool/check.h | 1 5 files changed, 59 insertions(+), 6 deletions(-)
arch/x86/include/asm/unwind_hints.h +10 -2
@@ -8,11 +8,11 @@#ifdef __ASSEMBLY__ .macro UNWIND_HINT_EMPTY - UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_CALL end=1 + UNWIND_HINT type=UNWIND_HINT_TYPE_CALL end=1 .endm .macro UNWIND_HINT_ENTRY - UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_ENTRY end=1 + UNWIND_HINT type=UNWIND_HINT_TYPE_ENTRY end=1 .endm .macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0
@@ -56,6 +56,14 @@ UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=8 type=UNWIND_HINT_TYPE_FUNC .endm +.macro UNWIND_HINT_SAVE + UNWIND_HINT type=UNWIND_HINT_TYPE_SAVE +.endm + +.macro UNWIND_HINT_RESTORE + UNWIND_HINT type=UNWIND_HINT_TYPE_RESTORE +.endm +#endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_UNWIND_HINTS_H */
include/linux/objtool.h +4 -2
@@ -40,6 +40,8 @@ struct unwind_hint {#define UNWIND_HINT_TYPE_REGS_PARTIAL 2#define UNWIND_HINT_TYPE_FUNC 3#define UNWIND_HINT_TYPE_ENTRY 4 +#define UNWIND_HINT_TYPE_SAVE 5 +#define UNWIND_HINT_TYPE_RESTORE 6#ifdef CONFIG_STACK_VALIDATION
@@ -102,7 +104,7 @@ struct unwind_hint {* the debuginfo as necessary. It will also warn if it sees any * inconsistencies. */ -.macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0 +.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 end=0 .Lunwind_hint_ip_\@: .pushsection .discard.unwind_hints/* struct unwind_hint */
@@ -126,7 +128,7 @@ struct unwind_hint {#define STACK_FRAME_NON_STANDARD (func)#else #define ANNOTATE_INTRA_FUNCTION_CALL -.macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0 +.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 end=0 .endm #endif
tools/include/linux/objtool.h +4 -2
@@ -40,6 +40,8 @@ struct unwind_hint {#define UNWIND_HINT_TYPE_REGS_PARTIAL 2#define UNWIND_HINT_TYPE_FUNC 3#define UNWIND_HINT_TYPE_ENTRY 4 +#define UNWIND_HINT_TYPE_SAVE 5 +#define UNWIND_HINT_TYPE_RESTORE 6#ifdef CONFIG_STACK_VALIDATION
@@ -102,7 +104,7 @@ struct unwind_hint {* the debuginfo as necessary. It will also warn if it sees any * inconsistencies. */ -.macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0 +.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 end=0 .Lunwind_hint_ip_\@: .pushsection .discard.unwind_hints/* struct unwind_hint */
@@ -126,7 +128,7 @@ struct unwind_hint {#define STACK_FRAME_NON_STANDARD (func)#else #define ANNOTATE_INTRA_FUNCTION_CALL -.macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0 +.macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 end=0 .endm #endif
tools/objtool/check.c +40 -0
@@ -1752,6 +1752,17 @@ static int read_unwind_hints(struct objt insn->hint = true; +if (hint->type ==UNWIND_HINT_TYPE_SAVE ) { + insn->hint = false; + insn->save = true; +continue ; + } + +if (hint->type ==UNWIND_HINT_TYPE_RESTORE ) { + insn->restore = true; +continue ; + } +if (hint->type ==UNWIND_HINT_TYPE_REGS_PARTIAL ) {struct symbol *sym =find_symbol_by_offset (insn->sec, insn->offset);
@@ -2847,6 +2858,35 @@ static int validate_branch(struct objtoo state.instr += insn->instr;if (insn->hint) { +if (insn->restore) { +struct instruction *save_insn, *i; + + i = insn; + save_insn =NULL ; + +sym_for_each_insn_continue_reverse (file, func, i) { +if (i->save) { + save_insn = i; +break ; + } + } + +if (!save_insn) { +WARN_FUNC ("no corresponding CFI save for CFI restore" , + sec, insn->offset); +return 1 ; + } + +if (!save_insn->visited) { +WARN_FUNC ("objtool isn't smart enough to handle this CFI save/restore combo" , + sec, insn->offset); +return 1 ; + } + + insn->cfi = save_insn->cfi; + nr_cfi_reused++; + } + state.cfi = *insn->cfi; }else {/* XXX track if we actually changed state.cfi */
tools/objtool/check.h +1 -0
@@ -47,6 +47,7 @@ struct instruction {unsigned long immediate;bool dead_end, ignore, ignore_alts;bool hint; +bool save, restore;bool retpoline_safe;bool entry;s8 instr;
Greg Kroah-Hartman
maintainerPATCH 118/148 KVM: VMX: Flatten __vmx_vcpu_run()
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 8bd200d23ec42d66ccd517a72dd0b9cc6132d2fd upstream.
Move the vmx_vm{enter,exit}() functionality into __vmx_vcpu_run(). This will make it easier to do the spec_ctrl handling before the first RET.
--- arch/x86/kvm/vmx/vmenter.S | 118 +++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 73 deletions(-)
arch/x86/kvm/vmx/vmenter.S +45 -73
@@ -31,68 +31,6 @@ .section .noinstr.text, "ax" /** - * vmx_vmenter - VM-Enter the current loaded VMCS - * - * %RFLAGS.ZF: !VMCS.LAUNCHED, i.e. controls VMLAUNCH vs. VMRESUME - * - * Returns: - * %RFLAGS.CF is set on VM-Fail Invalid - * %RFLAGS.ZF is set on VM-Fail Valid - * %RFLAGS.{CF,ZF} are cleared on VM-Success, i.e. VM-Exit - * - * Note that VMRESUME/VMLAUNCH fall-through and return directly if - * they VM-Fail, whereas a successful VM-Enter + VM-Exit will jump - * to vmx_vmexit. - */ -SYM_FUNC_START_LOCAL(vmx_vmenter) - /* EFLAGS.ZF is set if VMCS.LAUNCHED == 0 */ - je 2f - -1: vmresume - RET - -2: vmlaunch - RET - -3: cmpb $0, kvm_rebooting - je 4f - RET -4: ud2 - - _ASM_EXTABLE(1b, 3b) - _ASM_EXTABLE(2b, 3b) - -SYM_FUNC_END(vmx_vmenter) - -/** - * vmx_vmexit - Handle a VMX VM-Exit - * - * Returns: - * %RFLAGS.{CF,ZF} are cleared on VM-Success, i.e. VM-Exit - * - * This is vmx_vmenter's partner in crime. On a VM-Exit, control will jump - * here after hardware loads the host's state, i.e. this is the destination - * referred to by VMCS.HOST_RIP. - */ -SYM_FUNC_START(vmx_vmexit) -#ifdef CONFIG_RETPOLINE - ALTERNATIVE "jmp .Lvmexit_skip_rsb", "", X86_FEATURE_RETPOLINE - /* Preserve guest's RAX, it's used to stuff the RSB. */ - push %_ASM_AX - - /* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */ - FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE - - /* Clear RFLAGS.CF and RFLAGS.ZF to preserve VM-Exit, i.e. !VM-Fail. */ - or $1, %_ASM_AX - - pop %_ASM_AX -.Lvmexit_skip_rsb: -#endif - RET -SYM_FUNC_END(vmx_vmexit) - -/** * __vmx_vcpu_run - Run a vCPU via a transition to VMX guest mode * @vmx: struct vcpu_vmx * (forwarded to vmx_update_host_rsp) * @regs: unsigned long * (to guest registers)
@@ -124,8 +62,7 @@ SYM_FUNC_START(__vmx_vcpu_run) /* Copy @launched to BL, _ASM_ARG3 is volatile. */ mov %_ASM_ARG3B, %bl - /* Adjust RSP to account for the CALL to vmx_vmenter(). */ - lea -WORD_SIZE(%_ASM_SP), %_ASM_ARG2 + lea (%_ASM_SP), %_ASM_ARG2 call vmx_update_host_rsp /* Load @regs to RAX. */
@@ -154,11 +91,36 @@ SYM_FUNC_START(__vmx_vcpu_run) /* Load guest RAX. This kills the @regs pointer! */ mov VCPU_RAX(%_ASM_AX), %_ASM_AX - /* Enter guest mode */ - call vmx_vmenter + /* Check EFLAGS.ZF from 'testb' above */ + je .Lvmlaunch - /* Jump on VM-Fail. */ - jbe 2f + /* + * After a successful VMRESUME/VMLAUNCH, control flow "magically" + * resumes below at 'vmx_vmexit' due to the VMCS HOST_RIP setting. + * So this isn't a typical function and objtool needs to be told to + * save the unwind state here and restore it below. + */ + UNWIND_HINT_SAVE + +/* + * If VMRESUME/VMLAUNCH and corresponding vmexit succeed, execution resumes at + * the 'vmx_vmexit' label below. + */ +.Lvmresume: + vmresume + jmp .Lvmfail + +.Lvmlaunch: + vmlaunch + jmp .Lvmfail + + _ASM_EXTABLE(.Lvmresume, .Lfixup) + _ASM_EXTABLE(.Lvmlaunch, .Lfixup) + +SYM_INNER_LABEL(vmx_vmexit, SYM_L_GLOBAL) + + /* Restore unwind state from before the VMRESUME/VMLAUNCH. */ + UNWIND_HINT_RESTORE /* Temporarily save guest's RAX. */ push %_ASM_AX
@@ -185,9 +147,13 @@ SYM_FUNC_START(__vmx_vcpu_run) mov %r15, VCPU_R15(%_ASM_AX) #endif + /* IMPORTANT: RSB must be stuffed before the first return. */ + FILL_RETURN_BUFFER %_ASM_BX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE + /* Clear RAX to indicate VM-Exit (as opposed to VM-Fail). */ xor %eax, %eax +.Lclear_regs: /* * Clear all general purpose registers except RSP and RAX to prevent * speculative use of the guest's values, even those that are reloaded
@@ -197,7 +163,7 @@ SYM_FUNC_START(__vmx_vcpu_run) * free. RSP and RAX are exempt as RSP is restored by hardware during * VM-Exit and RAX is explicitly loaded with 0 or 1 to return VM-Fail. */ -1: xor %ecx, %ecx + xor %ecx, %ecx xor %edx, %edx xor %ebx, %ebx xor %ebp, %ebp
@@ -216,8 +182,8 @@ SYM_FUNC_START(__vmx_vcpu_run) /* "POP" @regs. */ add $WORD_SIZE, %_ASM_SP - pop %_ASM_BX + pop %_ASM_BX #ifdef CONFIG_X86_64 pop %r12 pop %r13
@@ -230,9 +196,15 @@ SYM_FUNC_START(__vmx_vcpu_run) pop %_ASM_BP RET - /* VM-Fail. Out-of-line to avoid a taken Jcc after VM-Exit. */ -2: mov $1, %eax - jmp 1b +.Lfixup: + cmpb $0, kvm_rebooting + jne .Lvmfail + ud2 +.Lvmfail: + /* VM-Fail: set return value to 1 */ + mov $1, %eax + jmp .Lclear_regs + SYM_FUNC_END(__vmx_vcpu_run)
Greg Kroah-Hartman
maintainerPATCH 119/148 KVM: VMX: Convert launched argument to flags
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit bb06650634d3552c0f8557e9d16aa1a408040e28 upstream.
Convert __vmx_vcpu_run()'s 'launched' argument to 'flags', in preparation for doing SPEC_CTRL handling immediately after vmexit, which will need another flag.
This is much easier than adding a fourth argument, because this code supports both 32-bit and 64-bit, and the fourth argument on 32-bit would have to be pushed on the stack.
Note that __vmx_vcpu_run_flags() is called outside of the noinstr critical section because it will soon start calling potentially traceable functions.
--- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/run_flags.h | 7 +++++++ arch/x86/kvm/vmx/vmenter.S | 9 +++++---- arch/x86/kvm/vmx/vmx.c | 17 ++++++++++++++--- arch/x86/kvm/vmx/vmx.h | 5 ++++- 5 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 arch/x86/kvm/vmx/run_flags.h
arch/x86/kvm/vmx/nested.c +1 -1
@@ -3077,7 +3077,7 @@ static int nested_vmx_check_vmentry_hw(s } vm_fail =__vmx_vcpu_run (vmx, (unsigned long *)&vcpu->arch.regs, - vmx->loaded_vmcs->launched); +__vmx_vcpu_run_flags (vmx));if (vmx->msr_autoload.host.nr)vmcs_write32 (VM_EXIT_MSR_LOAD_COUNT , vmx->msr_autoload.host.nr);
arch/x86/kvm/vmx/run_flags.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __KVM_X86_VMX_RUN_FLAGS_H +#define __KVM_X86_VMX_RUN_FLAGS_H + +#define VMX_RUN_VMRESUME (1 << 0) + +#endif /* __KVM_X86_VMX_RUN_FLAGS_H */
arch/x86/kvm/vmx/vmenter.S +5 -4
@@ -5,6 +5,7 @@ #include <asm/kvm_vcpu_regs.h> #include <asm/nospec-branch.h> #include <asm/segment.h> +#include "run_flags.h" #define WORD_SIZE (BITS_PER_LONG / 8)
@@ -34,7 +35,7 @@ * __vmx_vcpu_run - Run a vCPU via a transition to VMX guest mode * @vmx: struct vcpu_vmx * (forwarded to vmx_update_host_rsp) * @regs: unsigned long * (to guest registers) - * @launched: %true if the VMCS has been launched + * @flags: VMX_RUN_VMRESUME: use VMRESUME instead of VMLAUNCH * * Returns: * 0 on VM-Exit, 1 on VM-Fail
@@ -59,7 +60,7 @@ SYM_FUNC_START(__vmx_vcpu_run) */ push %_ASM_ARG2 - /* Copy @launched to BL, _ASM_ARG3 is volatile. */ + /* Copy @flags to BL, _ASM_ARG3 is volatile. */ mov %_ASM_ARG3B, %bl lea (%_ASM_SP), %_ASM_ARG2
@@ -69,7 +70,7 @@ SYM_FUNC_START(__vmx_vcpu_run) mov (%_ASM_SP), %_ASM_AX /* Check if vmlaunch or vmresume is needed */ - testb %bl, %bl + testb $VMX_RUN_VMRESUME, %bl /* Load guest registers. Don't clobber flags. */ mov VCPU_RCX(%_ASM_AX), %_ASM_CX
@@ -92,7 +93,7 @@ SYM_FUNC_START(__vmx_vcpu_run) mov VCPU_RAX(%_ASM_AX), %_ASM_AX /* Check EFLAGS.ZF from 'testb' above */ - je .Lvmlaunch + jz .Lvmlaunch /* * After a successful VMRESUME/VMLAUNCH, control flow "magically"
arch/x86/kvm/vmx/vmx.c +14 -3
@@ -936,6 +936,16 @@ static bool msr_write_intercepted(structreturn true; } +unsigned int __vmx_vcpu_run_flags (struct vcpu_vmx *vmx) +{ +unsigned int flags =0 ; + +if (vmx->loaded_vmcs->launched) + flags |=VMX_RUN_VMRESUME ; + +return flags; +} +static void clear_atomic_switch_msr_special (struct vcpu_vmx *vmx,unsigned long entry,unsigned long exit) {
@@ -6688,7 +6698,8 @@ static fastpath_t vmx_exit_handlers_fast } static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, -struct vcpu_vmx *vmx) +struct vcpu_vmx *vmx, +unsigned long flags) {/* * VMENTER enables interrupts (host state), but the kernel state is
@@ -6725,7 +6736,7 @@ static noinstr void vmx_vcpu_enter_exit(native_write_cr2 (vcpu->arch.cr2); vmx->fail =__vmx_vcpu_run (vmx, (unsigned long *)&vcpu->arch.regs, - vmx->loaded_vmcs->launched); + flags); vcpu->arch.cr2 =native_read_cr2 ();
@@ -6824,7 +6835,7 @@ reenter_guest:x86_spec_ctrl_set_guest (vmx->spec_ctrl,0 );/* The actual VMENTER/EXIT is in the .noinstr.text section. */ -vmx_vcpu_enter_exit (vcpu, vmx); +vmx_vcpu_enter_exit (vcpu, vmx,__vmx_vcpu_run_flags (vmx));/* * We do not use IBRS in the kernel. If this vCPU has used the
arch/x86/kvm/vmx/vmx.h +4 -1
@@ -13,6 +13,7 @@#include "vmcs.h" #include "vmx_ops.h" #include "cpuid.h" +#include "run_flags.h" extern const u32 vmx_msr_index[];
@@ -365,7 +366,9 @@ void vmx_set_virtual_apic_mode(struct kvstruct vmx_uret_msr *vmx_find_uret_msr (struct vcpu_vmx *vmx,u32 msr);void pt_update_intercept_for_msr (struct kvm_vcpu *vcpu);void vmx_update_host_rsp (struct vcpu_vmx *vmx,unsigned long host_rsp); -bool __vmx_vcpu_run (struct vcpu_vmx *vmx,unsigned long *regs,bool launched); +unsigned int __vmx_vcpu_run_flags (struct vcpu_vmx *vmx); +bool __vmx_vcpu_run (struct vcpu_vmx *vmx,unsigned long *regs, +unsigned int flags);int vmx_find_loadstore_msr_slot (struct vmx_msrs *m,u32 msr);void vmx_ept_load_pdptrs (struct kvm_vcpu *vcpu);
Greg Kroah-Hartman
maintainerPATCH 120/148 KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit fc02735b14fff8c6678b521d324ade27b1a3d4cf upstream.
On eIBRS systems, the returns in the vmexit return path from __vmx_vcpu_run() to vmx_vcpu_run() are exposed to RSB poisoning attacks.
Fix that by moving the post-vmexit spec_ctrl handling to immediately after the vmexit.
--- arch/x86/include/asm/nospec-branch.h | 1 arch/x86/kernel/cpu/bugs.c | 4 ++ arch/x86/kvm/vmx/run_flags.h | 1 arch/x86/kvm/vmx/vmenter.S | 49 +++++++++++++++++++++++++++-------- arch/x86/kvm/vmx/vmx.c | 48 ++++++++++++++++++++-------------- arch/x86/kvm/vmx/vmx.h | 1 6 files changed, 73 insertions(+), 31 deletions(-)
arch/x86/include/asm/nospec-branch.h +1 -0
@@ -275,6 +275,7 @@ static inline void indirect_branch_predi/* The Intel SPEC CTRL MSR base value cache */ extern u64 x86_spec_ctrl_base; +extern u64 x86_spec_ctrl_current;extern void write_spec_ctrl_current (u64 val,bool force);extern u64 spec_ctrl_current (void );
arch/x86/kernel/cpu/bugs.c +4 -0
@@ -186,6 +186,10 @@ void __init check_bugs(void)#endif } +/* +* NOTE: For VMX, this function is not called in the vmexit path. +* It uses vmx_spec_ctrl_restore_host() instead. +*/ void x86_virt_spec_ctrl (u64 guest_spec_ctrl,u64 guest_virt_spec_ctrl,bool setguest) {
arch/x86/kvm/vmx/run_flags.h +1 -0
@@ -3,5 +3,6 @@#define __KVM_X86_VMX_RUN_FLAGS_H#define VMX_RUN_VMRESUME (1 << 0) +#define VMX_RUN_SAVE_SPEC_CTRL (1 << 1)#endif /* __KVM_X86_VMX_RUN_FLAGS_H */
arch/x86/kvm/vmx/vmenter.S +38 -11
91 lines not on this page · raw message
arch/x86/kvm/vmx/vmx.c +28 -20
66 lines not on this page · raw message
arch/x86/kvm/vmx/vmx.h +1 -0
@@ -366,6 +366,7 @@ void vmx_set_virtual_apic_mode(struct kvstruct vmx_uret_msr *vmx_find_uret_msr (struct vcpu_vmx *vmx,u32 msr);void pt_update_intercept_for_msr (struct kvm_vcpu *vcpu);void vmx_update_host_rsp (struct vcpu_vmx *vmx,unsigned long host_rsp); +void vmx_spec_ctrl_restore_host (struct vcpu_vmx *vmx,unsigned int flags);unsigned int __vmx_vcpu_run_flags (struct vcpu_vmx *vmx);bool __vmx_vcpu_run (struct vcpu_vmx *vmx,unsigned long *regs,unsigned int flags);
Greg Kroah-Hartman
maintainerPATCH 121/148 KVM: VMX: Fix IBRS handling after vmexit
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit bea7e31a5caccb6fe8ed989c065072354f0ecb52 upstream.
For legacy IBRS to work, the IBRS bit needs to be always re-written after vmexit, even if it's already on.
--- arch/x86/kvm/vmx/vmx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +6 -1
@@ -6706,8 +6706,13 @@ void noinstr vmx_spec_ctrl_restore_host(/* * If the guest/host SPEC_CTRL values differ, restore the host value. +* +* For legacy IBRS, the IBRS bit always needs to be written after +* transitioning from a less privileged predictor mode, regardless of +* whether the guest/host values differ. */ -if (vmx->spec_ctrl != hostval) +if (cpu_feature_enabled (X86_FEATURE_KERNEL_IBRS ) || + vmx->spec_ctrl != hostval)native_wrmsrl (MSR_IA32_SPEC_CTRL , hostval);barrier_nospec ();
Greg Kroah-Hartman
maintainerPATCH 122/148 x86/speculation: Fill RSB on vmexit for IBRS
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 9756bba28470722dacb79ffce554336dd1f6a6cd upstream.
Prevent RSB underflow/poisoning attacks with RSB. While at it, add a bunch of comments to attempt to document the current state of tribal knowledge about RSB attacks and what exactly is being mitigated.
--- arch/x86/include/asm/cpufeatures.h | 2 - arch/x86/kernel/cpu/bugs.c | 63 ++++++++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/vmenter.S | 6 +-- 3 files changed, 62 insertions(+), 9 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -204,7 +204,7 @@#define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ #define X86_FEATURE_KERNEL_IBRS ( 7*32+12)/* "" Set/clear IBRS on kernel entry/exit */ -/* FREE! ( 7*32+13) */ +#define X86_FEATURE_RSB_VMEXIT ( 7*32+13)/* "" Fill RSB on VM-Exit */ #define X86_FEATURE_INTEL_PPIN ( 7*32+14)/* Intel Processor Inventory Number */ #define X86_FEATURE_CDP_L2 ( 7*32+15)/* Code and Data Prioritization L2 */ #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16)/* "" MSR SPEC_CTRL is implemented */
arch/x86/kernel/cpu/bugs.c +58 -5
75 lines not on this page · raw message
arch/x86/kvm/vmx/vmenter.S +3 -3
@@ -193,15 +193,15 @@ SYM_INNER_LABEL(vmx_vmexit, SYM_L_GLOBAL * IMPORTANT: RSB filling and SPEC_CTRL handling must be done before * the first unbalanced RET after vmexit! * - * For retpoline, RSB filling is needed to prevent poisoned RSB entries - * and (in some cases) RSB underflow. + * For retpoline or IBRS, RSB filling is needed to prevent poisoned RSB + * entries and (in some cases) RSB underflow. * * eIBRS has its own protection against poisoned RSB, so it doesn't * need the RSB filling sequence. But it does need to be enabled * before the first unbalanced RET. */ - FILL_RETURN_BUFFER %_ASM_CX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE + FILL_RETURN_BUFFER %_ASM_CX, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_VMEXIT pop %_ASM_ARG2 /* @flags */ pop %_ASM_ARG1 /* @vmx */
Greg Kroah-Hartman
maintainerPATCH 123/148 x86/common: Stamp out the stepping madness
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 7a05bc95ed1c5a59e47aaade9fb4083c27de9e62 upstream.
The whole MMIO/RETBLEED enumeration went overboard on steppings. Get rid of all that and simply use ANY.
If a future stepping of these models would not be affected, it had better set the relevant ARCH_CAP_$FOO_NO bit in IA32_ARCH_CAPABILITIES.
--- arch/x86/kernel/cpu/common.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
arch/x86/kernel/cpu/common.c +16 -21
@@ -1119,32 +1119,27 @@ static const struct x86_cpu_id cpu_vuln_VULNBL_INTEL_STEPPINGS (HASWELL ,X86_STEPPING_ANY ,SRBDS ),VULNBL_INTEL_STEPPINGS (HASWELL_L ,X86_STEPPING_ANY ,SRBDS ),VULNBL_INTEL_STEPPINGS (HASWELL_G ,X86_STEPPING_ANY ,SRBDS ), -VULNBL_INTEL_STEPPINGS (HASWELL_X ,BIT (2 ) |BIT (4 ),MMIO ), -VULNBL_INTEL_STEPPINGS (BROADWELL_D ,X86_STEPPINGS (0x3 ,0x5 ),MMIO ), +VULNBL_INTEL_STEPPINGS (HASWELL_X ,X86_STEPPING_ANY ,MMIO ), +VULNBL_INTEL_STEPPINGS (BROADWELL_D ,X86_STEPPING_ANY ,MMIO ),VULNBL_INTEL_STEPPINGS (BROADWELL_G ,X86_STEPPING_ANY ,SRBDS ),VULNBL_INTEL_STEPPINGS (BROADWELL_X ,X86_STEPPING_ANY ,MMIO ),VULNBL_INTEL_STEPPINGS (BROADWELL ,X86_STEPPING_ANY ,SRBDS ), -VULNBL_INTEL_STEPPINGS (SKYLAKE_L ,X86_STEPPINGS (0x3 ,0x3 ),SRBDS |MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (SKYLAKE_L ,X86_STEPPING_ANY ,SRBDS ), -VULNBL_INTEL_STEPPINGS (SKYLAKE_X ,BIT (3 ) |BIT (4 ) |BIT (6 ) | -BIT (7 ) |BIT (0xB ),MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPINGS (0x3 ,0x3 ),SRBDS |MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPING_ANY ,SRBDS ), -VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPINGS (0x9 ,0xC ),SRBDS |MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPINGS (0x0 ,0x8 ),SRBDS ), -VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPINGS (0x9 ,0xD ),SRBDS |MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPINGS (0x0 ,0x8 ),SRBDS ), -VULNBL_INTEL_STEPPINGS (ICELAKE_L ,X86_STEPPINGS (0x5 ,0x5 ),MMIO |MMIO_SBDS |RETBLEED ), -VULNBL_INTEL_STEPPINGS (ICELAKE_D ,X86_STEPPINGS (0x1 ,0x1 ),MMIO ), -VULNBL_INTEL_STEPPINGS (ICELAKE_X ,X86_STEPPINGS (0x4 ,0x6 ),MMIO ), -VULNBL_INTEL_STEPPINGS (COMETLAKE ,BIT (2 ) |BIT (3 ) |BIT (5 ),MMIO |MMIO_SBDS |RETBLEED ), -VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (SKYLAKE_L ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (SKYLAKE_X ,X86_STEPPING_ANY ,MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (ICELAKE_L ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (ICELAKE_D ,X86_STEPPING_ANY ,MMIO ), +VULNBL_INTEL_STEPPINGS (ICELAKE_X ,X86_STEPPING_ANY ,MMIO ), +VULNBL_INTEL_STEPPINGS (COMETLAKE ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS |RETBLEED ),VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPINGS (0x0 ,0x0 ),MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (LAKEFIELD ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS |RETBLEED ), -VULNBL_INTEL_STEPPINGS (ROCKETLAKE ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |RETBLEED ), -VULNBL_INTEL_STEPPINGS (ATOM_TREMONT ,X86_STEPPINGS (0x1 ,0x1 ),MMIO |MMIO_SBDS ), +VULNBL_INTEL_STEPPINGS (COMETLAKE_L ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (LAKEFIELD ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS |RETBLEED ), +VULNBL_INTEL_STEPPINGS (ROCKETLAKE ,X86_STEPPING_ANY ,MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (ATOM_TREMONT ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS ),VULNBL_INTEL_STEPPINGS (ATOM_TREMONT_D ,X86_STEPPING_ANY ,MMIO ), -VULNBL_INTEL_STEPPINGS (ATOM_TREMONT_L ,X86_STEPPINGS (0x0 ,0x0 ),MMIO |MMIO_SBDS ), +VULNBL_INTEL_STEPPINGS (ATOM_TREMONT_L ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS ),VULNBL_AMD (0x15 ,RETBLEED ), VULNBL_AMD(0x16, RETBLEED),
Greg Kroah-Hartman
maintainerPATCH 124/148 x86/cpu/amd: Enumerate BTC_NO
In reply to Greg Kroah-HartmanFrom: Andrew Cooper <[email protected]>
commit 26aae8ccbc1972233afd08fb3f368947c0314265 upstream.
BTC_NO indicates that hardware is not susceptible to Branch Type Confusion.
Zen3 CPUs don't suffer BTC.
Hypervisors are expected to synthesise BTC_NO when it is appropriate given the migration pool, to prevent kernels using heuristics.
[ bp: Massage. ]
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/amd.c | 21 +++++++++++++++------ arch/x86/kernel/cpu/common.c | 6 ++++-- 3 files changed, 20 insertions(+), 8 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -316,6 +316,7 @@#define X86_FEATURE_AMD_SSBD (13*32+24)/* "" Speculative Store Bypass Disable */ #define X86_FEATURE_VIRT_SSBD (13*32+25)/* Virtualized Speculative Store Bypass Disable */ #define X86_FEATURE_AMD_SSB_NO (13*32+26)/* "" Speculative Store Bypass is fixed in hardware. */ +#define X86_FEATURE_BTC_NO (13*32+29)/* "" Not vulnerable to Branch Type Confusion */ /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ #define X86_FEATURE_DTHERM (14*32+ 0)/* Digital Thermal Sensor */
arch/x86/kernel/cpu/amd.c +15 -6
@@ -942,12 +942,21 @@ static void init_amd_zn(struct cpuinfo_x node_reclaim_distance =32 ;#endif -/* -* Fix erratum 1076: CPB feature bit not being set in CPUID. -* Always set it, except when running under a hypervisor. -*/ -if (!cpu_has (c,X86_FEATURE_HYPERVISOR ) && !cpu_has (c,X86_FEATURE_CPB )) -set_cpu_cap (c,X86_FEATURE_CPB ); +/* Fix up CPUID bits, but only if not virtualised. */ +if (!cpu_has (c,X86_FEATURE_HYPERVISOR )) { + +/* Erratum 1076: CPB feature bit not being set in CPUID. */ +if (!cpu_has (c,X86_FEATURE_CPB )) +set_cpu_cap (c,X86_FEATURE_CPB ); + +/* +* Zen3 (Fam19 model < 0x10) parts are not susceptible to +* Branch Type Confusion, but predate the allocation of the +* BTC_NO bit. +*/ +if (c->x86 ==0x19 && !cpu_has (c,X86_FEATURE_BTC_NO )) +set_cpu_cap (c,X86_FEATURE_BTC_NO ); + } }static void init_amd (struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/common.c +4 -2
@@ -1246,8 +1246,10 @@ static void __init cpu_set_bug_bits(stru !arch_cap_mmio_immune(ia32_cap))setup_force_cpu_bug (X86_BUG_MMIO_STALE_DATA ); -if ((cpu_matches (cpu_vuln_blacklist,RETBLEED ) || (ia32_cap &ARCH_CAP_RSBA ))) -setup_force_cpu_bug (X86_BUG_RETBLEED ); +if (!cpu_has (c,X86_FEATURE_BTC_NO )) { +if (cpu_matches (cpu_vuln_blacklist,RETBLEED ) || (ia32_cap &ARCH_CAP_RSBA )) +setup_force_cpu_bug (X86_BUG_RETBLEED ); + }if (cpu_matches (cpu_vuln_whitelist,NO_MELTDOWN ))return ;
Greg Kroah-Hartman
maintainerPATCH 125/148 x86/retbleed: Add fine grained Kconfig knobs
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit f43b9876e857c739d407bc56df288b0ebe1a9164 upstream.
Do fine-grained Kconfig for all the various retbleed parts.
NOTE: if your compiler doesn't support return thunks this will silently 'upgrade' your mitigation to IBPB, you might not like this.
[bwh: Backported to 5.10:
- In scripts/Makefile.build, add the objtool option with an ifdef block, same as for other options
- Adjust filename, context]
--- Makefile | 8 +- arch/x86/Kconfig | 106 +++++++++++++++++++++++-------- arch/x86/entry/calling.h | 4 + arch/x86/include/asm/disabled-features.h | 18 ++++- arch/x86/include/asm/linkage.h | 4 - arch/x86/include/asm/nospec-branch.h | 10 ++ arch/x86/include/asm/static_call.h | 2 arch/x86/kernel/alternative.c | 5 + arch/x86/kernel/cpu/amd.c | 2 arch/x86/kernel/cpu/bugs.c | 42 +++++++----- arch/x86/kernel/static_call.c | 2 arch/x86/kvm/emulate.c | 4 - arch/x86/lib/retpoline.S | 4 + scripts/Makefile.build | 3 scripts/link-vmlinux.sh | 2 security/Kconfig | 11 --- tools/objtool/builtin-check.c | 3 tools/objtool/builtin.h | 2 tools/objtool/check.c | 9 ++ 19 files changed, 172 insertions(+), 69 deletions(-)
Makefile +6 -2
@@ -672,14 +672,18 @@ endif ifdef CONFIG_CC_IS_GCC RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) -RETPOLINE_CFLAGS += $(call cc-option,-mfunction-return=thunk-extern) RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) endif ifdef CONFIG_CC_IS_CLANG RETPOLINE_CFLAGS := -mretpoline-external-thunk RETPOLINE_VDSO_CFLAGS := -mretpoline -RETPOLINE_CFLAGS += $(call cc-option,-mfunction-return=thunk-extern) endif + +ifdef CONFIG_RETHUNK +RETHUNK_CFLAGS := -mfunction-return=thunk-extern +RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS) +endif + export RETPOLINE_CFLAGS export RETPOLINE_VDSO_CFLAGS
arch/x86/Kconfig +82 -24
118 lines not on this page · raw message
arch/x86/entry/calling.h +4 -0
@@ -323,6 +323,7 @@ For 32-bit we have the following convent* Assumes x86_spec_ctrl_{base,current} to have SPEC_CTRL_IBRS set. */ .macro IBRS_ENTER save_reg +#ifdef CONFIG_CPU_IBRS_ENTRY ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_KERNEL_IBRS movl $MSR_IA32_SPEC_CTRL, %ecx
@@ -343,6 +344,7 @@ For 32-bit we have the following convent shr $32, %rdx wrmsr .Lend_\@: +#endif .endm/*
@@ -350,6 +352,7 @@ For 32-bit we have the following convent* regs. Must be called after the last RET. */ .macro IBRS_EXIT save_reg +#ifdef CONFIG_CPU_IBRS_ENTRY ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_KERNEL_IBRS movl $MSR_IA32_SPEC_CTRL, %ecx
@@ -364,6 +367,7 @@ For 32-bit we have the following convent shr $32, %rdx wrmsr .Lend_\@: +#endif .endm/*
arch/x86/include/asm/disabled-features.h +14 -4
@@ -60,9 +60,19 @@# define DISABLE_RETPOLINE 0#else # define DISABLE_RETPOLINE ((1 << (X86_FEATURE_RETPOLINE & 31)) | \ - (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31)) | \ - (1 << (X86_FEATURE_RETHUNK & 31)) | \ - (1 << (X86_FEATURE_UNRET & 31))) + (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31))) +#endif + +#ifdef CONFIG_RETHUNK +# define DISABLE_RETHUNK 0 +#else +# define DISABLE_RETHUNK (1 << (X86_FEATURE_RETHUNK & 31)) +#endif + +#ifdef CONFIG_CPU_UNRET_ENTRY +# define DISABLE_UNRET 0 +#else +# define DISABLE_UNRET (1 << (X86_FEATURE_UNRET & 31))#endif /* Force disable because it's broken beyond repair */
@@ -82,7 +92,7 @@#define DISABLED_MASK8 0#define DISABLED_MASK9 (DISABLE_SMAP)#define DISABLED_MASK10 0 -#define DISABLED_MASK11 (DISABLE_RETPOLINE) +#define DISABLED_MASK11 (DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET)#define DISABLED_MASK12 0#define DISABLED_MASK13 0#define DISABLED_MASK14 0
arch/x86/include/asm/linkage.h +2 -2
@@ -18,7 +18,7 @@#define __ALIGN_STR __stringify(__ALIGN)#endif -#if defined(CONFIG_RETPOLINE ) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO ) +#if defined(CONFIG_RETHUNK ) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO )#define RET jmp __x86_return_thunk#else /* CONFIG_RETPOLINE */ #ifdef CONFIG_SLS
@@ -30,7 +30,7 @@#else /* __ASSEMBLY__ */ -#if defined(CONFIG_RETPOLINE ) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO ) +#if defined(CONFIG_RETHUNK ) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO )#define ASM_RET "jmp __x86_return_thunk\n\t"#else /* CONFIG_RETPOLINE */ #ifdef CONFIG_SLS
arch/x86/include/asm/nospec-branch.h +8 -2
@@ -127,6 +127,12 @@ .Lskip_rsb_\@: .endm +#ifdef CONFIG_CPU_UNRET_ENTRY +#define CALL_ZEN_UNTRAIN_RET "call zen_untrain_ret" +#else +#define CALL_ZEN_UNTRAIN_RET "" +#endif +/* * Mitigate RETBleed for AMD/Hygon Zen uarch. Requires KERNEL CR3 because the * return thunk isn't mapped into the userspace tables (then again, AMD
@@ -139,10 +145,10 @@* where we have a stack but before any RET instruction. */ .macro UNTRAIN_RET -#ifdef CONFIG_RETPOLINE +#if defined(CONFIG_CPU_UNRET_ENTRY ) || defined(CONFIG_CPU_IBPB_ENTRY )ANNOTATE_UNRET_END ALTERNATIVE_2 "", \ -"call zen_untrain_ret" ,X86_FEATURE_UNRET , \ +CALL_ZEN_UNTRAIN_RET ,X86_FEATURE_UNRET , \"call entry_ibpb" ,X86_FEATURE_ENTRY_IBPB #endif .endm
arch/x86/include/asm/static_call.h +1 -1
@@ -44,7 +44,7 @@#define ARCH_DEFINE_STATIC_CALL_TRAMP (name, func) \ __ARCH_DEFINE_STATIC_CALL_TRAMP(name, ".byte 0xe9; .long " #func " - (. + 4)") -#ifdef CONFIG_RETPOLINE +#ifdef CONFIG_RETHUNK #define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP (name) \ __ARCH_DEFINE_STATIC_CALL_TRAMP(name, "jmp __x86_return_thunk")#else
arch/x86/kernel/alternative.c +5 -0
@@ -662,6 +662,7 @@ void __init_or_module noinline apply_ret } } +#ifdef CONFIG_RETHUNK /* * Rewrite the compiler generated return thunk tail-calls. *
@@ -723,6 +724,10 @@ void __init_or_module noinline apply_ret } } } +#else +void __init_or_module noinline apply_returns(s32 *start, s32 *end) { } +#endif /* CONFIG_RETHUNK */ +#else /* !RETPOLINES || !CONFIG_STACK_VALIDATION */ void __init_or_module noinline apply_retpolines(s32 *start, s32 *end) { }
arch/x86/kernel/cpu/amd.c +2 -0
@@ -916,6 +916,7 @@ static void init_amd_bd(struct cpuinfo_xvoid init_spectral_chicken (struct cpuinfo_x86 *c) { +#ifdef CONFIG_CPU_UNRET_ENTRY u64 value;/*
@@ -932,6 +933,7 @@ void init_spectral_chicken(struct cpuinf wrmsrl_safe(MSR_ZEN2_SPECTRAL_CHICKEN, value); } } +#endif }static void init_amd_zn (struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/bugs.c +27 -15
86 lines not on this page · raw message
arch/x86/kernel/static_call.c +1 -1
@@ -108,7 +108,7 @@ void arch_static_call_transform(void *si }EXPORT_SYMBOL_GPL (arch_static_call_transform); -#ifdef CONFIG_RETPOLINE +#ifdef CONFIG_RETHUNK /* * This is called by apply_returns() to fix up static call trampolines, * specifically ARCH_DEFINE_STATIC_CALL_NULL_TRAMP which is recorded as
arch/x86/kvm/emulate.c +2 -2
@@ -435,10 +435,10 @@ static int fastop(struct x86_emulate_ctx* Depending on .config the SETcc functions look like: * * SETcc %al [3 bytes] -* RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETPOLINE] +* RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETHUNK] * INT3 [1 byte; CONFIG_SLS] */ -#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETPOLINE)) + \ +#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETHUNK)) + \ IS_ENABLED(CONFIG_SLS))#define SETCC_LENGTH (3 + RET_LENGTH)#define SETCC_ALIGN (4 << ((SETCC_LENGTH > 4) & 1) << ((SETCC_LENGTH > 8) & 1))
arch/x86/lib/retpoline.S +4 -0
@@ -71,6 +71,8 @@ SYM_CODE_END(__x86_indirect_thunk_array) * This function name is magical and is used by -mfunction-return=thunk-extern * for the compiler to generate JMPs to it. */ +#ifdef CONFIG_RETHUNK + .section .text.__x86.return_thunk /*
@@ -135,3 +137,5 @@ SYM_FUNC_END(zen_untrain_ret) __EXPORT_THUNK(zen_untrain_ret) EXPORT_SYMBOL(__x86_return_thunk) + +#endif /* CONFIG_RETHUNK */
scripts/Makefile.build +3 -0
@@ -227,6 +227,9 @@ endif ifdef CONFIG_RETPOLINE objtool_args += --retpoline endif +ifdef CONFIG_RETHUNK + objtool_args += --rethunk +endif ifdef CONFIG_X86_SMAP objtool_args += --uaccess endif
scripts/link-vmlinux.sh +1 -1
@@ -65,7 +65,7 @@ objtool_link() if [ -n "${CONFIG_VMLINUX_VALIDATION}" ]; then objtoolopt="check" - if [ -n "${CONFIG_RETPOLINE}" ]; then + if [ -n "${CONFIG_CPU_UNRET_ENTRY}" ]; then objtoolopt="${objtoolopt} --unret" fi if [ -z "${CONFIG_FRAME_POINTER}" ]; then
security/Kconfig +0 -11
@@ -54,17 +54,6 @@ config SECURITY_NETWORK implement socket and networking access controls. If you are unsure how to answer this question, answer N. -config PAGE_TABLE_ISOLATION - bool "Remove the kernel mapping in user mode" - default y - depends on (X86_64 || X86_PAE) && !UML - help - This feature reduces the number of hardware side channels by - ensuring that the majority of kernel addresses are not mapped - into userspace. - - See Documentation/x86/pti.rst for more details. - config SECURITY_INFINIBAND bool "Infiniband Security Hooks" depends on SECURITY && INFINIBAND
tools/objtool/builtin-check.c +2 -1
@@ -19,7 +19,7 @@#include "objtool.h" bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, - validate_dup, vmlinux, sls, unret; + validate_dup, vmlinux, sls, unret, rethunk;static const char *const check_usage[] = {"objtool check [<options>] file.o" ,
@@ -30,6 +30,7 @@ const struct option check_options[] = {OPT_BOOLEAN ('f' ,"no-fp" , &no_fp,"Skip frame pointer validation" ),OPT_BOOLEAN ('u' ,"no-unreachable" , &no_unreachable,"Skip 'unreachable instruction' warnings" ),OPT_BOOLEAN ('r' ,"retpoline" , &retpoline,"Validate retpoline assumptions" ), +OPT_BOOLEAN (0 ,"rethunk" , &rethunk,"validate and annotate rethunk usage" ),OPT_BOOLEAN (0 ,"unret" , &unret,"validate entry unret placement" ),OPT_BOOLEAN ('m' ,"module" , &module,"Indicates the object will be part of a kernel module" ), OPT_BOOLEAN('b', "backtrace", &backtrace, "unwind on error"),
tools/objtool/builtin.h +1 -1
@@ -9,7 +9,7 @@extern const struct option check_options[];extern bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, - validate_dup, vmlinux, sls, unret; + validate_dup, vmlinux, sls, unret, rethunk;extern int cmd_check (int argc,const char **argv);extern int cmd_orc (int argc,const char **argv);
tools/objtool/check.c +7 -2
@@ -3262,8 +3262,11 @@ static int validate_retpoline(struct objcontinue ;if (insn->type ==INSN_RETURN ) { -WARN_FUNC ("'naked' return found in RETPOLINE build" , - insn->sec, insn->offset); +if (rethunk) { +WARN_FUNC ("'naked' return found in RETHUNK build" , + insn->sec, insn->offset); + }else +continue ; }else { WARN_FUNC("indirect %s found in RETPOLINE build", insn->sec, insn->offset,
@@ -3533,7 +3536,9 @@ int check(struct objtool_file *file)if (ret <0 ) goto out; warnings += ret; + } +if (rethunk) { ret =create_return_sites_sections (file);if (ret <0 ) goto out;
Greg Kroah-Hartman
maintainerPATCH 126/148 x86/bugs: Add Cannon lake to RETBleed affected CPU list
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit f54d45372c6ac9c993451de5e51312485f7d10bc upstream.
Cannon lake is also affected by RETBleed, add it to the list.
--- arch/x86/kernel/cpu/common.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/cpu/common.c +1 -0
@@ -1129,6 +1129,7 @@ static const struct x86_cpu_id cpu_vuln_VULNBL_INTEL_STEPPINGS (SKYLAKE ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (KABYLAKE_L ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ),VULNBL_INTEL_STEPPINGS (KABYLAKE ,X86_STEPPING_ANY ,SRBDS |MMIO |RETBLEED ), +VULNBL_INTEL_STEPPINGS (CANNONLAKE_L ,X86_STEPPING_ANY ,RETBLEED ),VULNBL_INTEL_STEPPINGS (ICELAKE_L ,X86_STEPPING_ANY ,MMIO |MMIO_SBDS |RETBLEED ),VULNBL_INTEL_STEPPINGS (ICELAKE_D ,X86_STEPPING_ANY ,MMIO ), VULNBL_INTEL_STEPPINGS(ICELAKE_X, X86_STEPPING_ANY, MMIO),
Greg Kroah-Hartman
maintainerPATCH 127/148 x86/bugs: Do not enable IBPB-on-entry when IBPB is not supported
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit 2259da159fbe5dba8ac00b560cf00b6a6537fa18 upstream.
There are some VM configurations which have Skylake model but do not support IBPB. In those cases, when using retbleed=ibpb, userspace is going to be killed and kernel is going to panic.
If the CPU does not support IBPB, warn and proceed with the auto option. Also, do not fallback to IBPB on AMD/Hygon systems if it is not supported.
--- arch/x86/kernel/cpu/bugs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -2
@@ -821,7 +821,10 @@ static void __init retbleed_select_mitigbreak ;case RETBLEED_CMD_IBPB : -if (IS_ENABLED (CONFIG_CPU_IBPB_ENTRY )) { +if (!boot_cpu_has (X86_FEATURE_IBPB )) { +pr_err ("WARNING: CPU does not support IBPB.\n" ); + goto do_cmd_auto; + }else if (IS_ENABLED (CONFIG_CPU_IBPB_ENTRY )) { retbleed_mitigation =RETBLEED_MITIGATION_IBPB ; }else {pr_err ("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n" );
@@ -836,7 +839,7 @@ do_cmd_auto: boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {if (IS_ENABLED (CONFIG_CPU_UNRET_ENTRY )) retbleed_mitigation =RETBLEED_MITIGATION_UNRET ; -else if (IS_ENABLED (CONFIG_CPU_IBPB_ENTRY )) +else if (IS_ENABLED (CONFIG_CPU_IBPB_ENTRY ) &&boot_cpu_has (X86_FEATURE_IBPB )) retbleed_mitigation =RETBLEED_MITIGATION_IBPB ; }
Greg Kroah-Hartman
maintainerPATCH 128/148 x86/kexec: Disable RET on kexec
In reply to Greg Kroah-HartmanFrom: Konrad Rzeszutek Wilk <[email protected]>
commit 697977d8415d61f3acbc4ee6d564c9dcf0309507 upstream.
All the invocations unroll to __x86_return_thunk and this file must be PIC independent.
This fixes kexec on 64-bit AMD boxes.
[ bp: Fix 32-bit build. ]
--- arch/x86/kernel/relocate_kernel_32.S | 25 +++++++++++++++++++------ arch/x86/kernel/relocate_kernel_64.S | 23 +++++++++++++++++------ 2 files changed, 36 insertions(+), 12 deletions(-)
arch/x86/kernel/relocate_kernel_32.S +19 -6
@@ -7,10 +7,12 @@ #include <linux/linkage.h> #include <asm/page_types.h> #include <asm/kexec.h> +#include <asm/nospec-branch.h> #include <asm/processor-flags.h> /* - * Must be relocatable PIC code callable as a C function + * Must be relocatable PIC code callable as a C function, in particular + * there must be a plain RET and not jump to return thunk. */ #define PTR(x) (x << 2)
@@ -91,7 +93,9 @@ SYM_CODE_START_NOALIGN(relocate_kernel) movl %edi, %eax addl $(identity_mapped - relocate_kernel), %eax pushl %eax - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(relocate_kernel) SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
@@ -159,12 +163,15 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_ma xorl %edx, %edx xorl %esi, %esi xorl %ebp, %ebp - RET + ANNOTATE_UNRET_SAFE + ret + int3 1: popl %edx movl CP_PA_SWAP_PAGE(%edi), %esp addl $PAGE_SIZE, %esp 2: + ANNOTATE_RETPOLINE_SAFE call *%edx /* get the re-entry point of the peer system */
@@ -190,7 +197,9 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_ma movl %edi, %eax addl $(virtual_mapped - relocate_kernel), %eax pushl %eax - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(identity_mapped) SYM_CODE_START_LOCAL_NOALIGN(virtual_mapped)
@@ -208,7 +217,9 @@ SYM_CODE_START_LOCAL_NOALIGN(virtual_map popl %edi popl %esi popl %ebx - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(virtual_mapped) /* Do the copies */
@@ -271,7 +282,9 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) popl %edi popl %ebx popl %ebp - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(swap_pages) .globl kexec_control_code_size
arch/x86/kernel/relocate_kernel_64.S +17 -6
@@ -13,7 +13,8 @@ #include <asm/unwind_hints.h> /* - * Must be relocatable PIC code callable as a C function + * Must be relocatable PIC code callable as a C function, in particular + * there must be a plain RET and not jump to return thunk. */ #define PTR(x) (x << 3)
@@ -104,7 +105,9 @@ SYM_CODE_START_NOALIGN(relocate_kernel) /* jump to identity mapped page */ addq $(identity_mapped - relocate_kernel), %r8 pushq %r8 - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(relocate_kernel) SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
@@ -191,7 +194,9 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_ma xorl %r14d, %r14d xorl %r15d, %r15d - RET + ANNOTATE_UNRET_SAFE + ret + int3 1: popq %rdx
@@ -210,7 +215,9 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_ma call swap_pages movq $virtual_mapped, %rax pushq %rax - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(identity_mapped) SYM_CODE_START_LOCAL_NOALIGN(virtual_mapped)
@@ -231,7 +238,9 @@ SYM_CODE_START_LOCAL_NOALIGN(virtual_map popq %r12 popq %rbp popq %rbx - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(virtual_mapped) /* Do the copies */
@@ -288,7 +297,9 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) lea PAGE_SIZE(%rax), %rsi jmp 0b 3: - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(swap_pages) .globl kexec_control_code_size
Greg Kroah-Hartman
maintainerPATCH 129/148 x86/speculation: Disable RRSBA behavior
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 4ad3278df6fe2b0852b00d5757fc2ccd8e92c26e upstream.
Some Intel processors may use alternate predictors for RETs on RSB-underflow. This condition may be vulnerable to Branch History Injection (BHI) and intramode-BTI.
Kernel earlier added spectre_v2 mitigation modes (eIBRS+Retpolines, eIBRS+LFENCE, Retpolines) which protect indirect CALLs and JMPs against such attacks. However, on RSB-underflow, RET target prediction may fallback to alternate predictors. As a result, RET's predicted target may get influenced by branch history.
A new MSR_IA32_SPEC_CTRL bit (RRSBA_DIS_S) controls this fallback behavior when in kernel mode. When set, RETs will not take predictions from alternate predictors, hence mitigating RETs as well. Support for this is enumerated by CPUID.7.2.EDX[RRSBA_CTRL] (bit2).
For spectre v2 mitigation, when a user selects a mitigation that protects indirect CALLs and JMPs against BHI and intramode-BTI, set RRSBA_DIS_S also to protect RETs for RSB-underflow case.
--- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/include/asm/msr-index.h | 9 +++++++++ arch/x86/kernel/cpu/bugs.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/scattered.c | 1 + tools/arch/x86/include/asm/msr-index.h | 9 +++++++++ 5 files changed, 46 insertions(+), 1 deletion(-)
arch/x86/include/asm/cpufeatures.h +1 -1
@@ -293,7 +293,7 @@/* FREE! (11*32+ 8) */ /* FREE! (11*32+ 9) */ #define X86_FEATURE_ENTRY_IBPB (11*32+10)/* "" Issue an IBPB on kernel entry */ -/* FREE! (11*32+11) */ +#define X86_FEATURE_RRSBA_CTRL (11*32+11)/* "" RET prediction control */ #define X86_FEATURE_RETPOLINE (11*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ #define X86_FEATURE_RETPOLINE_LFENCE (11*32+13)/* "" Use LFENCE for Spectre variant 2 */ #define X86_FEATURE_RETHUNK (11*32+14)/* "" Use REturn THUNK */
arch/x86/include/asm/msr-index.h +9 -0
@@ -51,6 +51,8 @@#define SPEC_CTRL_STIBP BIT(SPEC_CTRL_STIBP_SHIFT)/* STIBP mask */ #define SPEC_CTRL_SSBD_SHIFT 2/* Speculative Store Bypass Disable bit */ #define SPEC_CTRL_SSBD BIT(SPEC_CTRL_SSBD_SHIFT)/* Speculative Store Bypass Disable */ +#define SPEC_CTRL_RRSBA_DIS_S_SHIFT 6/* Disable RRSBA behavior */ +#define SPEC_CTRL_RRSBA_DIS_S BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT)#define MSR_IA32_PRED_CMD 0x00000049/* Prediction Command */ #define PRED_CMD_IBPB BIT(0)/* Indirect Branch Prediction Barrier */
@@ -139,6 +141,13 @@* bit available to control VERW * behavior. */ +#define ARCH_CAP_RRSBA BIT(19)/* +* Indicates RET may use predictors +* other than the RSB. With eIBRS +* enabled predictions in kernel mode +* are restricted to targets in +* kernel. +*/ #define MSR_IA32_FLUSH_CMD 0x0000010b#define L1D_FLUSH BIT(0)/*
arch/x86/kernel/cpu/bugs.c +26 -0
@@ -1274,6 +1274,22 @@ static enum spectre_v2_mitigation __initreturn SPECTRE_V2_RETPOLINE ; } +/* Disable in-kernel use of non-RSB RET predictors */ +static void __init spec_ctrl_disable_kernel_rrsba (void ) +{ +u64 ia32_cap; + +if (!boot_cpu_has (X86_FEATURE_RRSBA_CTRL )) +return ; + + ia32_cap =x86_read_arch_cap_msr (); + +if (ia32_cap &ARCH_CAP_RRSBA ) { + x86_spec_ctrl_base |=SPEC_CTRL_RRSBA_DIS_S ; +write_spec_ctrl_current (x86_spec_ctrl_base, true); + } +} +static void __init spectre_v2_select_mitigation (void ) {enum spectre_v2_mitigation_cmd cmd =spectre_v2_parse_cmdline ();
@@ -1368,6 +1384,16 @@ static void __init spectre_v2_select_mitbreak ; } +/* +* Disable alternate RSB predictions in kernel when indirect CALLs and +* JMPs gets protection against BHI and Intramode-BTI, but RET +* prediction from a non-RSB predictor is still a risk. +*/ +if (mode ==SPECTRE_V2_EIBRS_LFENCE || + mode ==SPECTRE_V2_EIBRS_RETPOLINE || + mode ==SPECTRE_V2_RETPOLINE ) +spec_ctrl_disable_kernel_rrsba (); + spectre_v2_enabled = mode;pr_info ("%s\n" , spectre_v2_strings[mode]);
arch/x86/kernel/cpu/scattered.c +1 -0
@@ -26,6 +26,7 @@ struct cpuid_bit {static const struct cpuid_bit cpuid_bits[] = { {X86_FEATURE_APERFMPERF ,CPUID_ECX ,0 ,0x00000006 ,0 }, {X86_FEATURE_EPB ,CPUID_ECX ,3 ,0x00000006 ,0 }, + {X86_FEATURE_RRSBA_CTRL ,CPUID_EDX ,2 ,0x00000007 ,2 }, {X86_FEATURE_CQM_LLC ,CPUID_EDX ,1 ,0x0000000f ,0 }, {X86_FEATURE_CQM_OCCUP_LLC ,CPUID_EDX ,0 ,0x0000000f ,1 }, {X86_FEATURE_CQM_MBM_TOTAL ,CPUID_EDX ,1 ,0x0000000f ,1 },
tools/arch/x86/include/asm/msr-index.h +9 -0
@@ -51,6 +51,8 @@#define SPEC_CTRL_STIBP BIT(SPEC_CTRL_STIBP_SHIFT)/* STIBP mask */ #define SPEC_CTRL_SSBD_SHIFT 2/* Speculative Store Bypass Disable bit */ #define SPEC_CTRL_SSBD BIT(SPEC_CTRL_SSBD_SHIFT)/* Speculative Store Bypass Disable */ +#define SPEC_CTRL_RRSBA_DIS_S_SHIFT 6/* Disable RRSBA behavior */ +#define SPEC_CTRL_RRSBA_DIS_S BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT)#define MSR_IA32_PRED_CMD 0x00000049/* Prediction Command */ #define PRED_CMD_IBPB BIT(0)/* Indirect Branch Prediction Barrier */
@@ -138,6 +140,13 @@* bit available to control VERW * behavior. */ +#define ARCH_CAP_RRSBA BIT(19)/* +* Indicates RET may use predictors +* other than the RSB. With eIBRS +* enabled predictions in kernel mode +* are restricted to targets in +* kernel. +*/ #define MSR_IA32_FLUSH_CMD 0x0000010b#define L1D_FLUSH BIT(0)/*
Greg Kroah-Hartman
maintainerPATCH 130/148 x86/static_call: Serialize __static_call_fixup() properly
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit c27c753ea6fd1237f4f96abf8b623d7bab505513 upstream.
__static_call_fixup() invokes __static_call_transform() without holding text_mutex, which causes lockdep to complain in text_poke_bp().
Adding the proper locking cures that, but as this is either used during early boot or during module finalizing, it's not required to use text_poke_bp(). Add an argument to __static_call_transform() which tells it to use text_poke_early() for it.
--- arch/x86/kernel/static_call.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/x86/kernel/static_call.c +8 -5
@@ -20,7 +20,8 @@ static const u8 tramp_ud[] = { 0x0f, 0xbstatic const u8 retinsn[] = {RET_INSN_OPCODE ,0xcc ,0xcc ,0xcc ,0xcc }; -static void __ref __static_call_transform (void *insn,enum insn_type type,void *func) +static void __ref __static_call_transform (void *insn,enum insn_type type, +void *func,bool modinit) {int size =CALL_INSN_SIZE ;const void *code;
@@ -49,7 +50,7 @@ static void __ref __static_call_transforif (memcmp (insn, code, size) ==0 )return ; -if (unlikely (system_state ==SYSTEM_BOOTING )) +if (system_state ==SYSTEM_BOOTING || modinit)return text_poke_early (insn, code, size);text_poke_bp (insn, code, size,NULL );
@@ -96,12 +97,12 @@ void arch_static_call_transform(void *siif (tramp) {__static_call_validate (tramp, true); -__static_call_transform (tramp,__sc_insn (!func, true), func); +__static_call_transform (tramp,__sc_insn (!func, true), func, false); }if (IS_ENABLED (CONFIG_HAVE_STATIC_CALL_INLINE ) && site) {__static_call_validate (site, tail); -__static_call_transform (site,__sc_insn (!func, tail), func); +__static_call_transform (site,__sc_insn (!func, tail), func, false); }mutex_unlock (&text_mutex);
@@ -127,8 +128,10 @@ bool __static_call_fixup(void *tramp, u8return false; } +mutex_lock (&text_mutex);if (op ==RET_INSN_OPCODE || dest == &__x86_return_thunk) -__static_call_transform (tramp,RET ,NULL ); +__static_call_transform (tramp,RET ,NULL , true); +mutex_unlock (&text_mutex);return true; }
Greg Kroah-Hartman
maintainerPATCH 131/148 tools/insn: Restore the relative include paths for cross building
In reply to Greg Kroah-HartmanFrom: Borislav Petkov <[email protected]>
commit 0705ef64d1ff52b817e278ca6e28095585ff31e1 upstream.
Building perf on ppc causes:
In file included from util/intel-pt-decoder/intel-pt-insn-decoder.c:15:
util/intel-pt-decoder/../../../arch/x86/lib/insn.c:14:10: fatal error: asm/inat.h: No such file or directory
14 | #include <asm/inat.h> /*__ignore_sync_check__ */
| ^~~~~~~~~~~~Restore the relative include paths so that the compiler can find the headers.
--- tools/arch/x86/lib/insn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/arch/x86/lib/insn.c +3 -3
@@ -10,13 +10,13 @@#else #include <string.h> #endif -#include <asm/inat.h> /* __ignore_sync_check__ */ -#include <asm/insn.h> /* __ignore_sync_check__ */ +#include "../include/asm/inat.h" /* __ignore_sync_check__ */ +#include "../include/asm/insn.h" /* __ignore_sync_check__ */ #include <linux/errno.h> #include <linux/kconfig.h> -#include <asm/emulate_prefix.h> /* __ignore_sync_check__ */ +#include "../include/asm/emulate_prefix.h" /* __ignore_sync_check__ */ /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next (t, insn, n) \
Greg Kroah-Hartman
maintainerPATCH 132/148 x86, kvm: use proper ASM macros for kvm_vcpu_is_preempted
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
commit edbaf6e5e93acda96aae23ba134ef3c1466da3b5 upstream.
The build rightfully complains about:
arch/x86/kernel/kvm.o: warning: objtool: __raw_callee_save___kvm_vcpu_is_preempted()+0x12: missing int3 after ret
because the ASM_RET call is not being used correctly in kvm_vcpu_is_preempted().
This was hand-fixed-up in the kvm merge commit a4cfff3f0f8c ("Merge branch 'kvm-older-features' into HEAD") which of course can not be backported to stable kernels, so just fix this up directly instead.
--- arch/x86/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kvm.c +1 -1
@@ -953,7 +953,7 @@ asm("movq __per_cpu_offset(,%rdi,8), %rax;" "cmpb $0, " __stringify(KVM_STEAL_TIME_preempted) "+steal_time(%rax);""setne %al;" -"ret;" +ASM_RET ".size __raw_callee_save___kvm_vcpu_is_preempted, .-__raw_callee_save___kvm_vcpu_is_preempted;" ".popsection");
Greg Kroah-Hartman
maintainerPATCH 133/148 x86/xen: Fix initialisation in hypercall_page after rethunk
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
The hypercall_page is special and the RETs there should not be changed into rethunk calls (but can have SLS mitigation). Change the initial instructions to ret + int3 padding, as was done in upstream commit 5b2fc51576ef "x86/ibt,xen: Sprinkle the ENDBR".
--- arch/x86/xen/xen-head.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/xen/xen-head.S +2 -2
@@ -69,9 +69,9 @@ SYM_CODE_END(asm_cpu_bringup_and_idle) SYM_CODE_START(hypercall_page) .rept (PAGE_SIZE / 32) UNWIND_HINT_FUNC - .skip 31, 0x90 ANNOTATE_UNRET_SAFE - RET + ret + .skip 31, 0xcc .endr #define HYPERCALL(n) \
Greg Kroah-Hartman
maintainerPATCH 134/148 x86/ftrace: Add UNWIND_HINT_FUNC annotation for ftrace_stub
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 18660698a3d30868524cefb60dcd4e0e297f71bb upstream.
Prevent an unreachable objtool warning after the sibling call detection gets improved. ftrace_stub() is basically a function, annotate it as such.
--- arch/x86/kernel/ftrace_64.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/ftrace_64.S +1 -0
@@ -173,6 +173,7 @@ SYM_INNER_LABEL(ftrace_graph_call, SYM_L * It is also used to copy the RET for trampolines. */ SYM_INNER_LABEL_ALIGN(ftrace_stub, SYM_L_WEAK) + UNWIND_HINT_FUNC RET SYM_FUNC_END(ftrace_epilogue)
Greg Kroah-Hartman
maintainerPATCH 135/148 x86/asm/32: Fix ANNOTATE_UNRET_SAFE use on 32-bit
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit 3131ef39fb03bbde237d0b8260445898f3dfda5b upstream.
The build on x86_32 currently fails after commit
9bb2ec608a20 (objtool: Update Retpoline validation)
with:
arch/x86/kernel/../../x86/xen/xen-head.S:35: Error: no such instruction: `annotate_unret_safe'
ANNOTATE_UNRET_SAFE is defined in nospec-branch.h. And head_32.S is missing this include. Fix this.
--- arch/x86/kernel/head_32.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/head_32.S +1 -0
@@ -23,6 +23,7 @@ #include <asm/cpufeatures.h> #include <asm/percpu.h> #include <asm/nops.h> +#include <asm/nospec-branch.h> #include <asm/bootparam.h> #include <asm/export.h> #include <asm/pgtable_32.h>
Greg Kroah-Hartman
maintainerPATCH 136/148 x86/speculation: Use DECLARE_PER_CPU for x86_spec_ctrl_current
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit db886979683a8360ced9b24ab1125ad0c4d2cf76 upstream.
Clang warns:
arch/x86/kernel/cpu/bugs.c:58:21: error: section attribute is specified on redeclared variable [-Werror,-Wsection]
DEFINE_PER_CPU(u64, x86_spec_ctrl_current);
^
arch/x86/include/asm/nospec-branch.h:283:12: note: previous declaration is here
extern u64 x86_spec_ctrl_current;
^1 error generated.
The declaration should be using DECLARE_PER_CPU instead so all attributes stay in sync.
--- arch/x86/include/asm/nospec-branch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/nospec-branch.h +2 -1
@@ -11,6 +11,7 @@#include <asm/cpufeatures.h> #include <asm/msr-index.h> #include <asm/unwind_hints.h> +#include <asm/percpu.h> #define RETPOLINE_THUNK_SIZE 32
@@ -281,7 +282,7 @@ static inline void indirect_branch_predi/* The Intel SPEC CTRL MSR base value cache */ extern u64 x86_spec_ctrl_base; -extern u64 x86_spec_ctrl_current; +DECLARE_PER_CPU (u64, x86_spec_ctrl_current);extern void write_spec_ctrl_current (u64 val,bool force);extern u64 spec_ctrl_current (void );
Greg Kroah-Hartman
maintainerPATCH 137/148 efi/x86: use naked RET on mixed mode call wrapper
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit 51a6fa0732d6be6a44e0032752ad2ac10d67c796 upstream.
When running with return thunks enabled under 32-bit EFI, the system crashes with:
kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
BUG: unable to handle page fault for address: 000000005bc02900 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0011) - permissions violation PGD 18f7063 P4D 18f7063 PUD 18ff063 PMD 190e063 PTE 800000005bc02063 Oops: 0011 [#1] PREEMPT SMP PTI CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.19.0-rc6+ #166 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:0x5bc02900 Code: Unable to access opcode bytes at RIP 0x5bc028d6. RSP: 0018:ffffffffb3203e10 EFLAGS: 00010046 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000048 RDX: 000000000190dfac RSI: 0000000000001710 RDI: 000000007eae823b RBP: ffffffffb3203e70 R08: 0000000001970000 R09: ffffffffb3203e28 R10: 747563657865206c R11: 6c6977203a696665 R12: 0000000000001710 R13: 0000000000000030 R14: 0000000001970000 R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff8e013ca00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0018 ES: 0018 CR0: 0000000080050033 CR2: 000000005bc02900 CR3: 0000000001930000 CR4: 00000000000006f0 Call Trace: ? efi_set_virtual_address_map+0x9c/0x175 efi_enter_virtual_mode+0x4a6/0x53e start_kernel+0x67c/0x71e x86_64_start_reservations+0x24/0x2a x86_64_start_kernel+0xe9/0xf4 secondary_startup_64_no_verify+0xe5/0xeb
That's because it cannot jump to the return thunk from the 32-bit code.
Using a naked RET and marking it as safe allows the system to proceed booting.
--- arch/x86/platform/efi/efi_thunk_64.S | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/platform/efi/efi_thunk_64.S +4 -1
@@ -22,6 +22,7 @@ #include <linux/linkage.h> #include <asm/page_types.h> #include <asm/segment.h> +#include <asm/nospec-branch.h> .text .code64
@@ -63,7 +64,9 @@ SYM_CODE_START(__efi64_thunk) 1: movq 24(%rsp), %rsp pop %rbx pop %rbp - RET + ANNOTATE_UNRET_SAFE + ret + int3 .code32 2: pushl $__KERNEL_CS
Greg Kroah-Hartman
maintainerPATCH 138/148 x86/kvm: fix FASTOP_SIZE when return thunks are enabled
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit 84e7051c0bc1f2a13101553959b3a9d9a8e24939 upstream.
The return thunk call makes the fastop functions larger, just like IBT does. Consider a 16-byte FASTOP_SIZE when CONFIG_RETHUNK is enabled.
Otherwise, functions will be incorrectly aligned and when computing their position for differently sized operators, they will executed in the middle or end of a function, which may as well be an int3, leading to a crash like:
[ 36.091116] int3: 0000 [#1] SMP NOPTI [ 36.091119] CPU: 3 PID: 1371 Comm: qemu-system-x86 Not tainted 5.15.0-41-generic #44 [ 36.091120] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 [ 36.091121] RIP: 0010:xaddw_ax_dx+0x9/0x10 [kvm] [ 36.091185] Code: 00 0f bb d0 c3 cc cc cc cc 48 0f bb d0 c3 cc cc cc cc 0f 1f 80 00 00 00 00 0f c0 d0 c3 cc cc cc cc 66 0f c1 d0 c3 cc cc cc cc <0f> 1f 80 00 00 00 00 0f c1 d0 c3 cc cc cc cc 48 0f c1 d0 c3 cc cc [ 36.091186] RSP: 0018:ffffb1f541143c98 EFLAGS: 00000202 [ 36.091188] RAX: 0000000089abcdef RBX: 0000000000000001 RCX: 0000000000000000 [ 36.091188] RDX: 0000000076543210 RSI: ffffffffc073c6d0 RDI: 0000000000000200 [ 36.091189] RBP: ffffb1f541143ca0 R08: ffff9f1803350a70 R09: 0000000000000002 [ 36.091190] R10: ffff9f1803350a70 R11: 0000000000000000 R12: ffff9f1803350a70 [ 36.091190] R13: ffffffffc077fee0 R14: 0000000000000000 R15: 0000000000000000 [ 36.091191] FS: 00007efdfce8d640(0000) GS:ffff9f187dd80000(0000) knlGS:0000000000000000 [ 36.091192] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.091192] CR2: 0000000000000000 CR3: 0000000009b62002 CR4: 0000000000772ee0 [ 36.091195] PKRU: 55555554 [ 36.091195] Call Trace: [ 36.091197] <TASK> [ 36.091198] ? fastop+0x5a/0xa0 [kvm] [ 36.091222] x86_emulate_insn+0x7b8/0xe90 [kvm] [ 36.091244] x86_emulate_instruction+0x2f4/0x630 [kvm] [ 36.091263] ? kvm_arch_vcpu_load+0x7c/0x230 [kvm] [ 36.091283] ? vmx_prepare_switch_to_host+0xf7/0x190 [kvm_intel] [ 36.091290] complete_emulated_mmio+0x297/0x320 [kvm] [ 36.091310] kvm_arch_vcpu_ioctl_run+0x32f/0x550 [kvm] [ 36.091330] kvm_vcpu_ioctl+0x29e/0x6d0 [kvm] [ 36.091344] ? kvm_vcpu_ioctl+0x120/0x6d0 [kvm] [ 36.091357] ? __fget_files+0x86/0xc0 [ 36.091362] ? __fget_files+0x86/0xc0 [ 36.091363] __x64_sys_ioctl+0x92/0xd0 [ 36.091366] do_syscall_64+0x59/0xc0 [ 36.091369] ? syscall_exit_to_user_mode+0x27/0x50 [ 36.091370] ? do_syscall_64+0x69/0xc0 [ 36.091371] ? syscall_exit_to_user_mode+0x27/0x50 [ 36.091372] ? __x64_sys_writev+0x1c/0x30 [ 36.091374] ? do_syscall_64+0x69/0xc0 [ 36.091374] ? exit_to_user_mode_prepare+0x37/0xb0 [ 36.091378] ? syscall_exit_to_user_mode+0x27/0x50 [ 36.091379] ? do_syscall_64+0x69/0xc0 [ 36.091379] ? do_syscall_64+0x69/0xc0 [ 36.091380] ? do_syscall_64+0x69/0xc0 [ 36.091381] ? do_syscall_64+0x69/0xc0 [ 36.091381] entry_SYSCALL_64_after_hwframe+0x61/0xcb [ 36.091384] RIP: 0033:0x7efdfe6d1aff [ 36.091390] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00 [ 36.091391] RSP: 002b:00007efdfce8c460 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 36.091393] RAX: ffffffffffffffda RBX: 000000000000ae80 RCX: 00007efdfe6d1aff [ 36.091393] RDX: 0000000000000000 RSI: 000000000000ae80 RDI: 000000000000000c [ 36.091394] RBP: 0000558f1609e220 R08: 0000558f13fb8190 R09: 00000000ffffffff [ 36.091394] R10: 0000558f16b5e950 R11: 0000000000000246 R12: 0000000000000000 [ 36.091394] R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000000 [ 36.091396] </TASK> [ 36.091397] Modules linked in: isofs nls_iso8859_1 kvm_intel joydev kvm input_leds serio_raw sch_fq_codel dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua ipmi_devintf ipmi_msghandler drm msr ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel virtio_net net_failover crypto_simd ahci xhci_pci cryptd psmouse virtio_blk libahci xhci_pci_renesas failover [ 36.123271] ---[ end trace db3c0ab5a48fabcc ]--- [ 36.123272] RIP: 0010:xaddw_ax_dx+0x9/0x10 [kvm] [ 36.123319] Code: 00 0f bb d0 c3 cc cc cc cc 48 0f bb d0 c3 cc cc cc cc 0f 1f 80 00 00 00 00 0f c0 d0 c3 cc cc cc cc 66 0f c1 d0 c3 cc cc cc cc <0f> 1f 80 00 00 00 00 0f c1 d0 c3 cc cc cc cc 48 0f c1 d0 c3 cc cc [ 36.123320] RSP: 0018:ffffb1f541143c98 EFLAGS: 00000202 [ 36.123321] RAX: 0000000089abcdef RBX: 0000000000000001 RCX: 0000000000000000 [ 36.123321] RDX: 0000000076543210 RSI: ffffffffc073c6d0 RDI: 0000000000000200 [ 36.123322] RBP: ffffb1f541143ca0 R08: ffff9f1803350a70 R09: 0000000000000002 [ 36.123322] R10: ffff9f1803350a70 R11: 0000000000000000 R12: ffff9f1803350a70 [ 36.123323] R13: ffffffffc077fee0 R14: 0000000000000000 R15: 0000000000000000 [ 36.123323] FS: 00007efdfce8d640(0000) GS:ffff9f187dd80000(0000) knlGS:0000000000000000 [ 36.123324] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.123325] CR2: 0000000000000000 CR3: 0000000009b62002 CR4: 0000000000772ee0 [ 36.123327] PKRU: 55555554 [ 36.123328] Kernel panic - not syncing: Fatal exception in interrupt [ 36.123410] Kernel Offset: 0x1400000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) [ 36.135305] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
Message-Id: <[email protected]>
--- arch/x86/kvm/emulate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kvm/emulate.c +6 -4
@@ -188,8 +188,12 @@ #define X8(x...) X4(x), X4(x) #define X16(x...) X8(x), X8(x) -#define NR_FASTOP (ilog2(sizeof(ulong)) + 1) -#define FASTOP_SIZE 8 +#define NR_FASTOP (ilog2(sizeof(ulong)) + 1) +#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETHUNK)) + \ + IS_ENABLED(CONFIG_SLS)) +#define FASTOP_LENGTH (ENDBR_INSN_SIZE + 7 + RET_LENGTH) +#define FASTOP_SIZE (8 << ((FASTOP_LENGTH > 8) & 1) << ((FASTOP_LENGTH > 16) & 1)) +static_assert (FASTOP_LENGTH <=FASTOP_SIZE );struct opcode {u64 flags :56 ;
@@ -438,8 +442,6 @@ static int fastop(struct x86_emulate_ctx* RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETHUNK] * INT3 [1 byte; CONFIG_SLS] */ -#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETHUNK)) + \ - IS_ENABLED(CONFIG_SLS))#define SETCC_LENGTH (3 + RET_LENGTH)#define SETCC_ALIGN (4 << ((SETCC_LENGTH > 4) & 1) << ((SETCC_LENGTH > 8) & 1))static_assert (SETCC_LENGTH <=SETCC_ALIGN );
Greg Kroah-Hartman
maintainerPATCH 139/148 KVM: emulate: do not adjust size of fastop and setcc subroutines
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 79629181607e801c0b41b8790ac4ee2eb5d7bc3e upstream.
Instead of doing complicated calculations to find the size of the subroutines (which are even more complicated because they need to be stringified into an asm statement), just hardcode to 16.
It is less dense for a few combinations of IBT/SLS/retbleed, but it has the advantage of being really simple.
--- arch/x86/kvm/emulate.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/x86/kvm/emulate.c +7 -10
@@ -188,13 +188,6 @@ #define X8(x...) X4(x), X4(x) #define X16(x...) X8(x), X8(x) -#define NR_FASTOP (ilog2(sizeof(ulong)) + 1) -#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETHUNK)) + \ - IS_ENABLED(CONFIG_SLS)) -#define FASTOP_LENGTH (ENDBR_INSN_SIZE + 7 + RET_LENGTH) -#define FASTOP_SIZE (8 << ((FASTOP_LENGTH > 8) & 1) << ((FASTOP_LENGTH > 16) & 1)) -static_assert (FASTOP_LENGTH <=FASTOP_SIZE ); -struct opcode {u64 flags :56 ;u64 intercept :8 ;
@@ -308,9 +301,15 @@ static void invalidate_registers(struct* Moreover, they are all exactly FASTOP_SIZE bytes long, so functions for * different operand sizes can be reached by calculation, rather than a jump * table (which would be bigger than the code). +* +* The 16 byte alignment, considering 5 bytes for the RET thunk, 3 for ENDBR +* and 1 for the straight line speculation INT3, leaves 7 bytes for the +* body of the function. Currently none is larger than 4. */ static int fastop (struct x86_emulate_ctxt *ctxt,fastop_t fop); +#define FASTOP_SIZE 16 +#define __FOP_FUNC (name) \ ".align " __stringify(FASTOP_SIZE) " \n\t" \ ".type " name ", @function \n\t" \
@@ -442,9 +441,7 @@ static int fastop(struct x86_emulate_ctx* RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETHUNK] * INT3 [1 byte; CONFIG_SLS] */ -#define SETCC_LENGTH (3 + RET_LENGTH) -#define SETCC_ALIGN (4 << ((SETCC_LENGTH > 4) & 1) << ((SETCC_LENGTH > 8) & 1)) -static_assert (SETCC_LENGTH <=SETCC_ALIGN ); +#define SETCC_ALIGN 16#define FOP_SETCC (op) \ ".align " __stringify(SETCC_ALIGN) " \n\t" \
Greg Kroah-Hartman
maintainerPATCH 140/148 tools arch x86: Sync the msr-index.h copy with the kernel sources
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit 91d248c3b903b46a58cbc7e8d38d684d3e4007c2 upstream.
To pick up the changes from these csets:
4ad3278df6fe2b08 ("x86/speculation: Disable RRSBA behavior") d7caac991feeef1b ("x86/cpu/amd: Add Spectral Chicken")
That cause no changes to tooling:
$ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after $ diff -u before after $
Just silences this perf build warning:
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h' diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
--- tools/arch/x86/include/asm/msr-index.h | 4 ++++ 1 file changed, 4 insertions(+)
tools/arch/x86/include/asm/msr-index.h +4 -0
@@ -93,6 +93,7 @@#define MSR_IA32_ARCH_CAPABILITIES 0x0000010a#define ARCH_CAP_RDCL_NO BIT(0)/* Not susceptible to Meltdown */ #define ARCH_CAP_IBRS_ALL BIT(1)/* Enhanced IBRS support */ +#define ARCH_CAP_RSBA BIT(2)/* RET may use alternative branch predictors */ #define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH BIT(3)/* Skip L1D flush on vmentry */ #define ARCH_CAP_SSB_NO BIT(4)/* * Not susceptible to Speculative Store Bypass
@@ -516,6 +517,9 @@/* Fam 17h MSRs */ #define MSR_F17H_IRPERF 0xc00000e9 +#define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3 +#define MSR_ZEN2_SPECTRAL_CHICKEN_BIT BIT_ULL(1) +/* Fam 16h MSRs */ #define MSR_F16H_L2I_PERF_CTL 0xc0010230#define MSR_F16H_L2I_PERF_CTR 0xc0010231
Greg Kroah-Hartman
maintainerPATCH 141/148 tools headers cpufeatures: Sync with the kernel sources
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit f098addbdb44c8a565367f5162f3ab170ed9404a upstream.
To pick the changes from:
f43b9876e857c739 ("x86/retbleed: Add fine grained Kconfig knobs") a149180fbcf336e9 ("x86: Add magic AMD return-thunk") 15e67227c49a5783 ("x86: Undo return-thunk damage") 369ae6ffc41a3c11 ("x86/retpoline: Cleanup some #ifdefery") 4ad3278df6fe2b08 x86/speculation: Disable RRSBA behavior 26aae8ccbc197223 x86/cpu/amd: Enumerate BTC_NO
9756bba28470722d x86/speculation: Fill RSB on vmexit for IBRS 3ebc170068885b6f x86/bugs: Add retbleed=ibpb
2dbb887e875b1de3 x86/entry: Add kernel IBRS implementation 6b80b59b35557065 x86/bugs: Report AMD retbleed vulnerability a149180fbcf336e9 x86: Add magic AMD return-thunk
15e67227c49a5783 x86: Undo return-thunk damage
a883d624aed463c8 x86/cpufeatures: Move RETPOLINE flags to word 11 51802186158c74a0 x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug
This only causes these perf files to be rebuilt:
CC /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
CC /tmp/build/perf/bench/mem-memset-x86-64-asm.o
And addresses this perf build warning:
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h' diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/disabled-features.h' differs from latest version at 'arch/x86/include/asm/disabled-features.h' diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h
--- tools/arch/x86/include/asm/cpufeatures.h | 12 ++++++++++-- tools/arch/x86/include/asm/disabled-features.h | 21 ++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-)
tools/arch/x86/include/asm/cpufeatures.h +10 -2
@@ -203,8 +203,8 @@#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ #define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ -#define X86_FEATURE_RETPOLINE ( 7*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ -#define X86_FEATURE_RETPOLINE_LFENCE ( 7*32+13)/* "" Use LFENCEs for Spectre variant 2 */ +#define X86_FEATURE_KERNEL_IBRS ( 7*32+12)/* "" Set/clear IBRS on kernel entry/exit */ +#define X86_FEATURE_RSB_VMEXIT ( 7*32+13)/* "" Fill RSB on VM-Exit */ #define X86_FEATURE_INTEL_PPIN ( 7*32+14)/* Intel Processor Inventory Number */ #define X86_FEATURE_CDP_L2 ( 7*32+15)/* Code and Data Prioritization L2 */ #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16)/* "" MSR SPEC_CTRL is implemented */
@@ -290,6 +290,12 @@#define X86_FEATURE_FENCE_SWAPGS_KERNEL (11*32+ 5)/* "" LFENCE in kernel entry SWAPGS path */ #define X86_FEATURE_SPLIT_LOCK_DETECT (11*32+ 6)/* #AC for split lock */ #define X86_FEATURE_PER_THREAD_MBA (11*32+ 7)/* "" Per-thread Memory Bandwidth Allocation */ +#define X86_FEATURE_ENTRY_IBPB (11*32+10)/* "" Issue an IBPB on kernel entry */ +#define X86_FEATURE_RRSBA_CTRL (11*32+11)/* "" RET prediction control */ +#define X86_FEATURE_RETPOLINE (11*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE_LFENCE (11*32+13)/* "" Use LFENCE for Spectre variant 2 */ +#define X86_FEATURE_RETHUNK (11*32+14)/* "" Use REturn THUNK */ +#define X86_FEATURE_UNRET (11*32+15)/* "" AMD BTB untrain return */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5)/* AVX512 BFLOAT16 instructions */
@@ -308,6 +314,7 @@#define X86_FEATURE_AMD_SSBD (13*32+24)/* "" Speculative Store Bypass Disable */ #define X86_FEATURE_VIRT_SSBD (13*32+25)/* Virtualized Speculative Store Bypass Disable */ #define X86_FEATURE_AMD_SSB_NO (13*32+26)/* "" Speculative Store Bypass is fixed in hardware. */ +#define X86_FEATURE_BTC_NO (13*32+29)/* "" Not vulnerable to Branch Type Confusion */ /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ #define X86_FEATURE_DTHERM (14*32+ 0)/* Digital Thermal Sensor */
@@ -418,5 +425,6 @@#define X86_BUG_ITLB_MULTIHIT X86_BUG(23)/* CPU may incur MCE during certain page attribute changes */ #define X86_BUG_SRBDS X86_BUG(24)/* CPU may leak RNG bits if not mitigated */ #define X86_BUG_MMIO_STALE_DATA X86_BUG(25)/* CPU is affected by Processor MMIO Stale Data vulnerabilities */ +#define X86_BUG_RETBLEED X86_BUG(26)/* CPU is affected by RETBleed */ #endif /* _ASM_X86_CPUFEATURES_H */
tools/arch/x86/include/asm/disabled-features.h +20 -1
@@ -56,6 +56,25 @@# define DISABLE_PTI (1 << (X86_FEATURE_PTI & 31))#endif +#ifdef CONFIG_RETPOLINE +# define DISABLE_RETPOLINE 0 +#else +# define DISABLE_RETPOLINE ((1 << (X86_FEATURE_RETPOLINE & 31)) | \ + (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31))) +#endif + +#ifdef CONFIG_RETHUNK +# define DISABLE_RETHUNK 0 +#else +# define DISABLE_RETHUNK (1 << (X86_FEATURE_RETHUNK & 31)) +#endif + +#ifdef CONFIG_CPU_UNRET_ENTRY +# define DISABLE_UNRET 0 +#else +# define DISABLE_UNRET (1 << (X86_FEATURE_UNRET & 31)) +#endif +#ifdef CONFIG_IOMMU_SUPPORT # define DISABLE_ENQCMD 0#else
@@ -76,7 +95,7 @@#define DISABLED_MASK8 0#define DISABLED_MASK9 (DISABLE_SMAP)#define DISABLED_MASK10 0 -#define DISABLED_MASK11 0 +#define DISABLED_MASK11 (DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET)#define DISABLED_MASK12 0#define DISABLED_MASK13 0#define DISABLED_MASK14 0
Greg Kroah-Hartman
maintainerPATCH 142/148 x86/bugs: Remove apostrophe typo
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit bcf163150cd37348a0cb59e95c916a83a9344b0e upstream.
Remove a superfluous ' in the mitigation string.
--- arch/x86/kernel/cpu/bugs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -1137,7 +1137,7 @@ spectre_v2_user_select_mitigation(void)if (retbleed_mitigation ==RETBLEED_MITIGATION_UNRET ) {if (mode !=SPECTRE_V2_USER_STRICT && mode !=SPECTRE_V2_USER_STRICT_PREFERRED ) -pr_info ("Selecting STIBP always-on mode to complement retbleed mitigation'\n" ); +pr_info ("Selecting STIBP always-on mode to complement retbleed mitigation\n" ); mode =SPECTRE_V2_USER_STRICT_PREFERRED ; }
Greg Kroah-Hartman
maintainerPATCH 143/148 um: Add missing apply_returns()
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 564d998106397394b6aad260f219b882b3347e62 upstream.
Implement apply_returns() stub for UM, just like all the other patching routines.
--- arch/um/kernel/um_arch.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/um/kernel/um_arch.c +4 -0
@@ -362,6 +362,10 @@ void apply_retpolines(s32 *start, s32 *e { } +void apply_returns (s32 *start,s32 *end) +{ +} +void apply_alternatives (struct alt_instr *start,struct alt_instr *end) { }
Greg Kroah-Hartman
maintainerPATCH 144/148 x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d upstream.
In order to further enable commit:
bbe2df3f6b6d ("x86/alternative: Try inline spectre_v2=retpoline,amd")
add the new GCC flag -mindirect-branch-cs-prefix:
https://gcc.gnu.org/g:2196a681d7810ad8b227bf983f38ba716620545e
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102952
https://bugs.llvm.org/show_bug.cgi?id=52323
to RETPOLINE=y builds. This should allow fully inlining retpoline,amd for GCC builds.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -672,6 +672,7 @@ endif ifdef CONFIG_CC_IS_GCC RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) +RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix) RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) endif ifdef CONFIG_CC_IS_CLANG
Greg Kroah-Hartman
maintainerPATCH 145/148 kvm: fix objtool relocation warning
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 291073a566b2094c7192872cc0f17ce73d83cb76 upstream.
The recent change to make objtool aware of more symbol relocation types (commit 24ff65257375: "objtool: Teach get_alt_entry() about more relocation types") also added another check, and resulted in this objtool warning when building kvm on x86:
arch/x86/kvm/emulate.o: warning: objtool: __ex_table+0x4: don't know how to handle reloc symbol type: kvm_fastop_exception
The reason seems to be that kvm_fastop_exception() is marked as a global symbol, which causes the relocation to ke kept around for objtool. And at the same time, the kvm_fastop_exception definition (which is done as an inline asm statement) doesn't actually set the type of the global, which then makes objtool unhappy.
The minimal fix is to just not mark kvm_fastop_exception as being a global symbol. It's only used in that one compilation unit anyway, so it was always pointless. That's how all the other local exception table labels are done.
I'm not entirely happy about the kinds of games that the kvm code plays with doing its own exception handling, and the fact that it confused objtool is most definitely a symptom of the code being a bit too subtle and ad-hoc. But at least this trivial one-liner makes objtool no longer upset about what is going on.
--- arch/x86/kvm/emulate.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kvm/emulate.c +0 -1
@@ -452,7 +452,6 @@ static int fastop(struct x86_emulate_ctx ".skip " __stringify(SETCC_ALIGN) " - (.-" #op "), 0xcc \n\t" asm(".pushsection .fixup, \"ax\"\n" -".global kvm_fastop_exception \n" "kvm_fastop_exception: xor %esi, %esi; " ASM_RET ".popsection" );
Greg Kroah-Hartman
maintainerPATCH 146/148 objtool: Fix elf_create_undef_symbol() endianness
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
commit 46c7405df7de8deb97229eacebcee96d61415f3f upstream.
Currently x86 cross-compilation fails on big endian system with:
x86_64-cross-ld: init/main.o: invalid string offset 488112128 >= 6229 for section `.strtab'
Mark new ELF data in elf_create_undef_symbol() as symbol, so that libelf does endianness handling correctly.
--- tools/objtool/elf.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/elf.c +1 -0
@@ -961,6 +961,7 @@ static int elf_add_string(struct elf *el data->d_buf = str; data->d_size =strlen (str) +1 ; data->d_align =1 ; + data->d_type =ELF_T_SYM ; len = strtab->len; strtab->len += data->d_size;
Greg Kroah-Hartman
maintainerPATCH 147/148 tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in perf bench mem memcpy - again
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit fb24e308b6310541e70d11a3f19dc40742974b95 upstream.
To bring in the change made in this cset:
5e21a3ecad1500e3 ("x86/alternative: Merge include files")
This just silences these perf tools build warnings, no change in the tools:
Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S' diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs from latest version at 'arch/x86/lib/memset_64.S' diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S
---
tools/arch/x86/lib/memcpy_64.S | 2 +-
tools/arch/x86/lib/memset_64.S | 2 +-
tools/include/asm/{alternative-asm.h => alternative.h} | 0
tools/arch/x86/lib/memcpy_64.S | 2 +-
tools/arch/x86/lib/memset_64.S | 2 +-
tools/include/asm/alternative-asm.h | 10 ----------
tools/include/asm/alternative.h | 10 ++++++++++
4 files changed, 12 insertions(+), 12 deletions(-)
rename tools/include/asm/{alternative-asm.h => alternative.h} (100%)tools/arch/x86/lib/memcpy_64.S +1 -1
@@ -4,7 +4,7 @@ #include <linux/linkage.h> #include <asm/errno.h> #include <asm/cpufeatures.h> -#include <asm/alternative-asm.h> +#include <asm/alternative.h> #include <asm/export.h> .pushsection .noinstr.text, "ax"
tools/arch/x86/lib/memset_64.S +1 -1
@@ -3,7 +3,7 @@ #include <linux/linkage.h> #include <asm/cpufeatures.h> -#include <asm/alternative-asm.h> +#include <asm/alternative.h> #include <asm/export.h> /*
tools/include/asm/alternative-asm.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _TOOLS_ASM_ALTERNATIVE_ASM_H -#define _TOOLS_ASM_ALTERNATIVE_ASM_H - -/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */ - -#define altinstruction_entry # -#define ALTERNATIVE_2 # - -#endif
tools/include/asm/alternative.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TOOLS_ASM_ALTERNATIVE_ASM_H +#define _TOOLS_ASM_ALTERNATIVE_ASM_H + +/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */ + +#define altinstruction_entry # +#define ALTERNATIVE_2 # + +#endif
Greg Kroah-Hartman
maintainerPATCH 148/148 tools headers: Remove broken definition of __LITTLE_ENDIAN
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit fa2c02e5798c17c89cbb3135940086ebe07e5c9f upstream.
The linux/kconfig.h file was copied from the kernel but the line where with the generated/autoconf.h include from where the CONFIG_ entries would come from was deleted, as tools/ build system don't create that file, so we ended up always defining just __LITTLE_ENDIAN as CONFIG_CPU_BIG_ENDIAN was nowhere to be found.
This in turn ended up breaking the build in some systems where __LITTLE_ENDIAN was already defined, such as the androind NDK.
So just ditch that block that depends on the CONFIG_CPU_BIG_ENDIAN define.
The kconfig.h file was copied just to get IS_ENABLED() and a 'make -C tools/all' doesn't breaks with this removal.
--- tools/include/linux/kconfig.h | 6 ------ 1 file changed, 6 deletions(-)
tools/include/linux/kconfig.h +0 -6
@@ -4,12 +4,6 @@/* CONFIG_CC_VERSION_TEXT (Do not delete this comment. See help in Kconfig) */ -#ifdef CONFIG_CPU_BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#else -#define __LITTLE_ENDIAN 1234 -#endif -#define __ARG_PLACEHOLDER_1 0,#define __take_second_arg (__ignored, val, ...) val
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Mon, 25 Jul 2022 09:50:18 +0000. Anything received after that time might be too late.
Build results:
total: 163 pass: 163 fail: 0 Qemu test results: total: 477 pass: 477 fail: 0
Guenter
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Mon, 25 Jul 2022 09:50:18 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.133-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro's test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.10.133-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-5.10.y
* git commit: 00d1152b116251d5f40936f24f9ef31f52eba544
* git describe: v5.10.132-149-g00d1152b1162
* test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.10.y/build/v5.10.132-149-g00d1152b1162
## No test regressions (compared to v5.10.132)
## No metric regressions (compared to v5.10.132)
## No test fixes (compared to v5.10.132)
## No metric fixes (compared to v5.10.132)
## Test result summary
total: 138017, pass: 124391, fail: 610, skip: 12308, xfail: 708
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 308 total, 308 passed, 0 failed
* arm64: 62 total, 60 passed, 2 failed
* i386: 52 total, 50 passed, 2 failed
* mips: 45 total, 45 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 51 total, 51 passed, 0 failed
* riscv: 27 total, 27 passed, 0 failed
* s390: 21 total, 21 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 56 total, 54 passed, 2 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* packetdrill
* perf
* rcutorture
* ssuite
* v4l2-compliance
* vdso
Greetings!
Daniel Díaz
[email protected]
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Mon, 25 Jul 2022 09:50:18 +0000. Anything received after that time might be too late.
Hi Greg,
5.10.133-rc1 tested.
Run tested on:
- Intel Skylake x86_64 (nuc6 i5-6260U)
In addition - build tested for:
- Allwinner A64
- Allwinner H3
- Allwinner H5
- Allwinner H6
- Rockchip RK3288
- Rockchip RK3328
- Rockchip RK3399pro
Logs from: Intel Skylake x86_64 (nuc6 i5-6260U)
nuc6:~ # dmesg
[ 0.000000] microcode: microcode updated early to revision 0xe2, date = 2020-07-14 [ 0.000000] Linux version 5.10.133-rc1 (docker@0dae7cb4c0f4) (x86_64-libreelec-linux-gnu-gcc-10.2.0 (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP Sat Jul 23 11:54:48 UTC 2022 [ 0.000000] DMI: /NUC6i5SYB, BIOS SYSKLi35.86A.0073.2020.0909.1625 09/09/2020 ... [ 0.243172] Last level iTLB entries: 4KB 64, 2MB 8, 4MB 8 [ 0.243178] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization [ 0.243181] Spectre V2 : Mitigation: IBRS [ 0.243182] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch [ 0.243183] RETBleed: Mitigation: IBRS [ 0.243186] Spectre V2 : mitigation: Enabling conditional Indirect Branch Prediction Barrier [ 0.243188] Speculative Store Bypass: Mitigation: Speculative Store Bypass disabled via prctl and seccomp [ 0.243196] MDS: Mitigation: Clear CPU buffers [ 0.243197] MMIO Stale Data: Mitigation: Clear CPU buffers [ 0.243201] SRBDS: Mitigation: Microcode ... [ 0.313120] MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more details. [ 0.313120] MMIO Stale Data CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/processor_mmio_stale_data.html for more details.
nuc6:~ # lscpu | grep -e Vulnerability -e "Model name"
Model name: Intel(R) Core(TM) i5-6260U CPU @ 1.80GHz Vulnerability Itlb multihit: Processor vulnerable Vulnerability L1tf: Mitigation; PTE Inversion Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, RSB filling Vulnerability Srbds: Mitigation; Microcode Vulnerability Tsx async abort: Not affected
--
Rudi
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Mon, 25 Jul 2022 09:50:18 +0000. Anything received after that time might be too late.
Build test (gcc version 11.3.1 20220706):
mips: 63 configs -> no failure
arm: 104 configs -> no failure
arm64: 3 configs -> no failurex86_64: 4 configs -> no failure alpha allmodconfig -> no failure powerpc allmodconfig -> no failure riscv allmodconfig -> no failure s390 allmodconfig -> no failure xtensa allmodconfig -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
arm64: Booted on rpi4b (4GB model). No regression. [2]
[1]. https://openqa.qa.codethink.co.uk/tests/1556
[2]. https://openqa.qa.codethink.co.uk/tests/1557
--
Regards
Sudip
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Mon, 25 Jul 2022 09:50:18 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.133-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.10:
10 builds: 10 pass, 0 fail
28 boots: 28 pass, 0 fail
75 tests: 75 pass, 0 failLinux version: 5.10.133-rc1-g00d1152b1162
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
These are the specualtion fixes, 00d1152b1162, AFAICT. There's little confusion as patches are not in queue/5.10.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-5.10.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.133 release. There are 148 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Mon, 25 Jul 2022 09:50:18 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.133-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian