···15151616compatible : Must be "ams,as3645a".1717reg : The I2C address of the device. Typically 0x30.1818+#address-cells : 11919+#size-cells : 0182019212020-Required properties of the "flash" child node2121-=============================================2222+Required properties of the flash child node (0)2323+===============================================22242525+reg: 02326flash-timeout-us: Flash timeout in microseconds. The value must be in2427 the range [100000, 850000] and divisible by 50000.2528flash-max-microamp: Maximum flash current in microamperes. Has to be···3633 and divisible by 50000.373438353939-Optional properties of the "flash" child node4040-=============================================3636+Optional properties of the flash child node3737+===========================================41384239label : The label of the flash LED.434044414545-Required properties of the "indicator" child node4646-=================================================4242+Required properties of the indicator child node (1)4343+===================================================47444545+reg: 14846led-max-microamp: Maximum indicator current. The allowed values are4947 2500, 5000, 7500 and 10000.50485151-Optional properties of the "indicator" child node5252-=================================================4949+Optional properties of the indicator child node5050+===============================================53515452label : The label of the indicator LED.5553···5955=======60566157 as3645a@30 {5858+ #address-cells: 15959+ #size-cells: 06260 reg = <0x30>;6361 compatible = "ams,as3645a";6464- flash {6262+ flash@0 {6363+ reg = <0x0>;6564 flash-timeout-us = <150000>;6665 flash-max-microamp = <320000>;6766 led-max-microamp = <60000>;6867 ams,input-max-microamp = <1750000>;6968 label = "as3645a:flash";7069 };7171- indicator {7070+ indicator@1 {7171+ reg = <0x1>;7272 led-max-microamp = <10000>;7373 label = "as3645a:indicator";7474 };
+6
MAINTAINERS
···85978597S: Maintained85988598F: drivers/media/rc/mtk-cir.c8599859986008600+MEDIATEK PMIC LED DRIVER86018601+M: Sean Wang <sean.wang@mediatek.com>86028602+S: Maintained86038603+F: drivers/leds/leds-mt6323.c86048604+F: Documentation/devicetree/bindings/leds/leds-mt6323.txt86058605+86008606MEDIATEK ETHERNET DRIVER86018607M: Felix Fietkau <nbd@openwrt.org>86028608M: John Crispin <john@phrozen.org>
···3939# Endianness selection4040choice4141 prompt "Endianness selection"4242- default CPU_BIG_ENDIAN4242+ default CPU_LITTLE_ENDIAN4343 help4444 microblaze architectures can be configured for either little or4545 big endian formats. Be sure to select the appropriate mode.
···165165 unsigned long attrs)166166{167167#ifdef CONFIG_MMU168168- unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;168168+ unsigned long user_count = vma_pages(vma);169169 unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;170170 unsigned long off = vma->vm_pgoff;171171 unsigned long pfn;
+13-1
arch/powerpc/kvm/book3s_hv_rmhandlers.S
···11211121BEGIN_FTR_SECTION11221122 mtspr SPRN_PPR, r011231123END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)11241124+11251125+/* Move canary into DSISR to check for later */11261126+BEGIN_FTR_SECTION11271127+ li r0, 0x7fff11281128+ mtspr SPRN_HDSISR, r011291129+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)11301130+11241131 ld r0, VCPU_GPR(R0)(r4)11251132 ld r4, VCPU_GPR(R4)(r4)11261133···19631956kvmppc_hdsi:19641957 ld r3, VCPU_KVM(r9)19651958 lbz r0, KVM_RADIX(r3)19661966- cmpwi r0, 019671959 mfspr r4, SPRN_HDAR19681960 mfspr r6, SPRN_HDSISR19611961+BEGIN_FTR_SECTION19621962+ /* Look for DSISR canary. If we find it, retry instruction */19631963+ cmpdi r6, 0x7fff19641964+ beq 6f19651965+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)19661966+ cmpwi r0, 019691967 bne .Lradix_hdsi /* on radix, just save DAR/DSISR/ASDR */19701968 /* HPTE not found fault or protection fault? */19711969 andis. r0, r6, (DSISR_NOHPTE | DSISR_PROTFAULT)@h
···6363 case INTEL_FAM6_ATOM_SILVERMONT1:6464 case INTEL_FAM6_ATOM_SILVERMONT2:6565 case INTEL_FAM6_ATOM_AIRMONT:6666+6767+ case INTEL_FAM6_ATOM_GOLDMONT:6868+ case INTEL_FAM6_ATOM_DENVERTON:6969+7070+ case INTEL_FAM6_ATOM_GEMINI_LAKE:7171+7272+ case INTEL_FAM6_XEON_PHI_KNL:7373+ case INTEL_FAM6_XEON_PHI_KNM:6674 if (idx == PERF_MSR_SMI)6775 return true;6876 break;
+1-1
arch/x86/ia32/ia32_signal.c
···231231 ksig->ka.sa.sa_restorer)232232 sp = (unsigned long) ksig->ka.sa.sa_restorer;233233234234- if (fpu->fpstate_active) {234234+ if (fpu->initialized) {235235 unsigned long fx_aligned, math_size;236236237237 sp = fpu__alloc_mathframe(sp, 1, &fx_aligned, &math_size);
+5-3
arch/x86/include/asm/asm.h
···1111# define __ASM_FORM_COMMA(x) " " #x ","1212#endif13131414-#ifdef CONFIG_X86_321414+#ifndef __x86_64__1515+/* 32 bit */1516# define __ASM_SEL(a,b) __ASM_FORM(a)1617# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a)1718#else1919+/* 64 bit */1820# define __ASM_SEL(a,b) __ASM_FORM(b)1921# define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b)2022#endif···141139 * gets set up by the containing function. If you forget to do this, objtool142140 * may print a "call without frame pointer save/setup" warning.143141 */144144-register unsigned int __asm_call_sp asm("esp");145145-#define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp)142142+register unsigned long current_stack_pointer asm(_ASM_SP);143143+#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)146144#endif147145148146#endif /* _ASM_X86_ASM_H */
+22-68
arch/x86/include/asm/fpu/internal.h
···2323/*2424 * High level FPU state handling functions:2525 */2626-extern void fpu__activate_curr(struct fpu *fpu);2727-extern void fpu__activate_fpstate_read(struct fpu *fpu);2828-extern void fpu__activate_fpstate_write(struct fpu *fpu);2929-extern void fpu__current_fpstate_write_begin(void);3030-extern void fpu__current_fpstate_write_end(void);2626+extern void fpu__initialize(struct fpu *fpu);2727+extern void fpu__prepare_read(struct fpu *fpu);2828+extern void fpu__prepare_write(struct fpu *fpu);3129extern void fpu__save(struct fpu *fpu);3230extern void fpu__restore(struct fpu *fpu);3331extern int fpu__restore_sig(void __user *buf, int ia32_frame);···118120 err; \119121})120122121121-#define check_insn(insn, output, input...) \122122-({ \123123- int err; \123123+#define kernel_insn(insn, output, input...) \124124 asm volatile("1:" #insn "\n\t" \125125 "2:\n" \126126- ".section .fixup,\"ax\"\n" \127127- "3: movl $-1,%[err]\n" \128128- " jmp 2b\n" \129129- ".previous\n" \130130- _ASM_EXTABLE(1b, 3b) \131131- : [err] "=r" (err), output \132132- : "0"(0), input); \133133- err; \134134-})126126+ _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_fprestore) \127127+ : output : input)135128136129static inline int copy_fregs_to_user(struct fregs_state __user *fx)137130{···142153143154static inline void copy_kernel_to_fxregs(struct fxregs_state *fx)144155{145145- int err;146146-147156 if (IS_ENABLED(CONFIG_X86_32)) {148148- err = check_insn(fxrstor %[fx], "=m" (*fx), [fx] "m" (*fx));157157+ kernel_insn(fxrstor %[fx], "=m" (*fx), [fx] "m" (*fx));149158 } else {150159 if (IS_ENABLED(CONFIG_AS_FXSAVEQ)) {151151- err = check_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx));160160+ kernel_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx));152161 } else {153162 /* See comment in copy_fxregs_to_kernel() below. */154154- err = check_insn(rex64/fxrstor (%[fx]), "=m" (*fx), [fx] "R" (fx), "m" (*fx));163163+ kernel_insn(rex64/fxrstor (%[fx]), "=m" (*fx), [fx] "R" (fx), "m" (*fx));155164 }156165 }157157- /* Copying from a kernel buffer to FPU registers should never fail: */158158- WARN_ON_FPU(err);159166}160167161168static inline int copy_user_to_fxregs(struct fxregs_state __user *fx)···168183169184static inline void copy_kernel_to_fregs(struct fregs_state *fx)170185{171171- int err = check_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));172172-173173- WARN_ON_FPU(err);186186+ kernel_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));174187}175188176189static inline int copy_user_to_fregs(struct fregs_state __user *fx)···264281 * Use XRSTORS to restore context if it is enabled. XRSTORS supports compact265282 * XSAVE area format.266283 */267267-#define XSTATE_XRESTORE(st, lmask, hmask, err) \284284+#define XSTATE_XRESTORE(st, lmask, hmask) \268285 asm volatile(ALTERNATIVE(XRSTOR, \269286 XRSTORS, X86_FEATURE_XSAVES) \270287 "\n" \271271- "xor %[err], %[err]\n" \272288 "3:\n" \273273- ".pushsection .fixup,\"ax\"\n" \274274- "4: movl $-2, %[err]\n" \275275- "jmp 3b\n" \276276- ".popsection\n" \277277- _ASM_EXTABLE(661b, 4b) \278278- : [err] "=r" (err) \289289+ _ASM_EXTABLE_HANDLE(661b, 3b, ex_handler_fprestore)\290290+ : \279291 : "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \280292 : "memory")281293···314336 else315337 XSTATE_OP(XRSTOR, xstate, lmask, hmask, err);316338317317- /* We should never fault when copying from a kernel buffer: */339339+ /*340340+ * We should never fault when copying from a kernel buffer, and the FPU341341+ * state we set at boot time should be valid.342342+ */318343 WARN_ON_FPU(err);319344}320345···331350 u32 hmask = mask >> 32;332351 int err;333352334334- WARN_ON(!alternatives_patched);353353+ WARN_ON_FPU(!alternatives_patched);335354336355 XSTATE_XSAVE(xstate, lmask, hmask, err);337356···346365{347366 u32 lmask = mask;348367 u32 hmask = mask >> 32;349349- int err;350368351351- XSTATE_XRESTORE(xstate, lmask, hmask, err);352352-353353- /* We should never fault when copying from a kernel buffer: */354354- WARN_ON_FPU(err);369369+ XSTATE_XRESTORE(xstate, lmask, hmask);355370}356371357372/*···503526 */504527static inline void fpregs_deactivate(struct fpu *fpu)505528{506506- WARN_ON_FPU(!fpu->fpregs_active);507507-508508- fpu->fpregs_active = 0;509529 this_cpu_write(fpu_fpregs_owner_ctx, NULL);510530 trace_x86_fpu_regs_deactivated(fpu);511531}512532513533static inline void fpregs_activate(struct fpu *fpu)514534{515515- WARN_ON_FPU(fpu->fpregs_active);516516-517517- fpu->fpregs_active = 1;518535 this_cpu_write(fpu_fpregs_owner_ctx, fpu);519536 trace_x86_fpu_regs_activated(fpu);520520-}521521-522522-/*523523- * The question "does this thread have fpu access?"524524- * is slightly racy, since preemption could come in525525- * and revoke it immediately after the test.526526- *527527- * However, even in that very unlikely scenario,528528- * we can just assume we have FPU access - typically529529- * to save the FP state - we'll just take a #NM530530- * fault and get the FPU access back.531531- */532532-static inline int fpregs_active(void)533533-{534534- return current->thread.fpu.fpregs_active;535537}536538537539/*···527571static inline void528572switch_fpu_prepare(struct fpu *old_fpu, int cpu)529573{530530- if (old_fpu->fpregs_active) {574574+ if (old_fpu->initialized) {531575 if (!copy_fpregs_to_fpstate(old_fpu))532576 old_fpu->last_cpu = -1;533577 else534578 old_fpu->last_cpu = cpu;535579536580 /* But leave fpu_fpregs_owner_ctx! */537537- old_fpu->fpregs_active = 0;538581 trace_x86_fpu_regs_deactivated(old_fpu);539582 } else540583 old_fpu->last_cpu = -1;···550595static inline void switch_fpu_finish(struct fpu *new_fpu, int cpu)551596{552597 bool preload = static_cpu_has(X86_FEATURE_FPU) &&553553- new_fpu->fpstate_active;598598+ new_fpu->initialized;554599555600 if (preload) {556601 if (!fpregs_state_valid(new_fpu, cpu))···572617 struct fpu *fpu = ¤t->thread.fpu;573618574619 preempt_disable();575575- if (!fpregs_active())576576- fpregs_activate(fpu);620620+ fpregs_activate(fpu);577621 preempt_enable();578622}579623
+6-26
arch/x86/include/asm/fpu/types.h
···6868/* Default value for fxregs_state.mxcsr: */6969#define MXCSR_DEFAULT 0x1f8070707171+/* Copy both mxcsr & mxcsr_flags with a single u64 memcpy: */7272+#define MXCSR_AND_FLAGS_SIZE sizeof(u64)7373+7174/*7275 * Software based FPU emulation state. This is arbitrary really,7376 * it matches the x87 format to make it easier to understand:···293290 unsigned int last_cpu;294291295292 /*296296- * @fpstate_active:293293+ * @initialized:297294 *298298- * This flag indicates whether this context is active: if the task295295+ * This flag indicates whether this context is initialized: if the task299296 * is not running then we can restore from this context, if the task300297 * is running then we should save into this context.301298 */302302- unsigned char fpstate_active;303303-304304- /*305305- * @fpregs_active:306306- *307307- * This flag determines whether a given context is actively308308- * loaded into the FPU's registers and that those registers309309- * represent the task's current FPU state.310310- *311311- * Note the interaction with fpstate_active:312312- *313313- * # task does not use the FPU:314314- * fpstate_active == 0315315- *316316- * # task uses the FPU and regs are active:317317- * fpstate_active == 1 && fpregs_active == 1318318- *319319- * # the regs are inactive but still match fpstate:320320- * fpstate_active == 1 && fpregs_active == 0 && fpregs_owner == fpu321321- *322322- * The third state is what we use for the lazy restore optimization323323- * on lazy-switching CPUs.324324- */325325- unsigned char fpregs_active;299299+ unsigned char initialized;326300327301 /*328302 * @state:
+8-4
arch/x86/include/asm/fpu/xstate.h
···4848void *get_xsave_addr(struct xregs_state *xsave, int xstate);4949const void *get_xsave_field_ptr(int xstate_field);5050int using_compacted_format(void);5151-int copyout_from_xsaves(unsigned int pos, unsigned int count, void *kbuf,5252- void __user *ubuf, struct xregs_state *xsave);5353-int copyin_to_xsaves(const void *kbuf, const void __user *ubuf,5454- struct xregs_state *xsave);5151+int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset, unsigned int size);5252+int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned int offset, unsigned int size);5353+int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf);5454+int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf);5555+5656+/* Validate an xstate header supplied by userspace (ptrace or sigreturn) */5757+extern int validate_xstate_header(const struct xstate_header *hdr);5858+5559#endif
-11
arch/x86/include/asm/thread_info.h
···158158 */159159#ifndef __ASSEMBLY__160160161161-static inline unsigned long current_stack_pointer(void)162162-{163163- unsigned long sp;164164-#ifdef CONFIG_X86_64165165- asm("mov %%rsp,%0" : "=g" (sp));166166-#else167167- asm("mov %%esp,%0" : "=g" (sp));168168-#endif169169- return sp;170170-}171171-172161/*173162 * Walks up the stack frames to make sure that the specified object is174163 * entirely contained by a single stack frame.
···100100101101 kernel_fpu_disable();102102103103- if (fpu->fpregs_active) {103103+ if (fpu->initialized) {104104 /*105105 * Ignore return value -- we don't care if reg state106106 * is clobbered.···116116{117117 struct fpu *fpu = ¤t->thread.fpu;118118119119- if (fpu->fpregs_active)119119+ if (fpu->initialized)120120 copy_kernel_to_fpregs(&fpu->state);121121122122 kernel_fpu_enable();···148148149149 preempt_disable();150150 trace_x86_fpu_before_save(fpu);151151- if (fpu->fpregs_active) {151151+ if (fpu->initialized) {152152 if (!copy_fpregs_to_fpstate(fpu)) {153153 copy_kernel_to_fpregs(&fpu->state);154154 }···189189190190int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)191191{192192- dst_fpu->fpregs_active = 0;193192 dst_fpu->last_cpu = -1;194193195195- if (!src_fpu->fpstate_active || !static_cpu_has(X86_FEATURE_FPU))194194+ if (!src_fpu->initialized || !static_cpu_has(X86_FEATURE_FPU))196195 return 0;197196198197 WARN_ON_FPU(src_fpu != ¤t->thread.fpu);···205206 /*206207 * Save current FPU registers directly into the child207208 * FPU context, without any memory-to-memory copying.208208- * In lazy mode, if the FPU context isn't loaded into209209- * fpregs, CR0.TS will be set and do_device_not_available210210- * will load the FPU context.211209 *212212- * We have to do all this with preemption disabled,213213- * mostly because of the FNSAVE case, because in that214214- * case we must not allow preemption in the window215215- * between the FNSAVE and us marking the context lazy.216216- *217217- * It shouldn't be an issue as even FNSAVE is plenty218218- * fast in terms of critical section length.210210+ * ( The function 'fails' in the FNSAVE case, which destroys211211+ * register contents so we have to copy them back. )219212 */220220- preempt_disable();221213 if (!copy_fpregs_to_fpstate(dst_fpu)) {222222- memcpy(&src_fpu->state, &dst_fpu->state,223223- fpu_kernel_xstate_size);224224-214214+ memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size);225215 copy_kernel_to_fpregs(&src_fpu->state);226216 }227227- preempt_enable();228217229218 trace_x86_fpu_copy_src(src_fpu);230219 trace_x86_fpu_copy_dst(dst_fpu);···224237 * Activate the current task's in-memory FPU context,225238 * if it has not been used before:226239 */227227-void fpu__activate_curr(struct fpu *fpu)240240+void fpu__initialize(struct fpu *fpu)228241{229242 WARN_ON_FPU(fpu != ¤t->thread.fpu);230243231231- if (!fpu->fpstate_active) {244244+ if (!fpu->initialized) {232245 fpstate_init(&fpu->state);233246 trace_x86_fpu_init_state(fpu);234247235248 trace_x86_fpu_activate_state(fpu);236249 /* Safe to do for the current task: */237237- fpu->fpstate_active = 1;250250+ fpu->initialized = 1;238251 }239252}240240-EXPORT_SYMBOL_GPL(fpu__activate_curr);253253+EXPORT_SYMBOL_GPL(fpu__initialize);241254242255/*243256 * This function must be called before we read a task's fpstate.244257 *245245- * If the task has not used the FPU before then initialize its246246- * fpstate.258258+ * There's two cases where this gets called:259259+ *260260+ * - for the current task (when coredumping), in which case we have261261+ * to save the latest FPU registers into the fpstate,262262+ *263263+ * - or it's called for stopped tasks (ptrace), in which case the264264+ * registers were already saved by the context-switch code when265265+ * the task scheduled out - we only have to initialize the registers266266+ * if they've never been initialized.247267 *248268 * If the task has used the FPU before then save it.249269 */250250-void fpu__activate_fpstate_read(struct fpu *fpu)270270+void fpu__prepare_read(struct fpu *fpu)251271{252252- /*253253- * If fpregs are active (in the current CPU), then254254- * copy them to the fpstate:255255- */256256- if (fpu->fpregs_active) {272272+ if (fpu == ¤t->thread.fpu) {257273 fpu__save(fpu);258274 } else {259259- if (!fpu->fpstate_active) {275275+ if (!fpu->initialized) {260276 fpstate_init(&fpu->state);261277 trace_x86_fpu_init_state(fpu);262278263279 trace_x86_fpu_activate_state(fpu);264280 /* Safe to do for current and for stopped child tasks: */265265- fpu->fpstate_active = 1;281281+ fpu->initialized = 1;266282 }267283 }268284}···273283/*274284 * This function must be called before we write a task's fpstate.275285 *276276- * If the task has used the FPU before then unlazy it.286286+ * If the task has used the FPU before then invalidate any cached FPU registers.277287 * If the task has not used the FPU before then initialize its fpstate.278288 *279289 * After this function call, after registers in the fpstate are280290 * modified and the child task has woken up, the child task will281291 * restore the modified FPU state from the modified context. If we282282- * didn't clear its lazy status here then the lazy in-registers292292+ * didn't clear its cached status here then the cached in-registers283293 * state pending on its former CPU could be restored, corrupting284294 * the modifications.285295 */286286-void fpu__activate_fpstate_write(struct fpu *fpu)296296+void fpu__prepare_write(struct fpu *fpu)287297{288298 /*289299 * Only stopped child tasks can be used to modify the FPU···291301 */292302 WARN_ON_FPU(fpu == ¤t->thread.fpu);293303294294- if (fpu->fpstate_active) {295295- /* Invalidate any lazy state: */304304+ if (fpu->initialized) {305305+ /* Invalidate any cached state: */296306 __fpu_invalidate_fpregs_state(fpu);297307 } else {298308 fpstate_init(&fpu->state);···300310301311 trace_x86_fpu_activate_state(fpu);302312 /* Safe to do for stopped child tasks: */303303- fpu->fpstate_active = 1;313313+ fpu->initialized = 1;304314 }305305-}306306-307307-/*308308- * This function must be called before we write the current309309- * task's fpstate.310310- *311311- * This call gets the current FPU register state and moves312312- * it in to the 'fpstate'. Preemption is disabled so that313313- * no writes to the 'fpstate' can occur from context314314- * swiches.315315- *316316- * Must be followed by a fpu__current_fpstate_write_end().317317- */318318-void fpu__current_fpstate_write_begin(void)319319-{320320- struct fpu *fpu = ¤t->thread.fpu;321321-322322- /*323323- * Ensure that the context-switching code does not write324324- * over the fpstate while we are doing our update.325325- */326326- preempt_disable();327327-328328- /*329329- * Move the fpregs in to the fpu's 'fpstate'.330330- */331331- fpu__activate_fpstate_read(fpu);332332-333333- /*334334- * The caller is about to write to 'fpu'. Ensure that no335335- * CPU thinks that its fpregs match the fpstate. This336336- * ensures we will not be lazy and skip a XRSTOR in the337337- * future.338338- */339339- __fpu_invalidate_fpregs_state(fpu);340340-}341341-342342-/*343343- * This function must be paired with fpu__current_fpstate_write_begin()344344- *345345- * This will ensure that the modified fpstate gets placed back in346346- * the fpregs if necessary.347347- *348348- * Note: This function may be called whether or not an _actual_349349- * write to the fpstate occurred.350350- */351351-void fpu__current_fpstate_write_end(void)352352-{353353- struct fpu *fpu = ¤t->thread.fpu;354354-355355- /*356356- * 'fpu' now has an updated copy of the state, but the357357- * registers may still be out of date. Update them with358358- * an XRSTOR if they are active.359359- */360360- if (fpregs_active())361361- copy_kernel_to_fpregs(&fpu->state);362362-363363- /*364364- * Our update is done and the fpregs/fpstate are in sync365365- * if necessary. Context switches can happen again.366366- */367367- preempt_enable();368315}369316370317/*···316389 */317390void fpu__restore(struct fpu *fpu)318391{319319- fpu__activate_curr(fpu);392392+ fpu__initialize(fpu);320393321394 /* Avoid __kernel_fpu_begin() right after fpregs_activate() */322395 kernel_fpu_disable();···341414{342415 preempt_disable();343416344344- if (fpu->fpregs_active) {345345- /* Ignore delayed exceptions from user space */346346- asm volatile("1: fwait\n"347347- "2:\n"348348- _ASM_EXTABLE(1b, 2b));349349- fpregs_deactivate(fpu);417417+ if (fpu == ¤t->thread.fpu) {418418+ if (fpu->initialized) {419419+ /* Ignore delayed exceptions from user space */420420+ asm volatile("1: fwait\n"421421+ "2:\n"422422+ _ASM_EXTABLE(1b, 2b));423423+ fpregs_deactivate(fpu);424424+ }350425 }351426352352- fpu->fpstate_active = 0;427427+ fpu->initialized = 0;353428354429 trace_x86_fpu_dropped(fpu);355430···391462 * Make sure fpstate is cleared and initialized.392463 */393464 if (static_cpu_has(X86_FEATURE_FPU)) {394394- fpu__activate_curr(fpu);465465+ preempt_disable();466466+ fpu__initialize(fpu);395467 user_fpu_begin();396468 copy_init_fpstate_to_fpregs();469469+ preempt_enable();397470 }398471}399472
···1616{1717 struct fpu *target_fpu = &target->thread.fpu;18181919- return target_fpu->fpstate_active ? regset->n : 0;1919+ return target_fpu->initialized ? regset->n : 0;2020}21212222int regset_xregset_fpregs_active(struct task_struct *target, const struct user_regset *regset)2323{2424 struct fpu *target_fpu = &target->thread.fpu;25252626- if (boot_cpu_has(X86_FEATURE_FXSR) && target_fpu->fpstate_active)2626+ if (boot_cpu_has(X86_FEATURE_FXSR) && target_fpu->initialized)2727 return regset->n;2828 else2929 return 0;···3838 if (!boot_cpu_has(X86_FEATURE_FXSR))3939 return -ENODEV;40404141- fpu__activate_fpstate_read(fpu);4141+ fpu__prepare_read(fpu);4242 fpstate_sanitize_xstate(fpu);43434444 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,···5555 if (!boot_cpu_has(X86_FEATURE_FXSR))5656 return -ENODEV;57575858- fpu__activate_fpstate_write(fpu);5858+ fpu__prepare_write(fpu);5959 fpstate_sanitize_xstate(fpu);60606161 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,···89899090 xsave = &fpu->state.xsave;91919292- fpu__activate_fpstate_read(fpu);9292+ fpu__prepare_read(fpu);93939494 if (using_compacted_format()) {9595- ret = copyout_from_xsaves(pos, count, kbuf, ubuf, xsave);9595+ if (kbuf)9696+ ret = copy_xstate_to_kernel(kbuf, xsave, pos, count);9797+ else9898+ ret = copy_xstate_to_user(ubuf, xsave, pos, count);9699 } else {97100 fpstate_sanitize_xstate(fpu);98101 /*···132129133130 xsave = &fpu->state.xsave;134131135135- fpu__activate_fpstate_write(fpu);132132+ fpu__prepare_write(fpu);136133137137- if (boot_cpu_has(X86_FEATURE_XSAVES))138138- ret = copyin_to_xsaves(kbuf, ubuf, xsave);139139- else134134+ if (using_compacted_format()) {135135+ if (kbuf)136136+ ret = copy_kernel_to_xstate(xsave, kbuf);137137+ else138138+ ret = copy_user_to_xstate(xsave, ubuf);139139+ } else {140140 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);141141+ if (!ret)142142+ ret = validate_xstate_header(&xsave->header);143143+ }144144+145145+ /*146146+ * mxcsr reserved bits must be masked to zero for security reasons.147147+ */148148+ xsave->i387.mxcsr &= mxcsr_feature_mask;141149142150 /*143151 * In case of failure, mark all states as init:144152 */145153 if (ret)146154 fpstate_init(&fpu->state);147147-148148- /*149149- * mxcsr reserved bits must be masked to zero for security reasons.150150- */151151- xsave->i387.mxcsr &= mxcsr_feature_mask;152152- xsave->header.xfeatures &= xfeatures_mask;153153- /*154154- * These bits must be zero.155155- */156156- memset(&xsave->header.reserved, 0, 48);157155158156 return ret;159157}···303299 struct fpu *fpu = &target->thread.fpu;304300 struct user_i387_ia32_struct env;305301306306- fpu__activate_fpstate_read(fpu);302302+ fpu__prepare_read(fpu);307303308304 if (!boot_cpu_has(X86_FEATURE_FPU))309305 return fpregs_soft_get(target, regset, pos, count, kbuf, ubuf);···333329 struct user_i387_ia32_struct env;334330 int ret;335331336336- fpu__activate_fpstate_write(fpu);332332+ fpu__prepare_write(fpu);337333 fpstate_sanitize_xstate(fpu);338334339335 if (!boot_cpu_has(X86_FEATURE_FPU))···373369 struct fpu *fpu = &tsk->thread.fpu;374370 int fpvalid;375371376376- fpvalid = fpu->fpstate_active;372372+ fpvalid = fpu->initialized;377373 if (fpvalid)378374 fpvalid = !fpregs_get(tsk, NULL,379375 0, sizeof(struct user_i387_ia32_struct),
+21-16
arch/x86/kernel/fpu/signal.c
···155155 */156156int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)157157{158158- struct xregs_state *xsave = ¤t->thread.fpu.state.xsave;158158+ struct fpu *fpu = ¤t->thread.fpu;159159+ struct xregs_state *xsave = &fpu->state.xsave;159160 struct task_struct *tsk = current;160161 int ia32_fxstate = (buf != buf_fx);161162···171170 sizeof(struct user_i387_ia32_struct), NULL,172171 (struct _fpstate_32 __user *) buf) ? -1 : 1;173172174174- if (fpregs_active() || using_compacted_format()) {173173+ if (fpu->initialized || using_compacted_format()) {175174 /* Save the live register state to the user directly. */176175 if (copy_fpregs_to_sigframe(buf_fx))177176 return -1;178177 /* Update the thread's fxstate to save the fsave header. */179178 if (ia32_fxstate)180180- copy_fxregs_to_kernel(&tsk->thread.fpu);179179+ copy_fxregs_to_kernel(fpu);181180 } else {182181 /*183182 * It is a *bug* if kernel uses compacted-format for xsave···190189 return -1;191190 }192191193193- fpstate_sanitize_xstate(&tsk->thread.fpu);192192+ fpstate_sanitize_xstate(fpu);194193 if (__copy_to_user(buf_fx, xsave, fpu_user_xstate_size))195194 return -1;196195 }···214213 struct xstate_header *header = &xsave->header;215214216215 if (use_xsave()) {217217- /* These bits must be zero. */218218- memset(header->reserved, 0, 48);216216+ /*217217+ * Note: we don't need to zero the reserved bits in the218218+ * xstate_header here because we either didn't copy them at all,219219+ * or we checked earlier that they aren't set.220220+ */219221220222 /*221223 * Init the state that is not present in the memory···227223 if (fx_only)228224 header->xfeatures = XFEATURE_MASK_FPSSE;229225 else230230- header->xfeatures &= (xfeatures_mask & xfeatures);226226+ header->xfeatures &= xfeatures;231227 }232228233229 if (use_fxsr()) {···283279 if (!access_ok(VERIFY_READ, buf, size))284280 return -EACCES;285281286286- fpu__activate_curr(fpu);282282+ fpu__initialize(fpu);287283288284 if (!static_cpu_has(X86_FEATURE_FPU))289285 return fpregs_soft_set(current, NULL,···311307 /*312308 * For 32-bit frames with fxstate, copy the user state to the313309 * thread's fpu state, reconstruct fxstate from the fsave314314- * header. Sanitize the copied state etc.310310+ * header. Validate and sanitize the copied state.315311 */316312 struct fpu *fpu = &tsk->thread.fpu;317313 struct user_i387_ia32_struct env;318314 int err = 0;319315320316 /*321321- * Drop the current fpu which clears fpu->fpstate_active. This ensures317317+ * Drop the current fpu which clears fpu->initialized. This ensures322318 * that any context-switch during the copy of the new state,323319 * avoids the intermediate state from getting restored/saved.324320 * Thus avoiding the new restored state from getting corrupted.325321 * We will be ready to restore/save the state only after326326- * fpu->fpstate_active is again set.322322+ * fpu->initialized is again set.327323 */328324 fpu__drop(fpu);329325330326 if (using_compacted_format()) {331331- err = copyin_to_xsaves(NULL, buf_fx,332332- &fpu->state.xsave);327327+ err = copy_user_to_xstate(&fpu->state.xsave, buf_fx);333328 } else {334334- err = __copy_from_user(&fpu->state.xsave,335335- buf_fx, state_size);329329+ err = __copy_from_user(&fpu->state.xsave, buf_fx, state_size);330330+331331+ if (!err && state_size > offsetof(struct xregs_state, header))332332+ err = validate_xstate_header(&fpu->state.xsave.header);336333 }337334338335 if (err || __copy_from_user(&env, buf, sizeof(env))) {···344339 sanitize_restored_xstate(tsk, &env, xfeatures, fx_only);345340 }346341347347- fpu->fpstate_active = 1;342342+ fpu->initialized = 1;348343 preempt_disable();349344 fpu__restore(fpu);350345 preempt_enable();
+222-60
arch/x86/kernel/fpu/xstate.c
···483483 return boot_cpu_has(X86_FEATURE_XSAVES);484484}485485486486+/* Validate an xstate header supplied by userspace (ptrace or sigreturn) */487487+int validate_xstate_header(const struct xstate_header *hdr)488488+{489489+ /* No unknown or supervisor features may be set */490490+ if (hdr->xfeatures & (~xfeatures_mask | XFEATURE_MASK_SUPERVISOR))491491+ return -EINVAL;492492+493493+ /* Userspace must use the uncompacted format */494494+ if (hdr->xcomp_bv)495495+ return -EINVAL;496496+497497+ /*498498+ * If 'reserved' is shrunken to add a new field, make sure to validate499499+ * that new field here!500500+ */501501+ BUILD_BUG_ON(sizeof(hdr->reserved) != 48);502502+503503+ /* No reserved bits may be set */504504+ if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved)))505505+ return -EINVAL;506506+507507+ return 0;508508+}509509+486510static void __xstate_dump_leaves(void)487511{488512 int i;···891867{892868 struct fpu *fpu = ¤t->thread.fpu;893869894894- if (!fpu->fpstate_active)870870+ if (!fpu->initialized)895871 return NULL;896872 /*897873 * fpu__save() takes the CPU's xstate registers···945921#endif /* ! CONFIG_ARCH_HAS_PKEYS */946922947923/*924924+ * Weird legacy quirk: SSE and YMM states store information in the925925+ * MXCSR and MXCSR_FLAGS fields of the FP area. That means if the FP926926+ * area is marked as unused in the xfeatures header, we need to copy927927+ * MXCSR and MXCSR_FLAGS if either SSE or YMM are in use.928928+ */929929+static inline bool xfeatures_mxcsr_quirk(u64 xfeatures)930930+{931931+ if (!(xfeatures & (XFEATURE_MASK_SSE|XFEATURE_MASK_YMM)))932932+ return false;933933+934934+ if (xfeatures & XFEATURE_MASK_FP)935935+ return false;936936+937937+ return true;938938+}939939+940940+/*948941 * This is similar to user_regset_copyout(), but will not add offset to949942 * the source data pointer or increment pos, count, kbuf, and ubuf.950943 */951951-static inline int xstate_copyout(unsigned int pos, unsigned int count,952952- void *kbuf, void __user *ubuf,953953- const void *data, const int start_pos,954954- const int end_pos)944944+static inline void945945+__copy_xstate_to_kernel(void *kbuf, const void *data,946946+ unsigned int offset, unsigned int size, unsigned int size_total)955947{956956- if ((count == 0) || (pos < start_pos))957957- return 0;948948+ if (offset < size_total) {949949+ unsigned int copy = min(size, size_total - offset);958950959959- if (end_pos < 0 || pos < end_pos) {960960- unsigned int copy = (end_pos < 0 ? count : min(count, end_pos - pos));961961-962962- if (kbuf) {963963- memcpy(kbuf + pos, data, copy);964964- } else {965965- if (__copy_to_user(ubuf + pos, data, copy))966966- return -EFAULT;967967- }951951+ memcpy(kbuf + offset, data, copy);968952 }969969- return 0;970953}971954972955/*973956 * Convert from kernel XSAVES compacted format to standard format and copy974974- * to a ptrace buffer. It supports partial copy but pos always starts from975975- * zero. This is called from xstateregs_get() and there we check the CPU976976- * has XSAVES.957957+ * to a kernel-space ptrace buffer.958958+ *959959+ * It supports partial copy but pos always starts from zero. This is called960960+ * from xstateregs_get() and there we check the CPU has XSAVES.977961 */978978-int copyout_from_xsaves(unsigned int pos, unsigned int count, void *kbuf,979979- void __user *ubuf, struct xregs_state *xsave)962962+int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset_start, unsigned int size_total)980963{981964 unsigned int offset, size;982982- int ret, i;983965 struct xstate_header header;966966+ int i;984967985968 /*986969 * Currently copy_regset_to_user() starts from pos 0:987970 */988988- if (unlikely(pos != 0))971971+ if (unlikely(offset_start != 0))989972 return -EFAULT;990973991974 /*···1008977 offset = offsetof(struct xregs_state, header);1009978 size = sizeof(header);101097910111011- ret = xstate_copyout(offset, size, kbuf, ubuf, &header, 0, count);980980+ __copy_xstate_to_kernel(kbuf, &header, offset, size, size_total);1012981982982+ for (i = 0; i < XFEATURE_MAX; i++) {983983+ /*984984+ * Copy only in-use xstates:985985+ */986986+ if ((header.xfeatures >> i) & 1) {987987+ void *src = __raw_xsave_addr(xsave, 1 << i);988988+989989+ offset = xstate_offsets[i];990990+ size = xstate_sizes[i];991991+992992+ /* The next component has to fit fully into the output buffer: */993993+ if (offset + size > size_total)994994+ break;995995+996996+ __copy_xstate_to_kernel(kbuf, src, offset, size, size_total);997997+ }998998+999999+ }10001000+10011001+ if (xfeatures_mxcsr_quirk(header.xfeatures)) {10021002+ offset = offsetof(struct fxregs_state, mxcsr);10031003+ size = MXCSR_AND_FLAGS_SIZE;10041004+ __copy_xstate_to_kernel(kbuf, &xsave->i387.mxcsr, offset, size, size_total);10051005+ }10061006+10071007+ /*10081008+ * Fill xsave->i387.sw_reserved value for ptrace frame:10091009+ */10101010+ offset = offsetof(struct fxregs_state, sw_reserved);10111011+ size = sizeof(xstate_fx_sw_bytes);10121012+10131013+ __copy_xstate_to_kernel(kbuf, xstate_fx_sw_bytes, offset, size, size_total);10141014+10151015+ return 0;10161016+}10171017+10181018+static inline int10191019+__copy_xstate_to_user(void __user *ubuf, const void *data, unsigned int offset, unsigned int size, unsigned int size_total)10201020+{10211021+ if (!size)10221022+ return 0;10231023+10241024+ if (offset < size_total) {10251025+ unsigned int copy = min(size, size_total - offset);10261026+10271027+ if (__copy_to_user(ubuf + offset, data, copy))10281028+ return -EFAULT;10291029+ }10301030+ return 0;10311031+}10321032+10331033+/*10341034+ * Convert from kernel XSAVES compacted format to standard format and copy10351035+ * to a user-space buffer. It supports partial copy but pos always starts from10361036+ * zero. This is called from xstateregs_get() and there we check the CPU10371037+ * has XSAVES.10381038+ */10391039+int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned int offset_start, unsigned int size_total)10401040+{10411041+ unsigned int offset, size;10421042+ int ret, i;10431043+ struct xstate_header header;10441044+10451045+ /*10461046+ * Currently copy_regset_to_user() starts from pos 0:10471047+ */10481048+ if (unlikely(offset_start != 0))10491049+ return -EFAULT;10501050+10511051+ /*10521052+ * The destination is a ptrace buffer; we put in only user xstates:10531053+ */10541054+ memset(&header, 0, sizeof(header));10551055+ header.xfeatures = xsave->header.xfeatures;10561056+ header.xfeatures &= ~XFEATURE_MASK_SUPERVISOR;10571057+10581058+ /*10591059+ * Copy xregs_state->header:10601060+ */10611061+ offset = offsetof(struct xregs_state, header);10621062+ size = sizeof(header);10631063+10641064+ ret = __copy_xstate_to_user(ubuf, &header, offset, size, size_total);10131065 if (ret)10141066 return ret;10151067···1106992 offset = xstate_offsets[i];1107993 size = xstate_sizes[i];110899411091109- ret = xstate_copyout(offset, size, kbuf, ubuf, src, 0, count);995995+ /* The next component has to fit fully into the output buffer: */996996+ if (offset + size > size_total)997997+ break;1110998999999+ ret = __copy_xstate_to_user(ubuf, src, offset, size, size_total);11111000 if (ret)11121001 return ret;11131113-11141114- if (offset + size >= count)11151115- break;11161002 }1117100310041004+ }10051005+10061006+ if (xfeatures_mxcsr_quirk(header.xfeatures)) {10071007+ offset = offsetof(struct fxregs_state, mxcsr);10081008+ size = MXCSR_AND_FLAGS_SIZE;10091009+ __copy_xstate_to_user(ubuf, &xsave->i387.mxcsr, offset, size, size_total);11181010 }1119101111201012 /*···11291009 offset = offsetof(struct fxregs_state, sw_reserved);11301010 size = sizeof(xstate_fx_sw_bytes);1131101111321132- ret = xstate_copyout(offset, size, kbuf, ubuf, xstate_fx_sw_bytes, 0, count);11331133-10121012+ ret = __copy_xstate_to_user(ubuf, xstate_fx_sw_bytes, offset, size, size_total);11341013 if (ret)11351014 return ret;11361015···11371018}1138101911391020/*11401140- * Convert from a ptrace standard-format buffer to kernel XSAVES format11411141- * and copy to the target thread. This is called from xstateregs_set() and11421142- * there we check the CPU has XSAVES and a whole standard-sized buffer11431143- * exists.10211021+ * Convert from a ptrace standard-format kernel buffer to kernel XSAVES format10221022+ * and copy to the target thread. This is called from xstateregs_set().11441023 */11451145-int copyin_to_xsaves(const void *kbuf, const void __user *ubuf,11461146- struct xregs_state *xsave)10241024+int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf)11471025{11481026 unsigned int offset, size;11491027 int i;11501150- u64 xfeatures;11511151- u64 allowed_features;10281028+ struct xstate_header hdr;1152102911531030 offset = offsetof(struct xregs_state, header);11541154- size = sizeof(xfeatures);10311031+ size = sizeof(hdr);1155103211561156- if (kbuf) {11571157- memcpy(&xfeatures, kbuf + offset, size);11581158- } else {11591159- if (__copy_from_user(&xfeatures, ubuf + offset, size))11601160- return -EFAULT;11611161- }10331033+ memcpy(&hdr, kbuf + offset, size);1162103411631163- /*11641164- * Reject if the user sets any disabled or supervisor features:11651165- */11661166- allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR;11671167-11681168- if (xfeatures & ~allowed_features)10351035+ if (validate_xstate_header(&hdr))11691036 return -EINVAL;1170103711711038 for (i = 0; i < XFEATURE_MAX; i++) {11721039 u64 mask = ((u64)1 << i);1173104011741174- if (xfeatures & mask) {10411041+ if (hdr.xfeatures & mask) {11751042 void *dst = __raw_xsave_addr(xsave, 1 << i);1176104311771044 offset = xstate_offsets[i];11781045 size = xstate_sizes[i];1179104611801180- if (kbuf) {11811181- memcpy(dst, kbuf + offset, size);11821182- } else {11831183- if (__copy_from_user(dst, ubuf + offset, size))11841184- return -EFAULT;11851185- }10471047+ memcpy(dst, kbuf + offset, size);11861048 }10491049+ }10501050+10511051+ if (xfeatures_mxcsr_quirk(hdr.xfeatures)) {10521052+ offset = offsetof(struct fxregs_state, mxcsr);10531053+ size = MXCSR_AND_FLAGS_SIZE;10541054+ memcpy(&xsave->i387.mxcsr, kbuf + offset, size);11871055 }1188105611891057 /*···11821076 /*11831077 * Add back in the features that came in from userspace:11841078 */11851185- xsave->header.xfeatures |= xfeatures;10791079+ xsave->header.xfeatures |= hdr.xfeatures;10801080+10811081+ return 0;10821082+}10831083+10841084+/*10851085+ * Convert from a ptrace or sigreturn standard-format user-space buffer to10861086+ * kernel XSAVES format and copy to the target thread. This is called from10871087+ * xstateregs_set(), as well as potentially from the sigreturn() and10881088+ * rt_sigreturn() system calls.10891089+ */10901090+int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf)10911091+{10921092+ unsigned int offset, size;10931093+ int i;10941094+ struct xstate_header hdr;10951095+10961096+ offset = offsetof(struct xregs_state, header);10971097+ size = sizeof(hdr);10981098+10991099+ if (__copy_from_user(&hdr, ubuf + offset, size))11001100+ return -EFAULT;11011101+11021102+ if (validate_xstate_header(&hdr))11031103+ return -EINVAL;11041104+11051105+ for (i = 0; i < XFEATURE_MAX; i++) {11061106+ u64 mask = ((u64)1 << i);11071107+11081108+ if (hdr.xfeatures & mask) {11091109+ void *dst = __raw_xsave_addr(xsave, 1 << i);11101110+11111111+ offset = xstate_offsets[i];11121112+ size = xstate_sizes[i];11131113+11141114+ if (__copy_from_user(dst, ubuf + offset, size))11151115+ return -EFAULT;11161116+ }11171117+ }11181118+11191119+ if (xfeatures_mxcsr_quirk(hdr.xfeatures)) {11201120+ offset = offsetof(struct fxregs_state, mxcsr);11211121+ size = MXCSR_AND_FLAGS_SIZE;11221122+ if (__copy_from_user(&xsave->i387.mxcsr, ubuf + offset, size))11231123+ return -EFAULT;11241124+ }11251125+11261126+ /*11271127+ * The state that came in from userspace was user-state only.11281128+ * Mask all the user states out of 'xfeatures':11291129+ */11301130+ xsave->header.xfeatures &= XFEATURE_MASK_SUPERVISOR;11311131+11321132+ /*11331133+ * Add back in the features that came in from userspace:11341134+ */11351135+ xsave->header.xfeatures |= hdr.xfeatures;1186113611871137 return 0;11881138}
+3-3
arch/x86/kernel/irq_32.c
···64646565static inline void *current_stack(void)6666{6767- return (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));6767+ return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1));6868}69697070static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)···88888989 /* Save the next esp at the bottom of the stack */9090 prev_esp = (u32 *)irqstk;9191- *prev_esp = current_stack_pointer();9191+ *prev_esp = current_stack_pointer;92929393 if (unlikely(overflow))9494 call_on_stack(print_stack_overflow, isp);···139139140140 /* Push the previous esp onto the stack */141141 prev_esp = (u32 *)irqstk;142142- *prev_esp = current_stack_pointer();142142+ *prev_esp = current_stack_pointer;143143144144 call_on_stack(__do_softirq, isp);145145}
+1-1
arch/x86/kernel/ksysfs.c
···299299 return 0;300300301301out_clean_nodes:302302- for (j = i - 1; j > 0; j--)302302+ for (j = i - 1; j >= 0; j--)303303 cleanup_setup_data_node(*(kobjp + j));304304 kfree(kobjp);305305out_setup_data_kobj:
···200200 int cpu;201201 bool launched;202202 bool nmi_known_unmasked;203203+ unsigned long vmcs_host_cr3; /* May not match real cr3 */204204+ unsigned long vmcs_host_cr4; /* May not match real cr4 */203205 struct list_head loaded_vmcss_on_cpu_link;204206};205207···602600 int gs_ldt_reload_needed;603601 int fs_reload_needed;604602 u64 msr_host_bndcfgs;605605- unsigned long vmcs_host_cr3; /* May not match real cr3 */606606- unsigned long vmcs_host_cr4; /* May not match real cr4 */607603 } host_state;608604 struct {609605 int vm86_active;···22022202 struct pi_desc old, new;22032203 unsigned int dest;2204220422052205- if (!kvm_arch_has_assigned_device(vcpu->kvm) ||22062206- !irq_remapping_cap(IRQ_POSTING_CAP) ||22072207- !kvm_vcpu_apicv_active(vcpu))22052205+ /*22062206+ * In case of hot-plug or hot-unplug, we may have to undo22072207+ * vmx_vcpu_pi_put even if there is no assigned device. And we22082208+ * always keep PI.NDST up to date for simplicity: it makes the22092209+ * code easier, and CPU migration is not a fast path.22102210+ */22112211+ if (!pi_test_sn(pi_desc) && vcpu->cpu == cpu)22082212 return;2209221322142214+ /*22152215+ * First handle the simple case where no cmpxchg is necessary; just22162216+ * allow posting non-urgent interrupts.22172217+ *22182218+ * If the 'nv' field is POSTED_INTR_WAKEUP_VECTOR, do not change22192219+ * PI.NDST: pi_post_block will do it for us and the wakeup_handler22202220+ * expects the VCPU to be on the blocked_vcpu_list that matches22212221+ * PI.NDST.22222222+ */22232223+ if (pi_desc->nv == POSTED_INTR_WAKEUP_VECTOR ||22242224+ vcpu->cpu == cpu) {22252225+ pi_clear_sn(pi_desc);22262226+ return;22272227+ }22282228+22292229+ /* The full case. */22102230 do {22112231 old.control = new.control = pi_desc->control;2212223222132213- /*22142214- * If 'nv' field is POSTED_INTR_WAKEUP_VECTOR, there22152215- * are two possible cases:22162216- * 1. After running 'pre_block', context switch22172217- * happened. For this case, 'sn' was set in22182218- * vmx_vcpu_put(), so we need to clear it here.22192219- * 2. After running 'pre_block', we were blocked,22202220- * and woken up by some other guy. For this case,22212221- * we don't need to do anything, 'pi_post_block'22222222- * will do everything for us. However, we cannot22232223- * check whether it is case #1 or case #2 here22242224- * (maybe, not needed), so we also clear sn here,22252225- * I think it is not a big deal.22262226- */22272227- if (pi_desc->nv != POSTED_INTR_WAKEUP_VECTOR) {22282228- if (vcpu->cpu != cpu) {22292229- dest = cpu_physical_id(cpu);22332233+ dest = cpu_physical_id(cpu);2230223422312231- if (x2apic_enabled())22322232- new.ndst = dest;22332233- else22342234- new.ndst = (dest << 8) & 0xFF00;22352235- }22352235+ if (x2apic_enabled())22362236+ new.ndst = dest;22372237+ else22382238+ new.ndst = (dest << 8) & 0xFF00;2236223922372237- /* set 'NV' to 'notification vector' */22382238- new.nv = POSTED_INTR_VECTOR;22392239- }22402240-22412241- /* Allow posting non-urgent interrupts */22422240 new.sn = 0;22432243- } while (cmpxchg(&pi_desc->control, old.control,22442244- new.control) != old.control);22412241+ } while (cmpxchg64(&pi_desc->control, old.control,22422242+ new.control) != old.control);22452243}2246224422472245static void decache_tsc_multiplier(struct vcpu_vmx *vmx)···51765178 */51775179 cr3 = __read_cr3();51785180 vmcs_writel(HOST_CR3, cr3); /* 22.2.3 FIXME: shadow tables */51795179- vmx->host_state.vmcs_host_cr3 = cr3;51815181+ vmx->loaded_vmcs->vmcs_host_cr3 = cr3;5180518251815183 /* Save the most likely value for this task's CR4 in the VMCS. */51825184 cr4 = cr4_read_shadow();51835185 vmcs_writel(HOST_CR4, cr4); /* 22.2.3, 22.2.5 */51845184- vmx->host_state.vmcs_host_cr4 = cr4;51865186+ vmx->loaded_vmcs->vmcs_host_cr4 = cr4;5185518751865188 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */51875189#ifdef CONFIG_X86_64···92719273 vmcs_writel(GUEST_RIP, vcpu->arch.regs[VCPU_REGS_RIP]);9272927492739275 cr3 = __get_current_cr3_fast();92749274- if (unlikely(cr3 != vmx->host_state.vmcs_host_cr3)) {92769276+ if (unlikely(cr3 != vmx->loaded_vmcs->vmcs_host_cr3)) {92759277 vmcs_writel(HOST_CR3, cr3);92769276- vmx->host_state.vmcs_host_cr3 = cr3;92789278+ vmx->loaded_vmcs->vmcs_host_cr3 = cr3;92779279 }9278928092799281 cr4 = cr4_read_shadow();92809280- if (unlikely(cr4 != vmx->host_state.vmcs_host_cr4)) {92829282+ if (unlikely(cr4 != vmx->loaded_vmcs->vmcs_host_cr4)) {92819283 vmcs_writel(HOST_CR4, cr4);92829282- vmx->host_state.vmcs_host_cr4 = cr4;92849284+ vmx->loaded_vmcs->vmcs_host_cr4 = cr4;92839285 }9284928692859287 /* When single-stepping over STI and MOV SS, we must clear the···9589959195909592 vmx->msr_ia32_feature_control_valid_bits = FEATURE_CONTROL_LOCKED;9591959395949594+ /*95959595+ * Enforce invariant: pi_desc.nv is always either POSTED_INTR_VECTOR95969596+ * or POSTED_INTR_WAKEUP_VECTOR.95979597+ */95989598+ vmx->pi_desc.nv = POSTED_INTR_VECTOR;95999599+ vmx->pi_desc.sn = 1;96009600+95929601 return &vmx->vcpu;9593960295949603free_vmcs:···9844983998459840 WARN_ON(!is_guest_mode(vcpu));9846984198479847- if (nested_vmx_is_page_fault_vmexit(vmcs12, fault->error_code)) {98429842+ if (nested_vmx_is_page_fault_vmexit(vmcs12, fault->error_code) &&98439843+ !to_vmx(vcpu)->nested.nested_run_pending) {98489844 vmcs12->vm_exit_intr_error_code = fault->error_code;98499845 nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI,98509846 PF_VECTOR | INTR_TYPE_HARD_EXCEPTION |···1171011704 kvm_mmu_clear_dirty_pt_masked(kvm, memslot, offset, mask);1171111705}11712117061170711707+static void __pi_post_block(struct kvm_vcpu *vcpu)1170811708+{1170911709+ struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);1171011710+ struct pi_desc old, new;1171111711+ unsigned int dest;1171211712+1171311713+ do {1171411714+ old.control = new.control = pi_desc->control;1171511715+ WARN(old.nv != POSTED_INTR_WAKEUP_VECTOR,1171611716+ "Wakeup handler not enabled while the VCPU is blocked\n");1171711717+1171811718+ dest = cpu_physical_id(vcpu->cpu);1171911719+1172011720+ if (x2apic_enabled())1172111721+ new.ndst = dest;1172211722+ else1172311723+ new.ndst = (dest << 8) & 0xFF00;1172411724+1172511725+ /* set 'NV' to 'notification vector' */1172611726+ new.nv = POSTED_INTR_VECTOR;1172711727+ } while (cmpxchg64(&pi_desc->control, old.control,1172811728+ new.control) != old.control);1172911729+1173011730+ if (!WARN_ON_ONCE(vcpu->pre_pcpu == -1)) {1173111731+ spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));1173211732+ list_del(&vcpu->blocked_vcpu_list);1173311733+ spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));1173411734+ vcpu->pre_pcpu = -1;1173511735+ }1173611736+}1173711737+1171311738/*1171411739 * This routine does the following things for vCPU which is going1171511740 * to be blocked if VT-d PI is enabled.···1175611719 */1175711720static int pi_pre_block(struct kvm_vcpu *vcpu)1175811721{1175911759- unsigned long flags;1176011722 unsigned int dest;1176111723 struct pi_desc old, new;1176211724 struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);···1176511729 !kvm_vcpu_apicv_active(vcpu))1176611730 return 0;11767117311176811768- vcpu->pre_pcpu = vcpu->cpu;1176911769- spin_lock_irqsave(&per_cpu(blocked_vcpu_on_cpu_lock,1177011770- vcpu->pre_pcpu), flags);1177111771- list_add_tail(&vcpu->blocked_vcpu_list,1177211772- &per_cpu(blocked_vcpu_on_cpu,1177311773- vcpu->pre_pcpu));1177411774- spin_unlock_irqrestore(&per_cpu(blocked_vcpu_on_cpu_lock,1177511775- vcpu->pre_pcpu), flags);1173211732+ WARN_ON(irqs_disabled());1173311733+ local_irq_disable();1173411734+ if (!WARN_ON_ONCE(vcpu->pre_pcpu != -1)) {1173511735+ vcpu->pre_pcpu = vcpu->cpu;1173611736+ spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));1173711737+ list_add_tail(&vcpu->blocked_vcpu_list,1173811738+ &per_cpu(blocked_vcpu_on_cpu,1173911739+ vcpu->pre_pcpu));1174011740+ spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));1174111741+ }11776117421177711743 do {1177811744 old.control = new.control = pi_desc->control;1177911779-1178011780- /*1178111781- * We should not block the vCPU if1178211782- * an interrupt is posted for it.1178311783- */1178411784- if (pi_test_on(pi_desc) == 1) {1178511785- spin_lock_irqsave(&per_cpu(blocked_vcpu_on_cpu_lock,1178611786- vcpu->pre_pcpu), flags);1178711787- list_del(&vcpu->blocked_vcpu_list);1178811788- spin_unlock_irqrestore(1178911789- &per_cpu(blocked_vcpu_on_cpu_lock,1179011790- vcpu->pre_pcpu), flags);1179111791- vcpu->pre_pcpu = -1;1179211792-1179311793- return 1;1179411794- }11795117451179611746 WARN((pi_desc->sn == 1),1179711747 "Warning: SN field of posted-interrupts "···11800117781180111779 /* set 'NV' to 'wakeup vector' */1180211780 new.nv = POSTED_INTR_WAKEUP_VECTOR;1180311803- } while (cmpxchg(&pi_desc->control, old.control,1180411804- new.control) != old.control);1178111781+ } while (cmpxchg64(&pi_desc->control, old.control,1178211782+ new.control) != old.control);11805117831180611806- return 0;1178411784+ /* We should not block the vCPU if an interrupt is posted for it. */1178511785+ if (pi_test_on(pi_desc) == 1)1178611786+ __pi_post_block(vcpu);1178711787+1178811788+ local_irq_enable();1178911789+ return (vcpu->pre_pcpu == -1);1180711790}11808117911180911792static int vmx_pre_block(struct kvm_vcpu *vcpu)···11824117971182511798static void pi_post_block(struct kvm_vcpu *vcpu)1182611799{1182711827- struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);1182811828- struct pi_desc old, new;1182911829- unsigned int dest;1183011830- unsigned long flags;1183111831-1183211832- if (!kvm_arch_has_assigned_device(vcpu->kvm) ||1183311833- !irq_remapping_cap(IRQ_POSTING_CAP) ||1183411834- !kvm_vcpu_apicv_active(vcpu))1180011800+ if (vcpu->pre_pcpu == -1)1183511801 return;11836118021183711837- do {1183811838- old.control = new.control = pi_desc->control;1183911839-1184011840- dest = cpu_physical_id(vcpu->cpu);1184111841-1184211842- if (x2apic_enabled())1184311843- new.ndst = dest;1184411844- else1184511845- new.ndst = (dest << 8) & 0xFF00;1184611846-1184711847- /* Allow posting non-urgent interrupts */1184811848- new.sn = 0;1184911849-1185011850- /* set 'NV' to 'notification vector' */1185111851- new.nv = POSTED_INTR_VECTOR;1185211852- } while (cmpxchg(&pi_desc->control, old.control,1185311853- new.control) != old.control);1185411854-1185511855- if(vcpu->pre_pcpu != -1) {1185611856- spin_lock_irqsave(1185711857- &per_cpu(blocked_vcpu_on_cpu_lock,1185811858- vcpu->pre_pcpu), flags);1185911859- list_del(&vcpu->blocked_vcpu_list);1186011860- spin_unlock_irqrestore(1186111861- &per_cpu(blocked_vcpu_on_cpu_lock,1186211862- vcpu->pre_pcpu), flags);1186311863- vcpu->pre_pcpu = -1;1186411864- }1180311803+ WARN_ON(irqs_disabled());1180411804+ local_irq_disable();1180511805+ __pi_post_block(vcpu);1180611806+ local_irq_enable();1186511807}11866118081186711809static void vmx_post_block(struct kvm_vcpu *vcpu)
···22#include <linux/uaccess.h>33#include <linux/sched/debug.h>4455+#include <asm/fpu/internal.h>56#include <asm/traps.h>67#include <asm/kdebug.h>78···7877 return true;7978}8079EXPORT_SYMBOL_GPL(ex_handler_refcount);8080+8181+/*8282+ * Handler for when we fail to restore a task's FPU state. We should never get8383+ * here because the FPU state of a task using the FPU (task->thread.fpu.state)8484+ * should always be valid. However, past bugs have allowed userspace to set8585+ * reserved bits in the XSAVE area using PTRACE_SETREGSET or sys_rt_sigreturn().8686+ * These caused XRSTOR to fail when switching to the task, leaking the FPU8787+ * registers of the task previously executing on the CPU. Mitigate this class8888+ * of vulnerability by restoring from the initial state (essentially, zeroing8989+ * out all the FPU registers) if we can't restore from the task's FPU state.9090+ */9191+bool ex_handler_fprestore(const struct exception_table_entry *fixup,9292+ struct pt_regs *regs, int trapnr)9393+{9494+ regs->ip = ex_fixup_addr(fixup);9595+9696+ WARN_ONCE(1, "Bad FPU state detected at %pB, reinitializing FPU registers.",9797+ (void *)instruction_pointer(regs));9898+9999+ __copy_kernel_to_fpregs(&init_fpstate, -1);100100+ return true;101101+}102102+EXPORT_SYMBOL_GPL(ex_handler_fprestore);8110382104bool ex_handler_ext(const struct exception_table_entry *fixup,83105 struct pt_regs *regs, int trapnr)
+24-23
arch/x86/mm/fault.c
···192192 * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really193193 * faulted on a pte with its pkey=4.194194 */195195-static void fill_sig_info_pkey(int si_code, siginfo_t *info,196196- struct vm_area_struct *vma)195195+static void fill_sig_info_pkey(int si_code, siginfo_t *info, u32 *pkey)197196{198197 /* This is effectively an #ifdef */199198 if (!boot_cpu_has(X86_FEATURE_OSPKE))···208209 * valid VMA, so we should never reach this without a209210 * valid VMA.210211 */211211- if (!vma) {212212+ if (!pkey) {212213 WARN_ONCE(1, "PKU fault with no VMA passed in");213214 info->si_pkey = 0;214215 return;···218219 * absolutely guranteed to be 100% accurate because of219220 * the race explained above.220221 */221221- info->si_pkey = vma_pkey(vma);222222+ info->si_pkey = *pkey;222223}223224224225static void225226force_sig_info_fault(int si_signo, int si_code, unsigned long address,226226- struct task_struct *tsk, struct vm_area_struct *vma,227227- int fault)227227+ struct task_struct *tsk, u32 *pkey, int fault)228228{229229 unsigned lsb = 0;230230 siginfo_t info;···238240 lsb = PAGE_SHIFT;239241 info.si_addr_lsb = lsb;240242241241- fill_sig_info_pkey(si_code, &info, vma);243243+ fill_sig_info_pkey(si_code, &info, pkey);242244243245 force_sig_info(si_signo, &info, tsk);244246}···760762 struct task_struct *tsk = current;761763 unsigned long flags;762764 int sig;763763- /* No context means no VMA to pass down */764764- struct vm_area_struct *vma = NULL;765765766766 /* Are we prepared to handle this kernel fault? */767767 if (fixup_exception(regs, X86_TRAP_PF)) {···784788785789 /* XXX: hwpoison faults will set the wrong code. */786790 force_sig_info_fault(signal, si_code, address,787787- tsk, vma, 0);791791+ tsk, NULL, 0);788792 }789793790794 /*···892896893897static void894898__bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,895895- unsigned long address, struct vm_area_struct *vma,896896- int si_code)899899+ unsigned long address, u32 *pkey, int si_code)897900{898901 struct task_struct *tsk = current;899902···940945 tsk->thread.error_code = error_code;941946 tsk->thread.trap_nr = X86_TRAP_PF;942947943943- force_sig_info_fault(SIGSEGV, si_code, address, tsk, vma, 0);948948+ force_sig_info_fault(SIGSEGV, si_code, address, tsk, pkey, 0);944949945950 return;946951 }···953958954959static noinline void955960bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,956956- unsigned long address, struct vm_area_struct *vma)961961+ unsigned long address, u32 *pkey)957962{958958- __bad_area_nosemaphore(regs, error_code, address, vma, SEGV_MAPERR);963963+ __bad_area_nosemaphore(regs, error_code, address, pkey, SEGV_MAPERR);959964}960965961966static void···963968 unsigned long address, struct vm_area_struct *vma, int si_code)964969{965970 struct mm_struct *mm = current->mm;971971+ u32 pkey;972972+973973+ if (vma)974974+ pkey = vma_pkey(vma);966975967976 /*968977 * Something tried to access memory that isn't in our memory map..···974975 */975976 up_read(&mm->mmap_sem);976977977977- __bad_area_nosemaphore(regs, error_code, address, vma, si_code);978978+ __bad_area_nosemaphore(regs, error_code, address,979979+ (vma) ? &pkey : NULL, si_code);978980}979981980982static noinline void···1018101810191019static void10201020do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,10211021- struct vm_area_struct *vma, unsigned int fault)10211021+ u32 *pkey, unsigned int fault)10221022{10231023 struct task_struct *tsk = current;10241024 int code = BUS_ADRERR;···10451045 code = BUS_MCEERR_AR;10461046 }10471047#endif10481048- force_sig_info_fault(SIGBUS, code, address, tsk, vma, fault);10481048+ force_sig_info_fault(SIGBUS, code, address, tsk, pkey, fault);10491049}1050105010511051static noinline void10521052mm_fault_error(struct pt_regs *regs, unsigned long error_code,10531053- unsigned long address, struct vm_area_struct *vma,10541054- unsigned int fault)10531053+ unsigned long address, u32 *pkey, unsigned int fault)10551054{10561055 if (fatal_signal_pending(current) && !(error_code & PF_USER)) {10571056 no_context(regs, error_code, address, 0, 0);···10741075 } else {10751076 if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|10761077 VM_FAULT_HWPOISON_LARGE))10771077- do_sigbus(regs, error_code, address, vma, fault);10781078+ do_sigbus(regs, error_code, address, pkey, fault);10781079 else if (fault & VM_FAULT_SIGSEGV)10791079- bad_area_nosemaphore(regs, error_code, address, vma);10801080+ bad_area_nosemaphore(regs, error_code, address, pkey);10801081 else10811082 BUG();10821083 }···12661267 struct mm_struct *mm;12671268 int fault, major = 0;12681269 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;12701270+ u32 pkey;1269127112701272 tsk = current;12711273 mm = tsk->mm;···14671467 return;14681468 }1469146914701470+ pkey = vma_pkey(vma);14701471 up_read(&mm->mmap_sem);14711472 if (unlikely(fault & VM_FAULT_ERROR)) {14721472- mm_fault_error(regs, error_code, address, vma, fault);14731473+ mm_fault_error(regs, error_code, address, &pkey, fault);14731474 return;14741475 }14751476
+2
arch/x86/mm/mem_encrypt.c
···1010 * published by the Free Software Foundation.1111 */12121313+#define DISABLE_BRANCH_PROFILING1414+1315#include <linux/linkage.h>1416#include <linux/init.h>1517#include <linux/mm.h>
···191191 * mapped in the new pgd, we'll double-fault. Forcibly192192 * map it.193193 */194194- unsigned int index = pgd_index(current_stack_pointer());194194+ unsigned int index = pgd_index(current_stack_pointer);195195 pgd_t *pgd = next->pgd + index;196196197197 if (unlikely(pgd_none(*pgd)))
+4-9
arch/x86/xen/mmu_pv.c
···12381238 * from _brk_limit way up to the max_pfn_mapped (which is the end of12391239 * the ramdisk). We continue on, erasing PMD entries that point to page12401240 * tables - do note that they are accessible at this stage via __va.12411241- * For good measure we also round up to the PMD - which means that if12411241+ * As Xen is aligning the memory end to a 4MB boundary, for good12421242+ * measure we also round up to PMD_SIZE * 2 - which means that if12421243 * anybody is using __ka address to the initial boot-stack - and try12431244 * to use it - they are going to crash. The xen_start_info has been12441245 * taken care of already in xen_setup_kernel_pagetable. */12451246 addr = xen_start_info->pt_base;12461246- size = roundup(xen_start_info->nr_pt_frames * PAGE_SIZE, PMD_SIZE);12471247+ size = xen_start_info->nr_pt_frames * PAGE_SIZE;1247124812481248- xen_cleanhighmap(addr, addr + size);12491249+ xen_cleanhighmap(addr, roundup(addr + size, PMD_SIZE * 2));12491250 xen_start_info->pt_base = (unsigned long)__va(__pa(xen_start_info->pt_base));12501250-#ifdef DEBUG12511251- /* This is superfluous and is not necessary, but you know what12521252- * lets do it. The MODULES_VADDR -> MODULES_END should be clear of12531253- * anything at this stage. */12541254- xen_cleanhighmap(MODULES_VADDR, roundup(MODULES_VADDR, PUD_SIZE) - 1);12551255-#endif12561251}12571252#endif12581253
···743743 }744744 ghes_do_proc(ghes, ghes->estatus);745745746746+out:747747+ ghes_clear_estatus(ghes);748748+749749+ if (rc == -ENOENT)750750+ return rc;751751+746752 /*747753 * GHESv2 type HEST entries introduce support for error acknowledgment,748754 * so only acknowledge the error if this support is present.749755 */750750- if (is_hest_type_generic_v2(ghes)) {751751- rc = ghes_ack_error(ghes->generic_v2);752752- if (rc)753753- return rc;754754- }755755-out:756756- ghes_clear_estatus(ghes);756756+ if (is_hest_type_generic_v2(ghes))757757+ return ghes_ack_error(ghes->generic_v2);758758+757759 return rc;758760}759761
+7
drivers/base/power/opp/core.c
···1581158115821582 opp->available = availability_req;1583158315841584+ dev_pm_opp_get(opp);15851585+ mutex_unlock(&opp_table->lock);15861586+15841587 /* Notify the change of the OPP availability */15851588 if (availability_req)15861589 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE,···15921589 blocking_notifier_call_chain(&opp_table->head,15931590 OPP_EVENT_DISABLE, opp);1594159115921592+ dev_pm_opp_put(opp);15931593+ goto put_table;15941594+15951595unlock:15961596 mutex_unlock(&opp_table->lock);15971597+put_table:15971598 dev_pm_opp_put_opp_table(opp_table);15981599 return r;15991600}
···6767struct loop_cmd {6868 struct kthread_work work;6969 struct request *rq;7070- union {7171- bool use_aio; /* use AIO interface to handle I/O */7272- atomic_t ref; /* only for aio */7373- };7070+ bool use_aio; /* use AIO interface to handle I/O */7171+ atomic_t ref; /* only for aio */7472 long ret;7573 struct kiocb iocb;7674 struct bio_vec *bvec;
+6
drivers/block/nbd.c
···11941194 if (!capable(CAP_SYS_ADMIN))11951195 return -EPERM;1196119611971197+ /* The block layer will pass back some non-nbd ioctls in case we have11981198+ * special handling for them, but we don't so just return an error.11991199+ */12001200+ if (_IOC_TYPE(cmd) != 0xab)12011201+ return -EINVAL;12021202+11971203 mutex_lock(&nbd->config_lock);1198120411991205 /* Don't allow ioctl operations on a nbd device that was created with
···892892 int err = 0;893893894894 dev = kfd_device_by_id(args->gpu_id);895895+ if (!dev)896896+ return -EINVAL;895897896898 dev->kfd2kgd->get_tile_config(dev->kgd, &config);897899
+4-1
drivers/gpu/drm/amd/amdkfd/kfd_events.c
···292292 struct kfd_event *ev)293293{294294 if (p->signal_event_count == KFD_SIGNAL_EVENT_LIMIT) {295295- pr_warn("Signal event wasn't created because limit was reached\n");295295+ if (!p->signal_event_limit_reached) {296296+ pr_warn("Signal event wasn't created because limit was reached\n");297297+ p->signal_event_limit_reached = true;298298+ }296299 return -ENOMEM;297300 }298301
+16-4
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
···184184 if (kq->queue->properties.type == KFD_QUEUE_TYPE_HIQ)185185 kq->mqd->destroy_mqd(kq->mqd,186186 kq->queue->mqd,187187- false,187187+ KFD_PREEMPT_TYPE_WAVEFRONT_RESET,188188 QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS,189189 kq->queue->pipe,190190 kq->queue->queue);···210210 uint32_t wptr, rptr;211211 unsigned int *queue_address;212212213213+ /* When rptr == wptr, the buffer is empty.214214+ * When rptr == wptr + 1, the buffer is full.215215+ * It is always rptr that advances to the position of wptr, rather than216216+ * the opposite. So we can only use up to queue_size_dwords - 1 dwords.217217+ */213218 rptr = *kq->rptr_kernel;214219 wptr = *kq->wptr_kernel;215220 queue_address = (unsigned int *)kq->pq_kernel_addr;···224219 pr_debug("wptr: %d\n", wptr);225220 pr_debug("queue_address 0x%p\n", queue_address);226221227227- available_size = (rptr - 1 - wptr + queue_size_dwords) %222222+ available_size = (rptr + queue_size_dwords - 1 - wptr) %228223 queue_size_dwords;229224230230- if (packet_size_in_dwords >= queue_size_dwords ||231231- packet_size_in_dwords >= available_size) {225225+ if (packet_size_in_dwords > available_size) {232226 /*233227 * make sure calling functions know234228 * acquire_packet_buffer() failed···237233 }238234239235 if (wptr + packet_size_in_dwords >= queue_size_dwords) {236236+ /* make sure after rolling back to position 0, there is237237+ * still enough space.238238+ */239239+ if (packet_size_in_dwords >= rptr) {240240+ *buffer_ptr = NULL;241241+ return -ENOMEM;242242+ }243243+ /* fill nops, roll back and start at position 0 */240244 while (wptr > 0) {241245 queue_address[wptr] = kq->nop_packet;242246 wptr = (wptr + 1) % queue_size_dwords;
···16631663 radeon_agp_suspend(rdev);1664166416651665 pci_save_state(dev->pdev);16661666- if (freeze && rdev->family >= CHIP_CEDAR) {16661666+ if (freeze && rdev->family >= CHIP_CEDAR && !(rdev->flags & RADEON_IS_IGP)) {16671667 rdev->asic->asic_reset(rdev, true);16681668 pci_restore_state(dev->pdev);16691669 } else if (suspend) {
+1-1
drivers/gpu/drm/sun4i/Kconfig
···2626 bool "Allwinner A10 HDMI CEC Support"2727 depends on DRM_SUN4I_HDMI2828 select CEC_CORE2929- depends on CEC_PIN2929+ select CEC_PIN3030 help3131 Choose this option if you have an Allwinner SoC with an HDMI3232 controller and want to use CEC.
···63636464/* This part must be outside protection */6565#undef TRACE_INCLUDE_PATH6666-#define TRACE_INCLUDE_PATH .6666+#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/tegra6767#define TRACE_INCLUDE_FILE trace6868#include <trace/define_trace.h>
+3-1
drivers/infiniband/core/security.c
···432432 atomic_set(&qp->qp_sec->error_list_count, 0);433433 init_completion(&qp->qp_sec->error_complete);434434 ret = security_ib_alloc_security(&qp->qp_sec->security);435435- if (ret)435435+ if (ret) {436436 kfree(qp->qp_sec);437437+ qp->qp_sec = NULL;438438+ }437439438440 return ret;439441}
···10661066static int thermal_init(struct hfi1_devdata *dd);1067106710681068static void update_statusp(struct hfi1_pportdata *ppd, u32 state);10691069+static int wait_phys_link_offline_substates(struct hfi1_pportdata *ppd,10701070+ int msecs);10691071static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,10701072 int msecs);10711073static void log_state_transition(struct hfi1_pportdata *ppd, u32 state);···82408238 u64 regs[CCE_NUM_INT_CSRS];82418239 u32 bit;82428240 int i;82418241+ irqreturn_t handled = IRQ_NONE;8243824282448243 this_cpu_inc(*dd->int_counter);82458244···82618258 for_each_set_bit(bit, (unsigned long *)®s[0],82628259 CCE_NUM_INT_CSRS * 64) {82638260 is_interrupt(dd, bit);82618261+ handled = IRQ_HANDLED;82648262 }8265826382668266- return IRQ_HANDLED;82648264+ return handled;82678265}8268826682698267static irqreturn_t sdma_interrupt(int irq, void *data)···94179413 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK, mask);94189414}9419941594209420-void reset_qsfp(struct hfi1_pportdata *ppd)94169416+int reset_qsfp(struct hfi1_pportdata *ppd)94219417{94229418 struct hfi1_devdata *dd = ppd->dd;94239419 u64 mask, qsfp_mask;···94479443 * for alarms and warnings94489444 */94499445 set_qsfp_int_n(ppd, 1);94469446+94479447+ /*94489448+ * After the reset, AOC transmitters are enabled by default. They need94499449+ * to be turned off to complete the QSFP setup before they can be94509450+ * enabled again.94519451+ */94529452+ return set_qsfp_tx(ppd, 0);94509453}9451945494529455static int handle_qsfp_error_conditions(struct hfi1_pportdata *ppd,···1031610305{1031710306 struct hfi1_devdata *dd = ppd->dd;1031810307 u32 previous_state;1030810308+ int offline_state_ret;1031910309 int ret;10320103101032110311 update_lcb_cache(dd);···1033810326 ppd->offline_disabled_reason =1033910327 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);10340103281034110341- /*1034210342- * Wait for offline transition. It can take a while for1034310343- * the link to go down.1034410344- */1034510345- ret = wait_physical_linkstate(ppd, PLS_OFFLINE, 10000);1034610346- if (ret < 0)1034710347- return ret;1032910329+ offline_state_ret = wait_phys_link_offline_substates(ppd, 10000);1033010330+ if (offline_state_ret < 0)1033110331+ return offline_state_ret;10348103321034910349- /*1035010350- * Now in charge of LCB - must be after the physical state is1035110351- * offline.quiet and before host_link_state is changed.1035210352- */1035310353- set_host_lcb_access(dd);1035410354- write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */1035510355-1035610356- /* make sure the logical state is also down */1035710357- ret = wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000);1035810358- if (ret)1035910359- force_logical_link_state_down(ppd);1036010360-1036110361- ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */1036210362-1033310333+ /* Disabling AOC transmitters */1036310334 if (ppd->port_type == PORT_TYPE_QSFP &&1036410335 ppd->qsfp_info.limiting_active &&1036510336 qsfp_mod_present(ppd)) {···1035810363 "Unable to acquire lock to turn off QSFP TX\n");1035910364 }1036010365 }1036610366+1036710367+ /*1036810368+ * Wait for the offline.Quiet transition if it hasn't happened yet. It1036910369+ * can take a while for the link to go down.1037010370+ */1037110371+ if (offline_state_ret != PLS_OFFLINE_QUIET) {1037210372+ ret = wait_physical_linkstate(ppd, PLS_OFFLINE, 30000);1037310373+ if (ret < 0)1037410374+ return ret;1037510375+ }1037610376+1037710377+ /*1037810378+ * Now in charge of LCB - must be after the physical state is1037910379+ * offline.quiet and before host_link_state is changed.1038010380+ */1038110381+ set_host_lcb_access(dd);1038210382+ write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */1038310383+1038410384+ /* make sure the logical state is also down */1038510385+ ret = wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000);1038610386+ if (ret)1038710387+ force_logical_link_state_down(ppd);1038810388+1038910389+ ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */10361103901036210391 /*1036310392 * The LNI has a mandatory wait time after the physical state···1041510396 & (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) {1041610397 /* went down while attempting link up */1041710398 check_lni_states(ppd);1039910399+1040010400+ /* The QSFP doesn't need to be reset on LNI failure */1040110401+ ppd->qsfp_info.reset_needed = 0;1041810402 }10419104031042010404 /* the active link width (downgrade) is 0 on link down */···12824128021282512803 log_state_transition(ppd, state);1282612804 return 0;1280512805+}1280612806+1280712807+/*1280812808+ * wait_phys_link_offline_quiet_substates - wait for any offline substate1280912809+ * @ppd: port device1281012810+ * @msecs: the number of milliseconds to wait1281112811+ *1281212812+ * Wait up to msecs milliseconds for any offline physical link1281312813+ * state change to occur.1281412814+ * Returns 0 if at least one state is reached, otherwise -ETIMEDOUT.1281512815+ */1281612816+static int wait_phys_link_offline_substates(struct hfi1_pportdata *ppd,1281712817+ int msecs)1281812818+{1281912819+ u32 read_state;1282012820+ unsigned long timeout;1282112821+1282212822+ timeout = jiffies + msecs_to_jiffies(msecs);1282312823+ while (1) {1282412824+ read_state = read_physical_state(ppd->dd);1282512825+ if ((read_state & 0xF0) == PLS_OFFLINE)1282612826+ break;1282712827+ if (time_after(jiffies, timeout)) {1282812828+ dd_dev_err(ppd->dd,1282912829+ "timeout waiting for phy link offline.quiet substates. Read state 0x%x, %dms\n",1283012830+ read_state, msecs);1283112831+ return -ETIMEDOUT;1283212832+ }1283312833+ usleep_range(1950, 2050); /* sleep 2ms-ish */1283412834+ }1283512835+1283612836+ log_state_transition(ppd, read_state);1283712837+ return read_state;1282712838}12828128391282912840#define CLEAR_STATIC_RATE_CONTROL_SMASK(r) \
···204204 return ret;205205}206206207207-/* magic character sequence that trails an image */207207+/* magic character sequence that begins an image */208208+#define IMAGE_START_MAGIC "APO="209209+210210+/* magic character sequence that might trail an image */208211#define IMAGE_TRAIL_MAGIC "egamiAPO"209212210213/* EPROM file types */···253250{254251 void *buffer;255252 void *p;253253+ u32 length;256254 int ret;257255258256 buffer = kmalloc(P1_SIZE, GFP_KERNEL);···266262 return ret;267263 }268264269269- /* scan for image magic that may trail the actual data */270270- p = strnstr(buffer, IMAGE_TRAIL_MAGIC, P1_SIZE);271271- if (!p) {265265+ /* config partition is valid only if it starts with IMAGE_START_MAGIC */266266+ if (memcmp(buffer, IMAGE_START_MAGIC, strlen(IMAGE_START_MAGIC))) {272267 kfree(buffer);273268 return -ENOENT;274269 }275270271271+ /* scan for image magic that may trail the actual data */272272+ p = strnstr(buffer, IMAGE_TRAIL_MAGIC, P1_SIZE);273273+ if (p)274274+ length = p - buffer;275275+ else276276+ length = P1_SIZE;277277+276278 *data = buffer;277277- *size = p - buffer;279279+ *size = length;278280 return 0;279281}280282
+22-19
drivers/infiniband/hw/hfi1/file_ops.c
···930930 switch (ret) {931931 case 0:932932 ret = setup_base_ctxt(fd, uctxt);933933- if (uctxt->subctxt_cnt) {934934- /*935935- * Base context is done (successfully or not), notify936936- * anybody using a sub-context that is waiting for937937- * this completion.938938- */939939- clear_bit(HFI1_CTXT_BASE_UNINIT, &uctxt->event_flags);940940- wake_up(&uctxt->wait);941941- }933933+ if (ret)934934+ deallocate_ctxt(uctxt);942935 break;943936 case 1:944937 ret = complete_subctxt(fd);···12981305 /* Now allocate the RcvHdr queue and eager buffers. */12991306 ret = hfi1_create_rcvhdrq(dd, uctxt);13001307 if (ret)13011301- return ret;13081308+ goto done;1302130913031310 ret = hfi1_setup_eagerbufs(uctxt);13041311 if (ret)13051305- goto setup_failed;13121312+ goto done;1306131313071314 /* If sub-contexts are enabled, do the appropriate setup */13081315 if (uctxt->subctxt_cnt)13091316 ret = setup_subctxt(uctxt);13101317 if (ret)13111311- goto setup_failed;13181318+ goto done;1312131913131320 ret = hfi1_alloc_ctxt_rcv_groups(uctxt);13141321 if (ret)13151315- goto setup_failed;13221322+ goto done;1316132313171324 ret = init_user_ctxt(fd, uctxt);13181325 if (ret)13191319- goto setup_failed;13261326+ goto done;1320132713211328 user_init(uctxt);13221329···13241331 fd->uctxt = uctxt;13251332 hfi1_rcd_get(uctxt);1326133313271327- return 0;13341334+done:13351335+ if (uctxt->subctxt_cnt) {13361336+ /*13371337+ * On error, set the failed bit so sub-contexts will clean up13381338+ * correctly.13391339+ */13401340+ if (ret)13411341+ set_bit(HFI1_CTXT_BASE_FAILED, &uctxt->event_flags);1328134213291329-setup_failed:13301330- /* Set the failed bit so sub-context init can do the right thing */13311331- set_bit(HFI1_CTXT_BASE_FAILED, &uctxt->event_flags);13321332- deallocate_ctxt(uctxt);13431343+ /*13441344+ * Base context is done (successfully or not), notify anybody13451345+ * using a sub-context that is waiting for this completion.13461346+ */13471347+ clear_bit(HFI1_CTXT_BASE_UNINIT, &uctxt->event_flags);13481348+ wake_up(&uctxt->wait);13491349+ }1333135013341351 return ret;13351352}
+21-29
drivers/infiniband/hw/hfi1/pcie.c
···6868/*6969 * Code to adjust PCIe capabilities.7070 */7171-static int tune_pcie_caps(struct hfi1_devdata *);7171+static void tune_pcie_caps(struct hfi1_devdata *);72727373/*7474 * Do all the common PCIe setup and initialization.···351351 */352352int request_msix(struct hfi1_devdata *dd, u32 msireq)353353{354354- int nvec, ret;354354+ int nvec;355355356356 nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq,357357 PCI_IRQ_MSIX | PCI_IRQ_LEGACY);···360360 return nvec;361361 }362362363363- ret = tune_pcie_caps(dd);364364- if (ret) {365365- dd_dev_err(dd, "tune_pcie_caps() failed: %d\n", ret);366366- pci_free_irq_vectors(dd->pcidev);367367- return ret;368368- }363363+ tune_pcie_caps(dd);369364370365 /* check for legacy IRQ */371366 if (nvec == 1 && !dd->pcidev->msix_enabled)···497502module_param_named(aspm, aspm_mode, uint, S_IRUGO);498503MODULE_PARM_DESC(aspm, "PCIe ASPM: 0: disable, 1: enable, 2: dynamic");499504500500-static int tune_pcie_caps(struct hfi1_devdata *dd)505505+static void tune_pcie_caps(struct hfi1_devdata *dd)501506{502507 struct pci_dev *parent;503508 u16 rc_mpss, rc_mps, ep_mpss, ep_mps;···508513 * Turn on extended tags in DevCtl in case the BIOS has turned it off509514 * to improve WFR SDMA bandwidth510515 */511511- ret = pcie_capability_read_word(dd->pcidev,512512- PCI_EXP_DEVCTL, &ectl);513513- if (ret) {514514- dd_dev_err(dd, "Unable to read from PCI config\n");515515- return ret;516516- }517517-518518- if (!(ectl & PCI_EXP_DEVCTL_EXT_TAG)) {516516+ ret = pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl);517517+ if ((!ret) && !(ectl & PCI_EXP_DEVCTL_EXT_TAG)) {519518 dd_dev_info(dd, "Enabling PCIe extended tags\n");520519 ectl |= PCI_EXP_DEVCTL_EXT_TAG;521520 ret = pcie_capability_write_word(dd->pcidev,522521 PCI_EXP_DEVCTL, ectl);523523- if (ret) {524524- dd_dev_err(dd, "Unable to write to PCI config\n");525525- return ret;526526- }522522+ if (ret)523523+ dd_dev_info(dd, "Unable to write to PCI config\n");527524 }528525 /* Find out supported and configured values for parent (root) */529526 parent = dd->pcidev->bus->self;···523536 * The driver cannot perform the tuning if it does not have524537 * access to the upstream component.525538 */526526- if (!parent)527527- return -EINVAL;539539+ if (!parent) {540540+ dd_dev_info(dd, "Parent not found\n");541541+ return;542542+ }528543 if (!pci_is_root_bus(parent->bus)) {529544 dd_dev_info(dd, "Parent not root\n");530530- return -EINVAL;545545+ return;531546 }532532-533533- if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev))534534- return -EINVAL;547547+ if (!pci_is_pcie(parent)) {548548+ dd_dev_info(dd, "Parent is not PCI Express capable\n");549549+ return;550550+ }551551+ if (!pci_is_pcie(dd->pcidev)) {552552+ dd_dev_info(dd, "PCI device is not PCI Express capable\n");553553+ return;554554+ }535555 rc_mpss = parent->pcie_mpss;536556 rc_mps = ffs(pcie_get_mps(parent)) - 8;537557 /* Find out supported and configured values for endpoint (us) */···584590 ep_mrrs = max_mrrs;585591 pcie_set_readrq(dd->pcidev, ep_mrrs);586592 }587587-588588- return 0;589593}590594591595/* End of PCIe capability tuning */
+3-1
drivers/infiniband/hw/hfi1/platform.c
···790790 * reuse of stale settings established in our previous pass through.791791 */792792 if (ppd->qsfp_info.reset_needed) {793793- reset_qsfp(ppd);793793+ ret = reset_qsfp(ppd);794794+ if (ret)795795+ return ret;794796 refresh_qsfp_cache(ppd, &ppd->qsfp_info);795797 } else {796798 ppd->qsfp_info.reset_needed = 1;
···5050{5151 unsigned long tmp;5252 unsigned long m;5353- int i, k;5454- u64 base = 0;5555- int p = 0;5656- int skip;5757- int mask;5858- u64 len;5959- u64 pfn;5353+ u64 base = ~0, p = 0;5454+ u64 len, pfn;5555+ int i = 0;6056 struct scatterlist *sg;6157 int entry;6258 unsigned long page_shift = umem->page_shift;···7276 m = find_first_bit(&tmp, BITS_PER_LONG);7377 if (max_page_shift)7478 m = min_t(unsigned long, max_page_shift - page_shift, m);7575- skip = 1 << m;7676- mask = skip - 1;7777- i = 0;7979+7880 for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {7981 len = sg_dma_len(sg) >> page_shift;8082 pfn = sg_dma_address(sg) >> page_shift;8181- for (k = 0; k < len; k++) {8282- if (!(i & mask)) {8383- tmp = (unsigned long)pfn;8484- m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG));8585- skip = 1 << m;8686- mask = skip - 1;8787- base = pfn;8888- p = 0;8989- } else {9090- if (base + p != pfn) {9191- tmp = (unsigned long)p;9292- m = find_first_bit(&tmp, BITS_PER_LONG);9393- skip = 1 << m;9494- mask = skip - 1;9595- base = pfn;9696- p = 0;9797- }9898- }9999- p++;100100- i++;8383+ if (base + p != pfn) {8484+ /* If either the offset or the new8585+ * base are unaligned update m8686+ */8787+ tmp = (unsigned long)(pfn | p);8888+ if (!IS_ALIGNED(tmp, 1 << m))8989+ m = find_first_bit(&tmp, BITS_PER_LONG);9090+9191+ base = pfn;9292+ p = 0;10193 }9494+9595+ p += len;9696+ i += len;10297 }1039810499 if (i) {
···10001000 */10011001 priv->dev->broadcast[8] = priv->pkey >> 8;10021002 priv->dev->broadcast[9] = priv->pkey & 0xff;10031003-10041004- /*10051005- * Update the broadcast address in the priv->broadcast object,10061006- * in case it already exists, otherwise no one will do that.10071007- */10081008- if (priv->broadcast) {10091009- spin_lock_irq(&priv->lock);10101010- memcpy(priv->broadcast->mcmember.mgid.raw,10111011- priv->dev->broadcast + 4,10121012- sizeof(union ib_gid));10131013- spin_unlock_irq(&priv->lock);10141014- }10151015-10161003 return 0;10171004 }10181005
···141141 return restart_syscall();142142 }143143144144- priv = ipoib_intf_alloc(ppriv->ca, ppriv->port, intf_name);145145- if (!priv) {144144+ if (!down_write_trylock(&ppriv->vlan_rwsem)) {146145 rtnl_unlock();147146 mutex_unlock(&ppriv->sysfs_mutex);148148- return -ENOMEM;147147+ return restart_syscall();149148 }150149151151- down_write(&ppriv->vlan_rwsem);150150+ priv = ipoib_intf_alloc(ppriv->ca, ppriv->port, intf_name);151151+ if (!priv) {152152+ result = -ENOMEM;153153+ goto out;154154+ }152155153156 /*154157 * First ensure this isn't a duplicate. We check the parent device and···178175 rtnl_unlock();179176 mutex_unlock(&ppriv->sysfs_mutex);180177181181- if (result) {182182- free_netdev(priv->dev);178178+ if (result && priv) {179179+ struct rdma_netdev *rn;180180+181181+ rn = netdev_priv(priv->dev);182182+ rn->free_rdma_netdev(priv->dev);183183 kfree(priv);184184 }185185···210204 return restart_syscall();211205 }212206213213- down_write(&ppriv->vlan_rwsem);207207+ if (!down_write_trylock(&ppriv->vlan_rwsem)) {208208+ rtnl_unlock();209209+ mutex_unlock(&ppriv->sysfs_mutex);210210+ return restart_syscall();211211+ }212212+214213 list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) {215214 if (priv->pkey == pkey &&216215 priv->child_type == IPOIB_LEGACY_CHILD) {···235224 mutex_unlock(&ppriv->sysfs_mutex);236225237226 if (dev) {238238- free_netdev(dev);227227+ struct rdma_netdev *rn;228228+229229+ rn = netdev_priv(dev);230230+ rn->free_rdma_netdev(priv->dev);239231 kfree(priv);240232 return 0;241233 }
+1-1
drivers/infiniband/ulp/iser/iser_memory.c
···154154{155155 int i;156156157157- iser_err("page vec npages %d data length %d\n",157157+ iser_err("page vec npages %d data length %lld\n",158158 page_vec->npages, page_vec->fake_mr.length);159159 for (i = 0; i < page_vec->npages; i++)160160 iser_err("vec[%d]: %llx\n", i, page_vec->pages[i]);
+4-4
drivers/iommu/amd_iommu_init.c
···874874 hi = readl(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET + 4);875875 entry = (((u64) hi) << 32) + lo;876876 if (last_entry && last_entry != entry) {877877- pr_err("IOMMU:%d should use the same dev table as others!/n",877877+ pr_err("IOMMU:%d should use the same dev table as others!\n",878878 iommu->index);879879 return false;880880 }···882882883883 old_devtb_size = ((entry & ~PAGE_MASK) + 1) << 12;884884 if (old_devtb_size != dev_table_size) {885885- pr_err("The device table size of IOMMU:%d is not expected!/n",885885+ pr_err("The device table size of IOMMU:%d is not expected!\n",886886 iommu->index);887887 return false;888888 }···890890891891 old_devtb_phys = entry & PAGE_MASK;892892 if (old_devtb_phys >= 0x100000000ULL) {893893- pr_err("The address of old device table is above 4G, not trustworthy!/n");893893+ pr_err("The address of old device table is above 4G, not trustworthy!\n");894894 return false;895895 }896896 old_devtb = memremap(old_devtb_phys, dev_table_size, MEMREMAP_WB);···901901 old_dev_tbl_cpy = (void *)__get_free_pages(gfp_flag,902902 get_order(dev_table_size));903903 if (old_dev_tbl_cpy == NULL) {904904- pr_err("Failed to allocate memory for copying old device table!/n");904904+ pr_err("Failed to allocate memory for copying old device table!\n");905905 return false;906906 }907907
+1-1
drivers/iommu/io-pgtable-arm-v7s.c
···245245static void __arm_v7s_pte_sync(arm_v7s_iopte *ptep, int num_entries,246246 struct io_pgtable_cfg *cfg)247247{248248- if (!(cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA))248248+ if (cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA)249249 return;250250251251 dma_sync_single_for_device(cfg->iommu_dev, __arm_v7s_dma_addr(ptep),
+2-1
drivers/iommu/mtk_iommu.c
···371371 int ret;372372373373 spin_lock_irqsave(&dom->pgtlock, flags);374374- ret = dom->iop->map(dom->iop, iova, paddr, size, prot);374374+ ret = dom->iop->map(dom->iop, iova, paddr & DMA_BIT_MASK(32),375375+ size, prot);375376 spin_unlock_irqrestore(&dom->pgtlock, flags);376377377378 return ret;
+8-5
drivers/irqchip/irq-mips-gic.c
···175175176176static void gic_unmask_irq(struct irq_data *d)177177{178178- struct cpumask *affinity = irq_data_get_affinity_mask(d);179178 unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq);180179 unsigned int cpu;181180182181 write_gic_smask(intr);183182184183 gic_clear_pcpu_masks(intr);185185- cpu = cpumask_first_and(affinity, cpu_online_mask);184184+ cpu = cpumask_first(irq_data_get_effective_affinity_mask(d));186185 set_bit(intr, per_cpu_ptr(pcpu_masks, cpu));187186}188187···419420 irq_hw_number_t hw, unsigned int cpu)420421{421422 int intr = GIC_HWIRQ_TO_SHARED(hw);423423+ struct irq_data *data;422424 unsigned long flags;425425+426426+ data = irq_get_irq_data(virq);423427424428 spin_lock_irqsave(&gic_lock, flags);425429 write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin);426430 write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu)));427431 gic_clear_pcpu_masks(intr);428432 set_bit(intr, per_cpu_ptr(pcpu_masks, cpu));433433+ irq_data_update_effective_affinity(data, cpumask_of(cpu));429434 spin_unlock_irqrestore(&gic_lock, flags);430435431436 return 0;···648645649646 /* Find the first available CPU vector. */650647 i = 0;651651- reserved = (C_SW0 | C_SW1) >> __fls(C_SW0);648648+ reserved = (C_SW0 | C_SW1) >> __ffs(C_SW0);652649 while (!of_property_read_u32_index(node, "mti,reserved-cpu-vectors",653650 i++, &cpu_vec))654651 reserved |= BIT(cpu_vec);···687684688685 gicconfig = read_gic_config();689686 gic_shared_intrs = gicconfig & GIC_CONFIG_NUMINTERRUPTS;690690- gic_shared_intrs >>= __fls(GIC_CONFIG_NUMINTERRUPTS);687687+ gic_shared_intrs >>= __ffs(GIC_CONFIG_NUMINTERRUPTS);691688 gic_shared_intrs = (gic_shared_intrs + 1) * 8;692689693690 gic_vpes = gicconfig & GIC_CONFIG_PVPS;694694- gic_vpes >>= __fls(GIC_CONFIG_PVPS);691691+ gic_vpes >>= __ffs(GIC_CONFIG_PVPS);695692 gic_vpes = gic_vpes + 1;696693697694 if (cpu_has_veic) {
···266266 * call has finished, the bio has been linked into some internal structure267267 * and so is visible to ->quiesce(), so we don't need the refcount any more.268268 */269269+void md_handle_request(struct mddev *mddev, struct bio *bio)270270+{271271+check_suspended:272272+ rcu_read_lock();273273+ if (mddev->suspended) {274274+ DEFINE_WAIT(__wait);275275+ for (;;) {276276+ prepare_to_wait(&mddev->sb_wait, &__wait,277277+ TASK_UNINTERRUPTIBLE);278278+ if (!mddev->suspended)279279+ break;280280+ rcu_read_unlock();281281+ schedule();282282+ rcu_read_lock();283283+ }284284+ finish_wait(&mddev->sb_wait, &__wait);285285+ }286286+ atomic_inc(&mddev->active_io);287287+ rcu_read_unlock();288288+289289+ if (!mddev->pers->make_request(mddev, bio)) {290290+ atomic_dec(&mddev->active_io);291291+ wake_up(&mddev->sb_wait);292292+ goto check_suspended;293293+ }294294+295295+ if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)296296+ wake_up(&mddev->sb_wait);297297+}298298+EXPORT_SYMBOL(md_handle_request);299299+269300static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)270301{271302 const int rw = bio_data_dir(bio);···316285 bio_endio(bio);317286 return BLK_QC_T_NONE;318287 }319319-check_suspended:320320- rcu_read_lock();321321- if (mddev->suspended) {322322- DEFINE_WAIT(__wait);323323- for (;;) {324324- prepare_to_wait(&mddev->sb_wait, &__wait,325325- TASK_UNINTERRUPTIBLE);326326- if (!mddev->suspended)327327- break;328328- rcu_read_unlock();329329- schedule();330330- rcu_read_lock();331331- }332332- finish_wait(&mddev->sb_wait, &__wait);333333- }334334- atomic_inc(&mddev->active_io);335335- rcu_read_unlock();336288337289 /*338290 * save the sectors now since our bio can···324310 sectors = bio_sectors(bio);325311 /* bio could be mergeable after passing to underlayer */326312 bio->bi_opf &= ~REQ_NOMERGE;327327- if (!mddev->pers->make_request(mddev, bio)) {328328- atomic_dec(&mddev->active_io);329329- wake_up(&mddev->sb_wait);330330- goto check_suspended;331331- }313313+314314+ md_handle_request(mddev, bio);332315333316 cpu = part_stat_lock();334317 part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);335318 part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors);336319 part_stat_unlock();337337-338338- if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)339339- wake_up(&mddev->sb_wait);340320341321 return BLK_QC_T_NONE;342322}···447439 struct mddev *mddev = container_of(ws, struct mddev, flush_work);448440 struct bio *bio = mddev->flush_bio;449441442442+ /*443443+ * must reset flush_bio before calling into md_handle_request to avoid a444444+ * deadlock, because other bios passed md_handle_request suspend check445445+ * could wait for this and below md_handle_request could wait for those446446+ * bios because of suspend check447447+ */448448+ mddev->flush_bio = NULL;449449+ wake_up(&mddev->sb_wait);450450+450451 if (bio->bi_iter.bi_size == 0)451452 /* an empty barrier - all done */452453 bio_endio(bio);453454 else {454455 bio->bi_opf &= ~REQ_PREFLUSH;455455- mddev->pers->make_request(mddev, bio);456456+ md_handle_request(mddev, bio);456457 }457457-458458- mddev->flush_bio = NULL;459459- wake_up(&mddev->sb_wait);460458}461459462460void md_flush_request(struct mddev *mddev, struct bio *bio)
+1
drivers/md/md.h
···692692extern int md_rdev_init(struct md_rdev *rdev);693693extern void md_rdev_clear(struct md_rdev *rdev);694694695695+extern void md_handle_request(struct mddev *mddev, struct bio *bio);695696extern void mddev_suspend(struct mddev *mddev);696697extern void mddev_resume(struct mddev *mddev);697698extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,
+5-2
drivers/md/raid5.c
···65756575raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len)65766576{65776577 struct r5conf *conf;65786578- unsigned long new;65786578+ unsigned int new;65796579 int err;65806580 struct r5worker_group *new_groups, *old_groups;65816581 int group_cnt, worker_cnt_per_group;6582658265836583 if (len >= PAGE_SIZE)65846584 return -EINVAL;65856585- if (kstrtoul(page, 10, &new))65856585+ if (kstrtouint(page, 10, &new))65866586+ return -EINVAL;65876587+ /* 8192 should be big enough */65886588+ if (new > 8192)65866589 return -EINVAL;6587659065886591 err = mddev_lock(mddev);
···581581 slave->mtd.erasesize = parent->erasesize;582582 }583583584584+ /*585585+ * Slave erasesize might differ from the master one if the master586586+ * exposes several regions with different erasesize. Adjust587587+ * wr_alignment accordingly.588588+ */589589+ if (!(slave->mtd.flags & MTD_NO_ERASE))590590+ wr_alignment = slave->mtd.erasesize;591591+584592 tmp = slave->offset;585593 remainder = do_div(tmp, wr_alignment);586594 if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
+1-1
drivers/mtd/nand/atmel/pmecc.c
···363363 size += (req->ecc.strength + 1) * sizeof(u16);364364 /* Reserve space for mu, dmu and delta. */365365 size = ALIGN(size, sizeof(s32));366366- size += (req->ecc.strength + 1) * sizeof(s32);366366+ size += (req->ecc.strength + 1) * sizeof(s32) * 3;367367368368 user = kzalloc(size, GFP_KERNEL);369369 if (!user)
+4-5
drivers/nvme/host/core.c
···134134 return false;135135 if (nvme_req(req)->status & NVME_SC_DNR)136136 return false;137137- if (jiffies - req->start_time >= req->timeout)138138- return false;139137 if (nvme_req(req)->retries >= nvme_max_retries)140138 return false;141139 return true;···25882590 container_of(work, struct nvme_ctrl, async_event_work);2589259125902592 spin_lock_irq(&ctrl->lock);25912591- while (ctrl->event_limit > 0) {25932593+ while (ctrl->state == NVME_CTRL_LIVE && ctrl->event_limit > 0) {25922594 int aer_idx = --ctrl->event_limit;2593259525942596 spin_unlock_irq(&ctrl->lock);···26752677 /*FALLTHRU*/26762678 case NVME_SC_ABORT_REQ:26772679 ++ctrl->event_limit;26782678- queue_work(nvme_wq, &ctrl->async_event_work);26802680+ if (ctrl->state == NVME_CTRL_LIVE)26812681+ queue_work(nvme_wq, &ctrl->async_event_work);26792682 break;26802683 default:26812684 break;···26912692 nvme_queue_scan(ctrl);26922693 break;26932694 case NVME_AER_NOTICE_FW_ACT_STARTING:26942694- schedule_work(&ctrl->fw_act_work);26952695+ queue_work(nvme_wq, &ctrl->fw_act_work);26952696 break;26962697 default:26972698 dev_warn(ctrl->device, "async event result %08x\n", result);
+9-9
drivers/nvme/host/fabrics.c
···565565 opts->queue_size = NVMF_DEF_QUEUE_SIZE;566566 opts->nr_io_queues = num_online_cpus();567567 opts->reconnect_delay = NVMF_DEF_RECONNECT_DELAY;568568+ opts->kato = NVME_DEFAULT_KATO;568569569570 options = o = kstrdup(buf, GFP_KERNEL);570571 if (!options)···656655 goto out;657656 }658657659659- if (opts->discovery_nqn) {660660- pr_err("Discovery controllers cannot accept keep_alive_tmo != 0\n");661661- ret = -EINVAL;662662- goto out;663663- }664664-665658 if (token < 0) {666659 pr_err("Invalid keep_alive_tmo %d\n", token);667660 ret = -EINVAL;668661 goto out;669669- } else if (token == 0) {662662+ } else if (token == 0 && !opts->discovery_nqn) {670663 /* Allowed for debug */671664 pr_warn("keep_alive_tmo 0 won't execute keep alives!!!\n");672665 }673666 opts->kato = token;667667+668668+ if (opts->discovery_nqn && opts->kato) {669669+ pr_err("Discovery controllers cannot accept KATO != 0\n");670670+ ret = -EINVAL;671671+ goto out;672672+ }673673+674674 break;675675 case NVMF_OPT_CTRL_LOSS_TMO:676676 if (match_int(args, &token)) {···764762 uuid_copy(&opts->host->id, &hostid);765763766764out:767767- if (!opts->discovery_nqn && !opts->kato)768768- opts->kato = NVME_DEFAULT_KATO;769765 kfree(options);770766 return ret;771767}
+11-10
drivers/nvme/host/fc.c
···13761376 if (atomic_read(&op->state) == FCPOP_STATE_ABORTED)13771377 status = cpu_to_le16((NVME_SC_ABORT_REQ | NVME_SC_DNR) << 1);13781378 else if (freq->status)13791379- status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);13791379+ status = cpu_to_le16(NVME_SC_INTERNAL << 1);1380138013811381 /*13821382 * For the linux implementation, if we have an unsuccesful···14041404 */14051405 if (freq->transferred_length !=14061406 be32_to_cpu(op->cmd_iu.data_len)) {14071407- status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);14071407+ status = cpu_to_le16(NVME_SC_INTERNAL << 1);14081408 goto done;14091409 }14101410 result.u64 = 0;···14211421 freq->transferred_length ||14221422 op->rsp_iu.status_code ||14231423 sqe->common.command_id != cqe->command_id)) {14241424- status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);14241424+ status = cpu_to_le16(NVME_SC_INTERNAL << 1);14251425 goto done;14261426 }14271427 result = cqe->result;···14291429 break;1430143014311431 default:14321432- status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);14321432+ status = cpu_to_le16(NVME_SC_INTERNAL << 1);14331433 goto done;14341434 }14351435···19891989 * as well as those by FC-NVME spec.19901990 */19911991 WARN_ON_ONCE(sqe->common.metadata);19921992- WARN_ON_ONCE(sqe->common.dptr.prp1);19931993- WARN_ON_ONCE(sqe->common.dptr.prp2);19941992 sqe->common.flags |= NVME_CMD_SGL_METABUF;1995199319961994 /*19971997- * format SQE DPTR field per FC-NVME rules19981998- * type=data block descr; subtype=offset;19991999- * offset is currently 0.19951995+ * format SQE DPTR field per FC-NVME rules:19961996+ * type=0x5 Transport SGL Data Block Descriptor19971997+ * subtype=0xA Transport-specific value19981998+ * address=019991999+ * length=length of the data series20002000 */20012001- sqe->rw.dptr.sgl.type = NVME_SGL_FMT_OFFSET;20012001+ sqe->rw.dptr.sgl.type = (NVME_TRANSPORT_SGL_DATA_DESC << 4) |20022002+ NVME_SGL_FMT_TRANSPORT_A;20022003 sqe->rw.dptr.sgl.length = cpu_to_le32(data_len);20032004 sqe->rw.dptr.sgl.addr = 0;20042005
···169169static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)170170{171171 struct pci_bar_info *bar = data;172172+ unsigned int pos = (offset - PCI_BASE_ADDRESS_0) / 4;173173+ const struct resource *res = dev->resource;174174+ u32 mask;172175173176 if (unlikely(!bar)) {174177 pr_warn(DRV_NAME ": driver data not found for %s\n",···182179 /* A write to obtain the length must happen as a 32-bit write.183180 * This does not (yet) support writing individual bytes184181 */185185- if (value == ~0)182182+ if (res[pos].flags & IORESOURCE_IO)183183+ mask = ~PCI_BASE_ADDRESS_IO_MASK;184184+ else if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64))185185+ mask = 0;186186+ else187187+ mask = ~PCI_BASE_ADDRESS_MEM_MASK;188188+ if ((value | mask) == ~0U)186189 bar->which = 1;187190 else {188191 u32 tmpval;
+17-1
fs/btrfs/compression.c
···107107 struct inode *inode;108108 struct page *page;109109 unsigned long index;110110- int ret;110110+ unsigned int mirror = btrfs_io_bio(bio)->mirror_num;111111+ int ret = 0;111112112113 if (bio->bi_status)113114 cb->errors = 1;···118117 */119118 if (!refcount_dec_and_test(&cb->pending_bios))120119 goto out;120120+121121+ /*122122+ * Record the correct mirror_num in cb->orig_bio so that123123+ * read-repair can work properly.124124+ */125125+ ASSERT(btrfs_io_bio(cb->orig_bio));126126+ btrfs_io_bio(cb->orig_bio)->mirror_num = mirror;127127+ cb->mirror_num = mirror;128128+129129+ /*130130+ * Some IO in this cb have failed, just skip checksum as there131131+ * is no way it could be correct.132132+ */133133+ if (cb->errors == 1)134134+ goto csum_failed;121135122136 inode = cb->inode;123137 ret = check_compressed_csum(BTRFS_I(inode), cb,
···36433643 u64 flags;3644364436453645 do_barriers = !btrfs_test_opt(fs_info, NOBARRIER);36463646- backup_super_roots(fs_info);36463646+36473647+ /*36483648+ * max_mirrors == 0 indicates we're from commit_transaction,36493649+ * not from fsync where the tree roots in fs_info have not36503650+ * been consistent on disk.36513651+ */36523652+ if (max_mirrors == 0)36533653+ backup_super_roots(fs_info);3647365436483655 sb = fs_info->super_for_commit;36493656 dev_item = &sb->dev_item;
+2-6
fs/btrfs/extent_io.c
···34713471 unsigned int write_flags = 0;34723472 unsigned long nr_written = 0;3473347334743474- if (wbc->sync_mode == WB_SYNC_ALL)34753475- write_flags = REQ_SYNC;34743474+ write_flags = wbc_to_write_flags(wbc);3476347534773476 trace___extent_writepage(page, inode, wbc);34783477···37173718 unsigned long i, num_pages;37183719 unsigned long bio_flags = 0;37193720 unsigned long start, end;37203720- unsigned int write_flags = (epd->sync_io ? REQ_SYNC : 0) | REQ_META;37213721+ unsigned int write_flags = wbc_to_write_flags(wbc) | REQ_META;37213722 int ret = 0;3722372337233724 clear_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags);···40614062{40624063 if (epd->bio) {40634064 int ret;40644064-40654065- bio_set_op_attrs(epd->bio, REQ_OP_WRITE,40664066- epd->sync_io ? REQ_SYNC : 0);4067406540684066 ret = submit_one_bio(epd->bio, 0, epd->bio_flags);40694067 BUG_ON(ret < 0); /* -ENOMEM */
+22-5
fs/btrfs/inode.c
···135135 const u64 offset,136136 const u64 bytes)137137{138138+ unsigned long index = offset >> PAGE_SHIFT;139139+ unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT;140140+ struct page *page;141141+142142+ while (index <= end_index) {143143+ page = find_get_page(inode->i_mapping, index);144144+ index++;145145+ if (!page)146146+ continue;147147+ ClearPagePrivate2(page);148148+ put_page(page);149149+ }138150 return __endio_write_update_ordered(inode, offset + PAGE_SIZE,139151 bytes - PAGE_SIZE, false);140152}···83698357 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);83708358 blk_status_t err = bio->bi_status;8371835983728372- if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) {83608360+ if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED)83738361 err = btrfs_subio_endio_read(inode, io_bio, err);83748374- if (!err)83758375- bio->bi_status = 0;83768376- }8377836283788363 unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset,83798364 dip->logical_offset + dip->bytes - 1);···8378836983798370 kfree(dip);8380837183818381- dio_bio->bi_status = bio->bi_status;83728372+ dio_bio->bi_status = err;83828373 dio_end_io(dio_bio);8383837483848375 if (io_bio->end_io)···83968387 btrfs_work_func_t func;83978388 u64 ordered_offset = offset;83988389 u64 ordered_bytes = bytes;83908390+ u64 last_offset;83998391 int ret;8400839284018393 if (btrfs_is_free_space_inode(BTRFS_I(inode))) {···84088398 }8409839984108400again:84018401+ last_offset = ordered_offset;84118402 ret = btrfs_dec_test_first_ordered_pending(inode, &ordered,84128403 &ordered_offset,84138404 ordered_bytes,···84198408 btrfs_init_work(&ordered->work, func, finish_ordered_fn, NULL, NULL);84208409 btrfs_queue_work(wq, &ordered->work);84218410out_test:84118411+ /*84128412+ * If btrfs_dec_test_ordered_pending does not find any ordered extent84138413+ * in the range, we can exit.84148414+ */84158415+ if (ordered_offset == last_offset)84168416+ return;84228417 /*84238418 * our bio might span multiple ordered extents. If we haven't84248419 * completed the accounting for the whole dio, go back and try again
+8-4
fs/btrfs/ioctl.c
···27732773 }27742774 mutex_unlock(&fs_devices->device_list_mutex);2775277527762776- fi_args->nodesize = fs_info->super_copy->nodesize;27772777- fi_args->sectorsize = fs_info->super_copy->sectorsize;27782778- fi_args->clone_alignment = fs_info->super_copy->sectorsize;27762776+ fi_args->nodesize = fs_info->nodesize;27772777+ fi_args->sectorsize = fs_info->sectorsize;27782778+ fi_args->clone_alignment = fs_info->sectorsize;2779277927802780 if (copy_to_user(arg, fi_args, sizeof(*fi_args)))27812781 ret = -EFAULT;···30323032out:30333033 if (ret)30343034 btrfs_cmp_data_free(cmp);30353035- return 0;30353035+ return ret;30363036}3037303730383038static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp)···40594059 new_root = btrfs_read_fs_root_no_name(fs_info, &location);40604060 if (IS_ERR(new_root)) {40614061 ret = PTR_ERR(new_root);40624062+ goto out;40634063+ }40644064+ if (!is_fstree(new_root->objectid)) {40654065+ ret = -ENOENT;40624066 goto out;40634067 }40644068
+2-4
fs/btrfs/qgroup.c
···807807 }808808 ret = 0;809809out:810810- set_bit(BTRFS_FS_QUOTA_DISABLING, &root->fs_info->flags);811810 btrfs_free_path(path);812811 return ret;813812}···952953 if (!fs_info->quota_root)953954 goto out;954955 clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);955955- set_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags);956956 btrfs_qgroup_wait_for_completion(fs_info, false);957957 spin_lock(&fs_info->qgroup_lock);958958 quota_root = fs_info->quota_root;···13051307 }13061308 }13071309 ret = del_qgroup_item(trans, quota_root, qgroupid);13101310+ if (ret && ret != -ENOENT)13111311+ goto out;1308131213091313 while (!list_empty(&qgroup->groups)) {13101314 list = list_first_entry(&qgroup->groups,···2086208620872087 if (test_and_clear_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags))20882088 set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);20892089- if (test_and_clear_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags))20902090- clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);2091208920922090 spin_lock(&fs_info->qgroup_lock);20932091 while (!list_empty(&fs_info->dirty_qgroups)) {
···41814181 struct extent_map *em, *n;41824182 struct list_head extents;41834183 struct extent_map_tree *tree = &inode->extent_tree;41844184+ u64 logged_start, logged_end;41844185 u64 test_gen;41854186 int ret = 0;41864187 int num = 0;···41914190 down_write(&inode->dio_sem);41924191 write_lock(&tree->lock);41934192 test_gen = root->fs_info->last_trans_committed;41934193+ logged_start = start;41944194+ logged_end = end;4194419541954196 list_for_each_entry_safe(em, n, &tree->modified_extents, list) {41964197 list_del_init(&em->list);41974197-41984198 /*41994199 * Just an arbitrary number, this can be really CPU intensive42004200 * once we start getting a lot of extents, and really once we···4210420842114209 if (em->generation <= test_gen)42124210 continue;42114211+42124212+ if (em->start < logged_start)42134213+ logged_start = em->start;42144214+ if ((em->start + em->len - 1) > logged_end)42154215+ logged_end = em->start + em->len - 1;42164216+42134217 /* Need a ref to keep it from getting evicted from cache */42144218 refcount_inc(&em->refs);42154219 set_bit(EXTENT_FLAG_LOGGING, &em->flags);···42244216 }4225421742264218 list_sort(NULL, &extents, extent_cmp);42274227- btrfs_get_logged_extents(inode, logged_list, start, end);42194219+ btrfs_get_logged_extents(inode, logged_list, logged_start, logged_end);42284220 /*42294221 * Some ordered extents started by fsync might have completed42304222 * before we could collect them into the list logged_list, which
+1-1
fs/btrfs/volumes.c
···61666166 map_length = length;6167616761686168 btrfs_bio_counter_inc_blocked(fs_info);61696169- ret = __btrfs_map_block(fs_info, bio_op(bio), logical,61696169+ ret = __btrfs_map_block(fs_info, btrfs_op(bio), logical,61706170 &map_length, &bbio, mirror_num, 1);61716171 if (ret) {61726172 btrfs_bio_counter_dec(fs_info);
+43-6
fs/direct-io.c
···229229{230230 loff_t offset = dio->iocb->ki_pos;231231 ssize_t transferred = 0;232232+ int err;232233233234 /*234235 * AIO submission can race with bio completion to get here while···259258 if (ret == 0)260259 ret = transferred;261260261261+ /*262262+ * Try again to invalidate clean pages which might have been cached by263263+ * non-direct readahead, or faulted in by get_user_pages() if the source264264+ * of the write was an mmap'ed region of the file we're writing. Either265265+ * one is a pretty crazy thing to do, so we don't support it 100%. If266266+ * this invalidation fails, tough, the write still worked...267267+ */268268+ if (ret > 0 && dio->op == REQ_OP_WRITE &&269269+ dio->inode->i_mapping->nrpages) {270270+ err = invalidate_inode_pages2_range(dio->inode->i_mapping,271271+ offset >> PAGE_SHIFT,272272+ (offset + ret - 1) >> PAGE_SHIFT);273273+ WARN_ON_ONCE(err);274274+ }275275+262276 if (dio->end_io) {263263- int err;264277265278 // XXX: ki_pos??266279 err = dio->end_io(dio->iocb, offset, ret, dio->private);···319304 struct dio *dio = bio->bi_private;320305 unsigned long remaining;321306 unsigned long flags;307307+ bool defer_completion = false;322308323309 /* cleanup the bio */324310 dio_bio_complete(dio, bio);···331315 spin_unlock_irqrestore(&dio->bio_lock, flags);332316333317 if (remaining == 0) {334334- if (dio->result && dio->defer_completion) {318318+ /*319319+ * Defer completion when defer_completion is set or320320+ * when the inode has pages mapped and this is AIO write.321321+ * We need to invalidate those pages because there is a322322+ * chance they contain stale data in the case buffered IO323323+ * went in between AIO submission and completion into the324324+ * same region.325325+ */326326+ if (dio->result)327327+ defer_completion = dio->defer_completion ||328328+ (dio->op == REQ_OP_WRITE &&329329+ dio->inode->i_mapping->nrpages);330330+ if (defer_completion) {335331 INIT_WORK(&dio->complete_work, dio_aio_complete_work);336332 queue_work(dio->inode->i_sb->s_dio_done_wq,337333 &dio->complete_work);···12381210 * For AIO O_(D)SYNC writes we need to defer completions to a workqueue12391211 * so that we can call ->fsync.12401212 */12411241- if (dio->is_async && iov_iter_rw(iter) == WRITE &&12421242- ((iocb->ki_filp->f_flags & O_DSYNC) ||12431243- IS_SYNC(iocb->ki_filp->f_mapping->host))) {12441244- retval = dio_set_defer_completion(dio);12131213+ if (dio->is_async && iov_iter_rw(iter) == WRITE) {12141214+ retval = 0;12151215+ if ((iocb->ki_filp->f_flags & O_DSYNC) ||12161216+ IS_SYNC(iocb->ki_filp->f_mapping->host))12171217+ retval = dio_set_defer_completion(dio);12181218+ else if (!dio->inode->i_sb->s_dio_done_wq) {12191219+ /*12201220+ * In case of AIO write racing with buffered read we12211221+ * need to defer completion. We can't decide this now,12221222+ * however the workqueue needs to be initialized here.12231223+ */12241224+ retval = sb_init_dio_done_wq(dio->inode->i_sb);12251225+ }12451226 if (retval) {12461227 /*12471228 * We grab i_mutex only for reads so we don't have
···713713static ssize_t iomap_dio_complete(struct iomap_dio *dio)714714{715715 struct kiocb *iocb = dio->iocb;716716+ struct inode *inode = file_inode(iocb->ki_filp);716717 ssize_t ret;718718+719719+ /*720720+ * Try again to invalidate clean pages which might have been cached by721721+ * non-direct readahead, or faulted in by get_user_pages() if the source722722+ * of the write was an mmap'ed region of the file we're writing. Either723723+ * one is a pretty crazy thing to do, so we don't support it 100%. If724724+ * this invalidation fails, tough, the write still worked...725725+ */726726+ if (!dio->error &&727727+ (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {728728+ ret = invalidate_inode_pages2_range(inode->i_mapping,729729+ iocb->ki_pos >> PAGE_SHIFT,730730+ (iocb->ki_pos + dio->size - 1) >> PAGE_SHIFT);731731+ WARN_ON_ONCE(ret);732732+ }717733718734 if (dio->end_io) {719735 ret = dio->end_io(iocb,···1009993 WARN_ON_ONCE(ret);1010994 ret = 0;1011995996996+ if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&997997+ !inode->i_sb->s_dio_done_wq) {998998+ ret = sb_init_dio_done_wq(inode->i_sb);999999+ if (ret < 0)10001000+ goto out_free_dio;10011001+ }10021002+10121003 inode_dio_begin(inode);1013100410141005 blk_start_plug(&plug);···10381015 if (ret < 0)10391016 iomap_dio_set_error(dio, ret);1040101710411041- if (ret >= 0 && iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&10421042- !inode->i_sb->s_dio_done_wq) {10431043- ret = sb_init_dio_done_wq(inode->i_sb);10441044- if (ret < 0)10451045- iomap_dio_set_error(dio, ret);10461046- }10471047-10481018 if (!atomic_dec_and_test(&dio->ref)) {10491019 if (!is_sync_kiocb(iocb))10501020 return -EIOCBQUEUED;···10571041 }1058104210591043 ret = iomap_dio_complete(dio);10601060-10611061- /*10621062- * Try again to invalidate clean pages which might have been cached by10631063- * non-direct readahead, or faulted in by get_user_pages() if the source10641064- * of the write was an mmap'ed region of the file we're writing. Either10651065- * one is a pretty crazy thing to do, so we don't support it 100%. If10661066- * this invalidation fails, tough, the write still worked...10671067- */10681068- if (iov_iter_rw(iter) == WRITE) {10691069- int err = invalidate_inode_pages2_range(mapping,10701070- start >> PAGE_SHIFT, end >> PAGE_SHIFT);10711071- WARN_ON_ONCE(err);10721072- }1073104410741045 return ret;10751046
···119119 * simple bit tests.120120 */121121static const char * const task_state_array[] = {122122- "R (running)", /* 0 */123123- "S (sleeping)", /* 1 */124124- "D (disk sleep)", /* 2 */125125- "T (stopped)", /* 4 */126126- "t (tracing stop)", /* 8 */127127- "X (dead)", /* 16 */128128- "Z (zombie)", /* 32 */122122+123123+ /* states in TASK_REPORT: */124124+ "R (running)", /* 0x00 */125125+ "S (sleeping)", /* 0x01 */126126+ "D (disk sleep)", /* 0x02 */127127+ "T (stopped)", /* 0x04 */128128+ "t (tracing stop)", /* 0x08 */129129+ "X (dead)", /* 0x10 */130130+ "Z (zombie)", /* 0x20 */131131+ "P (parked)", /* 0x40 */132132+133133+ /* states beyond TASK_REPORT: */134134+ "I (idle)", /* 0x80 */129135};130136131137static inline const char *get_task_state(struct task_struct *tsk)132138{133133- unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT;134134-135135- /*136136- * Parked tasks do not run; they sit in __kthread_parkme().137137- * Without this check, we would report them as running, which is138138- * clearly wrong, so we report them as sleeping instead.139139- */140140- if (tsk->state == TASK_PARKED)141141- state = TASK_INTERRUPTIBLE;142142-143143- BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1);144144-145145- return task_state_array[fls(state)];139139+ BUILD_BUG_ON(1 + ilog2(TASK_REPORT_MAX) != ARRAY_SIZE(task_state_array));140140+ return task_state_array[__get_task_state(tsk)];146141}147142148143static inline int get_task_umask(struct task_struct *tsk)
+2
fs/quota/dquot.c
···19801980 ret = dquot_add_space(transfer_to[cnt], cur_space, rsv_space, 0,19811981 &warn_to[cnt]);19821982 if (ret) {19831983+ spin_lock(&transfer_to[cnt]->dq_dqb_lock);19831984 dquot_decr_inodes(transfer_to[cnt], inode_usage);19851985+ spin_unlock(&transfer_to[cnt]->dq_dqb_lock);19841986 goto over_quota;19851987 }19861988 }
+4
fs/quota/quota_v2.c
···328328 if (!dquot->dq_off) {329329 alloc = true;330330 down_write(&dqopt->dqio_sem);331331+ } else {332332+ down_read(&dqopt->dqio_sem);331333 }332334 ret = qtree_write_dquot(333335 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,334336 dquot);335337 if (alloc)336338 up_write(&dqopt->dqio_sem);339339+ else340340+ up_read(&dqopt->dqio_sem);337341 return ret;338342}339343
+2-2
fs/read_write.c
···112112 * In the generic case the entire file is data, so as long as113113 * offset isn't at the end of the file then the offset is data.114114 */115115- if (offset >= eof)115115+ if ((unsigned long long)offset >= eof)116116 return -ENXIO;117117 break;118118 case SEEK_HOLE:···120120 * There is a virtual hole at the end of the file, so as long as121121 * offset isn't i_size or larger, return i_size.122122 */123123- if (offset >= eof)123123+ if ((unsigned long long)offset >= eof)124124 return -ENXIO;125125 offset = eof;126126 break;
+10-2
fs/xfs/libxfs/xfs_ag_resv.c
···156156 trace_xfs_ag_resv_free(pag, type, 0);157157158158 resv = xfs_perag_resv(pag, type);159159- pag->pag_mount->m_ag_max_usable += resv->ar_asked;159159+ if (pag->pag_agno == 0)160160+ pag->pag_mount->m_ag_max_usable += resv->ar_asked;160161 /*161162 * AGFL blocks are always considered "free", so whatever162163 * was reserved at mount time must be given back at umount.···217216 return error;218217 }219218220220- mp->m_ag_max_usable -= ask;219219+ /*220220+ * Reduce the maximum per-AG allocation length by however much we're221221+ * trying to reserve for an AG. Since this is a filesystem-wide222222+ * counter, we only make the adjustment for AG 0. This assumes that223223+ * there aren't any AGs hungrier for per-AG reservation than AG 0.224224+ */225225+ if (pag->pag_agno == 0)226226+ mp->m_ag_max_usable -= ask;221227222228 resv = xfs_perag_resv(pag, type);223229 resv->ar_asked = ask;
+2-15
fs/xfs/libxfs/xfs_bmap.c
···4949#include "xfs_rmap.h"5050#include "xfs_ag_resv.h"5151#include "xfs_refcount.h"5252-#include "xfs_rmap_btree.h"5352#include "xfs_icache.h"54535554···191192 int maxrecs; /* maximum record count at this level */192193 xfs_mount_t *mp; /* mount structure */193194 xfs_filblks_t rval; /* return value */194194- xfs_filblks_t orig_len;195195196196 mp = ip->i_mount;197197-198198- /* Calculate the worst-case size of the bmbt. */199199- orig_len = len;200197 maxrecs = mp->m_bmap_dmxr[0];201198 for (level = 0, rval = 0;202199 level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);···200205 len += maxrecs - 1;201206 do_div(len, maxrecs);202207 rval += len;203203- if (len == 1) {204204- rval += XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -208208+ if (len == 1)209209+ return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -205210 level - 1;206206- break;207207- }208211 if (level == 0)209212 maxrecs = mp->m_bmap_dmxr[1];210213 }211211-212212- /* Calculate the worst-case size of the rmapbt. */213213- if (xfs_sb_version_hasrmapbt(&mp->m_sb))214214- rval += 1 + xfs_rmapbt_calc_size(mp, orig_len) +215215- mp->m_rmap_maxlevels;216216-217214 return rval;218215}219216
···14591459 return error;1460146014611461 /*14621462- * The extent shiting code works on extent granularity. So, if14621462+ * Clean out anything hanging around in the cow fork now that14631463+ * we've flushed all the dirty data out to disk to avoid having14641464+ * CoW extents at the wrong offsets.14651465+ */14661466+ if (xfs_is_reflink_inode(ip)) {14671467+ error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF,14681468+ true);14691469+ if (error)14701470+ return error;14711471+ }14721472+14731473+ /*14741474+ * The extent shifting code works on extent granularity. So, if14631475 * stop_fsb is not the starting block of extent, we need to split14641476 * the extent at stop_fsb.14651477 */
···5858 xfs_off_t count,5959 bool *did_zero)6060{6161- return iomap_zero_range(VFS_I(ip), pos, count, NULL, &xfs_iomap_ops);6161+ return iomap_zero_range(VFS_I(ip), pos, count, did_zero, &xfs_iomap_ops);6262}63636464int···377377 */378378 spin_lock(&ip->i_flags_lock);379379 if (iocb->ki_pos > i_size_read(inode)) {380380- bool zero = false;381381-382380 spin_unlock(&ip->i_flags_lock);383381 if (!drained_dio) {384382 if (*iolock == XFS_IOLOCK_SHARED) {···397399 drained_dio = true;398400 goto restart;399401 }400400- error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), &zero);402402+ error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), NULL);401403 if (error)402404 return error;403405 } else···434436 struct inode *inode = file_inode(iocb->ki_filp);435437 struct xfs_inode *ip = XFS_I(inode);436438 loff_t offset = iocb->ki_pos;437437- bool update_size = false;438439 int error = 0;439440440441 trace_xfs_end_io_direct_write(ip, offset, size);···443446444447 if (size <= 0)445448 return size;449449+450450+ if (flags & IOMAP_DIO_COW) {451451+ error = xfs_reflink_end_cow(ip, offset, size);452452+ if (error)453453+ return error;454454+ }455455+456456+ /*457457+ * Unwritten conversion updates the in-core isize after extent458458+ * conversion but before updating the on-disk size. Updating isize any459459+ * earlier allows a racing dio read to find unwritten extents before460460+ * they are converted.461461+ */462462+ if (flags & IOMAP_DIO_UNWRITTEN)463463+ return xfs_iomap_write_unwritten(ip, offset, size, true);446464447465 /*448466 * We need to update the in-core inode size here so that we don't end up···473461 spin_lock(&ip->i_flags_lock);474462 if (offset + size > i_size_read(inode)) {475463 i_size_write(inode, offset + size);476476- update_size = true;477477- }478478- spin_unlock(&ip->i_flags_lock);479479-480480- if (flags & IOMAP_DIO_COW) {481481- error = xfs_reflink_end_cow(ip, offset, size);482482- if (error)483483- return error;484484- }485485-486486- if (flags & IOMAP_DIO_UNWRITTEN)487487- error = xfs_iomap_write_unwritten(ip, offset, size);488488- else if (update_size)464464+ spin_unlock(&ip->i_flags_lock);489465 error = xfs_setfilesize(ip, offset, size);466466+ } else {467467+ spin_unlock(&ip->i_flags_lock);468468+ }490469491470 return error;492471}
+5-3
fs/xfs/xfs_inode.c
···16241624 goto out;1625162516261626 /*16271627- * Clear the reflink flag if we truncated everything.16271627+ * Clear the reflink flag if there are no data fork blocks and16281628+ * there are no extents staged in the cow fork.16281629 */16291629- if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {16301630- ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;16301630+ if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {16311631+ if (ip->i_d.di_nblocks == 0)16321632+ ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;16311633 xfs_inode_clear_cowblocks_tag(ip);16321634 }16331635
···16541654 "DAX and reflink have not been tested together!");16551655 }1656165616571657+ if (mp->m_flags & XFS_MOUNT_DISCARD) {16581658+ struct request_queue *q = bdev_get_queue(sb->s_bdev);16591659+16601660+ if (!blk_queue_discard(q)) {16611661+ xfs_warn(mp, "mounting with \"discard\" option, but "16621662+ "the device does not support discard");16631663+ mp->m_flags &= ~XFS_MOUNT_DISCARD;16641664+ }16651665+ }16661666+16571667 if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {16581668 if (mp->m_sb.sb_rblocks) {16591669 xfs_alert(mp,
+1
include/linux/blkdev.h
···551551 int node;552552#ifdef CONFIG_BLK_DEV_IO_TRACE553553 struct blk_trace *blk_trace;554554+ struct mutex blk_trace_mutex;554555#endif555556 /*556557 * for flush operations
···167167 * @map: map a physically contiguous memory region to an iommu domain168168 * @unmap: unmap a physically contiguous memory region from an iommu domain169169 * @map_sg: map a scatter-gather list of physically contiguous memory chunks170170+ * to an iommu domain170171 * @flush_tlb_all: Synchronously flush all hardware TLBs for this domain171172 * @tlb_range_add: Add a given iova range to the flush queue for this domain172173 * @tlb_sync: Flush all queued ranges from the hardware TLBs and empty flush173174 * queue174174- * to an iommu domain175175 * @iova_to_phys: translate iova to physical address176176 * @add_device: add device to iommu grouping177177 * @remove_device: remove device from iommu grouping
+2
include/linux/key.h
···187187#define KEY_FLAG_BUILTIN 8 /* set if key is built in to the kernel */188188#define KEY_FLAG_ROOT_CAN_INVAL 9 /* set if key can be invalidated by root without permission */189189#define KEY_FLAG_KEEP 10 /* set if key should not be removed */190190+#define KEY_FLAG_UID_KEYRING 11 /* set if key is a user or user session keyring */190191191192 /* the key type and key description string192193 * - the desc is used to match a key against search criteria···244243#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */245244#define KEY_ALLOC_BUILT_IN 0x0004 /* Key is built into kernel */246245#define KEY_ALLOC_BYPASS_RESTRICTION 0x0008 /* Override the check on restricted keyrings */246246+#define KEY_ALLOC_UID_KEYRING 0x0010 /* allocating a user or user session keyring */247247248248extern void key_revoke(struct key *key);249249extern void key_invalidate(struct key *key);
+8-5
include/linux/nvme-fc-driver.h
···346346 * indicating an FC transport Aborted status.347347 * Entrypoint is Mandatory.348348 *349349- * @defer_rcv: Called by the transport to signal the LLLD that it has350350- * begun processing of a previously received NVME CMD IU. The LLDD351351- * is now free to re-use the rcv buffer associated with the352352- * nvmefc_tgt_fcp_req.353353- *354349 * @max_hw_queues: indicates the maximum number of hw queues the LLDD355350 * supports for cpu affinitization.356351 * Value is Mandatory. Must be at least 1.···801806 * outstanding operation (if there was one) to complete, then will802807 * call the fcp_req_release() callback to return the command's803808 * exchange context back to the LLDD.809809+ * Entrypoint is Mandatory.804810 *805811 * @fcp_req_release: Called by the transport to return a nvmefc_tgt_fcp_req806812 * to the LLDD after all operations on the fcp operation are complete.807813 * This may be due to the command completing or upon completion of808814 * abort cleanup.815815+ * Entrypoint is Mandatory.816816+ *817817+ * @defer_rcv: Called by the transport to signal the LLLD that it has818818+ * begun processing of a previously received NVME CMD IU. The LLDD819819+ * is now free to re-use the rcv buffer associated with the820820+ * nvmefc_tgt_fcp_req.821821+ * Entrypoint is Optional.809822 *810823 * @max_hw_queues: indicates the maximum number of hw queues the LLDD811824 * supports for cpu affinitization.
+6-13
include/linux/nvme.h
···471471 *472472 * @NVME_SGL_FMT_ADDRESS: absolute address of the data block473473 * @NVME_SGL_FMT_OFFSET: relative offset of the in-capsule data block474474+ * @NVME_SGL_FMT_TRANSPORT_A: transport defined format, value 0xA474475 * @NVME_SGL_FMT_INVALIDATE: RDMA transport specific remote invalidation475476 * request subtype476477 */477478enum {478479 NVME_SGL_FMT_ADDRESS = 0x00,479480 NVME_SGL_FMT_OFFSET = 0x01,481481+ NVME_SGL_FMT_TRANSPORT_A = 0x0A,480482 NVME_SGL_FMT_INVALIDATE = 0x0f,481483};482484···492490 *493491 * For struct nvme_keyed_sgl_desc:494492 * @NVME_KEY_SGL_FMT_DATA_DESC: keyed data block descriptor493493+ *494494+ * Transport-specific SGL types:495495+ * @NVME_TRANSPORT_SGL_DATA_DESC: Transport SGL data dlock descriptor495496 */496497enum {497498 NVME_SGL_FMT_DATA_DESC = 0x00,498499 NVME_SGL_FMT_SEG_DESC = 0x02,499500 NVME_SGL_FMT_LAST_SEG_DESC = 0x03,500501 NVME_KEY_SGL_FMT_DATA_DESC = 0x04,502502+ NVME_TRANSPORT_SGL_DATA_DESC = 0x05,501503};502504503505struct nvme_sgl_desc {···11331127 NVME_SC_UNWRITTEN_BLOCK = 0x287,1134112811351129 NVME_SC_DNR = 0x4000,11361136-11371137-11381138- /*11391139- * FC Transport-specific error status values for NVME commands11401140- *11411141- * Transport-specific status code values must be in the range 0xB0..0xBF11421142- */11431143-11441144- /* Generic FC failure - catchall */11451145- NVME_SC_FC_TRANSPORT_ERROR = 0x00B0,11461146-11471147- /* I/O failure due to FC ABTS'd */11481148- NVME_SC_FC_TRANSPORT_ABORTED = 0x00B1,11491130};1150113111511132struct nvme_completion {
···4646 * @bringup: Single callback bringup or teardown selector4747 * @cb_state: The state for a single callback (install/uninstall)4848 * @result: Result of the operation4949- * @done: Signal completion to the issuer of the task4949+ * @done_up: Signal completion to the issuer of the task for cpu-up5050+ * @done_down: Signal completion to the issuer of the task for cpu-down5051 */5152struct cpuhp_cpu_state {5253 enum cpuhp_state state;5354 enum cpuhp_state target;5555+ enum cpuhp_state fail;5456#ifdef CONFIG_SMP5557 struct task_struct *thread;5658 bool should_run;···6058 bool single;6159 bool bringup;6260 struct hlist_node *node;6161+ struct hlist_node *last;6362 enum cpuhp_state cb_state;6463 int result;6565- struct completion done;6464+ struct completion done_up;6565+ struct completion done_down;6666#endif6767};68686969-static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state);6969+static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = {7070+ .fail = CPUHP_INVALID,7171+};70727173#if defined(CONFIG_LOCKDEP) && defined(CONFIG_SMP)7272-static struct lock_class_key cpuhp_state_key;7373-static struct lockdep_map cpuhp_state_lock_map =7474- STATIC_LOCKDEP_MAP_INIT("cpuhp_state", &cpuhp_state_key);7474+static struct lockdep_map cpuhp_state_up_map =7575+ STATIC_LOCKDEP_MAP_INIT("cpuhp_state-up", &cpuhp_state_up_map);7676+static struct lockdep_map cpuhp_state_down_map =7777+ STATIC_LOCKDEP_MAP_INIT("cpuhp_state-down", &cpuhp_state_down_map);7878+7979+8080+static void inline cpuhp_lock_acquire(bool bringup)8181+{8282+ lock_map_acquire(bringup ? &cpuhp_state_up_map : &cpuhp_state_down_map);8383+}8484+8585+static void inline cpuhp_lock_release(bool bringup)8686+{8787+ lock_map_release(bringup ? &cpuhp_state_up_map : &cpuhp_state_down_map);8888+}8989+#else9090+9191+static void inline cpuhp_lock_acquire(bool bringup) { }9292+static void inline cpuhp_lock_release(bool bringup) { }9393+7594#endif76957796/**···146123/**147124 * cpuhp_invoke_callback _ Invoke the callbacks for a given state148125 * @cpu: The cpu for which the callback should be invoked149149- * @step: The step in the state machine126126+ * @state: The state to do callbacks for150127 * @bringup: True if the bringup callback should be invoked128128+ * @node: For multi-instance, do a single entry callback for install/remove129129+ * @lastp: For multi-instance rollback, remember how far we got151130 *152131 * Called from cpu hotplug and from the state register machinery.153132 */154133static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state,155155- bool bringup, struct hlist_node *node)134134+ bool bringup, struct hlist_node *node,135135+ struct hlist_node **lastp)156136{157137 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);158138 struct cpuhp_step *step = cpuhp_get_step(state);···163137 int (*cb)(unsigned int cpu);164138 int ret, cnt;165139140140+ if (st->fail == state) {141141+ st->fail = CPUHP_INVALID;142142+143143+ if (!(bringup ? step->startup.single : step->teardown.single))144144+ return 0;145145+146146+ return -EAGAIN;147147+ }148148+166149 if (!step->multi_instance) {150150+ WARN_ON_ONCE(lastp && *lastp);167151 cb = bringup ? step->startup.single : step->teardown.single;168152 if (!cb)169153 return 0;···188152189153 /* Single invocation for instance add/remove */190154 if (node) {155155+ WARN_ON_ONCE(lastp && *lastp);191156 trace_cpuhp_multi_enter(cpu, st->target, state, cbm, node);192157 ret = cbm(cpu, node);193158 trace_cpuhp_exit(cpu, st->state, state, ret);···198161 /* State transition. Invoke on all instances */199162 cnt = 0;200163 hlist_for_each(node, &step->list) {164164+ if (lastp && node == *lastp)165165+ break;166166+201167 trace_cpuhp_multi_enter(cpu, st->target, state, cbm, node);202168 ret = cbm(cpu, node);203169 trace_cpuhp_exit(cpu, st->state, state, ret);204204- if (ret)205205- goto err;170170+ if (ret) {171171+ if (!lastp)172172+ goto err;173173+174174+ *lastp = node;175175+ return ret;176176+ }206177 cnt++;207178 }179179+ if (lastp)180180+ *lastp = NULL;208181 return 0;209182err:210183 /* Rollback the instances if one failed */···225178 hlist_for_each(node, &step->list) {226179 if (!cnt--)227180 break;228228- cbm(cpu, node);181181+182182+ trace_cpuhp_multi_enter(cpu, st->target, state, cbm, node);183183+ ret = cbm(cpu, node);184184+ trace_cpuhp_exit(cpu, st->state, state, ret);185185+ /*186186+ * Rollback must not fail,187187+ */188188+ WARN_ON_ONCE(ret);229189 }230190 return ret;231191}232192233193#ifdef CONFIG_SMP194194+static inline void wait_for_ap_thread(struct cpuhp_cpu_state *st, bool bringup)195195+{196196+ struct completion *done = bringup ? &st->done_up : &st->done_down;197197+ wait_for_completion(done);198198+}199199+200200+static inline void complete_ap_thread(struct cpuhp_cpu_state *st, bool bringup)201201+{202202+ struct completion *done = bringup ? &st->done_up : &st->done_down;203203+ complete(done);204204+}205205+206206+/*207207+ * The former STARTING/DYING states, ran with IRQs disabled and must not fail.208208+ */209209+static bool cpuhp_is_atomic_state(enum cpuhp_state state)210210+{211211+ return CPUHP_AP_IDLE_DEAD <= state && state < CPUHP_AP_ONLINE;212212+}213213+234214/* Serializes the updates to cpu_online_mask, cpu_present_mask */235215static DEFINE_MUTEX(cpu_add_remove_lock);236216bool cpuhp_tasks_frozen;···345271EXPORT_SYMBOL_GPL(cpu_hotplug_enable);346272#endif /* CONFIG_HOTPLUG_CPU */347273348348-static void __cpuhp_kick_ap_work(struct cpuhp_cpu_state *st);274274+static inline enum cpuhp_state275275+cpuhp_set_state(struct cpuhp_cpu_state *st, enum cpuhp_state target)276276+{277277+ enum cpuhp_state prev_state = st->state;278278+279279+ st->rollback = false;280280+ st->last = NULL;281281+282282+ st->target = target;283283+ st->single = false;284284+ st->bringup = st->state < target;285285+286286+ return prev_state;287287+}288288+289289+static inline void290290+cpuhp_reset_state(struct cpuhp_cpu_state *st, enum cpuhp_state prev_state)291291+{292292+ st->rollback = true;293293+294294+ /*295295+ * If we have st->last we need to undo partial multi_instance of this296296+ * state first. Otherwise start undo at the previous state.297297+ */298298+ if (!st->last) {299299+ if (st->bringup)300300+ st->state--;301301+ else302302+ st->state++;303303+ }304304+305305+ st->target = prev_state;306306+ st->bringup = !st->bringup;307307+}308308+309309+/* Regular hotplug invocation of the AP hotplug thread */310310+static void __cpuhp_kick_ap(struct cpuhp_cpu_state *st)311311+{312312+ if (!st->single && st->state == st->target)313313+ return;314314+315315+ st->result = 0;316316+ /*317317+ * Make sure the above stores are visible before should_run becomes318318+ * true. Paired with the mb() above in cpuhp_thread_fun()319319+ */320320+ smp_mb();321321+ st->should_run = true;322322+ wake_up_process(st->thread);323323+ wait_for_ap_thread(st, st->bringup);324324+}325325+326326+static int cpuhp_kick_ap(struct cpuhp_cpu_state *st, enum cpuhp_state target)327327+{328328+ enum cpuhp_state prev_state;329329+ int ret;330330+331331+ prev_state = cpuhp_set_state(st, target);332332+ __cpuhp_kick_ap(st);333333+ if ((ret = st->result)) {334334+ cpuhp_reset_state(st, prev_state);335335+ __cpuhp_kick_ap(st);336336+ }337337+338338+ return ret;339339+}349340350341static int bringup_wait_for_ap(unsigned int cpu)351342{352343 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);353344354345 /* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */355355- wait_for_completion(&st->done);346346+ wait_for_ap_thread(st, true);356347 if (WARN_ON_ONCE((!cpu_online(cpu))))357348 return -ECANCELED;358349···425286 stop_machine_unpark(cpu);426287 kthread_unpark(st->thread);427288428428- /* Should we go further up ? */429429- if (st->target > CPUHP_AP_ONLINE_IDLE) {430430- __cpuhp_kick_ap_work(st);431431- wait_for_completion(&st->done);432432- }433433- return st->result;289289+ if (st->target <= CPUHP_AP_ONLINE_IDLE)290290+ return 0;291291+292292+ return cpuhp_kick_ap(st, st->target);434293}435294436295static int bringup_cpu(unsigned int cpu)···454317/*455318 * Hotplug state machine related functions456319 */457457-static void undo_cpu_down(unsigned int cpu, struct cpuhp_cpu_state *st)458458-{459459- for (st->state++; st->state < st->target; st->state++) {460460- struct cpuhp_step *step = cpuhp_get_step(st->state);461461-462462- if (!step->skip_onerr)463463- cpuhp_invoke_callback(cpu, st->state, true, NULL);464464- }465465-}466466-467467-static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,468468- enum cpuhp_state target)469469-{470470- enum cpuhp_state prev_state = st->state;471471- int ret = 0;472472-473473- for (; st->state > target; st->state--) {474474- ret = cpuhp_invoke_callback(cpu, st->state, false, NULL);475475- if (ret) {476476- st->target = prev_state;477477- undo_cpu_down(cpu, st);478478- break;479479- }480480- }481481- return ret;482482-}483320484321static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)485322{···461350 struct cpuhp_step *step = cpuhp_get_step(st->state);462351463352 if (!step->skip_onerr)464464- cpuhp_invoke_callback(cpu, st->state, false, NULL);353353+ cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);465354 }466355}467356···473362474363 while (st->state < target) {475364 st->state++;476476- ret = cpuhp_invoke_callback(cpu, st->state, true, NULL);365365+ ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL);477366 if (ret) {478367 st->target = prev_state;479368 undo_cpu_up(cpu, st);···490379{491380 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);492381493493- init_completion(&st->done);382382+ init_completion(&st->done_up);383383+ init_completion(&st->done_down);494384}495385496386static int cpuhp_should_run(unsigned int cpu)···501389 return st->should_run;502390}503391504504-/* Execute the teardown callbacks. Used to be CPU_DOWN_PREPARE */505505-static int cpuhp_ap_offline(unsigned int cpu, struct cpuhp_cpu_state *st)506506-{507507- enum cpuhp_state target = max((int)st->target, CPUHP_TEARDOWN_CPU);508508-509509- return cpuhp_down_callbacks(cpu, st, target);510510-}511511-512512-/* Execute the online startup callbacks. Used to be CPU_ONLINE */513513-static int cpuhp_ap_online(unsigned int cpu, struct cpuhp_cpu_state *st)514514-{515515- return cpuhp_up_callbacks(cpu, st, st->target);516516-}517517-518392/*519393 * Execute teardown/startup callbacks on the plugged cpu. Also used to invoke520394 * callbacks when a state gets [un]installed at runtime.395395+ *396396+ * Each invocation of this function by the smpboot thread does a single AP397397+ * state callback.398398+ *399399+ * It has 3 modes of operation:400400+ * - single: runs st->cb_state401401+ * - up: runs ++st->state, while st->state < st->target402402+ * - down: runs st->state--, while st->state > st->target403403+ *404404+ * When complete or on error, should_run is cleared and the completion is fired.521405 */522406static void cpuhp_thread_fun(unsigned int cpu)523407{524408 struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);525525- int ret = 0;409409+ bool bringup = st->bringup;410410+ enum cpuhp_state state;526411527412 /*528528- * Paired with the mb() in cpuhp_kick_ap_work and529529- * cpuhp_invoke_ap_callback, so the work set is consistent visible.413413+ * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures414414+ * that if we see ->should_run we also see the rest of the state.530415 */531416 smp_mb();532532- if (!st->should_run)417417+418418+ if (WARN_ON_ONCE(!st->should_run))533419 return;534420535535- st->should_run = false;421421+ cpuhp_lock_acquire(bringup);536422537537- lock_map_acquire(&cpuhp_state_lock_map);538538- /* Single callback invocation for [un]install ? */539423 if (st->single) {540540- if (st->cb_state < CPUHP_AP_ONLINE) {541541- local_irq_disable();542542- ret = cpuhp_invoke_callback(cpu, st->cb_state,543543- st->bringup, st->node);544544- local_irq_enable();545545- } else {546546- ret = cpuhp_invoke_callback(cpu, st->cb_state,547547- st->bringup, st->node);548548- }549549- } else if (st->rollback) {550550- BUG_ON(st->state < CPUHP_AP_ONLINE_IDLE);551551-552552- undo_cpu_down(cpu, st);553553- st->rollback = false;424424+ state = st->cb_state;425425+ st->should_run = false;554426 } else {555555- /* Cannot happen .... */556556- BUG_ON(st->state < CPUHP_AP_ONLINE_IDLE);557557-558558- /* Regular hotplug work */559559- if (st->state < st->target)560560- ret = cpuhp_ap_online(cpu, st);561561- else if (st->state > st->target)562562- ret = cpuhp_ap_offline(cpu, st);427427+ if (bringup) {428428+ st->state++;429429+ state = st->state;430430+ st->should_run = (st->state < st->target);431431+ WARN_ON_ONCE(st->state > st->target);432432+ } else {433433+ state = st->state;434434+ st->state--;435435+ st->should_run = (st->state > st->target);436436+ WARN_ON_ONCE(st->state < st->target);437437+ }563438 }564564- lock_map_release(&cpuhp_state_lock_map);565565- st->result = ret;566566- complete(&st->done);439439+440440+ WARN_ON_ONCE(!cpuhp_is_ap_state(state));441441+442442+ if (st->rollback) {443443+ struct cpuhp_step *step = cpuhp_get_step(state);444444+ if (step->skip_onerr)445445+ goto next;446446+ }447447+448448+ if (cpuhp_is_atomic_state(state)) {449449+ local_irq_disable();450450+ st->result = cpuhp_invoke_callback(cpu, state, bringup, st->node, &st->last);451451+ local_irq_enable();452452+453453+ /*454454+ * STARTING/DYING must not fail!455455+ */456456+ WARN_ON_ONCE(st->result);457457+ } else {458458+ st->result = cpuhp_invoke_callback(cpu, state, bringup, st->node, &st->last);459459+ }460460+461461+ if (st->result) {462462+ /*463463+ * If we fail on a rollback, we're up a creek without no464464+ * paddle, no way forward, no way back. We loose, thanks for465465+ * playing.466466+ */467467+ WARN_ON_ONCE(st->rollback);468468+ st->should_run = false;469469+ }470470+471471+next:472472+ cpuhp_lock_release(bringup);473473+474474+ if (!st->should_run)475475+ complete_ap_thread(st, bringup);567476}568477569478/* Invoke a single callback on a remote cpu */···593460 struct hlist_node *node)594461{595462 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);463463+ int ret;596464597465 if (!cpu_online(cpu))598466 return 0;599467600600- lock_map_acquire(&cpuhp_state_lock_map);601601- lock_map_release(&cpuhp_state_lock_map);468468+ cpuhp_lock_acquire(false);469469+ cpuhp_lock_release(false);470470+471471+ cpuhp_lock_acquire(true);472472+ cpuhp_lock_release(true);602473603474 /*604475 * If we are up and running, use the hotplug thread. For early calls605476 * we invoke the thread function directly.606477 */607478 if (!st->thread)608608- return cpuhp_invoke_callback(cpu, state, bringup, node);479479+ return cpuhp_invoke_callback(cpu, state, bringup, node, NULL);609480481481+ st->rollback = false;482482+ st->last = NULL;483483+484484+ st->node = node;485485+ st->bringup = bringup;610486 st->cb_state = state;611487 st->single = true;612612- st->bringup = bringup;613613- st->node = node;488488+489489+ __cpuhp_kick_ap(st);614490615491 /*616616- * Make sure the above stores are visible before should_run becomes617617- * true. Paired with the mb() above in cpuhp_thread_fun()492492+ * If we failed and did a partial, do a rollback.618493 */619619- smp_mb();620620- st->should_run = true;621621- wake_up_process(st->thread);622622- wait_for_completion(&st->done);623623- return st->result;624624-}494494+ if ((ret = st->result) && st->last) {495495+ st->rollback = true;496496+ st->bringup = !bringup;625497626626-/* Regular hotplug invocation of the AP hotplug thread */627627-static void __cpuhp_kick_ap_work(struct cpuhp_cpu_state *st)628628-{629629- st->result = 0;630630- st->single = false;631631- /*632632- * Make sure the above stores are visible before should_run becomes633633- * true. Paired with the mb() above in cpuhp_thread_fun()634634- */635635- smp_mb();636636- st->should_run = true;637637- wake_up_process(st->thread);498498+ __cpuhp_kick_ap(st);499499+ }500500+501501+ return ret;638502}639503640504static int cpuhp_kick_ap_work(unsigned int cpu)641505{642506 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);643643- enum cpuhp_state state = st->state;507507+ enum cpuhp_state prev_state = st->state;508508+ int ret;644509645645- trace_cpuhp_enter(cpu, st->target, state, cpuhp_kick_ap_work);646646- lock_map_acquire(&cpuhp_state_lock_map);647647- lock_map_release(&cpuhp_state_lock_map);648648- __cpuhp_kick_ap_work(st);649649- wait_for_completion(&st->done);650650- trace_cpuhp_exit(cpu, st->state, state, st->result);651651- return st->result;510510+ cpuhp_lock_acquire(false);511511+ cpuhp_lock_release(false);512512+513513+ cpuhp_lock_acquire(true);514514+ cpuhp_lock_release(true);515515+516516+ trace_cpuhp_enter(cpu, st->target, prev_state, cpuhp_kick_ap_work);517517+ ret = cpuhp_kick_ap(st, st->target);518518+ trace_cpuhp_exit(cpu, st->state, prev_state, ret);519519+520520+ return ret;652521}653522654523static struct smp_hotplug_thread cpuhp_threads = {···716581 struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);717582 enum cpuhp_state target = max((int)st->target, CPUHP_AP_OFFLINE);718583 int err, cpu = smp_processor_id();584584+ int ret;719585720586 /* Ensure this CPU doesn't handle any more interrupts. */721587 err = __cpu_disable();···730594 WARN_ON(st->state != CPUHP_TEARDOWN_CPU);731595 st->state--;732596 /* Invoke the former CPU_DYING callbacks */733733- for (; st->state > target; st->state--)734734- cpuhp_invoke_callback(cpu, st->state, false, NULL);597597+ for (; st->state > target; st->state--) {598598+ ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);599599+ /*600600+ * DYING must not fail!601601+ */602602+ WARN_ON_ONCE(ret);603603+ }735604736605 /* Give up timekeeping duties */737606 tick_handover_do_timer();···780639 *781640 * Wait for the stop thread to go away.782641 */783783- wait_for_completion(&st->done);642642+ wait_for_ap_thread(st, false);784643 BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);785644786645 /* Interrupts are moved away from the dying cpu, reenable alloc/free */···799658{800659 struct cpuhp_cpu_state *st = arg;801660802802- complete(&st->done);661661+ complete_ap_thread(st, false);803662}804663805664void cpuhp_report_idle_dead(void)···817676 cpuhp_complete_idle_dead, st, 0);818677}819678820820-#else821821-#define takedown_cpu NULL822822-#endif679679+static void undo_cpu_down(unsigned int cpu, struct cpuhp_cpu_state *st)680680+{681681+ for (st->state++; st->state < st->target; st->state++) {682682+ struct cpuhp_step *step = cpuhp_get_step(st->state);823683824824-#ifdef CONFIG_HOTPLUG_CPU684684+ if (!step->skip_onerr)685685+ cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL);686686+ }687687+}688688+689689+static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,690690+ enum cpuhp_state target)691691+{692692+ enum cpuhp_state prev_state = st->state;693693+ int ret = 0;694694+695695+ for (; st->state > target; st->state--) {696696+ ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);697697+ if (ret) {698698+ st->target = prev_state;699699+ undo_cpu_down(cpu, st);700700+ break;701701+ }702702+ }703703+ return ret;704704+}825705826706/* Requires cpu_add_remove_lock to be held */827707static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,···861699862700 cpuhp_tasks_frozen = tasks_frozen;863701864864- prev_state = st->state;865865- st->target = target;702702+ prev_state = cpuhp_set_state(st, target);866703 /*867704 * If the current CPU state is in the range of the AP hotplug thread,868705 * then we need to kick the thread.869706 */870707 if (st->state > CPUHP_TEARDOWN_CPU) {708708+ st->target = max((int)target, CPUHP_TEARDOWN_CPU);871709 ret = cpuhp_kick_ap_work(cpu);872710 /*873711 * The AP side has done the error rollback already. Just···882720 */883721 if (st->state > CPUHP_TEARDOWN_CPU)884722 goto out;723723+724724+ st->target = target;885725 }886726 /*887727 * The AP brought itself down to CPUHP_TEARDOWN_CPU. So we need···891727 */892728 ret = cpuhp_down_callbacks(cpu, st, target);893729 if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) {894894- st->target = prev_state;895895- st->rollback = true;896896- cpuhp_kick_ap_work(cpu);730730+ cpuhp_reset_state(st, prev_state);731731+ __cpuhp_kick_ap(st);897732 }898733899734out:···917754 cpu_maps_update_done();918755 return err;919756}757757+920758int cpu_down(unsigned int cpu)921759{922760 return do_cpu_down(cpu, CPUHP_OFFLINE);923761}924762EXPORT_SYMBOL(cpu_down);763763+764764+#else765765+#define takedown_cpu NULL925766#endif /*CONFIG_HOTPLUG_CPU*/926767927768/**···939772{940773 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);941774 enum cpuhp_state target = min((int)st->target, CPUHP_AP_ONLINE);775775+ int ret;942776943777 rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */944778 while (st->state < target) {945779 st->state++;946946- cpuhp_invoke_callback(cpu, st->state, true, NULL);780780+ ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL);781781+ /*782782+ * STARTING must not fail!783783+ */784784+ WARN_ON_ONCE(ret);947785 }948786}949787···966794 return;967795968796 st->state = CPUHP_AP_ONLINE_IDLE;969969- complete(&st->done);797797+ complete_ap_thread(st, true);970798}971799972800/* Requires cpu_add_remove_lock to be held */···10018291002830 cpuhp_tasks_frozen = tasks_frozen;100383110041004- st->target = target;832832+ cpuhp_set_state(st, target);1005833 /*1006834 * If the current CPU state is in the range of the AP hotplug thread,1007835 * then we need to kick the thread once more.···14681296 struct cpuhp_step *sp = cpuhp_get_step(state);14691297 int ret;1470129812991299+ /*13001300+ * If there's nothing to do, we done.13011301+ * Relies on the union for multi_instance.13021302+ */14711303 if ((bringup && !sp->startup.single) ||14721304 (!bringup && !sp->teardown.single))14731305 return 0;···14831307 if (cpuhp_is_ap_state(state))14841308 ret = cpuhp_invoke_ap_callback(cpu, state, bringup, node);14851309 else14861486- ret = cpuhp_invoke_callback(cpu, state, bringup, node);13101310+ ret = cpuhp_invoke_callback(cpu, state, bringup, node, NULL);14871311#else14881488- ret = cpuhp_invoke_callback(cpu, state, bringup, node);13121312+ ret = cpuhp_invoke_callback(cpu, state, bringup, node, NULL);14891313#endif14901314 BUG_ON(ret && !bringup);14911315 return ret;···18171641}18181642static DEVICE_ATTR(target, 0644, show_cpuhp_target, write_cpuhp_target);1819164316441644+16451645+static ssize_t write_cpuhp_fail(struct device *dev,16461646+ struct device_attribute *attr,16471647+ const char *buf, size_t count)16481648+{16491649+ struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id);16501650+ struct cpuhp_step *sp;16511651+ int fail, ret;16521652+16531653+ ret = kstrtoint(buf, 10, &fail);16541654+ if (ret)16551655+ return ret;16561656+16571657+ /*16581658+ * Cannot fail STARTING/DYING callbacks.16591659+ */16601660+ if (cpuhp_is_atomic_state(fail))16611661+ return -EINVAL;16621662+16631663+ /*16641664+ * Cannot fail anything that doesn't have callbacks.16651665+ */16661666+ mutex_lock(&cpuhp_state_mutex);16671667+ sp = cpuhp_get_step(fail);16681668+ if (!sp->startup.single && !sp->teardown.single)16691669+ ret = -EINVAL;16701670+ mutex_unlock(&cpuhp_state_mutex);16711671+ if (ret)16721672+ return ret;16731673+16741674+ st->fail = fail;16751675+16761676+ return count;16771677+}16781678+16791679+static ssize_t show_cpuhp_fail(struct device *dev,16801680+ struct device_attribute *attr, char *buf)16811681+{16821682+ struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id);16831683+16841684+ return sprintf(buf, "%d\n", st->fail);16851685+}16861686+16871687+static DEVICE_ATTR(fail, 0644, show_cpuhp_fail, write_cpuhp_fail);16881688+18201689static struct attribute *cpuhp_cpu_attrs[] = {18211690 &dev_attr_state.attr,18221691 &dev_attr_target.attr,16921692+ &dev_attr_fail.attr,18231693 NULL18241694};18251695
+15-5
kernel/events/ring_buffer.c
···412412 return NULL;413413}414414415415+static bool __always_inline rb_need_aux_wakeup(struct ring_buffer *rb)416416+{417417+ if (rb->aux_overwrite)418418+ return false;419419+420420+ if (rb->aux_head - rb->aux_wakeup >= rb->aux_watermark) {421421+ rb->aux_wakeup = rounddown(rb->aux_head, rb->aux_watermark);422422+ return true;423423+ }424424+425425+ return false;426426+}427427+415428/*416429 * Commit the data written by hardware into the ring buffer by adjusting417430 * aux_head and posting a PERF_RECORD_AUX into the perf buffer. It is the···464451 }465452466453 rb->user_page->aux_head = rb->aux_head;467467- if (rb->aux_head - rb->aux_wakeup >= rb->aux_watermark) {454454+ if (rb_need_aux_wakeup(rb))468455 wakeup = true;469469- rb->aux_wakeup = rounddown(rb->aux_head, rb->aux_watermark);470470- }471456472457 if (wakeup) {473458 if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED)···495484 rb->aux_head += size;496485497486 rb->user_page->aux_head = rb->aux_head;498498- if (rb->aux_head - rb->aux_wakeup >= rb->aux_watermark) {487487+ if (rb_need_aux_wakeup(rb)) {499488 perf_output_wakeup(handle);500500- rb->aux_wakeup = rounddown(rb->aux_head, rb->aux_watermark);501489 handle->wakeup = rb->aux_wakeup + rb->aux_watermark;502490 }503491
+10-13
kernel/exit.c
···16001600 struct waitid_info info = {.status = 0};16011601 long err = kernel_waitid(which, upid, &info, options, ru ? &r : NULL);16021602 int signo = 0;16031603+16031604 if (err > 0) {16041605 signo = SIGCHLD;16051606 err = 0;16061606- }16071607-16081608- if (!err) {16091607 if (ru && copy_to_user(ru, &r, sizeof(struct rusage)))16101608 return -EFAULT;16111609 }···17211723 if (err > 0) {17221724 signo = SIGCHLD;17231725 err = 0;17241724- }17251725-17261726- if (!err && uru) {17271727- /* kernel_waitid() overwrites everything in ru */17281728- if (COMPAT_USE_64BIT_TIME)17291729- err = copy_to_user(uru, &ru, sizeof(ru));17301730- else17311731- err = put_compat_rusage(&ru, uru);17321732- if (err)17331733- return -EFAULT;17261726+ if (uru) {17271727+ /* kernel_waitid() overwrites everything in ru */17281728+ if (COMPAT_USE_64BIT_TIME)17291729+ err = copy_to_user(uru, &ru, sizeof(ru));17301730+ else17311731+ err = put_compat_rusage(&ru, uru);17321732+ if (err)17331733+ return -EFAULT;17341734+ }17341735 }1735173617361737 if (!infop)
+31-14
kernel/extable.c
···102102103103int __kernel_text_address(unsigned long addr)104104{105105- if (core_kernel_text(addr))106106- return 1;107107- if (is_module_text_address(addr))108108- return 1;109109- if (is_ftrace_trampoline(addr))110110- return 1;111111- if (is_kprobe_optinsn_slot(addr) || is_kprobe_insn_slot(addr))112112- return 1;113113- if (is_bpf_text_address(addr))105105+ if (kernel_text_address(addr))114106 return 1;115107 /*116108 * There might be init symbols in saved stacktraces.···119127120128int kernel_text_address(unsigned long addr)121129{130130+ bool no_rcu;131131+ int ret = 1;132132+122133 if (core_kernel_text(addr))123134 return 1;135135+136136+ /*137137+ * If a stack dump happens while RCU is not watching, then138138+ * RCU needs to be notified that it requires to start139139+ * watching again. This can happen either by tracing that140140+ * triggers a stack trace, or a WARN() that happens during141141+ * coming back from idle, or cpu on or offlining.142142+ *143143+ * is_module_text_address() as well as the kprobe slots144144+ * and is_bpf_text_address() require RCU to be watching.145145+ */146146+ no_rcu = !rcu_is_watching();147147+148148+ /* Treat this like an NMI as it can happen anywhere */149149+ if (no_rcu)150150+ rcu_nmi_enter();151151+124152 if (is_module_text_address(addr))125125- return 1;153153+ goto out;126154 if (is_ftrace_trampoline(addr))127127- return 1;155155+ goto out;128156 if (is_kprobe_optinsn_slot(addr) || is_kprobe_insn_slot(addr))129129- return 1;157157+ goto out;130158 if (is_bpf_text_address(addr))131131- return 1;132132- return 0;159159+ goto out;160160+ ret = 0;161161+out:162162+ if (no_rcu)163163+ rcu_nmi_exit();164164+165165+ return ret;133166}134167135168/*
+22-11
kernel/futex.c
···821821/*822822 * Drops a reference to the pi_state object and frees or caches it823823 * when the last reference is gone.824824- *825825- * Must be called with the hb lock held.826824 */827825static void put_pi_state(struct futex_pi_state *pi_state)828826{···835837 * and has cleaned up the pi_state already836838 */837839 if (pi_state->owner) {838838- raw_spin_lock_irq(&pi_state->owner->pi_lock);839839- list_del_init(&pi_state->list);840840- raw_spin_unlock_irq(&pi_state->owner->pi_lock);840840+ struct task_struct *owner;841841842842- rt_mutex_proxy_unlock(&pi_state->pi_mutex, pi_state->owner);842842+ raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);843843+ owner = pi_state->owner;844844+ if (owner) {845845+ raw_spin_lock(&owner->pi_lock);846846+ list_del_init(&pi_state->list);847847+ raw_spin_unlock(&owner->pi_lock);848848+ }849849+ rt_mutex_proxy_unlock(&pi_state->pi_mutex, owner);850850+ raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);843851 }844852845845- if (current->pi_state_cache)853853+ if (current->pi_state_cache) {846854 kfree(pi_state);847847- else {855855+ } else {848856 /*849857 * pi_state->list is already empty.850858 * clear pi_state->owner.···911907 raw_spin_unlock_irq(&curr->pi_lock);912908913909 spin_lock(&hb->lock);914914-915915- raw_spin_lock_irq(&curr->pi_lock);910910+ raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);911911+ raw_spin_lock(&curr->pi_lock);916912 /*917913 * We dropped the pi-lock, so re-check whether this918914 * task still owns the PI-state:919915 */920916 if (head->next != next) {917917+ raw_spin_unlock(&pi_state->pi_mutex.wait_lock);921918 spin_unlock(&hb->lock);922919 continue;923920 }···927922 WARN_ON(list_empty(&pi_state->list));928923 list_del_init(&pi_state->list);929924 pi_state->owner = NULL;930930- raw_spin_unlock_irq(&curr->pi_lock);925925+ raw_spin_unlock(&curr->pi_lock);931926932927 get_pi_state(pi_state);928928+ raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);933929 spin_unlock(&hb->lock);934930935931 rt_mutex_futex_unlock(&pi_state->pi_mutex);···1214120812151209 WARN_ON(!list_empty(&pi_state->list));12161210 list_add(&pi_state->list, &p->pi_state_list);12111211+ /*12121212+ * Assignment without holding pi_state->pi_mutex.wait_lock is safe12131213+ * because there is no concurrency as the object is not published yet.12141214+ */12171215 pi_state->owner = p;12181216 raw_spin_unlock_irq(&p->pi_lock);12191217···28882878 raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);28892879 spin_unlock(&hb->lock);2890288028812881+ /* drops pi_state->pi_mutex.wait_lock */28912882 ret = wake_futex_pi(uaddr, uval, pi_state);2892288328932884 put_pi_state(pi_state);
-1
kernel/irq/generic-chip.c
···322322 /* Calc pointer to the next generic chip */323323 tmp += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);324324 }325325- d->name = name;326325 return 0;327326}328327EXPORT_SYMBOL_GPL(__irq_alloc_domain_generic_chips);
+27
kernel/locking/rwsem-xadd.c
···613613 DEFINE_WAKE_Q(wake_q);614614615615 /*616616+ * __rwsem_down_write_failed_common(sem)617617+ * rwsem_optimistic_spin(sem)618618+ * osq_unlock(sem->osq)619619+ * ...620620+ * atomic_long_add_return(&sem->count)621621+ *622622+ * - VS -623623+ *624624+ * __up_write()625625+ * if (atomic_long_sub_return_release(&sem->count) < 0)626626+ * rwsem_wake(sem)627627+ * osq_is_locked(&sem->osq)628628+ *629629+ * And __up_write() must observe !osq_is_locked() when it observes the630630+ * atomic_long_add_return() in order to not miss a wakeup.631631+ *632632+ * This boils down to:633633+ *634634+ * [S.rel] X = 1 [RmW] r0 = (Y += 0)635635+ * MB RMB636636+ * [RmW] Y += 1 [L] r1 = X637637+ *638638+ * exists (r0=1 /\ r1=0)639639+ */640640+ smp_rmb();641641+642642+ /*616643 * If a spinner is present, it is not necessary to do the wakeup.617644 * Try to do wakeup only if the trylock succeeds to minimize618645 * spinlock contention which may introduce too much delay in the
+10
kernel/rcu/tree.c
···882882883883 RCU_LOCKDEP_WARN(!irqs_disabled(), "rcu_irq_exit() invoked with irqs enabled!!!");884884 rdtp = this_cpu_ptr(&rcu_dynticks);885885+886886+ /* Page faults can happen in NMI handlers, so check... */887887+ if (READ_ONCE(rdtp->dynticks_nmi_nesting))888888+ return;889889+885890 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&886891 rdtp->dynticks_nesting < 1);887892 if (rdtp->dynticks_nesting <= 1) {···1020101510211016 RCU_LOCKDEP_WARN(!irqs_disabled(), "rcu_irq_enter() invoked with irqs enabled!!!");10221017 rdtp = this_cpu_ptr(&rcu_dynticks);10181018+10191019+ /* Page faults can happen in NMI handlers, so check... */10201020+ if (READ_ONCE(rdtp->dynticks_nmi_nesting))10211021+ return;10221022+10231023 oldval = rdtp->dynticks_nesting;10241024 rdtp->dynticks_nesting++;10251025 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
+23-1
kernel/sched/core.c
···51665166 put_task_stack(p);51675167}5168516851695169+static inline bool51705170+state_filter_match(unsigned long state_filter, struct task_struct *p)51715171+{51725172+ /* no filter, everything matches */51735173+ if (!state_filter)51745174+ return true;51755175+51765176+ /* filter, but doesn't match */51775177+ if (!(p->state & state_filter))51785178+ return false;51795179+51805180+ /*51815181+ * When looking for TASK_UNINTERRUPTIBLE skip TASK_IDLE (allows51825182+ * TASK_KILLABLE).51835183+ */51845184+ if (state_filter == TASK_UNINTERRUPTIBLE && p->state == TASK_IDLE)51855185+ return false;51865186+51875187+ return true;51885188+}51895189+51905190+51695191void show_state_filter(unsigned long state_filter)51705192{51715193 struct task_struct *g, *p;···52105188 */52115189 touch_nmi_watchdog();52125190 touch_all_softlockup_watchdogs();52135213- if (!state_filter || (p->state & state_filter))51915191+ if (state_filter_match(state_filter, p))52145192 sched_show_task(p);52155193 }52165194
···648648}649649EXPORT_SYMBOL_GPL(blk_trace_startstop);650650651651+/*652652+ * When reading or writing the blktrace sysfs files, the references to the653653+ * opened sysfs or device files should prevent the underlying block device654654+ * from being removed. So no further delete protection is really needed.655655+ */656656+651657/**652658 * blk_trace_ioctl: - handle the ioctls associated with tracing653659 * @bdev: the block device···671665 if (!q)672666 return -ENXIO;673667674674- mutex_lock(&bdev->bd_mutex);668668+ mutex_lock(&q->blk_trace_mutex);675669676670 switch (cmd) {677671 case BLKTRACESETUP:···697691 break;698692 }699693700700- mutex_unlock(&bdev->bd_mutex);694694+ mutex_unlock(&q->blk_trace_mutex);701695 return ret;702696}703697···17331727 if (q == NULL)17341728 goto out_bdput;1735172917361736- mutex_lock(&bdev->bd_mutex);17301730+ mutex_lock(&q->blk_trace_mutex);1737173117381732 if (attr == &dev_attr_enable) {17391733 ret = sprintf(buf, "%u\n", !!q->blk_trace);···17521746 ret = sprintf(buf, "%llu\n", q->blk_trace->end_lba);1753174717541748out_unlock_bdev:17551755- mutex_unlock(&bdev->bd_mutex);17491749+ mutex_unlock(&q->blk_trace_mutex);17561750out_bdput:17571751 bdput(bdev);17581752out:···17941788 if (q == NULL)17951789 goto out_bdput;1796179017971797- mutex_lock(&bdev->bd_mutex);17911791+ mutex_lock(&q->blk_trace_mutex);1798179217991793 if (attr == &dev_attr_enable) {18001794 if (value)···18201814 }1821181518221816out_unlock_bdev:18231823- mutex_unlock(&bdev->bd_mutex);18171817+ mutex_unlock(&q->blk_trace_mutex);18241818out_bdput:18251819 bdput(bdev);18261820out:
+6-15
kernel/trace/trace_output.c
···656656 return !trace_seq_has_overflowed(s);657657}658658659659-static const char state_to_char[] = TASK_STATE_TO_CHAR_STR;660660-661661-static int task_state_char(unsigned long state)662662-{663663- int bit = state ? __ffs(state) + 1 : 0;664664-665665- return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?';666666-}667667-668659/**669660 * ftrace_find_event - find a registered event670661 * @type: the type of event to look for···921930922931 trace_assign_type(field, iter->ent);923932924924- T = task_state_char(field->next_state);925925- S = task_state_char(field->prev_state);933933+ T = __task_state_to_char(field->next_state);934934+ S = __task_state_to_char(field->prev_state);926935 trace_find_cmdline(field->next_pid, comm);927936 trace_seq_printf(&iter->seq,928937 " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",···957966 trace_assign_type(field, iter->ent);958967959968 if (!S)960960- S = task_state_char(field->prev_state);961961- T = task_state_char(field->next_state);969969+ S = __task_state_to_char(field->prev_state);970970+ T = __task_state_to_char(field->next_state);962971 trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n",963972 field->prev_pid,964973 field->prev_prio,···9931002 trace_assign_type(field, iter->ent);99410039951004 if (!S)996996- S = task_state_char(field->prev_state);997997- T = task_state_char(field->next_state);10051005+ S = __task_state_to_char(field->prev_state);10061006+ T = __task_state_to_char(field->next_state);99810079991008 SEQ_PUT_HEX_FIELD(s, field->prev_pid);10001009 SEQ_PUT_HEX_FIELD(s, field->prev_prio);
···9696 if (in_nmi())9797 return;98989999- /*100100- * There's a slight chance that we are tracing inside the101101- * RCU infrastructure, and rcu_irq_enter() will not work102102- * as expected.103103- */104104- if (unlikely(rcu_irq_enter_disabled()))105105- return;106106-10799 local_irq_save(flags);108100 arch_spin_lock(&stack_trace_max_lock);109109-110110- /*111111- * RCU may not be watching, make it see us.112112- * The stack trace code uses rcu_sched.113113- */114114- rcu_irq_enter();115101116102 /* In case another CPU set the tracer_frame on us */117103 if (unlikely(!frame_size))···191205 }192206193207 out:194194- rcu_irq_exit();195208 arch_spin_unlock(&stack_trace_max_lock);196209 local_irq_restore(flags);197210}
+8-2
mm/filemap.c
···29262926 * we're writing. Either one is a pretty crazy thing to do,29272927 * so we don't support it 100%. If this invalidation29282928 * fails, tough, the write still worked...29292929+ *29302930+ * Most of the time we do not need this since dio_complete() will do29312931+ * the invalidation for us. However there are some file systems that29322932+ * do not end up with dio_complete() being called, so let's not break29332933+ * them by removing it completely29292934 */29302930- invalidate_inode_pages2_range(mapping,29312931- pos >> PAGE_SHIFT, end);29352935+ if (mapping->nrpages)29362936+ invalidate_inode_pages2_range(mapping,29372937+ pos >> PAGE_SHIFT, end);2932293829332939 if (written > 0) {29342940 pos += written;
-10
net/bluetooth/Kconfig
···126126 Provide extensive information about internal Bluetooth states127127 in debugfs.128128129129-config BT_LEGACY_IOCTL130130- bool "Enable legacy ioctl interfaces"131131- depends on BT && BT_BREDR132132- default y133133- help134134- Enable support for legacy ioctl interfaces. This is only needed135135- for old and deprecated applications using direct ioctl calls for136136- controller management. Since Linux 3.4 all configuration and137137- setup is done via mgmt interface and this is no longer needed.138138-139129source "drivers/bluetooth/Kconfig"
···401401 if (unlikely(n != mw->mw_nents))402402 goto out_mapmr_err;403403404404- dprintk("RPC: %s: Using frmr %p to map %u segments (%u bytes)\n",404404+ dprintk("RPC: %s: Using frmr %p to map %u segments (%llu bytes)\n",405405 __func__, frmr, mw->mw_nents, mr->length);406406407407 key = (u8)(mr->rkey & 0x000000FF);
+2
scripts/Makefile.build
···265265endif266266ifdef CONFIG_GCOV_KERNEL267267objtool_args += --no-unreachable268268+else269269+objtool_args += $(call cc-ifversion, -lt, 0405, --no-unreachable)268270endif269271270272# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
+1-3
security/keys/Kconfig
···4545 bool "Large payload keys"4646 depends on KEYS4747 depends on TMPFS4848- depends on (CRYPTO_ANSI_CPRNG = y || CRYPTO_DRBG = y)4948 select CRYPTO_AES5050- select CRYPTO_ECB5151- select CRYPTO_RNG4949+ select CRYPTO_GCM5250 help5351 This option provides support for holding large keys within the kernel5452 (for example Kerberos ticket caches). The data may be stored out to
+64-73
security/keys/big_key.c
···11/* Large capacity key type22 *33+ * Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.34 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.45 * Written by David Howells (dhowells@redhat.com)56 *···1716#include <linux/shmem_fs.h>1817#include <linux/err.h>1918#include <linux/scatterlist.h>1919+#include <linux/random.h>2020#include <keys/user-type.h>2121#include <keys/big_key-type.h>2222-#include <crypto/rng.h>2323-#include <crypto/skcipher.h>2222+#include <crypto/aead.h>24232524/*2625 * Layout of key payload words.···5049/*5150 * Key size for big_key data encryption5251 */5353-#define ENC_KEY_SIZE 165252+#define ENC_KEY_SIZE 325353+5454+/*5555+ * Authentication tag length5656+ */5757+#define ENC_AUTHTAG_SIZE 1654585559/*5660 * big_key defined keys take an arbitrary string as the description and an···7064 .destroy = big_key_destroy,7165 .describe = big_key_describe,7266 .read = big_key_read,6767+ /* no ->update(); don't add it without changing big_key_crypt() nonce */7368};74697570/*7676- * Crypto names for big_key data encryption7171+ * Crypto names for big_key data authenticated encryption7772 */7878-static const char big_key_rng_name[] = "stdrng";7979-static const char big_key_alg_name[] = "ecb(aes)";7373+static const char big_key_alg_name[] = "gcm(aes)";80748175/*8282- * Crypto algorithms for big_key data encryption7676+ * Crypto algorithms for big_key data authenticated encryption8377 */8484-static struct crypto_rng *big_key_rng;8585-static struct crypto_skcipher *big_key_skcipher;7878+static struct crypto_aead *big_key_aead;86798780/*8888- * Generate random key to encrypt big_key data8181+ * Since changing the key affects the entire object, we need a mutex.8982 */9090-static inline int big_key_gen_enckey(u8 *key)9191-{9292- return crypto_rng_get_bytes(big_key_rng, key, ENC_KEY_SIZE);9393-}8383+static DEFINE_MUTEX(big_key_aead_lock);94849585/*9686 * Encrypt/decrypt big_key data9787 */9888static int big_key_crypt(enum big_key_op op, u8 *data, size_t datalen, u8 *key)9989{100100- int ret = -EINVAL;9090+ int ret;10191 struct scatterlist sgio;102102- SKCIPHER_REQUEST_ON_STACK(req, big_key_skcipher);9292+ struct aead_request *aead_req;9393+ /* We always use a zero nonce. The reason we can get away with this is9494+ * because we're using a different randomly generated key for every9595+ * different encryption. Notably, too, key_type_big_key doesn't define9696+ * an .update function, so there's no chance we'll wind up reusing the9797+ * key to encrypt updated data. Simply put: one key, one encryption.9898+ */9999+ u8 zero_nonce[crypto_aead_ivsize(big_key_aead)];103100104104- if (crypto_skcipher_setkey(big_key_skcipher, key, ENC_KEY_SIZE)) {101101+ aead_req = aead_request_alloc(big_key_aead, GFP_KERNEL);102102+ if (!aead_req)103103+ return -ENOMEM;104104+105105+ memset(zero_nonce, 0, sizeof(zero_nonce));106106+ sg_init_one(&sgio, data, datalen + (op == BIG_KEY_ENC ? ENC_AUTHTAG_SIZE : 0));107107+ aead_request_set_crypt(aead_req, &sgio, &sgio, datalen, zero_nonce);108108+ aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL);109109+ aead_request_set_ad(aead_req, 0);110110+111111+ mutex_lock(&big_key_aead_lock);112112+ if (crypto_aead_setkey(big_key_aead, key, ENC_KEY_SIZE)) {105113 ret = -EAGAIN;106114 goto error;107115 }108108-109109- skcipher_request_set_tfm(req, big_key_skcipher);110110- skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,111111- NULL, NULL);112112-113113- sg_init_one(&sgio, data, datalen);114114- skcipher_request_set_crypt(req, &sgio, &sgio, datalen, NULL);115115-116116 if (op == BIG_KEY_ENC)117117- ret = crypto_skcipher_encrypt(req);117117+ ret = crypto_aead_encrypt(aead_req);118118 else119119- ret = crypto_skcipher_decrypt(req);120120-121121- skcipher_request_zero(req);122122-119119+ ret = crypto_aead_decrypt(aead_req);123120error:121121+ mutex_unlock(&big_key_aead_lock);122122+ aead_request_free(aead_req);124123 return ret;125124}126125···157146 *158147 * File content is stored encrypted with randomly generated key.159148 */160160- size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));149149+ size_t enclen = datalen + ENC_AUTHTAG_SIZE;161150 loff_t pos = 0;162151163163- /* prepare aligned data to encrypt */164152 data = kmalloc(enclen, GFP_KERNEL);165153 if (!data)166154 return -ENOMEM;167167-168155 memcpy(data, prep->data, datalen);169169- memset(data + datalen, 0x00, enclen - datalen);170156171157 /* generate random key */172158 enckey = kmalloc(ENC_KEY_SIZE, GFP_KERNEL);···171163 ret = -ENOMEM;172164 goto error;173165 }174174-175175- ret = big_key_gen_enckey(enckey);176176- if (ret)166166+ ret = get_random_bytes_wait(enckey, ENC_KEY_SIZE);167167+ if (unlikely(ret))177168 goto err_enckey;178169179170 /* encrypt aligned data */180180- ret = big_key_crypt(BIG_KEY_ENC, data, enclen, enckey);171171+ ret = big_key_crypt(BIG_KEY_ENC, data, datalen, enckey);181172 if (ret)182173 goto err_enckey;183174···202195 *path = file->f_path;203196 path_get(path);204197 fput(file);205205- kfree(data);198198+ kzfree(data);206199 } else {207200 /* Just store the data in a buffer */208201 void *data = kmalloc(datalen, GFP_KERNEL);···218211err_fput:219212 fput(file);220213err_enckey:221221- kfree(enckey);214214+ kzfree(enckey);222215error:223223- kfree(data);216216+ kzfree(data);224217 return ret;225218}226219···234227235228 path_put(path);236229 }237237- kfree(prep->payload.data[big_key_data]);230230+ kzfree(prep->payload.data[big_key_data]);238231}239232240233/*···266259 path->mnt = NULL;267260 path->dentry = NULL;268261 }269269- kfree(key->payload.data[big_key_data]);262262+ kzfree(key->payload.data[big_key_data]);270263 key->payload.data[big_key_data] = NULL;271264}272265···302295 struct file *file;303296 u8 *data;304297 u8 *enckey = (u8 *)key->payload.data[big_key_data];305305- size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));298298+ size_t enclen = datalen + ENC_AUTHTAG_SIZE;306299 loff_t pos = 0;307300308301 data = kmalloc(enclen, GFP_KERNEL);···335328err_fput:336329 fput(file);337330error:338338- kfree(data);331331+ kzfree(data);339332 } else {340333 ret = datalen;341334 if (copy_to_user(buffer, key->payload.data[big_key_data],···351344 */352345static int __init big_key_init(void)353346{354354- struct crypto_skcipher *cipher;355355- struct crypto_rng *rng;356347 int ret;357348358358- rng = crypto_alloc_rng(big_key_rng_name, 0, 0);359359- if (IS_ERR(rng)) {360360- pr_err("Can't alloc rng: %ld\n", PTR_ERR(rng));361361- return PTR_ERR(rng);362362- }363363-364364- big_key_rng = rng;365365-366366- /* seed RNG */367367- ret = crypto_rng_reset(rng, NULL, crypto_rng_seedsize(rng));368368- if (ret) {369369- pr_err("Can't reset rng: %d\n", ret);370370- goto error_rng;371371- }372372-373349 /* init block cipher */374374- cipher = crypto_alloc_skcipher(big_key_alg_name, 0, CRYPTO_ALG_ASYNC);375375- if (IS_ERR(cipher)) {376376- ret = PTR_ERR(cipher);350350+ big_key_aead = crypto_alloc_aead(big_key_alg_name, 0, CRYPTO_ALG_ASYNC);351351+ if (IS_ERR(big_key_aead)) {352352+ ret = PTR_ERR(big_key_aead);377353 pr_err("Can't alloc crypto: %d\n", ret);378378- goto error_rng;354354+ return ret;379355 }380380-381381- big_key_skcipher = cipher;356356+ ret = crypto_aead_setauthsize(big_key_aead, ENC_AUTHTAG_SIZE);357357+ if (ret < 0) {358358+ pr_err("Can't set crypto auth tag len: %d\n", ret);359359+ goto free_aead;360360+ }382361383362 ret = register_key_type(&key_type_big_key);384363 if (ret < 0) {385364 pr_err("Can't register type: %d\n", ret);386386- goto error_cipher;365365+ goto free_aead;387366 }388367389368 return 0;390369391391-error_cipher:392392- crypto_free_skcipher(big_key_skcipher);393393-error_rng:394394- crypto_free_rng(big_key_rng);370370+free_aead:371371+ crypto_free_aead(big_key_aead);395372 return ret;396373}397374
···766766767767 key = key_ref_to_ptr(key_ref);768768769769+ if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {770770+ ret = -ENOKEY;771771+ goto error2;772772+ }773773+769774 /* see if we can read it directly */770775 ret = key_permission(key_ref, KEY_NEED_READ);771776 if (ret == 0)772777 goto can_read_key;773778 if (ret != -EACCES)774774- goto error;779779+ goto error2;775780776781 /* we can't; see if it's searchable from this process's keyrings777782 * - we automatically take account of the fact that it may be···14111406 }1412140714131408 ret = keyctl_change_reqkey_auth(authkey);14141414- if (ret < 0)14151415- goto error;14091409+ if (ret == 0)14101410+ ret = authkey->serial;14161411 key_put(authkey);14171417-14181418- ret = authkey->serial;14191412error:14201413 return ret;14211414}
+19-18
security/keys/keyring.c
···423423}424424425425struct keyring_read_iterator_context {426426- size_t qty;426426+ size_t buflen;427427 size_t count;428428 key_serial_t __user *buffer;429429};···435435 int ret;436436437437 kenter("{%s,%d},,{%zu/%zu}",438438- key->type->name, key->serial, ctx->count, ctx->qty);438438+ key->type->name, key->serial, ctx->count, ctx->buflen);439439440440- if (ctx->count >= ctx->qty)440440+ if (ctx->count >= ctx->buflen)441441 return 1;442442443443 ret = put_user(key->serial, ctx->buffer);···472472 return 0;473473474474 /* Calculate how much data we could return */475475- ctx.qty = nr_keys * sizeof(key_serial_t);476476-477475 if (!buffer || !buflen)478478- return ctx.qty;479479-480480- if (buflen > ctx.qty)481481- ctx.qty = buflen;476476+ return nr_keys * sizeof(key_serial_t);482477483478 /* Copy the IDs of the subscribed keys into the buffer */484479 ctx.buffer = (key_serial_t __user *)buffer;480480+ ctx.buflen = buflen;485481 ctx.count = 0;486482 ret = assoc_array_iterate(&keyring->keys, keyring_read_iterator, &ctx);487483 if (ret < 0) {···10971101/*10981102 * Find a keyring with the specified name.10991103 *11001100- * All named keyrings in the current user namespace are searched, provided they11011101- * grant Search permission directly to the caller (unless this check is11021102- * skipped). Keyrings whose usage points have reached zero or who have been11031103- * revoked are skipped.11041104+ * Only keyrings that have nonzero refcount, are not revoked, and are owned by a11051105+ * user in the current user namespace are considered. If @uid_keyring is %true,11061106+ * the keyring additionally must have been allocated as a user or user session11071107+ * keyring; otherwise, it must grant Search permission directly to the caller.11041108 *11051109 * Returns a pointer to the keyring with the keyring's refcount having being11061110 * incremented on success. -ENOKEY is returned if a key could not be found.11071111 */11081108-struct key *find_keyring_by_name(const char *name, bool skip_perm_check)11121112+struct key *find_keyring_by_name(const char *name, bool uid_keyring)11091113{11101114 struct key *keyring;11111115 int bucket;···11331137 if (strcmp(keyring->description, name) != 0)11341138 continue;1135113911361136- if (!skip_perm_check &&11371137- key_permission(make_key_ref(keyring, 0),11381138- KEY_NEED_SEARCH) < 0)11391139- continue;11401140+ if (uid_keyring) {11411141+ if (!test_bit(KEY_FLAG_UID_KEYRING,11421142+ &keyring->flags))11431143+ continue;11441144+ } else {11451145+ if (key_permission(make_key_ref(keyring, 0),11461146+ KEY_NEED_SEARCH) < 0)11471147+ continue;11481148+ }1140114911411150 /* we've got a match but we might end up racing with11421151 * key_cleanup() if the keyring is currently 'dead'
+2-6
security/keys/proc.c
···187187 struct keyring_search_context ctx = {188188 .index_key.type = key->type,189189 .index_key.description = key->description,190190- .cred = current_cred(),190190+ .cred = m->file->f_cred,191191 .match_data.cmp = lookup_user_key_possessed,192192 .match_data.raw_data = key,193193 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT,···207207 }208208 }209209210210- /* check whether the current task is allowed to view the key (assuming211211- * non-possession)212212- * - the caller holds a spinlock, and thus the RCU read lock, making our213213- * access to __current_cred() safe214214- */210210+ /* check whether the current task is allowed to view the key */215211 rc = key_task_permission(key_ref, ctx.cred, KEY_NEED_VIEW);216212 if (rc < 0)217213 return 0;
+4-2
security/keys/process_keys.c
···7777 if (IS_ERR(uid_keyring)) {7878 uid_keyring = keyring_alloc(buf, user->uid, INVALID_GID,7979 cred, user_keyring_perm,8080- KEY_ALLOC_IN_QUOTA,8080+ KEY_ALLOC_UID_KEYRING |8181+ KEY_ALLOC_IN_QUOTA,8182 NULL, NULL);8283 if (IS_ERR(uid_keyring)) {8384 ret = PTR_ERR(uid_keyring);···9594 session_keyring =9695 keyring_alloc(buf, user->uid, INVALID_GID,9796 cred, user_keyring_perm,9898- KEY_ALLOC_IN_QUOTA,9797+ KEY_ALLOC_UID_KEYRING |9898+ KEY_ALLOC_IN_QUOTA,9999 NULL, NULL);100100 if (IS_ERR(session_keyring)) {101101 ret = PTR_ERR(session_keyring);
+33-41
security/keys/request_key_auth.c
···120120 }121121}122122123123+static void free_request_key_auth(struct request_key_auth *rka)124124+{125125+ if (!rka)126126+ return;127127+ key_put(rka->target_key);128128+ key_put(rka->dest_keyring);129129+ if (rka->cred)130130+ put_cred(rka->cred);131131+ kfree(rka->callout_info);132132+ kfree(rka);133133+}134134+123135/*124136 * Destroy an instantiation authorisation token key.125137 */···141129142130 kenter("{%d}", key->serial);143131144144- if (rka->cred) {145145- put_cred(rka->cred);146146- rka->cred = NULL;147147- }148148-149149- key_put(rka->target_key);150150- key_put(rka->dest_keyring);151151- kfree(rka->callout_info);152152- kfree(rka);132132+ free_request_key_auth(rka);153133}154134155135/*···155151 const struct cred *cred = current->cred;156152 struct key *authkey = NULL;157153 char desc[20];158158- int ret;154154+ int ret = -ENOMEM;159155160156 kenter("%d,", target->serial);161157162158 /* allocate a auth record */163163- rka = kmalloc(sizeof(*rka), GFP_KERNEL);164164- if (!rka) {165165- kleave(" = -ENOMEM");166166- return ERR_PTR(-ENOMEM);167167- }168168- rka->callout_info = kmalloc(callout_len, GFP_KERNEL);169169- if (!rka->callout_info) {170170- kleave(" = -ENOMEM");171171- kfree(rka);172172- return ERR_PTR(-ENOMEM);173173- }159159+ rka = kzalloc(sizeof(*rka), GFP_KERNEL);160160+ if (!rka)161161+ goto error;162162+ rka->callout_info = kmemdup(callout_info, callout_len, GFP_KERNEL);163163+ if (!rka->callout_info)164164+ goto error_free_rka;165165+ rka->callout_len = callout_len;174166175167 /* see if the calling process is already servicing the key request of176168 * another process */···176176177177 /* if the auth key has been revoked, then the key we're178178 * servicing is already instantiated */179179- if (test_bit(KEY_FLAG_REVOKED, &cred->request_key_auth->flags))180180- goto auth_key_revoked;179179+ if (test_bit(KEY_FLAG_REVOKED,180180+ &cred->request_key_auth->flags)) {181181+ up_read(&cred->request_key_auth->sem);182182+ ret = -EKEYREVOKED;183183+ goto error_free_rka;184184+ }181185182186 irka = cred->request_key_auth->payload.data[0];183187 rka->cred = get_cred(irka->cred);···197193198194 rka->target_key = key_get(target);199195 rka->dest_keyring = key_get(dest_keyring);200200- memcpy(rka->callout_info, callout_info, callout_len);201201- rka->callout_len = callout_len;202196203197 /* allocate the auth key */204198 sprintf(desc, "%x", target->serial);···207205 KEY_USR_VIEW, KEY_ALLOC_NOT_IN_QUOTA, NULL);208206 if (IS_ERR(authkey)) {209207 ret = PTR_ERR(authkey);210210- goto error_alloc;208208+ goto error_free_rka;211209 }212210213211 /* construct the auth key */214212 ret = key_instantiate_and_link(authkey, rka, 0, NULL, NULL);215213 if (ret < 0)216216- goto error_inst;214214+ goto error_put_authkey;217215218216 kleave(" = {%d,%d}", authkey->serial, refcount_read(&authkey->usage));219217 return authkey;220218221221-auth_key_revoked:222222- up_read(&cred->request_key_auth->sem);223223- kfree(rka->callout_info);224224- kfree(rka);225225- kleave("= -EKEYREVOKED");226226- return ERR_PTR(-EKEYREVOKED);227227-228228-error_inst:229229- key_revoke(authkey);219219+error_put_authkey:230220 key_put(authkey);231231-error_alloc:232232- key_put(rka->target_key);233233- key_put(rka->dest_keyring);234234- kfree(rka->callout_info);235235- kfree(rka);221221+error_free_rka:222222+ free_request_key_auth(rka);223223+error:236224 kleave("= %d", ret);237225 return ERR_PTR(ret);238226}
+6
tools/arch/s390/include/uapi/asm/kvm.h
···8888/* kvm attributes for KVM_S390_VM_TOD */8989#define KVM_S390_VM_TOD_LOW 09090#define KVM_S390_VM_TOD_HIGH 19191+#define KVM_S390_VM_TOD_EXT 29292+9393+struct kvm_s390_vm_tod_clock {9494+ __u8 epoch_idx;9595+ __u64 tod;9696+};91979298/* kvm attributes for KVM_S390_VM_CPU_MODEL */9399/* processor related attributes are r/w */
···11+#ifndef _ASM_GENERIC_HUGETLB_ENCODE_H_22+#define _ASM_GENERIC_HUGETLB_ENCODE_H_33+44+/*55+ * Several system calls take a flag to request "hugetlb" huge pages.66+ * Without further specification, these system calls will use the77+ * system's default huge page size. If a system supports multiple88+ * huge page sizes, the desired huge page size can be specified in99+ * bits [26:31] of the flag arguments. The value in these 6 bits1010+ * will encode the log2 of the huge page size.1111+ *1212+ * The following definitions are associated with this huge page size1313+ * encoding in flag arguments. System call specific header files1414+ * that use this encoding should include this file. They can then1515+ * provide definitions based on these with their own specific prefix.1616+ * for example:1717+ * #define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT1818+ */1919+2020+#define HUGETLB_FLAG_ENCODE_SHIFT 262121+#define HUGETLB_FLAG_ENCODE_MASK 0x3f2222+2323+#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)2424+#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)2525+#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)2626+#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)2727+#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT)2828+#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT)2929+#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT)3030+#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)3131+#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT)3232+#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT)3333+3434+#endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */
+3-11
tools/include/uapi/asm-generic/mman-common.h
···5858 overrides the coredump filter bits */5959#define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag */60606161+#define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */6262+#define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */6363+6164/* compatibility flags */6265#define MAP_FILE 06363-6464-/*6565- * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.6666- * This gives us 6 bits, which is enough until someone invents 128 bit address6767- * spaces.6868- *6969- * Assume these are all power of twos.7070- * When 0 use the default page size.7171- */7272-#define MAP_HUGE_SHIFT 267373-#define MAP_HUGE_MASK 0x3f74667567#define PKEY_DISABLE_ACCESS 0x17668#define PKEY_DISABLE_WRITE 0x2
+22
tools/include/uapi/drm/drm.h
···700700701701struct drm_syncobj_create {702702 __u32 handle;703703+#define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0)703704 __u32 flags;704705};705706···716715 __u32 flags;717716718717 __s32 fd;718718+ __u32 pad;719719+};720720+721721+#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)722722+#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)723723+struct drm_syncobj_wait {724724+ __u64 handles;725725+ /* absolute timeout */726726+ __s64 timeout_nsec;727727+ __u32 count_handles;728728+ __u32 flags;729729+ __u32 first_signaled; /* only valid when not waiting all */730730+ __u32 pad;731731+};732732+733733+struct drm_syncobj_array {734734+ __u64 handles;735735+ __u32 count_handles;719736 __u32 pad;720737};721738···859840#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy)860841#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)861842#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)843843+#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)844844+#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)845845+#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array)862846863847/**864848 * Device specific ioctls should only be in their respective headers
+49-2
tools/include/uapi/drm/i915_drm.h
···260260#define DRM_I915_GEM_CONTEXT_GETPARAM 0x34261261#define DRM_I915_GEM_CONTEXT_SETPARAM 0x35262262#define DRM_I915_PERF_OPEN 0x36263263+#define DRM_I915_PERF_ADD_CONFIG 0x37264264+#define DRM_I915_PERF_REMOVE_CONFIG 0x38263265264266#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)265267#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)···317315#define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)318316#define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)319317#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)318318+#define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)319319+#define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)320320321321/* Allow drivers to submit batchbuffers directly to hardware, relying322322 * on the security mechanisms provided by hardware.···434430 * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.435431 */436432#define I915_PARAM_HAS_EXEC_BATCH_FIRST 48433433+434434+/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of435435+ * drm_i915_gem_exec_fence structures. See I915_EXEC_FENCE_ARRAY.436436+ */437437+#define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49437438438439typedef struct drm_i915_getparam {439440 __s32 param;···821812 __u64 rsvd2;822813};823814815815+struct drm_i915_gem_exec_fence {816816+ /**817817+ * User's handle for a drm_syncobj to wait on or signal.818818+ */819819+ __u32 handle;820820+821821+#define I915_EXEC_FENCE_WAIT (1<<0)822822+#define I915_EXEC_FENCE_SIGNAL (1<<1)823823+ __u32 flags;824824+};825825+824826struct drm_i915_gem_execbuffer2 {825827 /**826828 * List of gem_exec_object2 structs···846826 __u32 DR1;847827 __u32 DR4;848828 __u32 num_cliprects;849849- /** This is a struct drm_clip_rect *cliprects */829829+ /**830830+ * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY831831+ * is not set. If I915_EXEC_FENCE_ARRAY is set, then this is a832832+ * struct drm_i915_gem_exec_fence *fences.833833+ */850834 __u64 cliprects_ptr;851835#define I915_EXEC_RING_MASK (7<<0)852836#define I915_EXEC_DEFAULT (0<<0)···951927 * element).952928 */953929#define I915_EXEC_BATCH_FIRST (1<<18)954954-#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_BATCH_FIRST<<1))930930+931931+/* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr932932+ * define an array of i915_gem_exec_fence structures which specify a set of933933+ * dma fences to wait upon or signal.934934+ */935935+#define I915_EXEC_FENCE_ARRAY (1<<19)936936+937937+#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1))955938956939#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)957940#define i915_execbuffer2_set_context_id(eb2, context) \···14961465 DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,1497146614981467 DRM_I915_PERF_RECORD_MAX /* non-ABI */14681468+};14691469+14701470+/**14711471+ * Structure to upload perf dynamic configuration into the kernel.14721472+ */14731473+struct drm_i915_perf_oa_config {14741474+ /** String formatted like "%08x-%04x-%04x-%04x-%012x" */14751475+ char uuid[36];14761476+14771477+ __u32 n_mux_regs;14781478+ __u32 n_boolean_regs;14791479+ __u32 n_flex_regs;14801480+14811481+ __u64 __user mux_regs_ptr;14821482+ __u64 __user boolean_regs_ptr;14831483+ __u64 __user flex_regs_ptr;14991484};1500148515011486#if defined(__cplusplus)
+20-12
tools/include/uapi/linux/bpf.h
···143143144144#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE145145146146-enum bpf_sockmap_flags {147147- BPF_SOCKMAP_UNSPEC,148148- BPF_SOCKMAP_STRPARSER,149149- __MAX_BPF_SOCKMAP_FLAG150150-};151151-152146/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command153147 * to the given target_fd cgroup the descendent cgroup will be able to154148 * override effective bpf program that was inherited from this cgroup···362368 * int bpf_redirect(ifindex, flags)363369 * redirect to another netdev364370 * @ifindex: ifindex of the net device365365- * @flags: bit 0 - if set, redirect to ingress instead of egress366366- * other bits - reserved367367- * Return: TC_ACT_REDIRECT371371+ * @flags:372372+ * cls_bpf:373373+ * bit 0 - if set, redirect to ingress instead of egress374374+ * other bits - reserved375375+ * xdp_bpf:376376+ * all bits - reserved377377+ * Return: cls_bpf: TC_ACT_REDIRECT on success or TC_ACT_SHOT on error378378+ * xdp_bfp: XDP_REDIRECT on success or XDP_ABORT on error379379+ * int bpf_redirect_map(map, key, flags)380380+ * redirect to endpoint in map381381+ * @map: pointer to dev map382382+ * @key: index in map to lookup383383+ * @flags: --384384+ * Return: XDP_REDIRECT on success or XDP_ABORT on error368385 *369386 * u32 bpf_get_route_realm(skb)370387 * retrieve a dst's tclassid···637632 FN(skb_adjust_room), \638633 FN(redirect_map), \639634 FN(sk_redirect_map), \640640- FN(sock_map_update),635635+ FN(sock_map_update), \641636642637/* integer value in 'imm' field of BPF_CALL instruction selects which helper643638 * function eBPF program intends to call···758753 __u32 family;759754 __u32 type;760755 __u32 protocol;756756+ __u32 mark;757757+ __u32 priority;761758};762759763760#define XDP_PACKET_HEADROOM 256764761765762/* User return codes for XDP prog type.766763 * A valid XDP program must return one of these defined values. All other767767- * return codes are reserved for future use. Unknown return codes will result768768- * in packet drop.764764+ * return codes are reserved for future use. Unknown return codes will765765+ * result in packet drops and a warning via bpf_warn_invalid_xdp_action().769766 */770767enum xdp_action {771768 XDP_ABORTED = 0,772769 XDP_DROP,773770 XDP_PASS,774771 XDP_TX,772772+ XDP_REDIRECT,775773};776774777775/* user accessible metadata for XDP packet hook
···11#ifndef _UAPI_LINUX_MMAN_H22#define _UAPI_LINUX_MMAN_H3344-#include <uapi/asm/mman.h>44+#include <asm/mman.h>55+#include <asm-generic/hugetlb_encode.h>5667#define MREMAP_MAYMOVE 178#define MREMAP_FIXED 2···109#define OVERCOMMIT_GUESS 01110#define OVERCOMMIT_ALWAYS 11211#define OVERCOMMIT_NEVER 21212+1313+/*1414+ * Huge page size encoding when MAP_HUGETLB is specified, and a huge page1515+ * size other than the default is desired. See hugetlb_encode.h.1616+ * All known huge page size encodings are provided here. It is the1717+ * responsibility of the application to know which sizes are supported on1818+ * the running system. See mmap(2) man page for details.1919+ */2020+#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT2121+#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK2222+2323+#define MAP_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB2424+#define MAP_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB2525+#define MAP_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB2626+#define MAP_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB2727+#define MAP_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB2828+#define MAP_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB2929+#define MAP_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB3030+#define MAP_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB3131+#define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB3232+#define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB13331434#endif /* _UAPI_LINUX_MMAN_H */
···11-/*22- * Architecture specific ELF symbol handling and relocation mapping.33- *44- * Copyright 2017 IBM Corp.55- * Author(s): Thomas Richter <tmricht@linux.vnet.ibm.com>66- *77- * This program is free software; you can redistribute it and/or modify88- * it under the terms of the GNU General Public License (version 2 only)99- * as published by the Free Software Foundation.1010- */1111-1212-#include "symbol.h"1313-1414-#ifdef HAVE_LIBELF_SUPPORT1515-bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)1616-{1717- if (ehdr.e_type == ET_EXEC)1818- return false;1919- return ehdr.e_type == ET_REL || ehdr.e_type == ET_DYN;2020-}2121-2222-void arch__adjust_sym_map_offset(GElf_Sym *sym,2323- GElf_Shdr *shdr __maybe_unused,2424- struct map *map)2525-{2626- if (map->type == MAP__FUNCTION)2727- sym->st_value += map->start;2828-}2929-#endif
+21-14
tools/perf/util/callchain.c
···6565 callchain_param.mode = CHAIN_FOLDED;6666 return 0;6767 }6868-6969- pr_err("Invalid callchain mode: %s\n", value);7068 return -1;7169}7270···8082 callchain_param.order_set = true;8183 return 0;8284 }8383-8484- pr_err("Invalid callchain order: %s\n", value);8585 return -1;8686}8787···101105 callchain_param.branch_callstack = 1;102106 return 0;103107 }104104-105105- pr_err("Invalid callchain sort key: %s\n", value);106108 return -1;107109}108110···118124 callchain_param.value = CCVAL_COUNT;119125 return 0;120126 }121121-122122- pr_err("Invalid callchain config key: %s\n", value);123127 return -1;124128}125129···311319312320 return ret;313321 }314314- if (!strcmp(var, "print-type"))315315- return parse_callchain_mode(value);316316- if (!strcmp(var, "order"))317317- return parse_callchain_order(value);318318- if (!strcmp(var, "sort-key"))319319- return parse_callchain_sort_key(value);322322+ if (!strcmp(var, "print-type")){323323+ int ret;324324+ ret = parse_callchain_mode(value);325325+ if (ret == -1)326326+ pr_err("Invalid callchain mode: %s\n", value);327327+ return ret;328328+ }329329+ if (!strcmp(var, "order")){330330+ int ret;331331+ ret = parse_callchain_order(value);332332+ if (ret == -1)333333+ pr_err("Invalid callchain order: %s\n", value);334334+ return ret;335335+ }336336+ if (!strcmp(var, "sort-key")){337337+ int ret;338338+ ret = parse_callchain_sort_key(value);339339+ if (ret == -1)340340+ pr_err("Invalid callchain sort key: %s\n", value);341341+ return ret;342342+ }320343 if (!strcmp(var, "threshold")) {321344 callchain_param.min_percent = strtod(value, &endptr);322345 if (value == endptr) {
···5252override MAKEFLAGS =5353endif54545555+ifneq ($(KBUILD_SRC),)5656+override LDFLAGS =5757+endif5858+5559BUILD := $(O)5660ifndef BUILD5761 BUILD := $(KBUILD_OUTPUT)···66626763export BUILD6864all:6969- for TARGET in $(TARGETS); do \6565+ @for TARGET in $(TARGETS); do \7066 BUILD_TARGET=$$BUILD/$$TARGET; \7167 mkdir $$BUILD_TARGET -p; \7268 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\7369 done;74707571run_tests: all7676- for TARGET in $(TARGETS); do \7272+ @for TARGET in $(TARGETS); do \7773 BUILD_TARGET=$$BUILD/$$TARGET; \7874 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\7975 done;80768177hotplug:8282- for TARGET in $(TARGETS_HOTPLUG); do \7878+ @for TARGET in $(TARGETS_HOTPLUG); do \8379 BUILD_TARGET=$$BUILD/$$TARGET; \8480 make OUTPUT=$$BUILD_TARGET -C $$TARGET;\8581 done;86828783run_hotplug: hotplug8888- for TARGET in $(TARGETS_HOTPLUG); do \8484+ @for TARGET in $(TARGETS_HOTPLUG); do \8985 BUILD_TARGET=$$BUILD/$$TARGET; \9086 make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\9187 done;92889389clean_hotplug:9494- for TARGET in $(TARGETS_HOTPLUG); do \9090+ @for TARGET in $(TARGETS_HOTPLUG); do \9591 BUILD_TARGET=$$BUILD/$$TARGET; \9692 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\9793 done;···107103ifdef INSTALL_PATH108104 @# Ask all targets to install their files109105 mkdir -p $(INSTALL_PATH)110110- for TARGET in $(TARGETS); do \106106+ @for TARGET in $(TARGETS); do \111107 BUILD_TARGET=$$BUILD/$$TARGET; \112108 make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \113109 done;···132128endif133129134130clean:135135- for TARGET in $(TARGETS); do \131131+ @for TARGET in $(TARGETS); do \136132 BUILD_TARGET=$$BUILD/$$TARGET; \137133 make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\138134 done;
+9-8
tools/testing/selftests/bpf/bpf_util.h
···1212 unsigned int start, end, possible_cpus = 0;1313 char buff[128];1414 FILE *fp;1515+ int n;15161617 fp = fopen(fcpu, "r");1718 if (!fp) {···2120 }22212322 while (fgets(buff, sizeof(buff), fp)) {2424- if (sscanf(buff, "%u-%u", &start, &end) == 2) {2525- possible_cpus = start == 0 ? end + 1 : 0;2626- break;2323+ n = sscanf(buff, "%u-%u", &start, &end);2424+ if (n == 0) {2525+ printf("Failed to retrieve # possible CPUs!\n");2626+ exit(1);2727+ } else if (n == 1) {2828+ end = start;2729 }3030+ possible_cpus = start == 0 ? end + 1 : 0;3131+ break;2832 }2929-3033 fclose(fp);3131- if (!possible_cpus) {3232- printf("Failed to retrieve # possible CPUs!\n");3333- exit(1);3434- }35343635 return possible_cpus;3736}
···11#!/bin/sh22# description: Register/unregister many kprobe events3344+[ -f kprobe_events ] || exit_unsupported # this is configurable55+46# ftrace fentry skip size depends on the machine architecture.57# Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le68case `uname -m` in
+6-3
tools/testing/selftests/futex/Makefile
···77include ../lib.mk8899all:1010- for DIR in $(SUBDIRS); do \1010+ @for DIR in $(SUBDIRS); do \1111 BUILD_TARGET=$(OUTPUT)/$$DIR; \1212 mkdir $$BUILD_TARGET -p; \1313 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\1414+ if [ -e $$DIR/$(TEST_PROGS) ]; then1515+ rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/;1616+ fi1417 done15181619override define RUN_TESTS1717- $(OUTPUT)/run.sh2020+ @cd $(OUTPUT); ./run.sh1821endef19222023override define INSTALL_RULE···3633endef37343835override define CLEAN3939- for DIR in $(SUBDIRS); do \3636+ @for DIR in $(SUBDIRS); do \4037 BUILD_TARGET=$(OUTPUT)/$$DIR; \4138 mkdir $$BUILD_TARGET -p; \4239 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
···178178 exit 0179179fi180180181181-ip -Version 2>/dev/null >/dev/null181181+ip link show 2>/dev/null >/dev/null182182if [ $? -ne 0 ];then183183 echo "SKIP: Could not run test without the ip tool"184184 exit 0
+114
tools/testing/selftests/net/reuseaddr_conflict.c
···11+/*22+ * Test for the regression introduced by33+ *44+ * b9470c27607b ("inet: kill smallest_size and smallest_port")55+ *66+ * If we open an ipv4 socket on a port with reuseaddr we shouldn't reset the tb77+ * when we open the ipv6 conterpart, which is what was happening previously.88+ */99+#include <errno.h>1010+#include <error.h>1111+#include <arpa/inet.h>1212+#include <netinet/in.h>1313+#include <stdbool.h>1414+#include <stdio.h>1515+#include <sys/socket.h>1616+#include <sys/types.h>1717+#include <unistd.h>1818+1919+#define PORT 99992020+2121+int open_port(int ipv6, int any)2222+{2323+ int fd = -1;2424+ int reuseaddr = 1;2525+ int v6only = 1;2626+ int addrlen;2727+ int ret = -1;2828+ struct sockaddr *addr;2929+ int family = ipv6 ? AF_INET6 : AF_INET;3030+3131+ struct sockaddr_in6 addr6 = {3232+ .sin6_family = AF_INET6,3333+ .sin6_port = htons(PORT),3434+ .sin6_addr = in6addr_any3535+ };3636+ struct sockaddr_in addr4 = {3737+ .sin_family = AF_INET,3838+ .sin_port = htons(PORT),3939+ .sin_addr.s_addr = any ? htonl(INADDR_ANY) : inet_addr("127.0.0.1"),4040+ };4141+4242+4343+ if (ipv6) {4444+ addr = (struct sockaddr*)&addr6;4545+ addrlen = sizeof(addr6);4646+ } else {4747+ addr = (struct sockaddr*)&addr4;4848+ addrlen = sizeof(addr4);4949+ }5050+5151+ if ((fd = socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0) {5252+ perror("socket");5353+ goto out;5454+ }5555+5656+ if (ipv6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&v6only,5757+ sizeof(v6only)) < 0) {5858+ perror("setsockopt IPV6_V6ONLY");5959+ goto out;6060+ }6161+6262+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,6363+ sizeof(reuseaddr)) < 0) {6464+ perror("setsockopt SO_REUSEADDR");6565+ goto out;6666+ }6767+6868+ if (bind(fd, addr, addrlen) < 0) {6969+ perror("bind");7070+ goto out;7171+ }7272+7373+ if (any)7474+ return fd;7575+7676+ if (listen(fd, 1) < 0) {7777+ perror("listen");7878+ goto out;7979+ }8080+ return fd;8181+out:8282+ close(fd);8383+ return ret;8484+}8585+8686+int main(void)8787+{8888+ int listenfd;8989+ int fd1, fd2;9090+9191+ fprintf(stderr, "Opening 127.0.0.1:%d\n", PORT);9292+ listenfd = open_port(0, 0);9393+ if (listenfd < 0)9494+ error(1, errno, "Couldn't open listen socket");9595+ fprintf(stderr, "Opening INADDR_ANY:%d\n", PORT);9696+ fd1 = open_port(0, 1);9797+ if (fd1 >= 0)9898+ error(1, 0, "Was allowed to create an ipv4 reuseport on a already bound non-reuseport socket");9999+ fprintf(stderr, "Opening in6addr_any:%d\n", PORT);100100+ fd1 = open_port(1, 1);101101+ if (fd1 < 0)102102+ error(1, errno, "Couldn't open ipv6 reuseport");103103+ fprintf(stderr, "Opening INADDR_ANY:%d\n", PORT);104104+ fd2 = open_port(0, 1);105105+ if (fd2 >= 0)106106+ error(1, 0, "Was allowed to create an ipv4 reuseport on a already bound non-reuseport socket");107107+ close(fd1);108108+ fprintf(stderr, "Opening INADDR_ANY:%d after closing ipv6 socket\n", PORT);109109+ fd1 = open_port(0, 1);110110+ if (fd1 >= 0)111111+ error(1, 0, "Was allowed to create an ipv4 reuseport on an already bound non-reuseport socket with no ipv6");112112+ fprintf(stderr, "Success");113113+ return 0;114114+}
+13-5
tools/testing/selftests/seccomp/seccomp_bpf.c
···66 */7788#include <sys/types.h>99-#include <asm/siginfo.h>1010-#define __have_siginfo_t 11111-#define __have_sigval_t 11212-#define __have_sigevent_t 199+1010+/*1111+ * glibc 2.26 and later have SIGSYS in siginfo_t. Before that,1212+ * we need to use the kernel's siginfo.h file and trick glibc1313+ * into accepting it.1414+ */1515+#if !__GLIBC_PREREQ(2, 26)1616+# include <asm/siginfo.h>1717+# define __have_siginfo_t 11818+# define __have_sigval_t 11919+# define __have_sigevent_t 12020+#endif13211422#include <errno.h>1523#include <linux/filter.h>···892884 syscall(__NR_getpid);893885}894886895895-static struct siginfo TRAP_info;887887+static siginfo_t TRAP_info;896888static volatile int TRAP_nr;897889static void TRAP_action(int nr, siginfo_t *info, void *void_context)898890{
+4
tools/testing/selftests/sigaltstack/sas.c
···3939 stack_t stk;4040 struct stk_data *p;41414242+#if __s390x__4343+ register unsigned long sp asm("%15");4444+#else4245 register unsigned long sp asm("sp");4646+#endif43474448 if (sp < (unsigned long)sstack ||4549 sp >= (unsigned long)sstack + SIGSTKSZ) {
+19-5
tools/testing/selftests/sync/Makefile
···22CFLAGS += -I../../../../usr/include/33LDFLAGS += -pthread4455-TEST_PROGS = sync_test66-77-all: $(TEST_PROGS)55+.PHONY: all clean8697include ../lib.mk88+99+# lib.mk TEST_CUSTOM_PROGS var is for custom tests that need special1010+# build rules. lib.mk will run and install them.1111+1212+TEST_CUSTOM_PROGS := $(OUTPUT)/sync_test1313+all: $(TEST_CUSTOM_PROGS)10141115OBJS = sync_test.o sync.o1216···2218TESTS += sync_stress_consumer.o2319TESTS += sync_stress_merge.o24202525-sync_test: $(OBJS) $(TESTS)2121+OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))2222+TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))26232727-EXTRA_CLEAN := sync_test $(OBJS) $(TESTS)2424+$(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)2525+ $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)2626+2727+$(OBJS): $(OUTPUT)/%.o: %.c2828+ $(CC) -c $^ -o $@2929+3030+$(TESTS): $(OUTPUT)/%.o: %.c3131+ $(CC) -c $^ -o $@3232+3333+EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)
+7-6
tools/testing/selftests/timers/set-timer-lat.c
···143143 printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n",144144 clockstring(clock_id),145145 flags ? "ABSTIME":"RELTIME");146146- return 0;146146+ /* Indicate timer isn't set, so caller doesn't wait */147147+ return 1;147148 }148149 printf("%s - timer_create() failed\n", clockstring(clock_id));149150 return -1;···214213 int err;215214216215 err = setup_timer(clock_id, flags, interval, &tm1);216216+ /* Unsupported case - return 0 to not fail the test */217217 if (err)218218- return err;218218+ return err == 1 ? 0 : err;219219220220 while (alarmcount < 5)221221 sleep(1);···230228 timer_t tm1;231229 const int interval = 0;232230 struct timeval timeout;233233- fd_set fds;234231 int err;235232236233 err = setup_timer(clock_id, flags, interval, &tm1);234234+ /* Unsupported case - return 0 to not fail the test */237235 if (err)238238- return err;236236+ return err == 1 ? 0 : err;239237240238 memset(&timeout, 0, sizeof(timeout));241239 timeout.tv_sec = 5;242242- FD_ZERO(&fds);243240 do {244244- err = select(FD_SETSIZE, &fds, NULL, NULL, &timeout);241241+ err = select(0, NULL, NULL, NULL, &timeout);245242 } while (err == -1 && errno == EINTR);246243247244 timer_delete(tm1);