Revert "evm: Fix memleak in init_desc"
Subsystems (14)
Sasha Levin
maintainerPATCH 1/54 Revert "evm: Fix memleak in init_desc"
From: Xiu Jianfeng <[email protected]>
[ Upstream commit 51dd64bb99e4478fc5280171acd8e1b529eadaf7 ]
This reverts commit ccf11dbaa07b328fa469415c362d33459c140a37.
Commit ccf11dbaa07b ("evm: Fix memleak in init_desc") said there is memleak in init_desc. That may be incorrect, as we can see, tmp_tfm is saved in one of the two global variables hmac_tfm or evm_tfm[hash_algo], then if init_desc is called next time, there is no need to alloc tfm again, so in the error path of kmalloc desc or crypto_shash_init(desc), It is not a problem without freeing tmp_tfm.
And also that commit did not reset the global variable to NULL after freeing tmp_tfm and this makes *tfm a dangling pointer which may cause a UAF issue.
--- security/integrity/evm/evm_crypto.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
security/integrity/evm/evm_crypto.c +2 -5
@@ -75,7 +75,7 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo) {long rc;const char *algo; -struct crypto_shash **tfm, *tmp_tfm =NULL ; +struct crypto_shash **tfm, *tmp_tfm;struct shash_desc *desc;if (type ==EVM_XATTR_HMAC ) {
@@ -120,16 +120,13 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo) alloc: desc =kmalloc (sizeof (*desc) +crypto_shash_descsize (*tfm),GFP_KERNEL ); -if (!desc) { -crypto_free_shash (tmp_tfm); +if (!desc)return ERR_PTR (-ENOMEM ); - } desc->tfm = *tfm; rc =crypto_shash_init (desc);if (rc) { -crypto_free_shash (tmp_tfm);kfree (desc);return ERR_PTR (rc); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 2/54 ARM: rockchip: Add missing of_node_put() in rockchip_suspend_init()
From: Liang He <[email protected]>
[ Upstream commit f4470dbfb5ff92804650bc71d115c3f150d430f6 ]
In rockchip_suspend_init(), of_find_matching_node_and_match() will return a node pointer with refcount incremented. We should use of_node_put() in fail path or when it is not used anymore.
--- arch/arm/mach-rockchip/pm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/pm.c +5 -2
@@ -311,7 +311,7 @@ void __init rockchip_suspend_init(void) &match);if (!match) {pr_err ("Failed to find PMU node\n" ); -return ; + goto out_put; } pm_data = (struct rockchip_pm_data *) match->data;
@@ -320,9 +320,12 @@ void __init rockchip_suspend_init(void)if (ret) {pr_err ("%s: matches init error %d\n" , __func__, ret); -return ; + goto out_put; } }suspend_set_ops (pm_data->ops); + +out_put: +of_node_put (np); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 3/54 x86/kvm/vmx: Make noinstr clean
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 742ab6df974ae8384a2dd213db1a3a06cf6d8936 ]
The recent mmio_stale_data fixes broke the noinstr constraints:
vmlinux.o: warning: objtool: vmx_vcpu_enter_exit+0x15b: call to wrmsrl.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: vmx_vcpu_enter_exit+0x1bf: call to kvm_arch_has_assigned_device() leaves .noinstr.text section
make it all happy again.
--- arch/x86/kvm/vmx/vmx.c | 6 +++--- arch/x86/kvm/x86.c | 4 ++-- include/linux/kvm_host.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/kvm/vmx/vmx.c +3 -3
@@ -383,9 +383,9 @@ static __always_inline void vmx_disable_fb_clear(struct vcpu_vmx *vmx)if (!vmx->disable_fb_clear)return ; -rdmsrl (MSR_IA32_MCU_OPT_CTRL , msr); + msr =__rdmsr (MSR_IA32_MCU_OPT_CTRL ); msr |=FB_CLEAR_DIS ; -wrmsrl (MSR_IA32_MCU_OPT_CTRL , msr); +native_wrmsrl (MSR_IA32_MCU_OPT_CTRL , msr);/* Cache the MSR value to avoid reading it later */ vmx->msr_ia32_mcu_opt_ctrl = msr; }
@@ -396,7 +396,7 @@ static __always_inline void vmx_enable_fb_clear(struct vcpu_vmx *vmx)return ; vmx->msr_ia32_mcu_opt_ctrl &= ~FB_CLEAR_DIS ; -wrmsrl (MSR_IA32_MCU_OPT_CTRL , vmx->msr_ia32_mcu_opt_ctrl); +native_wrmsrl (MSR_IA32_MCU_OPT_CTRL , vmx->msr_ia32_mcu_opt_ctrl); }static void vmx_update_fb_clear_dis (struct kvm_vcpu *vcpu,struct vcpu_vmx *vmx)
arch/x86/kvm/x86.c +2 -2
@@ -12531,9 +12531,9 @@ void kvm_arch_end_assignment(struct kvm *kvm) }EXPORT_SYMBOL_GPL (kvm_arch_end_assignment); -bool kvm_arch_has_assigned_device (struct kvm *kvm) +bool noinstr kvm_arch_has_assigned_device(struct kvm *kvm) { -return atomic_read (&kvm->arch.assigned_device_count); +return arch_atomic_read (&kvm->arch.assigned_device_count); }EXPORT_SYMBOL_GPL (kvm_arch_has_assigned_device);
include/linux/kvm_host.h +1 -1
@@ -1511,7 +1511,7 @@ static inline void kvm_arch_end_assignment(struct kvm *kvm) { } -static inline bool kvm_arch_has_assigned_device (struct kvm *kvm) +static __always_inline bool kvm_arch_has_assigned_device(struct kvm *kvm) {return false; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 4/54 x86/cpufeatures: Move RETPOLINE flags to word 11
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit a883d624aed463c84c22596006e5a96f5b44db31 ]
In order to extend the RETPOLINE features to 4, move them to word 11 where there is still room. This mostly keeps DISABLE_RETPOLINE simple.
--- arch/x86/include/asm/cpufeatures.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +6 -2
@@ -203,8 +203,8 @@#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ /* FREE! ( 7*32+10) */ #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 LFENCE for Spectre variant 2 */ +/* FREE! ( 7*32+12) */ +/* 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 */ #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16)/* "" MSR SPEC_CTRL is implemented */
@@ -295,6 +295,10 @@#define X86_FEATURE_PER_THREAD_MBA (11*32+ 7)/* "" Per-thread Memory Bandwidth Allocation */ #define X86_FEATURE_SGX1 (11*32+ 8)/* "" Basic SGX */ #define X86_FEATURE_SGX2 (11*32+ 9)/* "" SGX Enclave Dynamic Memory Management (EDMM) */ +/* FREE! (11*32+10) */ +/* 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 */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4)/* AVX VNNI instructions */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 5/54 x86/retpoline: Cleanup some #ifdefery
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 369ae6ffc41a3c1137cab697635a84d0cc7cdcea ]
On it's own not much of a cleanup but it prepares for more/similar code.
--- arch/x86/include/asm/disabled-features.h | 9 ++++++++- arch/x86/include/asm/nospec-branch.h | 7 +++---- arch/x86/net/bpf_jit_comp.c | 7 +++---- 3 files changed, 14 insertions(+), 9 deletions(-)
arch/x86/include/asm/disabled-features.h +8 -1
@@ -56,6 +56,13 @@# 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_INTEL_IOMMU_SVM # define DISABLE_ENQCMD 0#else
@@ -82,7 +89,7 @@#define DISABLED_MASK8 0#define DISABLED_MASK9 (DISABLE_SMAP|DISABLE_SGX)#define DISABLED_MASK10 0 -#define DISABLED_MASK11 0 +#define DISABLED_MASK11 (DISABLE_RETPOLINE)#define DISABLED_MASK12 0#define DISABLED_MASK13 0#define DISABLED_MASK14 0
arch/x86/include/asm/nospec-branch.h +3 -4
@@ -120,17 +120,16 @@ _ASM_PTR" 999b\n\t" \".popsection\n\t" -#ifdef CONFIG_RETPOLINE - typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE ]; +extern retpoline_thunk_t __x86_indirect_thunk_array[]; + +#ifdef CONFIG_RETPOLINE #define GEN (reg) \ extern retpoline_thunk_t __x86_indirect_thunk_ ## reg;#include <asm/GEN-for-each-reg.h> #undef GEN -extern retpoline_thunk_t __x86_indirect_thunk_array[]; -#ifdef CONFIG_X86_64 /*
arch/x86/net/bpf_jit_comp.c +3 -4
@@ -407,16 +407,15 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip) {u8 *prog = *pprog; -#ifdef CONFIG_RETPOLINE if (cpu_feature_enabled (X86_FEATURE_RETPOLINE_LFENCE )) {EMIT_LFENCE ();EMIT2 (0xFF ,0xE0 + reg); }else if (cpu_feature_enabled (X86_FEATURE_RETPOLINE )) {OPTIMIZER_HIDE_VAR (reg);emit_jump (&prog, &__x86_indirect_thunk_array[reg], ip); - } else -#endif -EMIT2 (0xFF ,0xE0 + reg); + }else { +EMIT2 (0xFF ,0xE0 + reg); + } *pprog = prog; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 6/54 x86/retpoline: Swizzle retpoline thunk
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 00e1533325fd1fb5459229fe37f235462649f668 ]
Put the actual retpoline thunk as the original code so that it can become more complicated. Specifically, it allows RET to be a JMP, which can't be .altinstr_replacement since that doesn't do relocations (except for the very first instruction).
--- arch/x86/lib/retpoline.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/lib/retpoline.S +3 -3
@@ -33,9 +33,9 @@ SYM_INNER_LABEL(__x86_indirect_thunk_\reg, SYM_L_GLOBAL) UNWIND_HINT_EMPTY ANNOTATE_NOENDBR - ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), \ - __stringify(RETPOLINE \reg), X86_FEATURE_RETPOLINE, \ - __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; jmp *%\reg; int3), X86_FEATURE_RETPOLINE_LFENCE + ALTERNATIVE_2 __stringify(RETPOLINE \reg), \ + __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; jmp *%\reg; int3), X86_FEATURE_RETPOLINE_LFENCE, \ + __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), ALT_NOT(X86_FEATURE_RETPOLINE) .endm
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 7/54 x86/retpoline: Use -mfunction-return
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 0b53c374b9eff2255a386f1f1cfb9a928e52a5ae ]
Utilize -mfunction-return=thunk-extern when available to have the compiler replace RET instructions with direct JMPs to the symbol __x86_return_thunk. This does not affect assembler (.S) sources, only C sources.
-mfunction-return=thunk-extern has been available since gcc 7.3 and clang 15.
--- arch/x86/Makefile | 2 ++ arch/x86/include/asm/nospec-branch.h | 2 ++ arch/x86/lib/retpoline.S | 13 +++++++++++++ 3 files changed, 17 insertions(+)
arch/x86/Makefile +2 -0
@@ -15,11 +15,13 @@ 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_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 export RETPOLINE_CFLAGS export RETPOLINE_VDSO_CFLAGS
arch/x86/include/asm/nospec-branch.h +2 -0
@@ -123,6 +123,8 @@typedef u8 retpoline_thunk_t [RETPOLINE_THUNK_SIZE ];extern retpoline_thunk_t __x86_indirect_thunk_array[]; +extern void __x86_return_thunk (void ); +#ifdef CONFIG_RETPOLINE #define GEN (reg) \
arch/x86/lib/retpoline.S +13 -0
@@ -67,3 +67,16 @@ SYM_CODE_END(__x86_indirect_thunk_array) #define GEN(reg) EXPORT_THUNK(reg) #include <asm/GEN-for-each-reg.h> #undef GEN + +/* + * This function name is magical and is used by -mfunction-return=thunk-extern + * for the compiler to generate JMPs to it. + */ +SYM_CODE_START(__x86_return_thunk) + UNWIND_HINT_EMPTY + ANNOTATE_NOENDBR + ret + int3 +SYM_CODE_END(__x86_return_thunk) + +__EXPORT_THUNK(__x86_return_thunk)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 8/54 x86,objtool: Create .return_sites
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit d9e9d2300681d68a775c28de6aa6e5290ae17796 ]
Find all the return-thunk sites and record them in a .return_sites section such that the kernel can undo this.
--- tools/objtool/arch/x86/decode.c | 5 ++ tools/objtool/check.c | 74 +++++++++++++++++++++++++ tools/objtool/include/objtool/arch.h | 1 + tools/objtool/include/objtool/elf.h | 1 + tools/objtool/include/objtool/objtool.h | 1 + tools/objtool/objtool.c | 1 + 6 files changed, 83 insertions(+)
tools/objtool/arch/x86/decode.c +5 -0
@@ -787,3 +787,8 @@ bool arch_is_retpoline(struct symbol *sym) {return !strncmp (sym->name,"__x86_indirect_" ,15 ); } + +bool arch_is_rethunk (struct symbol *sym) +{ +return !strcmp (sym->name,"__x86_return_thunk" ); +}
tools/objtool/check.c +74 -0
110 lines not on this page · raw message
tools/objtool/include/objtool/arch.h +1 -0
@@ -89,6 +89,7 @@ const char *arch_ret_insn(int len);int arch_decode_hint_reg (u8 sp_reg,int *base);bool arch_is_retpoline (struct symbol *sym); +bool arch_is_rethunk (struct symbol *sym);int arch_rewrite_retpolines (struct objtool_file *file);
tools/objtool/include/objtool/elf.h +1 -0
@@ -57,6 +57,7 @@ struct symbol { u8 uaccess_safe : 1; u8 static_call_tramp : 1; u8 retpoline_thunk : 1; + u8 return_thunk : 1; u8 fentry : 1; u8 profiling_func : 1;struct list_head pv_target;
tools/objtool/include/objtool/objtool.h +1 -0
@@ -24,6 +24,7 @@ struct objtool_file {struct list_head insn_list;DECLARE_HASHTABLE (insn_hash,20 );struct list_head retpoline_call_list; +struct list_head return_thunk_list;struct list_head static_call_list;struct list_head mcount_loc_list;struct list_head endbr_list;
tools/objtool/objtool.c +1 -0
@@ -126,6 +126,7 @@ struct objtool_file *objtool_open_read(const char *_objname)INIT_LIST_HEAD (&file.insn_list);hash_init (file.insn_hash);INIT_LIST_HEAD (&file.retpoline_call_list); +INIT_LIST_HEAD (&file.return_thunk_list);INIT_LIST_HEAD (&file.static_call_list);INIT_LIST_HEAD (&file.mcount_loc_list);INIT_LIST_HEAD (&file.endbr_list);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 9/54 x86/kvm: Fix SETcc emulation for return thunks
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit af2e140f34208a5dfb6b7a8ad2d56bda88f0524d ]
Prepare the SETcc fastop stuff for when RET can be larger still.
The tricky bit here is that the expressions should not only be constant C expressions, but also absolute GAS expressions. This means no ?: and 'true' is ~0.
Also ensure em_setcc() has the same alignment as the actual FOP_SETCC() ops, this ensures there cannot be an alignment hole between em_setcc() and the first op.
Additionally, add a .skip directive to the FOP_SETCC() macro to fill any remaining space with INT3 traps; however the primary purpose of this directive is to generate AS warnings when the remaining space goes negative. Which is a very good indication the alignment magic went side-ways.
--- arch/x86/kvm/emulate.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
arch/x86/kvm/emulate.c +15 -13
@@ -325,13 +325,15 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);#define FOP_RET (name) \ __FOP_RET(#name) -#define FOP_START (op) \ +#define __FOP_START (op, align) \ extern void em_##op(struct fastop *fake); \ asm(".pushsection .text, \"ax\" \n\t" \ ".global em_" #op " \n\t" \ - ".align " __stringify(FASTOP_SIZE) " \n\t" \ + ".align " __stringify(align) " \n\t" \ "em_" #op ":\n\t" +#define FOP_START (op) __FOP_START(op, FASTOP_SIZE) +#define FOP_END \ ".popsection")
@@ -435,16 +437,15 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);/* * Depending on .config the SETcc functions look like: * -* ENDBR [4 bytes; CONFIG_X86_KERNEL_IBT] -* SETcc %al [3 bytes] -* RET [1 byte] -* INT3 [1 byte; CONFIG_SLS] -* -* Which gives possible sizes 4, 5, 8 or 9. When rounded up to the -* next power-of-two alignment they become 4, 8 or 16 resp. +* ENDBR [4 bytes; CONFIG_X86_KERNEL_IBT] +* SETcc %al [3 bytes] +* RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETPOLINE] +* INT3 [1 byte; CONFIG_SLS] */ -#define SETCC_LENGTH (ENDBR_INSN_SIZE + 4 + IS_ENABLED(CONFIG_SLS)) -#define SETCC_ALIGN (4 << IS_ENABLED(CONFIG_SLS) << HAS_KERNEL_IBT) +#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETPOLINE)) + \ + IS_ENABLED(CONFIG_SLS)) +#define SETCC_LENGTH (ENDBR_INSN_SIZE + 3 + RET_LENGTH) +#define SETCC_ALIGN (4 << ((SETCC_LENGTH > 4) & 1) << ((SETCC_LENGTH > 8) & 1))static_assert (SETCC_LENGTH <=SETCC_ALIGN );#define FOP_SETCC (op) \
@@ -453,9 +454,10 @@ static_assert(SETCC_LENGTH <= SETCC_ALIGN);#op ": \n\t" \ ASM_ENDBR \ #op " %al \n\t" \ - __FOP_RET(#op) + __FOP_RET(#op) \ + ".skip " __stringify(SETCC_ALIGN) " - (.-" #op "), 0xcc \n\t" -FOP_START(setcc) +__FOP_START(setcc, SETCC_ALIGN) FOP_SETCC(seto) FOP_SETCC(setno) FOP_SETCC(setc)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 10/54 x86/vsyscall_emu/64: Don't use RET in vsyscall emulation
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 15583e514eb16744b80be85dea0774ece153177d ]
This is userspace code and doesn't play by the normal kernel rules.
--- arch/x86/entry/vsyscall/vsyscall_emu_64.S | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/entry/vsyscall/vsyscall_emu_64.S +6 -3
@@ -19,17 +19,20 @@ __vsyscall_page: mov $__NR_gettimeofday, %rax syscall - RET + ret + int3 .balign 1024, 0xcc mov $__NR_time, %rax syscall - RET + ret + int3 .balign 1024, 0xcc mov $__NR_getcpu, %rax syscall - RET + ret + int3 .balign 4096, 0xcc
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 11/54 x86/sev: Avoid using __x86_return_thunk
In reply to Sasha LevinFrom: Kim Phillips <[email protected]>
[ Upstream commit 0ee9073000e8791f8b134a8ded31bcc767f7f232 ]
Specifically, it's because __enc_copy() encrypts the kernel after being relocated outside the kernel in sme_encrypt_execute(), and the RET macro's jmp offset isn't amended prior to execution.
--- arch/x86/mm/mem_encrypt_boot.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/mm/mem_encrypt_boot.S +6 -2
@@ -65,7 +65,9 @@ SYM_FUNC_START(sme_encrypt_execute) movq %rbp, %rsp /* Restore original stack pointer */ pop %rbp - RET + /* Offset to __x86_return_thunk would be wrong here */ + ret + int3 SYM_FUNC_END(sme_encrypt_execute) SYM_FUNC_START(__enc_copy)
@@ -151,6 +153,8 @@ SYM_FUNC_START(__enc_copy) pop %r12 pop %r15 - RET + /* Offset to __x86_return_thunk would be wrong here */ + ret + int3 .L__enc_copy_end: SYM_FUNC_END(__enc_copy)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 12/54 objtool: Treat .text.__x86.* as noinstr
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 951ddecf435659553ed15a9214e153a3af43a9a1 ]
Needed because zen_untrain_ret() will be called from noinstr code.
Also makes sense since the thunks MUST NOT contain instrumentation nor be poked with dynamic instrumentation.
--- tools/objtool/check.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/objtool/check.c +2 -1
@@ -374,7 +374,8 @@ static int decode_instructions(struct objtool_file *file) sec->text = true;if (!strcmp (sec->name,".noinstr.text" ) || - !strcmp (sec->name,".entry.text" )) + !strcmp (sec->name,".entry.text" ) || + !strncmp (sec->name,".text.__x86." ,12 )) sec->noinstr = true;for (offset =0 ; offset < sec->sh.sh_size; offset += insn->len) {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 13/54 x86/bugs: Report AMD retbleed vulnerability
In reply to Sasha LevinFrom: Alexandre Chartre <[email protected]>
[ Upstream commit 6b80b59b3555706508008f1f127b5412c89c7fd8 ]
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
@@ -448,5 +448,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
@@ -1987,6 +1987,11 @@ static ssize_t srbds_show_state(char *buf)return 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) {
@@ -2032,6 +2037,9 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attrcase X86_BUG_MMIO_STALE_DATA :return mmio_stale_data_show_state (buf); +case X86_BUG_RETBLEED : +return retbleed_show_state (buf); +default :break ; }
@@ -2088,4 +2096,9 @@ ssize_t cpu_show_mmio_stale_data(struct device *dev, struct device_attribute *at {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
@@ -1231,16 +1231,27 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = { {} }; +#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 ),
@@ -1273,6 +1284,11 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {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), {} };
@@ -1374,6 +1390,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) !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
@@ -570,6 +570,12 @@ ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,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);
@@ -580,6 +586,7 @@ static DEVICE_ATTR(tsx_async_abort, 0444, cpu_show_tsx_async_abort, NULL); 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,
@@ -592,6 +599,7 @@ static struct attribute *cpu_root_vulnerabilities_attrs[] = { &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 device *dev, struct device_attribute *attr,extern 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,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 14/54 x86/bugs: Add AMD retbleed= boot parameter
In reply to Sasha LevinFrom: Alexandre Chartre <[email protected]>
[ Upstream commit 7fbf47c7ce50b38a64576b150e7011ae73d54669 ]
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]
--- .../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
@@ -5124,6 +5124,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
@@ -469,6 +469,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
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 15/54 x86/bugs: Enable STIBP for JMP2RET
In reply to Sasha LevinFrom: Kim Phillips <[email protected]>
[ Upstream commit e8ec1b6e08a2102d8755ccb06fa26d540f26a2fa ]
For untrained return thunks to be fully effective, STIBP must be enabled or SMT disabled.
--- .../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
@@ -5128,11 +5128,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
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 16/54 x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit caa0ff24d5d0e02abce5e65c3d2b7f20a6617be5 ]
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
@@ -236,6 +236,7 @@ static inline void indirect_branch_prediction_barrier(void)/* 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
@@ -49,11 +49,29 @@ static void __init mmio_select_mitigation(void);static void __init srbds_select_mitigation (void );static void __init l1d_flush_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.
@@ -1272,7 +1290,7 @@ static void __init spectre_v2_select_mitigation(void)if (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) {
@@ -1327,7 +1345,7 @@ static void __init spectre_v2_select_mitigation(void)static 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. */
@@ -1570,7 +1588,7 @@ static enum ssb_mitigation __init __ssb_select_mitigation(void)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); } }
@@ -1821,7 +1839,7 @@ int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)void 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
@@ -600,7 +600,7 @@ static __always_inline void __speculation_ctrl_update(unsigned long tifp, }if (updmsr) -wrmsrl (MSR_IA32_SPEC_CTRL , msr); +write_spec_ctrl_current (msr); }static unsigned long speculation_ctrl_update_tif (struct task_struct *tsk)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 17/54 x86/bugs: Optimize SPEC_CTRL MSR writes
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit c779bc1a9002fa474175b80e72b85c9bf628abb0 ]
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
@@ -236,7 +236,7 @@ static inline void indirect_branch_prediction_barrier(void)/* 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
@@ -63,13 +63,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); }/*
@@ -1290,7 +1296,7 @@ static void __init spectre_v2_select_mitigation(void)if (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) {
@@ -1345,7 +1351,7 @@ static void __init spectre_v2_select_mitigation(void)static 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. */
@@ -1588,7 +1594,7 @@ static enum ssb_mitigation __init __ssb_select_mitigation(void)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); } }
@@ -1839,7 +1845,7 @@ int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)void 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
@@ -600,7 +600,7 @@ static __always_inline void __speculation_ctrl_update(unsigned long tifp, }if (updmsr) -write_spec_ctrl_current (msr); +write_spec_ctrl_current (msr, false); }static unsigned long speculation_ctrl_update_tif (struct task_struct *tsk)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 18/54 x86/bugs: Split spectre_v2_select_mitigation() and spectre_v2_user_select_mitigation()
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 166115c08a9b0b846b783088808a27d739be6e8d ]
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 );
@@ -145,13 +146,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 ();
@@ -1005,13 +1012,15 @@ static void __init spec_v2_user_print_cond(const char *reason, bool secure)pr_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 :
@@ -1045,7 +1054,7 @@ static inline bool spectre_v2_in_eibrs_mode(enum spectre_v2_mitigation mode) }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 );
@@ -1058,7 +1067,7 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) 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;
@@ -1346,7 +1355,7 @@ static void __init spectre_v2_select_mitigation(void) }/* 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)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 19/54 x86/bugs: Report Intel retbleed vulnerability
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 6ad0ad2bf8a67e27d1f9d006a1dabb0e1c360cc3 ]
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
@@ -783,12 +783,17 @@ static int __init nospectre_v1_cmdline(char *str) }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 {
@@ -800,6 +805,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 =
@@ -842,6 +849,7 @@ early_param("retbleed", retbleed_parse_cmdline);#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 ) {
@@ -858,12 +866,15 @@ static void __init retbleed_select_mitigation(void)case 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 ; }
@@ -893,15 +904,31 @@ static void __init retbleed_select_mitigation(void)break ; } +/* +* 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
@@ -1263,24 +1263,24 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {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),
@@ -1390,7 +1390,7 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) !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 ))
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 20/54 objtool: Update Retpoline validation
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 9bb2ec608a209018080ca262f771e6a9ff203b6f ]
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
@@ -75,6 +75,12 @@ .popsection .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
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
@@ -26,6 +26,7 @@ SYM_CODE_START(hypercall_page) .rept (PAGE_SIZE / 32) UNWIND_HINT_FUNC ANNOTATE_NOENDBR + ANNOTATE_UNRET_SAFE ret /* * Xen will write the hypercall page, and sort out ENDBR.
tools/objtool/check.c +13 -6
@@ -2097,8 +2097,9 @@ static int read_retpoline_hints(struct objtool_file *file) }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 ; }
@@ -3631,7 +3632,8 @@ static int validate_retpoline(struct objtool_file *file)for_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)
@@ -3646,9 +3648,14 @@ static int validate_retpoline(struct objtool_file *file)if (!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++; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 21/54 x86/xen: Rename SYS* entry points
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit b75b7f8ef1148be1b9321ffc2f6c19238904b438 ]
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
@@ -918,7 +918,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); }
@@ -927,7 +927,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
@@ -936,7 +936,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
@@ -234,7 +234,7 @@ SYM_CODE_END(xenpv_restore_regs_and_return_to_usermode) */ /* Normal 64-bit system call target */ -SYM_CODE_START(xen_syscall_target) +SYM_CODE_START(xen_entry_SYSCALL_64) UNWIND_HINT_EMPTY ENDBR popq %rcx
@@ -249,12 +249,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 ENDBR popq %rcx
@@ -269,10 +269,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 ENDBR /*
@@ -291,19 +291,19 @@ 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 ENDBR 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;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 22/54 x86/bugs: Do IBPB fallback check only once
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 0fe4aeea9c01baabecc8c3afc7889c809d939bc2 ]
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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -2
@@ -871,8 +871,9 @@ static void __init retbleed_select_mitigation(void) 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 ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 23/54 x86/cpu/amd: Add Spectral Chicken
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit d7caac991feeef1b871ee6988fd2c9725df09039 ]
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
@@ -553,6 +553,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
@@ -862,6 +862,26 @@ static void init_amd_bd(struct cpuinfo_x86 *c)clear_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 );
@@ -907,7 +927,8 @@ static void init_amd(struct cpuinfo_x86 *c)case 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
@@ -61,6 +61,8 @@ static inline void tsx_init(void) { }static inline void tsx_ap_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
@@ -302,6 +302,12 @@ static void init_hygon(struct cpuinfo_x86 *c)/* 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 );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 24/54 x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit b2620facef4889fefcbf2e87284f34dcd4189bce ]
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
@@ -698,7 +698,6 @@ SYM_CODE_START(__switch_to_asm) movl %ebx, PER_CPU_VAR(__stack_chk_guard) #endif -#ifdef CONFIG_RETPOLINE /* * When switching from a shallower to a deeper call stack * the RSB may either underflow or use entries populated
@@ -707,7 +706,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
@@ -245,7 +245,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
@@ -254,7 +253,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
@@ -111,11 +111,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 #else /* __ASSEMBLY__ */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 25/54 KVM: VMX: Flatten __vmx_vcpu_run()
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 8bd200d23ec42d66ccd517a72dd0b9cc6132d2fd ]
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 | 119 ++++++++++++++----------------------- 1 file changed, 46 insertions(+), 73 deletions(-)
arch/x86/kvm/vmx/vmenter.S +46 -73
@@ -30,68 +30,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)
@@ -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,37 @@ 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 + + /* + * 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) - /* Jump on VM-Fail. */ - jbe 2f +SYM_INNER_LABEL(vmx_vmexit, SYM_L_GLOBAL) + + /* Restore unwind state from before the VMRESUME/VMLAUNCH. */ + UNWIND_HINT_RESTORE + ENDBR /* Temporarily save guest's RAX. */ push %_ASM_AX
@@ -185,9 +148,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 +164,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 +183,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 +197,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)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 26/54 KVM: VMX: Convert launched argument to flags
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit bb06650634d3552c0f8557e9d16aa1a408040e28 ]
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
@@ -3091,7 +3091,7 @@ static int nested_vmx_check_vmentry_hw(struct kvm_vcpu *vcpu) } 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
@@ -839,6 +839,16 @@ static bool msr_write_intercepted(struct vcpu_vmx *vmx, u32 msr) MSR_IA32_SPEC_CTRL); } +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) {
@@ -6827,7 +6837,8 @@ static fastpath_t vmx_exit_handlers_fastpath(struct kvm_vcpu *vcpu) } static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, -struct vcpu_vmx *vmx) +struct vcpu_vmx *vmx, +unsigned long flags) {guest_state_enter_irqoff ();
@@ -6846,7 +6857,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,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 ();
@@ -6954,7 +6965,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)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" #define MSR_TYPE_R 1#define MSR_TYPE_W 2
@@ -404,7 +405,9 @@ void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu);struct 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);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 27/54 KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit fc02735b14fff8c6678b521d324ade27b1a3d4cf ]
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
@@ -240,6 +240,7 @@ static inline void indirect_branch_prediction_barrier(void)/* 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);/*
arch/x86/kernel/cpu/bugs.c +4 -0
@@ -199,6 +199,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
@@ -405,6 +405,7 @@ void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu);struct 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);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 28/54 tty: Add N_CAN327 line discipline ID for ELM327 based CAN driver
In reply to Sasha LevinFrom: Max Staudt <[email protected]>
[ Upstream commit ec5ad331680c96ef3dd30dc297b206988023b9e1 ]
The actual driver will be added via the CAN tree.
--- include/uapi/linux/tty.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/linux/tty.h +2 -1
@@ -38,8 +38,9 @@#define N_NULL 27/* Null ldisc used for error handling */ #define N_MCTP 28/* MCTP-over-serial */ #define N_DEVELOPMENT 29/* Manual out-of-tree testing */ +#define N_CAN327 30/* ELM327 based OBD-II interfaces */ /* Always the newest line discipline + 1 */ -#define NR_LDISCS 30 +#define NR_LDISCS 31#endif /* _UAPI_LINUX_TTY_H */
Signature · 1 line
2.35.1
Re: [PATCH AUTOSEL 5.18 28/54] tty: Add N_CAN327 line discipline ID for ELM327 based CAN driver
Quoted 5 lines · Sasha Levin
From: Max Staudt <[email protected]>
[ Upstream commit
ec5ad331680c96ef3dd30dc297b206988023b9e1]The actual driver will be added via the CAN tree.
Hmm, it's a new driver (ldisc). Should it really go to stable?
Quoted 24 lines
Signed-off-by Max Staudt <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- include/uapi/linux/tty.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/uapi/linux/tty.h +2
-1@@ -38,8 +38,9 @@#define N_NULL 27/* Null ldisc used for error handling */ #define N_MCTP 28/* MCTP-over-serial */ #define N_DEVELOPMENT 29/* Manual out-of-tree testing */ +#define N_CAN327 30/* ELM327 based OBD-II interfaces */ /* Always the newest line discipline + 1 */ -#define NR_LDISCS 30 +#define NR_LDISCS 31#endif /* _UAPI_LINUX_TTY_H */
Signature · 2 lines
js suse labs
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 5.18 28/54] tty: Add N_CAN327 line discipline ID for ELM327 based CAN driver
Quoted 8 lines · Jiri Slaby
Quoted 5 lines · Sasha Levin
From: Max Staudt <[email protected]>
[ Upstream commit
ec5ad331680c96ef3dd30dc297b206988023b9e1]The actual driver will be added via the CAN tree.
Hmm, it's a new driver (ldisc). Should it really go to stable?
You are right, no, this shouldn't go to stable kernels, it doesn't affect them at all.
Sasha, can you drop this from all autosel queues?
thanks,
greg k-h
Sasha Levin
maintainerPATCH 29/54 wifi: mac80211: check skb_shared in ieee80211_8023_xmit()
In reply to Sasha LevinFrom: Ryder Lee <[email protected]>
[ Upstream commit a4926abb787e2ef3ee2997e6ca8844d859478647 ]
Add a missing skb_shared check into 802.3 path to prevent potential use-after-free from happening. This also uses skb_share_check() instead of open-coding in tx path.
--- net/mac80211/tx.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
net/mac80211/tx.c +13 -23
@@ -2818,19 +2818,10 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,/* * If the skb is shared we need to obtain our own copy. */ -if (skb_shared (skb)) { -struct sk_buff *tmp_skb = skb; - -/* can't happen -- skb is a clone if info_id != 0 */ -WARN_ON (info_id); - - skb =skb_clone (skb,GFP_ATOMIC ); -kfree_skb (tmp_skb); - -if (!skb) { - ret = -ENOMEM ; - goto free; - } + skb =skb_share_check (skb,GFP_ATOMIC ); +if (unlikely (!skb)) { + ret = -ENOMEM ; + goto free; } hdr.frame_control = fc;
@@ -3541,15 +3532,9 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,/* after this point (skb is modified) we cannot return false */ -if (skb_shared (skb)) { -struct sk_buff *tmp_skb = skb; - - skb =skb_clone (skb,GFP_ATOMIC ); -kfree_skb (tmp_skb); - -if (!skb) -return true; - } + skb =skb_share_check (skb,GFP_ATOMIC ); +if (unlikely (!skb)) +return true;if ((hdr->frame_control &cpu_to_le16 (IEEE80211_STYPE_QOS_DATA )) &&ieee80211_amsdu_aggregate (sdata, sta, fast_tx, skb))
@@ -4439,7 +4424,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, struct net_device *dev, struct sta_info *sta, struct ieee80211_key *key, struct sk_buff *skb) { - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_tx_info *info;struct ieee80211_local *local = sdata->local;struct tid_ampdu_tx *tid_tx;u8 tid;
@@ -4454,6 +4439,11 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) goto out_free; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (unlikely (!skb)) +return ; + + info =IEEE80211_SKB_CB (skb);memset (info,0 ,sizeof (*info));ieee80211_aggr_check (sdata, sta, skb);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 30/54 wifi: mac80211: do not wake queues on a vif that is being stopped
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit f856373e2f31ffd340e47e2b00027bd4070f74b3 ]
When a vif is being removed and sdata->bss is cleared, __ieee80211_wake_txqs can still be called on it, which crashes as soon as sdata->bss is being dereferenced.
To fix this properly, check for SDATA_STATE_RUNNING before waking queues, and take the fq lock when setting it (to ensure that __ieee80211_wake_txqs observes the change when running on a different CPU)
--- net/mac80211/iface.c | 2 ++ net/mac80211/util.c | 3 +++ 2 files changed, 5 insertions(+)
net/mac80211/iface.c +2 -0
@@ -377,7 +377,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_dobool cancel_scan;struct cfg80211_nan_func *func; +spin_lock_bh (&local->fq.lock);clear_bit (SDATA_STATE_RUNNING , &sdata->state); +spin_unlock_bh (&local->fq.lock); cancel_scan =rcu_access_pointer (local->scan_sdata) == sdata;if (cancel_scan)
net/mac80211/util.c +3 -0
@@ -301,6 +301,9 @@ static void __ieee80211_wake_txqs(struct ieee80211_sub_if_data *sdata, int ac)local_bh_disable ();spin_lock (&fq->lock); +if (!test_bit (SDATA_STATE_RUNNING , &sdata->state)) + goto out; +if (sdata->vif.type ==NL80211_IFTYPE_AP ) ps = &sdata->bss->ps;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 31/54 wifi: cfg80211: Allow P2P client interface to indicate port authorization
In reply to Sasha LevinFrom: Vinayak Yadawad <[email protected]>
[ Upstream commit 8d70f33ed7207e82e51d5a4436c8ba2268a83b14 ]
In case of 4way handshake offload, cfg80211_port_authorized enables driver to indicate successful 4way handshake to cfg80211 layer. Currently this path of port authorization is restricted to interface type NL80211_IFTYPE_STATION. This patch extends the use of port authorization API for P2P client as well.
--- net/wireless/sme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/sme.c +2 -1
@@ -1031,7 +1031,8 @@ void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *bssid) {ASSERT_WDEV_LOCK (wdev); -if (WARN_ON (wdev->iftype !=NL80211_IFTYPE_STATION )) +if (WARN_ON (wdev->iftype !=NL80211_IFTYPE_STATION && + wdev->iftype !=NL80211_IFTYPE_P2P_CLIENT ))return ; if (WARN_ON(!wdev->current_bss) ||
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 32/54 drm: panel-orientation-quirks: Add quirk for the Lenovo Yoga Tablet 2 830
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 144248515246e52a3706de1ee928af29a63794b8 ]
The Lenovo Yoga Tablet 2 830F / 830L use a panel which has been mounted 90 degrees rotated. Add a quirk for this.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +15 -0
@@ -280,6 +280,21 @@ static const struct dmi_system_id orientation_data[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"), }, .driver_data = (void *)&lcd1200x1920_rightside_up, + }, { /* Lenovo Yoga Tablet 2 830F / 830L */ + .matches = { +/* +* Note this also matches the Lenovo Yoga Tablet 2 1050F/L +* since that uses the same mainboard. The resolution match +* will limit this to only matching on the 830F/L. Neither has +* any external video outputs so those are not a concern. +*/ +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corp." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"VALLEYVIEW C0 PLATFORM" ), +DMI_MATCH (DMI_BOARD_NAME ,"BYT-T FFD8" ), +/* Partial match on beginning of BIOS version */ + DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"), + }, + .driver_data = (void *)&lcd1200x1920_rightside_up, }, { /* OneGX1 Pro */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "SYSTEM_MANUFACTURER"),
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 33/54 nilfs2: fix incorrect masking of permission flags for symlinks
In reply to Sasha LevinFrom: Ryusuke Konishi <[email protected]>
[ Upstream commit 5924e6ec1585445f251ea92713eb15beb732622a ]
The permission flags of newly created symlinks are wrongly dropped on nilfs2 with the current umask value even though symlinks should have 777 (rwxrwxrwx) permissions:
$ umask 0022 $ touch file && ln -s file symlink; ls -l file symlink -rw-r--r--. 1 root root 0 Jun 23 16:29 file lrwxr-xr-x. 1 root root 4 Jun 23 16:29 symlink -> file
This fixes the bug by inserting a missing check that excludes symlinks.
--- fs/nilfs2/nilfs.h | 3 +++ 1 file changed, 3 insertions(+)
fs/nilfs2/nilfs.h +3 -0
@@ -198,6 +198,9 @@ static inline int nilfs_acl_chmod(struct inode *inode)static inline int nilfs_init_acl (struct inode *inode,struct inode *dir) { +if (S_ISLNK (inode->i_mode)) +return 0 ; + inode->i_mode &= ~current_umask ();return 0 ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 34/54 xdp: Fix spurious packet loss in generic XDP TX path
In reply to Sasha LevinFrom: Johan Almbladh <[email protected]>
[ Upstream commit 1fd6e5675336daf4747940b4285e84b0c114ae32 ]
The byte queue limits (BQL) mechanism is intended to move queuing from the driver to the network stack in order to reduce latency caused by excessive queuing in hardware. However, when transmitting or redirecting a packet using generic XDP, the qdisc layer is bypassed and there are no additional queues. Since netif_xmit_stopped() also takes BQL limits into account, but without having any alternative queuing, packets are silently dropped.
This patch modifies the drop condition to only consider cases when the driver itself cannot accept any more packets. This is analogous to the condition in __dev_direct_xmit(). Dropped packets are also counted on the device.
Bypassing the qdisc layer in the generic XDP TX path means that XDP packets are able to starve other packets going through a qdisc, and DDOS attacks will be more effective. In-driver-XDP use dedicated TX queues, so they do not have this starvation issue.
--- net/core/dev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/core/dev.c +6 -2
@@ -4792,7 +4792,10 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, }/* When doing generic XDP we have to bypass the qdisc layer and the -* network taps in order to match in-driver-XDP behavior. +* network taps in order to match in-driver-XDP behavior. This also means +* that XDP packets are able to starve other packets going through a qdisc, +* and DDOS attacks will be more effective. In-driver-XDP use dedicated TX +* queues, so they do not have this starvation issue. */ void generic_xdp_tx (struct sk_buff *skb,struct bpf_prog *xdp_prog) {
@@ -4804,7 +4807,7 @@ void generic_xdp_tx(struct sk_buff *skb, struct bpf_prog *xdp_prog) txq =netdev_core_pick_tx (dev, skb,NULL ); cpu =smp_processor_id ();HARD_TX_LOCK (dev, txq, cpu); -if (!netif_xmit_stopped (txq)) { +if (!netif_xmit_frozen_or_drv_stopped (txq)) { rc =netdev_start_xmit (skb, dev, txq,0 );if (dev_xmit_complete (rc)) free_skb = false;
@@ -4812,6 +4815,7 @@ void generic_xdp_tx(struct sk_buff *skb, struct bpf_prog *xdp_prog)HARD_TX_UNLOCK (dev, txq);if (free_skb) {trace_xdp_exception (dev, xdp_prog,XDP_TX ); +dev_core_stats_tx_dropped_inc (dev);kfree_skb (skb); } }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 35/54 drm/ssd130x: Fix pre-charge period setting
In reply to Sasha LevinFrom: Ezequiel Garcia <[email protected]>
[ Upstream commit b68277f19e31a25312c4acccadb5cf1502e52e84 ]
Fix small typo which causes the mask for the 'precharge1' setting to be used with the 'precharge2' value.
--- drivers/gpu/drm/solomon/ssd130x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/solomon/ssd130x.c +1 -1
@@ -293,7 +293,7 @@ static int ssd130x_init(struct ssd130x_device *ssd130x)/* Set precharge period in number of ticks from the internal clock */ precharge = (SSD130X_SET_PRECHARGE_PERIOD1_SET (ssd130x->prechargep1) | -SSD130X_SET_PRECHARGE_PERIOD1_SET (ssd130x->prechargep2)); +SSD130X_SET_PRECHARGE_PERIOD2_SET (ssd130x->prechargep2)); ret =ssd130x_write_cmd (ssd130x,2 ,SSD130X_SET_PRECHARGE_PERIOD , precharge);if (ret <0 )return ret;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 36/54 ASoC: ti: omap-mcbsp: duplicate sysfs error
In reply to Sasha LevinFrom: David Owens <[email protected]>
[ Upstream commit f0d96937d31c4615a6418e4bed5cee50a952040e ]
Convert to managed versions of sysfs and clk allocation to simplify unbinding and error handling in probe. Managed sysfs node creation specifically addresses the following error seen the second time probe is attempted after sdma_pcm_platform_register() previously requsted probe deferral:
sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'
--- sound/soc/ti/omap-mcbsp-priv.h | 2 -- sound/soc/ti/omap-mcbsp-st.c | 14 ++------------ sound/soc/ti/omap-mcbsp.c | 19 ++----------------- 3 files changed, 4 insertions(+), 31 deletions(-)
sound/soc/ti/omap-mcbsp-priv.h +0 -2
@@ -316,8 +316,6 @@ static inline int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg,/* Sidetone specific API */ int omap_mcbsp_st_init (struct platform_device *pdev); -void omap_mcbsp_st_cleanup (struct platform_device *pdev); -int omap_mcbsp_st_start (struct omap_mcbsp *mcbsp);int omap_mcbsp_st_stop (struct omap_mcbsp *mcbsp);
sound/soc/ti/omap-mcbsp-st.c +2 -12
@@ -347,7 +347,7 @@ int omap_mcbsp_st_init(struct platform_device *pdev)if (!st_data)return -ENOMEM ; - st_data->mcbsp_iclk =clk_get (mcbsp->dev,"ick" ); + st_data->mcbsp_iclk =devm_clk_get (mcbsp->dev,"ick" );if (IS_ERR (st_data->mcbsp_iclk)) {dev_warn (mcbsp->dev,"Failed to get ick, sidetone might be broken\n" );
@@ -359,7 +359,7 @@ int omap_mcbsp_st_init(struct platform_device *pdev)if (!st_data->io_base_st)return -ENOMEM ; - ret =sysfs_create_group (&mcbsp->dev->kobj, &sidetone_attr_group); + ret =devm_device_add_group (mcbsp->dev, &sidetone_attr_group);if (ret)return ret;
@@ -368,16 +368,6 @@ int omap_mcbsp_st_init(struct platform_device *pdev)return 0 ; } -void omap_mcbsp_st_cleanup (struct platform_device *pdev) -{ -struct omap_mcbsp *mcbsp =platform_get_drvdata (pdev); - -if (mcbsp->st_data) { -sysfs_remove_group (&mcbsp->dev->kobj, &sidetone_attr_group); -clk_put (mcbsp->st_data->mcbsp_iclk); - } -} -static int omap_mcbsp_st_info_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo) {
sound/soc/ti/omap-mcbsp.c +2 -17
@@ -702,8 +702,7 @@ static int omap_mcbsp_init(struct platform_device *pdev) mcbsp->max_tx_thres =max_thres (mcbsp) -0x10 ; mcbsp->max_rx_thres =max_thres (mcbsp) -0x10 ; - ret =sysfs_create_group (&mcbsp->dev->kobj, - &additional_attr_group); + ret =devm_device_add_group (mcbsp->dev, &additional_attr_group);if (ret) {dev_err (mcbsp->dev,"Unable to create additional controls\n" );
@@ -711,16 +710,7 @@ static int omap_mcbsp_init(struct platform_device *pdev) } } - ret =omap_mcbsp_st_init (pdev); -if (ret) - goto err_st; - -return 0 ; - -err_st: -if (mcbsp->pdata->buffer_size) -sysfs_remove_group (&mcbsp->dev->kobj, &additional_attr_group); -return ret; +return omap_mcbsp_st_init (pdev); }/*
@@ -1431,11 +1421,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev)if (cpu_latency_qos_request_active (&mcbsp->pm_qos_req))cpu_latency_qos_remove_request (&mcbsp->pm_qos_req); -if (mcbsp->pdata->buffer_size) -sysfs_remove_group (&mcbsp->dev->kobj, &additional_attr_group); - -omap_mcbsp_st_cleanup (pdev); -return 0 ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 37/54 ASoC: tlv320adcx140: Fix tx_mask check
In reply to Sasha LevinFrom: Sascha Hauer <[email protected]>
[ Upstream commit 7d90c8e6396ba245da16bedd789df6d669375408 ]
The tx_mask check doesn't reflect what the driver and the chip support.
The check currently checks for exactly two slots being enabled. The tlv320adcx140 supports anything between one and eight channels, so relax the check accordingly.
The tlv320adcx140 supports arbitrary tx_mask settings, but the driver currently only supports adjacent slots beginning with the first slot, so extend the check to check that the first slot is being used and that there are no holes in the tx_mask.
Leave a comment to make it's the driver that limits the tx_mask settings, not the chip itself.
While at it remove the set-but-unused struct adcx140p_priv::tdm_delay field.
--- sound/soc/codecs/tlv320adcx140.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
sound/soc/codecs/tlv320adcx140.c +6 -7
@@ -33,7 +33,6 @@ struct adcx140_priv {bool micbias_vg;unsigned int dai_fmt; -unsigned int tdm_delay;unsigned int slot_width; };
@@ -792,12 +791,13 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai, {struct snd_soc_component *component = codec_dai->component;struct adcx140_priv *adcx140 =snd_soc_component_get_drvdata (component); -unsigned int lsb; -/* TDM based on DSP mode requires slots to be adjacent */ - lsb =__ffs (tx_mask); -if ((lsb +1 ) !=__fls (tx_mask)) { -dev_err (component->dev,"Invalid mask, slots must be adjacent\n" ); +/* +* The chip itself supports arbitrary masks, but the driver currently +* only supports adjacent slots beginning at the first slot. +*/ +if (tx_mask !=GENMASK (__fls (tx_mask),0 )) { +dev_err (component->dev,"Only lower adjacent slots are supported\n" );return -EINVAL ; }
@@ -812,7 +812,6 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai,return -EINVAL ; } - adcx140->tdm_delay = lsb; adcx140->slot_width = slot_width;return 0 ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 38/54 ASoC: wcd9335: Use int array instead of bitmask for TX mixers
In reply to Sasha LevinFrom: Yassine Oudjana <[email protected]>
[ Upstream commit a5d6d28e2ea38dff017cb562dfbe0259d093a851 ]
Currently slim_tx_mixer_get reports all TX mixers as enabled when at least one is, due to it reading the entire tx_port_value bitmask without testing the specific bit corresponding to a TX port. Furthermore, using the same bitmask for all capture DAIs makes setting one mixer affect them all. To prevent this, and since the SLIM TX muxes effectively only connect to one of the mixers at a time, turn tx_port_value into an int array storing the DAI index each of the ports is connected to.
--- sound/soc/codecs/wcd9335.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
sound/soc/codecs/wcd9335.c +11 -6
@@ -342,7 +342,7 @@ struct wcd9335_codec {struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY ];unsigned int rx_port_value[WCD9335_RX_MAX ]; -unsigned int tx_port_value; +unsigned int tx_port_value[WCD9335_TX_MAX ];int hph_l_gain;int hph_r_gain;u32 rx_bias_count;
@@ -1328,8 +1328,13 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc,struct snd_soc_dapm_context *dapm =snd_soc_dapm_kcontrol_dapm (kc);struct wcd9335_codec *wcd =dev_get_drvdata (dapm->dev); +struct snd_soc_dapm_widget *widget =snd_soc_dapm_kcontrol_widget (kc); +struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kc->private_value; +int dai_id = widget->shift; +int port_id = mixer->shift; - ucontrol->value.integer.value[0 ] = wcd->tx_port_value; + ucontrol->value.integer.value[0 ] = wcd->tx_port_value[port_id] == dai_id;return 0 ; }
@@ -1352,12 +1357,12 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc,case AIF2_CAP :case AIF3_CAP :/* only add to the list if value not set */ -if (enable && !(wcd->tx_port_value &BIT (port_id))) { - wcd->tx_port_value |=BIT (port_id); +if (enable && wcd->tx_port_value[port_id] != dai_id) { + wcd->tx_port_value[port_id] = dai_id;list_add_tail (&wcd->tx_chs[port_id].list, &wcd->dai[dai_id].slim_ch_list); - }else if (!enable && (wcd->tx_port_value &BIT (port_id))) { - wcd->tx_port_value &= ~BIT (port_id); + }else if (!enable && wcd->tx_port_value[port_id] == dai_id) { + wcd->tx_port_value[port_id] =-1 ;list_del_init (&wcd->tx_chs[port_id].list); }break ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 39/54 ASoC: wm5102: Fix event generation for output compensation
In reply to Sasha LevinFrom: Charles Keepax <[email protected]>
[ Upstream commit 71b5ab96ffe6589abe7a2e302b83f7a426ebe099 ]
The output compensation controls always returns zero regardless of if the control value was updated. This results in missing notifications to user-space of the control change. Update the handling to return 1 when the value is changed.
--- sound/soc/codecs/wm5102.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
sound/soc/codecs/wm5102.c +17 -4
@@ -680,12 +680,17 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol, {struct snd_soc_component *component =snd_soc_kcontrol_component (kcontrol);struct arizona *arizona =dev_get_drvdata (component->dev->parent); +uint16_t dac_comp_coeff =get_unaligned_be16 (ucontrol->value.bytes.data); +int ret =0 ;mutex_lock (&arizona->dac_comp_lock); - arizona->dac_comp_coeff =get_unaligned_be16 (ucontrol->value.bytes.data); +if (arizona->dac_comp_coeff != dac_comp_coeff) { + arizona->dac_comp_coeff = dac_comp_coeff; + ret =1 ; + }mutex_unlock (&arizona->dac_comp_lock); -return 0 ; +return ret; } static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol,
@@ -706,12 +711,20 @@ static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol, {struct snd_soc_component *component =snd_soc_kcontrol_component (kcontrol);struct arizona *arizona =dev_get_drvdata (component->dev->parent); +struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret =0 ; + +if (ucontrol->value.integer.value[0 ] > mc->max) +return -EINVAL ;mutex_lock (&arizona->dac_comp_lock); - arizona->dac_comp_enabled = ucontrol->value.integer.value[0 ]; +if (arizona->dac_comp_enabled != ucontrol->value.integer.value[0 ]) { + arizona->dac_comp_enabled = ucontrol->value.integer.value[0 ]; + ret =1 ; + }mutex_unlock (&arizona->dac_comp_lock); -return 0 ; +return ret; }static const char *const wm5102_osr_text[] = {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 40/54 ASoC: wm8998: Fix event generation for input mux
In reply to Sasha LevinFrom: Charles Keepax <[email protected]>
[ Upstream commit 15b2e5d10ccf32a1a1ae7c636511e2f51320fdb5 ]
wm8998_inmux_put returns the value of snd_soc_dapm_mux_update_power, which returns a 1 if a path was found for the kcontrol. This is obviously different to the expected return a 1 if the control was updated value. This results in spurious notifications to user-space. Update the handling to only return a 1 when the value is changed.
--- sound/soc/codecs/wm8998.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
sound/soc/codecs/wm8998.c +14 -7
@@ -108,6 +108,7 @@ static int wm8998_inmux_put(struct snd_kcontrol *kcontrol,struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int mode_reg, mode_index;unsigned int mux, inmode, src_val, mode_val; +int change, ret; mux = ucontrol->value.enumerated.item[0 ];if (mux >1 )
@@ -137,14 +138,20 @@ static int wm8998_inmux_put(struct snd_kcontrol *kcontrol,snd_soc_component_update_bits (component, mode_reg,ARIZONA_IN1_MODE_MASK , mode_val); -snd_soc_component_update_bits (component, e->reg, -ARIZONA_IN1L_SRC_MASK | -ARIZONA_IN1L_SRC_SE_MASK , - src_val); + change =snd_soc_component_update_bits (component, e->reg, +ARIZONA_IN1L_SRC_MASK | +ARIZONA_IN1L_SRC_SE_MASK , + src_val); -return snd_soc_dapm_mux_update_power (dapm, kcontrol, - ucontrol->value.enumerated.item[0 ], - e,NULL ); + ret =snd_soc_dapm_mux_update_power (dapm, kcontrol, + ucontrol->value.enumerated.item[0 ], + e,NULL ); +if (ret <0 ) { +dev_err (arizona->dev,"Failed to update demux power state: %d\n" , ret); +return ret; + } + +return change; }static const char *const wm8998_inmux_texts[] = {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 41/54 ASoC: cs47l92: Fix event generation for OUT1 demux
In reply to Sasha LevinFrom: Charles Keepax <[email protected]>
[ Upstream commit 870d72ab9228575b2f005c9a23ea08787e0f63e6 ]
cs47l92_put_demux returns the value of snd_soc_dapm_mux_update_power, which returns a 1 if a path was found for the kcontrol. This is obviously different to the expected return a 1 if the control was updated value. This results in spurious notifications to user-space. Update the handling to only return a 1 when the value is changed.
--- sound/soc/codecs/cs47l92.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/codecs/cs47l92.c +7 -1
@@ -119,7 +119,13 @@ static int cs47l92_put_demux(struct snd_kcontrol *kcontrol, end:snd_soc_dapm_mutex_unlock (dapm); -return snd_soc_dapm_mux_update_power (dapm, kcontrol, mux, e,NULL ); + ret =snd_soc_dapm_mux_update_power (dapm, kcontrol, mux, e,NULL ); +if (ret <0 ) { +dev_err (madera->dev,"Failed to update demux power state: %d\n" , ret); +return ret; + } + +return change; } static SOC_ENUM_SINGLE_DECL(cs47l92_outdemux_enum,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 42/54 ASoC: arizona: Update arizona_aif_cfg_changed to use RX_BCLK_RATE
In reply to Sasha LevinFrom: Charles Keepax <[email protected]>
[ Upstream commit f99e930655f411453170a5f332e12c2d2748822e ]
Currently the function arizona_aif_cfg_changed uses the TX_BCLK_RATE, however this register is not used on wm8998. This was not noticed as previously snd_soc_component_read did not print an error message. However, now the log gets filled with error messages, further more the test for if the LRCLK changed will return spurious results.
Update the code to use the RX_BCLK_RATE register, the LRCLK parameters are written to both registers and the RX_BCLK_RATE register is used across all Arizona devices.
--- sound/soc/codecs/arizona.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/arizona.c +2 -2
@@ -1760,8 +1760,8 @@ static bool arizona_aif_cfg_changed(struct snd_soc_component *component,if (bclk != (val &ARIZONA_AIF1_BCLK_FREQ_MASK ))return true; - val =snd_soc_component_read (component, base +ARIZONA_AIF_TX_BCLK_RATE ); -if (lrclk != (val &ARIZONA_AIF1TX_BCPF_MASK )) + val =snd_soc_component_read (component, base +ARIZONA_AIF_RX_BCLK_RATE ); +if (lrclk != (val &ARIZONA_AIF1RX_BCPF_MASK ))return true; val =snd_soc_component_read (component, base +ARIZONA_AIF_FRAME_CTRL_1 );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 43/54 ASoC: qdsp6: fix potential memory leak in q6apm_get_audioreach_graph()
In reply to Sasha LevinFrom: Jianglei Nie <[email protected]>
[ Upstream commit df5b4aca7248dc5a5cae93f162eae0decf972e48 ]
q6apm_get_audioreach_graph() allocates a memory chunk for graph->graph with audioreach_alloc_graph_pkt(). When idr_alloc() fails, graph->graph is not released, which will lead to a memory leak.
We can release the graph->graph with kfree() when idr_alloc() fails to fix the memory leak.
--- sound/soc/qcom/qdsp6/q6apm.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/qcom/qdsp6/q6apm.c +1 -0
@@ -75,6 +75,7 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui id =idr_alloc (&apm->graph_idr, graph, graph_id, graph_id +1 ,GFP_KERNEL );if (id <0 ) {dev_err (apm->dev,"Unable to allocate graph id (%d)\n" , graph_id); +kfree (graph->graph);kfree (graph);mutex_unlock (&apm->lock);return ERR_PTR (id);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 44/54 ASoC: rt5640: Fix the wrong state of JD1 and JD2
In reply to Sasha LevinFrom: Oder Chiou <[email protected]>
[ Upstream commit 051dade346957d5b68ad986f497835805fa7a9dd ]
The patch fixes the wrong state of JD1 and JD2 while the bst1 or bst2 is power on in the HDA JD using.
--- sound/soc/codecs/rt5640.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
sound/soc/codecs/rt5640.c +22 -8
@@ -1984,7 +1984,12 @@ static int rt5640_set_bias_level(struct snd_soc_component *component,snd_soc_component_write (component,RT5640_PWR_DIG2 ,0x0000 );snd_soc_component_write (component,RT5640_PWR_VOL ,0x0000 );snd_soc_component_write (component,RT5640_PWR_MIXER ,0x0000 ); -snd_soc_component_write (component,RT5640_PWR_ANLG1 ,0x0000 ); +if (rt5640->jd_src ==RT5640_JD_SRC_HDA_HEADER ) +snd_soc_component_write (component,RT5640_PWR_ANLG1 , +0x0018 ); +else +snd_soc_component_write (component,RT5640_PWR_ANLG1 , +0x0000 );snd_soc_component_write (component,RT5640_PWR_ANLG2 ,0x0000 );break ;
@@ -2393,9 +2398,15 @@ static void rt5640_jack_work(struct work_struct *work)static irqreturn_t rt5640_irq (int irq,void *data) {struct rt5640_priv *rt5640 = data; +int delay =0 ; + +if (rt5640->jd_src ==RT5640_JD_SRC_HDA_HEADER ) { +cancel_delayed_work_sync (&rt5640->jack_work); + delay =100 ; + }if (rt5640->jack) -queue_delayed_work (system_long_wq, &rt5640->jack_work,0 ); +queue_delayed_work (system_long_wq, &rt5640->jack_work, delay);return IRQ_HANDLED ; }
@@ -2580,6 +2591,12 @@ static void rt5640_enable_hda_jack_detect(snd_soc_component_update_bits (component,RT5640_DUMMY1 ,0x400 ,0x0 ); +snd_soc_component_update_bits (component,RT5640_PWR_ANLG1 , +RT5640_PWR_VREF2 ,RT5640_PWR_VREF2 ); +usleep_range (10000 ,15000 ); +snd_soc_component_update_bits (component,RT5640_PWR_ANLG1 , +RT5640_PWR_FV2 ,RT5640_PWR_FV2 ); + rt5640->jack = jack; ret = request_irq(rt5640->irq, rt5640_irq,
@@ -2696,16 +2713,13 @@ static int rt5640_probe(struct snd_soc_component *component)if (device_property_read_u32 (component->dev,"realtek,jack-detect-source" , &val) ==0 ) { -if (val <=RT5640_JD_SRC_GPIO4 ) { +if (val <=RT5640_JD_SRC_GPIO4 ) rt5640->jd_src = val <<RT5640_JD_SFT ; - }else if (val ==RT5640_JD_SRC_HDA_HEADER ) { +else if (val ==RT5640_JD_SRC_HDA_HEADER ) rt5640->jd_src =RT5640_JD_SRC_HDA_HEADER ; -snd_soc_component_update_bits (component,RT5640_DUMMY1 , -0x0300 ,0x0 ); - }else { +else dev_warn (component->dev,"Warning: Invalid jack-detect-source value: %d, leaving jack-detect disabled\n" , val); - } }if (!device_property_read_bool (component->dev,"realtek,jack-detect-not-inverted" ))
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 45/54 scsi: target: Fix WRITE_SAME No Data Buffer crash
In reply to Sasha LevinFrom: Mike Christie <[email protected]>
[ Upstream commit ccd3f449052449a917a3e577d8ba0368f43b8f29 ]
In newer version of the SBC specs, we have a NDOB bit that indicates there is no data buffer that gets written out. If this bit is set using commands like "sg_write_same --ndob" we will crash in target_core_iblock/file's execute_write_same handlers when we go to access the se_cmd->t_data_sg because its NULL.
This patch adds a check for the NDOB bit in the common WRITE SAME code because we don't support it. And, it adds a check for zero SG elements in each handler in case the initiator tries to send a normal WRITE SAME with no data buffer.
--- drivers/target/target_core_file.c | 3 +++ drivers/target/target_core_iblock.c | 4 ++++ drivers/target/target_core_sbc.c | 6 ++++++ 3 files changed, 13 insertions(+)
drivers/target/target_core_file.c +3 -0
@@ -448,6 +448,9 @@ fd_execute_write_same(struct se_cmd *cmd)return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; } +if (!cmd->t_data_nents) +return TCM_INVALID_CDB_FIELD ; +if (cmd->t_data_nents >1 || cmd->t_data_sg[0 ].length != cmd->se_dev->dev_attrib.block_size) { pr_err("WRITE_SAME: Illegal SGL t_data_nents: %u length: %u"
drivers/target/target_core_iblock.c +4 -0
@@ -494,6 +494,10 @@ iblock_execute_write_same(struct se_cmd *cmd) " backends not supported\n");return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; } + +if (!cmd->t_data_nents) +return TCM_INVALID_CDB_FIELD ; + sg = &cmd->t_data_sg[0 ]; if (cmd->t_data_nents > 1 ||
drivers/target/target_core_sbc.c +6 -0
@@ -312,6 +312,12 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char flags, struct sbc_ops *oppr_warn ("WRITE SAME with ANCHOR not supported\n" );return TCM_INVALID_CDB_FIELD ; } + +if (flags &0x01 ) { +pr_warn ("WRITE SAME with NDOB not supported\n" ); +return TCM_INVALID_CDB_FIELD ; + } +/* * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting * translated into block discard requests within backend code.
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 46/54 x86/kexec: Disable RET on kexec
In reply to Sasha LevinFrom: Konrad Rzeszutek Wilk <[email protected]>
[ Upstream commit 697977d8415d61f3acbc4ee6d564c9dcf0309507 ]
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_mapped) 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_mapped) 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_mapped) 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)
@@ -105,7 +106,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)
@@ -200,7 +203,9 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) xorl %r14d, %r14d xorl %r15d, %r15d - RET + ANNOTATE_UNRET_SAFE + ret + int3 1: popq %rdx
@@ -219,7 +224,9 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) 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)
@@ -241,7 +248,9 @@ SYM_CODE_START_LOCAL_NOALIGN(virtual_mapped) popq %r12 popq %rbp popq %rbx - RET + ANNOTATE_UNRET_SAFE + ret + int3 SYM_CODE_END(virtual_mapped) /* Do the copies */
@@ -298,7 +307,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
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 47/54 platform/x86: gigabyte-wmi: add support for B660I AORUS PRO DDR4
In reply to Sasha LevinFrom: Pär Eriksson <[email protected]>
[ Upstream commit 5d62261a65698c1ee4e71f00963b269282015b1e ]
Add support for the B660I AORUS PRO DDR4.
--- drivers/platform/x86/gigabyte-wmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/gigabyte-wmi.c +1 -0
@@ -150,6 +150,7 @@ static const struct dmi_system_id gigabyte_wmi_known_working_platforms[] = {DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME ("B550M AORUS PRO-P" ),DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME ("B550M DS3H" ),DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME ("B660 GAMING X DDR4" ), +DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME ("B660I AORUS PRO DDR4" ),DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME ("Z390 I AORUS PRO WIFI-CF" ),DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME ("X570 AORUS ELITE" ), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 GAMING X"),
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 48/54 platform/x86: asus-wmi: Add key mappings
In reply to Sasha LevinFrom: Misaka19465 <[email protected]>
[ Upstream commit f56e676a7f1ca7de9002526df3d2ee0e47dfd8ce ]
On laptops like ASUS TUF Gaming A15, which have hotkeys to start Armoury Crate or AURA Sync, these hotkeys are unavailable. This patch add mappings for them.
--- drivers/platform/x86/asus-nb-wmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/x86/asus-nb-wmi.c +2 -0
@@ -522,6 +522,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, { KE_KEY, 0x32, { KEY_MUTE } }, { KE_KEY, 0x35, { KEY_SCREENLOCK } }, + { KE_KEY, 0x38, { KEY_PROG3 } }, /* Armoury Crate */ { KE_KEY, 0x40, { KEY_PREVIOUSSONG } }, { KE_KEY, 0x41, { KEY_NEXTSONG } }, { KE_KEY, 0x43, { KEY_STOPCD } }, /* Stop/Eject */
@@ -573,6 +574,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xA5, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV + HDMI */ { KE_KEY, 0xA6, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV + HDMI */ { KE_KEY, 0xA7, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + HDMI */ + { KE_KEY, 0xB3, { KEY_PROG4 } }, /* AURA */ { KE_KEY, 0xB5, { KEY_CALC } }, { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } },
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 49/54 platform/x86: intel_atomisp2_led: Also turn off the always-on camera LED on the Asus T100TAF
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit b0d55983b2b885f6f96d6d6898d27a60bd9dc9a2 ]
Like the Asus T100TA the Asus T100TAF has a camera LED which is always on by default and both also use the same GPIO for the LED.
Relax the DMI match for the Asus T100TA so that it also matches the T100TAF.
--- drivers/platform/x86/intel/atomisp2/led.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/atomisp2/led.c +2 -1
@@ -50,7 +50,8 @@ static const struct dmi_system_id atomisp2_led_systems[] __initconst = { { .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"), + /* Non exact match to also match T100TAF */ + DMI_MATCH(DMI_PRODUCT_NAME, "T100TA"), }, .driver_data = &asus_t100ta_lookup, },
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 50/54 scsi: ufs: core: Fix missing clk change notification on host reset
In reply to Sasha LevinFrom: Po-Wen Kao <[email protected]>
[ Upstream commit 52a518019ca187227b786f8b8ee20869a97f3af4 ]
In ufshcd_host_reset_and_restore(), ufshcd_set_clk_freq() is called to scale clock rate. However, this did not call vops->clk_scale_notify() to inform platform driver of clock change.
Call ufshcd_scale_clks() instead so that clock change can be properly handled.
--- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
@@ -7235,7 +7235,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) hba->silence_err_logs = false;/* scale up clocks to max frequency before full reinitialization */ -ufshcd_set_clk_freq (hba, true); +ufshcd_scale_clks (hba, true); err =ufshcd_hba_enable (hba);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 51/54 scsi: pm80xx: Fix 'Unknown' max/min linkrate
In reply to Sasha LevinFrom: Changyuan Lyu <[email protected]>
[ Upstream commit e78276cadb669d3e55cffe66bd166ff3c8572e38 ]
Currently, the data flow of the max/min linkrate in the driver is
* in pm8001_get_lrate_mode():
hardcoded value ==> struct sas_phy
* in pm8001_bytes_dmaed():
struct pm8001_phy ==> struct sas_phy
* in pm8001_phy_control():
libsas data ==> struct pm8001_phy
Since pm8001_bytes_dmaed() follows pm8001_get_lrate_mode(), and the fields in struct pm8001_phy are not initialized, sysfs /sys/class/sas_phy/phy-*/maximum_linkrate always shows Unknown.
To fix the issue, change the dataflow to the following:
* in pm8001_phy_init():
initial value ==> struct pm8001_phy
* in pm8001_get_lrate_mode():
struct pm8001_phy ==> struct sas_phy
* in pm8001_phy_control():
libsas data ==> struct pm8001_phy
For negotiated linkrate, the current dataflow is:
* in pm8001_get_lrate_mode():
iomb data ==> struct asd_sas_phy ==> struct sas_phy
* in pm8001_bytes_dmaed():
struct asd_sas_phy ==> struct sas_phy
Since pm8001_bytes_dmaed() follows pm8001_get_lrate_mode(), the assignment statements in pm8001_bytes_dmaed() are unnecessary and cleaned up.
--- drivers/scsi/pm8001/pm8001_hwi.c | 19 +++---------------- drivers/scsi/pm8001/pm8001_init.c | 2 ++ 2 files changed, 5 insertions(+), 16 deletions(-)
drivers/scsi/pm8001/pm8001_hwi.c +3 -16
@@ -3145,15 +3145,6 @@ void pm8001_bytes_dmaed(struct pm8001_hba_info *pm8001_ha, int i)if (!phy->phy_attached)return ; -if (sas_phy->phy) { -struct sas_phy *sphy = sas_phy->phy; - sphy->negotiated_linkrate = sas_phy->linkrate; - sphy->minimum_linkrate = phy->minimum_linkrate; - sphy->minimum_linkrate_hw =SAS_LINK_RATE_1_5_GBPS ; - sphy->maximum_linkrate = phy->maximum_linkrate; - sphy->maximum_linkrate_hw = phy->maximum_linkrate; - } -if (phy->phy_type &PORT_TYPE_SAS ) {struct sas_identify_frame *id; id = (struct sas_identify_frame *)phy->frame_rcvd;
@@ -3177,26 +3168,22 @@ void pm8001_get_lrate_mode(struct pm8001_phy *phy, u8 link_rate)switch (link_rate) {case PHY_SPEED_120 : phy->sas_phy.linkrate =SAS_LINK_RATE_12_0_GBPS ; - phy->sas_phy.phy->negotiated_linkrate =SAS_LINK_RATE_12_0_GBPS ;break ;case PHY_SPEED_60 : phy->sas_phy.linkrate =SAS_LINK_RATE_6_0_GBPS ; - phy->sas_phy.phy->negotiated_linkrate =SAS_LINK_RATE_6_0_GBPS ;break ;case PHY_SPEED_30 : phy->sas_phy.linkrate =SAS_LINK_RATE_3_0_GBPS ; - phy->sas_phy.phy->negotiated_linkrate =SAS_LINK_RATE_3_0_GBPS ;break ;case PHY_SPEED_15 : phy->sas_phy.linkrate =SAS_LINK_RATE_1_5_GBPS ; - phy->sas_phy.phy->negotiated_linkrate =SAS_LINK_RATE_1_5_GBPS ;break ; } sas_phy->negotiated_linkrate = phy->sas_phy.linkrate; - sas_phy->maximum_linkrate_hw =SAS_LINK_RATE_6_0_GBPS ; + sas_phy->maximum_linkrate_hw = phy->maximum_linkrate; sas_phy->minimum_linkrate_hw =SAS_LINK_RATE_1_5_GBPS ; - sas_phy->maximum_linkrate =SAS_LINK_RATE_6_0_GBPS ; - sas_phy->minimum_linkrate =SAS_LINK_RATE_1_5_GBPS ; + sas_phy->maximum_linkrate = phy->maximum_linkrate; + sas_phy->minimum_linkrate = phy->minimum_linkrate; }/**
drivers/scsi/pm8001/pm8001_init.c +2 -0
@@ -143,6 +143,8 @@ static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id)struct asd_sas_phy *sas_phy = &phy->sas_phy; phy->phy_state =PHY_LINK_DISABLE ; phy->pm8001_ha = pm8001_ha; + phy->minimum_linkrate =SAS_LINK_RATE_1_5_GBPS ; + phy->maximum_linkrate =SAS_LINK_RATE_6_0_GBPS ; sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ?1 :0 ; sas_phy->class =SAS ; sas_phy->iproto =SAS_PROTOCOL_ALL ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 52/54 scsi: pm80xx: Set stopped phy's linkrate to Disabled
In reply to Sasha LevinFrom: Changyuan Lyu <[email protected]>
[ Upstream commit 355bf2e036c954317ddc4a9618b4f7e38ea5a970 ]
Negotiated link rate needs to be updated to 'Disabled' when phy is stopped.
--- drivers/scsi/pm8001/pm80xx_hwi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/pm8001/pm80xx_hwi.c +5 -1
@@ -3723,8 +3723,12 @@ static int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)pm8001_dbg (pm8001_ha,MSG ,"phy:0x%x status:0x%x\n" , phyid, status);if (status ==PHY_STOP_SUCCESS || - status ==PHY_STOP_ERR_DEVICE_ATTACHED ) + status ==PHY_STOP_ERR_DEVICE_ATTACHED ) { phy->phy_state =PHY_LINK_DISABLE ; + phy->sas_phy.phy->negotiated_linkrate =SAS_PHY_DISABLED ; + phy->sas_phy.linkrate =SAS_PHY_DISABLED ; + } +return 0 ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 53/54 KVM: nVMX: Always enable TSC scaling for L2 when it was enabled for L1
In reply to Sasha LevinFrom: Vitaly Kuznetsov <[email protected]>
[ Upstream commit 99482726452bdf8be9325199022b17fa6d7d58fe ]
Windows 10/11 guests with Hyper-V role (WSL2) enabled are observed to hang upon boot or shortly after when a non-default TSC frequency was set for L1. The issue is observed on a host where TSC scaling is supported. The problem appears to be that Windows doesn't use TSC frequency for its guests even when the feature is advertised and KVM filters SECONDARY_EXEC_TSC_SCALING out when creating L2 controls from L1's. This leads to L2 running with the default frequency (matching host's) while L1 is running with an altered one.
Keep SECONDARY_EXEC_TSC_SCALING in secondary exec controls for L2 when it was set for L1. TSC_MULTIPLIER is already correctly computed and written by prepare_vmcs02().
Message-Id: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kvm/vmx/nested.c +0 -1
@@ -2279,7 +2279,6 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct loaded_vmcs *vmcs0SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |SECONDARY_EXEC_APIC_REGISTER_VIRT |SECONDARY_EXEC_ENABLE_VMFUNC | -SECONDARY_EXEC_TSC_SCALING | SECONDARY_EXEC_DESC); if (nested_cpu_has(vmcs12,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 54/54 ubsan: disable UBSAN_DIV_ZERO for clang
In reply to Sasha LevinFrom: Nick Desaulniers <[email protected]>
[ Upstream commit e5d523f1ae8f2cef01f8e071aeee432654166708 ]
Building with UBSAN_DIV_ZERO with clang produces numerous fallthrough warnings from objtool.
In the case of uncheck division, UBSAN_DIV_ZERO may introduce new control flow to check for division by zero.
Because the result of the division is undefined, LLVM may optimize the control flow such that after the call to __ubsan_handle_divrem_overflow doesn't matter. If panic_on_warn was set, __ubsan_handle_divrem_overflow would panic.
The problem is is that panic_on_warn is run time configurable. If it's disabled, then we cannot guarantee that we will be able to recover safely. Disable this config for clang until we can come up with a solution in LLVM.
--- lib/Kconfig.ubsan | 3 +++ 1 file changed, 3 insertions(+)
lib/Kconfig.ubsan +3 -0
@@ -84,6 +84,9 @@ config UBSAN_SHIFT config UBSAN_DIV_ZERO bool "Perform checking for integer divide-by-zero" depends on $(cc-option,-fsanitize=integer-divide-by-zero) + # https://github.com/ClangBuiltLinux/linux/issues/1657 + # https://github.com/llvm/llvm-project/issues/56289 + depends on !CC_IS_CLANG help This option enables -fsanitize=integer-divide-by-zero which checks for integer division by zero. This is effectively redundant with the
Signature · 1 line
2.35.1