···4545 MPX-instrumented.46463) The kernel detects that the CPU has MPX, allows the new prctl() to4747 succeed, and notes the location of the bounds directory. Userspace is4848- expected to keep the bounds directory at that locationWe note it4848+ expected to keep the bounds directory at that location. We note it4949 instead of reading it each time because the 'xsave' operation needed5050 to access the bounds directory register is an expensive operation.51514) If the application needs to spill bounds out of the 4 registers, it···167167We need to decode MPX instructions to get violation address and168168set this address into extended struct siginfo.169169170170-The _sigfault feild of struct siginfo is extended as follow:170170+The _sigfault field of struct siginfo is extended as follow:17117117217287 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */17317388 struct {···240240This is allowed architecturally. See more information "Intel(R) Architecture241241Instruction Set Extensions Programming Reference" (9.3.4).242242243243-However, if users did this, the kernel might be fooled in to unmaping an243243+However, if users did this, the kernel might be fooled in to unmapping an244244in-use bounds table since it does not recognize sharing.
+2-2
Documentation/x86/tlb.txt
···55 from areas other than the one we are trying to flush will be66 destroyed and must be refilled later, at some cost.77 2. Use the invlpg instruction to invalidate a single page at a88- time. This could potentialy cost many more instructions, but88+ time. This could potentially cost many more instructions, but99 it is a much more precise operation, causing no collateral1010 damage to other TLB entries.1111···1919 work.2020 3. The size of the TLB. The larger the TLB, the more collateral2121 damage we do with a full flush. So, the larger the TLB, the2222- more attrative an individual flush looks. Data and2222+ more attractive an individual flush looks. Data and2323 instructions have separate TLBs, as do different page sizes.2424 4. The microarchitecture. The TLB has become a multi-level2525 cache on modern CPUs, and the global flushes have become more
+1-1
Documentation/x86/x86_64/machinecheck
···36363737check_interval3838 How often to poll for corrected machine check errors, in seconds3939- (Note output is hexademical). Default 5 minutes. When the poller3939+ (Note output is hexadecimal). Default 5 minutes. When the poller4040 finds MCEs it triggers an exponential speedup (poll more often) on4141 the polling interval. When the poller stops finding MCEs, it4242 triggers an exponential backoff (poll less often) on the polling
···2828#include <asm/errno.h>2929#include <asm/esr.h>3030#include <asm/irq.h>3131+#include <asm/memory.h>3132#include <asm/thread_info.h>3233#include <asm/unistd.h>3334···9897 mov x29, xzr // fp pointed to user-space9998 .else10099 add x21, sp, #S_FRAME_SIZE101101- .endif100100+ get_thread_info tsk101101+ /* Save the task's original addr_limit and set USER_DS (TASK_SIZE_64) */102102+ ldr x20, [tsk, #TI_ADDR_LIMIT]103103+ str x20, [sp, #S_ORIG_ADDR_LIMIT]104104+ mov x20, #TASK_SIZE_64105105+ str x20, [tsk, #TI_ADDR_LIMIT]106106+ ALTERNATIVE(nop, SET_PSTATE_UAO(0), ARM64_HAS_UAO, CONFIG_ARM64_UAO)107107+ .endif /* \el == 0 */102108 mrs x22, elr_el1103109 mrs x23, spsr_el1104110 stp lr, x21, [sp, #S_LR]···136128 .endm137129138130 .macro kernel_exit, el131131+ .if \el != 0132132+ /* Restore the task's original addr_limit. */133133+ ldr x20, [sp, #S_ORIG_ADDR_LIMIT]134134+ str x20, [tsk, #TI_ADDR_LIMIT]135135+136136+ /* No need to restore UAO, it will be restored from SPSR_EL1 */137137+ .endif138138+139139 ldp x21, x22, [sp, #S_PC] // load ELR, SPSR140140 .if \el == 0141141 ct_user_enter···422406 bl trace_hardirqs_off423407#endif424408425425- get_thread_info tsk426409 irq_handler427410428411#ifdef CONFIG_PREEMPT
+2-1
arch/arm64/mm/fault.c
···280280 }281281282282 if (permission_fault(esr) && (addr < USER_DS)) {283283- if (get_fs() == KERNEL_DS)283283+ /* regs->orig_addr_limit may be 0 if we entered from EL0 */284284+ if (regs->orig_addr_limit == KERNEL_DS)284285 die("Accessing user space memory with fs=KERNEL_DS", regs, esr);285286286287 if (!search_exception_tables(regs->pc))
-5
arch/x86/Kconfig
···294294 def_bool y295295 depends on X86_32 && !CC_STACKPROTECTOR296296297297-config ARCH_HWEIGHT_CFLAGS298298- string299299- default "-fcall-saved-ecx -fcall-saved-edx" if X86_32300300- default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64301301-302297config ARCH_SUPPORTS_UPROBES303298 def_bool y304299
···11-/*22- * Common code for the sigreturn entry points in vDSO images.33- * So far this code is the same for both int80 and sysenter versions.44- * This file is #include'd by int80.S et al to define them first thing.55- * The kernel assumes that the addresses of these routines are constant66- * for all vDSO implementations.77- */88-91#include <linux/linkage.h>102#include <asm/unistd_32.h>113#include <asm/asm-offsets.h>
+1-6
arch/x86/entry/vdso/vdso32/system_call.S
···22 * AT_SYSINFO entry point33*/4455+#include <linux/linkage.h>56#include <asm/dwarf2.h>67#include <asm/cpufeatures.h>78#include <asm/alternative-asm.h>88-99-/*1010- * First get the common code for the sigreturn entry points.1111- * This must come first.1212- */1313-#include "sigreturn.S"1491510 .text1611 .globl __kernel_vsyscall
+6-5
arch/x86/events/core.c
···23192319perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)23202320{23212321 struct stack_frame frame;23222322- const void __user *fp;23222322+ const unsigned long __user *fp;2323232323242324 if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {23252325 /* TODO: We don't support guest os callchain now */···23322332 if (regs->flags & (X86_VM_MASK | PERF_EFLAGS_VM))23332333 return;2334233423352335- fp = (void __user *)regs->bp;23352335+ fp = (unsigned long __user *)regs->bp;2336233623372337 perf_callchain_store(entry, regs->ip);23382338···23452345 pagefault_disable();23462346 while (entry->nr < entry->max_stack) {23472347 unsigned long bytes;23482348+23482349 frame.next_frame = NULL;23492350 frame.return_address = 0;2350235123512351- if (!access_ok(VERIFY_READ, fp, 16))23522352+ if (!access_ok(VERIFY_READ, fp, sizeof(*fp) * 2))23522353 break;2353235423542354- bytes = __copy_from_user_nmi(&frame.next_frame, fp, 8);23552355+ bytes = __copy_from_user_nmi(&frame.next_frame, fp, sizeof(*fp));23552356 if (bytes != 0)23562357 break;23572357- bytes = __copy_from_user_nmi(&frame.return_address, fp+8, 8);23582358+ bytes = __copy_from_user_nmi(&frame.return_address, fp + 1, sizeof(*fp));23582359 if (bytes != 0)23592360 break;23602361
···115115 INTEL_UEVENT_CONSTRAINT(0x04a3, 0xf), /* CYCLE_ACTIVITY.CYCLES_NO_DISPATCH */116116 INTEL_UEVENT_CONSTRAINT(0x02a3, 0x4), /* CYCLE_ACTIVITY.CYCLES_L1D_PENDING */117117118118+ /*119119+ * When HT is off these events can only run on the bottom 4 counters120120+ * When HT is on, they are impacted by the HT bug and require EXCL access121121+ */118122 INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */119123 INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */120124 INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */···143139 INTEL_UEVENT_CONSTRAINT(0x0ca3, 0x4), /* CYCLE_ACTIVITY.STALLS_L1D_PENDING */144140 INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */145141142142+ /*143143+ * When HT is off these events can only run on the bottom 4 counters144144+ * When HT is on, they are impacted by the HT bug and require EXCL access145145+ */146146 INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */147147 INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */148148 INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */···190182 FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */191183 FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */192184 INTEL_UEVENT_CONSTRAINT(0x1c0, 0x2), /* INST_RETIRED.PREC_DIST */185185+186186+ /*187187+ * when HT is off, these can only run on the bottom 4 counters188188+ */189189+ INTEL_EVENT_CONSTRAINT(0xd0, 0xf), /* MEM_INST_RETIRED.* */190190+ INTEL_EVENT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_RETIRED.* */191191+ INTEL_EVENT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_L3_HIT_RETIRED.* */192192+ INTEL_EVENT_CONSTRAINT(0xcd, 0xf), /* MEM_TRANS_RETIRED.* */193193+ INTEL_EVENT_CONSTRAINT(0xc6, 0xf), /* FRONTEND_RETIRED.* */194194+193195 EVENT_CONSTRAINT_END194196};195197···268250 /* CYCLE_ACTIVITY.CYCLES_NO_EXECUTE */269251 INTEL_UEVENT_CONSTRAINT(0x04a3, 0xf),270252253253+ /*254254+ * When HT is off these events can only run on the bottom 4 counters255255+ * When HT is on, they are impacted by the HT bug and require EXCL access256256+ */271257 INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */272258 INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */273259 INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */···286264 FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */287265 INTEL_UEVENT_CONSTRAINT(0x148, 0x4), /* L1D_PEND_MISS.PENDING */288266 INTEL_UBIT_EVENT_CONSTRAINT(0x8a3, 0x4), /* CYCLE_ACTIVITY.CYCLES_L1D_MISS */267267+ /*268268+ * when HT is off, these can only run on the bottom 4 counters269269+ */270270+ INTEL_EVENT_CONSTRAINT(0xd0, 0xf), /* MEM_INST_RETIRED.* */271271+ INTEL_EVENT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_RETIRED.* */272272+ INTEL_EVENT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_L3_HIT_RETIRED.* */273273+ INTEL_EVENT_CONSTRAINT(0xcd, 0xf), /* MEM_TRANS_RETIRED.* */289274 EVENT_CONSTRAINT_END290275};291276
+3-3
arch/x86/include/asm/apm.h
···4545 : "memory", "cc");4646}47474848-static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,4949- u32 ecx_in, u32 *eax)4848+static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in,4949+ u32 ecx_in, u32 *eax)5050{5151 int cx, dx, si;5252- u8 error;5252+ bool error;53535454 /*5555 * N.B. We do NOT need a cld after the BIOS call
+10-14
arch/x86/include/asm/arch_hweight.h
···44#include <asm/cpufeatures.h>5566#ifdef CONFIG_64BIT77-/* popcnt %edi, %eax -- redundant REX prefix for alignment */88-#define POPCNT32 ".byte 0xf3,0x40,0x0f,0xb8,0xc7"77+/* popcnt %edi, %eax */88+#define POPCNT32 ".byte 0xf3,0x0f,0xb8,0xc7"99/* popcnt %rdi, %rax */1010#define POPCNT64 ".byte 0xf3,0x48,0x0f,0xb8,0xc7"1111#define REG_IN "D"···1717#define REG_OUT "a"1818#endif19192020-/*2121- * __sw_hweightXX are called from within the alternatives below2222- * and callee-clobbered registers need to be taken care of. See2323- * ARCH_HWEIGHT_CFLAGS in <arch/x86/Kconfig> for the respective2424- * compiler switches.2525- */2020+#define __HAVE_ARCH_SW_HWEIGHT2121+2622static __always_inline unsigned int __arch_hweight32(unsigned int w)2723{2828- unsigned int res = 0;2424+ unsigned int res;29253026 asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT)3131- : "="REG_OUT (res)3232- : REG_IN (w));2727+ : "="REG_OUT (res)2828+ : REG_IN (w));33293430 return res;3531}···4953#else5054static __always_inline unsigned long __arch_hweight64(__u64 w)5155{5252- unsigned long res = 0;5656+ unsigned long res;53575458 asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)5555- : "="REG_OUT (res)5656- : REG_IN (w));5959+ : "="REG_OUT (res)6060+ : REG_IN (w));57615862 return res;5963}
+62-70
arch/x86/include/asm/archrandom.h
···25252626#include <asm/processor.h>2727#include <asm/cpufeature.h>2828-#include <asm/alternative.h>2929-#include <asm/nops.h>30283129#define RDRAND_RETRY_LOOPS 103230···3840# define RDSEED_LONG RDSEED_INT3941#endif40424141-#ifdef CONFIG_ARCH_RANDOM4343+/* Unconditional execution of RDRAND and RDSEED */42444343-/* Instead of arch_get_random_long() when alternatives haven't run. */4444-static inline int rdrand_long(unsigned long *v)4545+static inline bool rdrand_long(unsigned long *v)4546{4646- int ok;4747- asm volatile("1: " RDRAND_LONG "\n\t"4848- "jc 2f\n\t"4949- "decl %0\n\t"5050- "jnz 1b\n\t"5151- "2:"5252- : "=r" (ok), "=a" (*v)5353- : "0" (RDRAND_RETRY_LOOPS));5454- return ok;4747+ bool ok;4848+ unsigned int retry = RDRAND_RETRY_LOOPS;4949+ do {5050+ asm volatile(RDRAND_LONG "\n\t"5151+ CC_SET(c)5252+ : CC_OUT(c) (ok), "=a" (*v));5353+ if (ok)5454+ return true;5555+ } while (--retry);5656+ return false;5557}56585757-/* A single attempt at RDSEED */5959+static inline bool rdrand_int(unsigned int *v)6060+{6161+ bool ok;6262+ unsigned int retry = RDRAND_RETRY_LOOPS;6363+ do {6464+ asm volatile(RDRAND_INT "\n\t"6565+ CC_SET(c)6666+ : CC_OUT(c) (ok), "=a" (*v));6767+ if (ok)6868+ return true;6969+ } while (--retry);7070+ return false;7171+}7272+5873static inline bool rdseed_long(unsigned long *v)5974{6060- unsigned char ok;7575+ bool ok;6176 asm volatile(RDSEED_LONG "\n\t"6262- "setc %0"6363- : "=qm" (ok), "=a" (*v));7777+ CC_SET(c)7878+ : CC_OUT(c) (ok), "=a" (*v));6479 return ok;6580}66816767-#define GET_RANDOM(name, type, rdrand, nop) \6868-static inline int name(type *v) \6969-{ \7070- int ok; \7171- alternative_io("movl $0, %0\n\t" \7272- nop, \7373- "\n1: " rdrand "\n\t" \7474- "jc 2f\n\t" \7575- "decl %0\n\t" \7676- "jnz 1b\n\t" \7777- "2:", \7878- X86_FEATURE_RDRAND, \7979- ASM_OUTPUT2("=r" (ok), "=a" (*v)), \8080- "0" (RDRAND_RETRY_LOOPS)); \8181- return ok; \8282+static inline bool rdseed_int(unsigned int *v)8383+{8484+ bool ok;8585+ asm volatile(RDSEED_INT "\n\t"8686+ CC_SET(c)8787+ : CC_OUT(c) (ok), "=a" (*v));8888+ return ok;8289}83908484-#define GET_SEED(name, type, rdseed, nop) \8585-static inline int name(type *v) \8686-{ \8787- unsigned char ok; \8888- alternative_io("movb $0, %0\n\t" \8989- nop, \9090- rdseed "\n\t" \9191- "setc %0", \9292- X86_FEATURE_RDSEED, \9393- ASM_OUTPUT2("=q" (ok), "=a" (*v))); \9494- return ok; \9595-}9696-9797-#ifdef CONFIG_X86_649898-9999-GET_RANDOM(arch_get_random_long, unsigned long, RDRAND_LONG, ASM_NOP5);100100-GET_RANDOM(arch_get_random_int, unsigned int, RDRAND_INT, ASM_NOP4);101101-102102-GET_SEED(arch_get_random_seed_long, unsigned long, RDSEED_LONG, ASM_NOP5);103103-GET_SEED(arch_get_random_seed_int, unsigned int, RDSEED_INT, ASM_NOP4);104104-105105-#else106106-107107-GET_RANDOM(arch_get_random_long, unsigned long, RDRAND_LONG, ASM_NOP3);108108-GET_RANDOM(arch_get_random_int, unsigned int, RDRAND_INT, ASM_NOP3);109109-110110-GET_SEED(arch_get_random_seed_long, unsigned long, RDSEED_LONG, ASM_NOP4);111111-GET_SEED(arch_get_random_seed_int, unsigned int, RDSEED_INT, ASM_NOP4);112112-113113-#endif /* CONFIG_X86_64 */114114-9191+/* Conditional execution based on CPU type */11592#define arch_has_random() static_cpu_has(X86_FEATURE_RDRAND)11693#define arch_has_random_seed() static_cpu_has(X86_FEATURE_RDSEED)11794118118-#else9595+/*9696+ * These are the generic interfaces; they must not be declared if the9797+ * stubs in <linux/random.h> are to be invoked,9898+ * i.e. CONFIG_ARCH_RANDOM is not defined.9999+ */100100+#ifdef CONFIG_ARCH_RANDOM119101120120-static inline int rdrand_long(unsigned long *v)102102+static inline bool arch_get_random_long(unsigned long *v)121103{122122- return 0;104104+ return arch_has_random() ? rdrand_long(v) : false;123105}124106125125-static inline bool rdseed_long(unsigned long *v)107107+static inline bool arch_get_random_int(unsigned int *v)126108{127127- return 0;109109+ return arch_has_random() ? rdrand_int(v) : false;128110}129111130130-#endif /* CONFIG_ARCH_RANDOM */112112+static inline bool arch_get_random_seed_long(unsigned long *v)113113+{114114+ return arch_has_random_seed() ? rdseed_long(v) : false;115115+}116116+117117+static inline bool arch_get_random_seed_int(unsigned int *v)118118+{119119+ return arch_has_random_seed() ? rdseed_int(v) : false;120120+}131121132122extern void x86_init_rdrand(struct cpuinfo_x86 *c);123123+124124+#else /* !CONFIG_ARCH_RANDOM */125125+126126+static inline void x86_init_rdrand(struct cpuinfo_x86 *c) { }127127+128128+#endif /* !CONFIG_ARCH_RANDOM */133129134130#endif /* ASM_X86_ARCHRANDOM_H */
+12
arch/x86/include/asm/asm.h
···4242#define _ASM_SI __ASM_REG(si)4343#define _ASM_DI __ASM_REG(di)44444545+/*4646+ * Macros to generate condition code outputs from inline assembly,4747+ * The output operand must be type "bool".4848+ */4949+#ifdef __GCC_ASM_FLAG_OUTPUTS__5050+# define CC_SET(c) "\n\t/* output condition code " #c "*/\n"5151+# define CC_OUT(c) "=@cc" #c5252+#else5353+# define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n"5454+# define CC_OUT(c) [_cc_ ## c] "=qm"5555+#endif5656+4557/* Exception table entry */4658#ifdef __ASSEMBLY__4759# define _ASM_EXTABLE_HANDLE(from, to, handler) \
+8-8
arch/x86/include/asm/atomic.h
···7575 * true if the result is zero, or false for all7676 * other cases.7777 */7878-static __always_inline int atomic_sub_and_test(int i, atomic_t *v)7878+static __always_inline bool atomic_sub_and_test(int i, atomic_t *v)7979{8080- GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", "e");8080+ GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", e);8181}82828383/**···112112 * returns true if the result is 0, or false for all other113113 * cases.114114 */115115-static __always_inline int atomic_dec_and_test(atomic_t *v)115115+static __always_inline bool atomic_dec_and_test(atomic_t *v)116116{117117- GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e");117117+ GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", e);118118}119119120120/**···125125 * and returns true if the result is zero, or false for all126126 * other cases.127127 */128128-static __always_inline int atomic_inc_and_test(atomic_t *v)128128+static __always_inline bool atomic_inc_and_test(atomic_t *v)129129{130130- GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", "e");130130+ GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", e);131131}132132133133/**···139139 * if the result is negative, or false when140140 * result is greater than or equal to zero.141141 */142142-static __always_inline int atomic_add_negative(int i, atomic_t *v)142142+static __always_inline bool atomic_add_negative(int i, atomic_t *v)143143{144144- GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", "s");144144+ GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", s);145145}146146147147/**
+9-9
arch/x86/include/asm/atomic64_64.h
···7070 * true if the result is zero, or false for all7171 * other cases.7272 */7373-static inline int atomic64_sub_and_test(long i, atomic64_t *v)7373+static inline bool atomic64_sub_and_test(long i, atomic64_t *v)7474{7575- GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", "e");7575+ GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", e);7676}77777878/**···109109 * returns true if the result is 0, or false for all other110110 * cases.111111 */112112-static inline int atomic64_dec_and_test(atomic64_t *v)112112+static inline bool atomic64_dec_and_test(atomic64_t *v)113113{114114- GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", "e");114114+ GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", e);115115}116116117117/**···122122 * and returns true if the result is zero, or false for all123123 * other cases.124124 */125125-static inline int atomic64_inc_and_test(atomic64_t *v)125125+static inline bool atomic64_inc_and_test(atomic64_t *v)126126{127127- GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", "e");127127+ GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", e);128128}129129130130/**···136136 * if the result is negative, or false when137137 * result is greater than or equal to zero.138138 */139139-static inline int atomic64_add_negative(long i, atomic64_t *v)139139+static inline bool atomic64_add_negative(long i, atomic64_t *v)140140{141141- GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", "s");141141+ GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", s);142142}143143144144/**···180180 * Atomically adds @a to @v, so long as it was not @u.181181 * Returns the old value of @v.182182 */183183-static inline int atomic64_add_unless(atomic64_t *v, long a, long u)183183+static inline bool atomic64_add_unless(atomic64_t *v, long a, long u)184184{185185 long c, old;186186 c = atomic64_read(v);
+25-25
arch/x86/include/asm/bitops.h
···201201 * This operation is atomic and cannot be reordered.202202 * It also implies a memory barrier.203203 */204204-static __always_inline int test_and_set_bit(long nr, volatile unsigned long *addr)204204+static __always_inline bool test_and_set_bit(long nr, volatile unsigned long *addr)205205{206206- GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");206206+ GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", c);207207}208208209209/**···213213 *214214 * This is the same as test_and_set_bit on x86.215215 */216216-static __always_inline int216216+static __always_inline bool217217test_and_set_bit_lock(long nr, volatile unsigned long *addr)218218{219219 return test_and_set_bit(nr, addr);···228228 * If two examples of this operation race, one can appear to succeed229229 * but actually fail. You must protect multiple accesses with a lock.230230 */231231-static __always_inline int __test_and_set_bit(long nr, volatile unsigned long *addr)231231+static __always_inline bool __test_and_set_bit(long nr, volatile unsigned long *addr)232232{233233- int oldbit;233233+ bool oldbit;234234235235 asm("bts %2,%1\n\t"236236- "sbb %0,%0"237237- : "=r" (oldbit), ADDR236236+ CC_SET(c)237237+ : CC_OUT(c) (oldbit), ADDR238238 : "Ir" (nr));239239 return oldbit;240240}···247247 * This operation is atomic and cannot be reordered.248248 * It also implies a memory barrier.249249 */250250-static __always_inline int test_and_clear_bit(long nr, volatile unsigned long *addr)250250+static __always_inline bool test_and_clear_bit(long nr, volatile unsigned long *addr)251251{252252- GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");252252+ GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", c);253253}254254255255/**···268268 * accessed from a hypervisor on the same CPU if running in a VM: don't change269269 * this without also updating arch/x86/kernel/kvm.c270270 */271271-static __always_inline int __test_and_clear_bit(long nr, volatile unsigned long *addr)271271+static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long *addr)272272{273273- int oldbit;273273+ bool oldbit;274274275275 asm volatile("btr %2,%1\n\t"276276- "sbb %0,%0"277277- : "=r" (oldbit), ADDR276276+ CC_SET(c)277277+ : CC_OUT(c) (oldbit), ADDR278278 : "Ir" (nr));279279 return oldbit;280280}281281282282/* WARNING: non atomic and it can be reordered! */283283-static __always_inline int __test_and_change_bit(long nr, volatile unsigned long *addr)283283+static __always_inline bool __test_and_change_bit(long nr, volatile unsigned long *addr)284284{285285- int oldbit;285285+ bool oldbit;286286287287 asm volatile("btc %2,%1\n\t"288288- "sbb %0,%0"289289- : "=r" (oldbit), ADDR288288+ CC_SET(c)289289+ : CC_OUT(c) (oldbit), ADDR290290 : "Ir" (nr) : "memory");291291292292 return oldbit;···300300 * This operation is atomic and cannot be reordered.301301 * It also implies a memory barrier.302302 */303303-static __always_inline int test_and_change_bit(long nr, volatile unsigned long *addr)303303+static __always_inline bool test_and_change_bit(long nr, volatile unsigned long *addr)304304{305305- GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");305305+ GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", c);306306}307307308308-static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)308308+static __always_inline bool constant_test_bit(long nr, const volatile unsigned long *addr)309309{310310 return ((1UL << (nr & (BITS_PER_LONG-1))) &311311 (addr[nr >> _BITOPS_LONG_SHIFT])) != 0;312312}313313314314-static __always_inline int variable_test_bit(long nr, volatile const unsigned long *addr)314314+static __always_inline bool variable_test_bit(long nr, volatile const unsigned long *addr)315315{316316- int oldbit;316316+ bool oldbit;317317318318 asm volatile("bt %2,%1\n\t"319319- "sbb %0,%0"320320- : "=r" (oldbit)319319+ CC_SET(c)320320+ : CC_OUT(c) (oldbit)321321 : "m" (*(unsigned long *)addr), "Ir" (nr));322322323323 return oldbit;···329329 * @nr: bit number to test330330 * @addr: Address to start counting from331331 */332332-static int test_bit(int nr, const volatile unsigned long *addr);332332+static bool test_bit(int nr, const volatile unsigned long *addr);333333#endif334334335335#define test_bit(nr, addr) \
+11
arch/x86/include/asm/compat.h
···4040typedef s64 __attribute__((aligned(4))) compat_s64;4141typedef u32 compat_uint_t;4242typedef u32 compat_ulong_t;4343+typedef u32 compat_u32;4344typedef u64 __attribute__((aligned(4))) compat_u64;4445typedef u32 compat_uptr_t;4546···182181 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */183182 struct {184183 unsigned int _addr; /* faulting insn/memory ref. */184184+ short int _addr_lsb; /* Valid LSB of the reported address. */185185+ union {186186+ /* used when si_code=SEGV_BNDERR */187187+ struct {188188+ compat_uptr_t _lower;189189+ compat_uptr_t _upper;190190+ } _addr_bnd;191191+ /* used when si_code=SEGV_PKUERR */192192+ compat_u32 _pkey;193193+ };185194 } _sigfault;186195187196 /* SIGPOLL */
+8-8
arch/x86/include/asm/local.h
···5050 * true if the result is zero, or false for all5151 * other cases.5252 */5353-static inline int local_sub_and_test(long i, local_t *l)5353+static inline bool local_sub_and_test(long i, local_t *l)5454{5555- GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", "e");5555+ GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", e);5656}57575858/**···6363 * returns true if the result is 0, or false for all other6464 * cases.6565 */6666-static inline int local_dec_and_test(local_t *l)6666+static inline bool local_dec_and_test(local_t *l)6767{6868- GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", "e");6868+ GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", e);6969}70707171/**···7676 * and returns true if the result is zero, or false for all7777 * other cases.7878 */7979-static inline int local_inc_and_test(local_t *l)7979+static inline bool local_inc_and_test(local_t *l)8080{8181- GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", "e");8181+ GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", e);8282}83838484/**···9090 * if the result is negative, or false when9191 * result is greater than or equal to zero.9292 */9393-static inline int local_add_negative(long i, local_t *l)9393+static inline bool local_add_negative(long i, local_t *l)9494{9595- GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", "s");9595+ GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", s);9696}97979898/**
+9-8
arch/x86/include/asm/percpu.h
···510510/* This is not atomic against other CPUs -- CPU preemption needs to be off */511511#define x86_test_and_clear_bit_percpu(bit, var) \512512({ \513513- int old__; \514514- asm volatile("btr %2,"__percpu_arg(1)"\n\tsbbl %0,%0" \515515- : "=r" (old__), "+m" (var) \513513+ bool old__; \514514+ asm volatile("btr %2,"__percpu_arg(1)"\n\t" \515515+ CC_SET(c) \516516+ : CC_OUT(c) (old__), "+m" (var) \516517 : "dIr" (bit)); \517518 old__; \518519})519520520520-static __always_inline int x86_this_cpu_constant_test_bit(unsigned int nr,521521+static __always_inline bool x86_this_cpu_constant_test_bit(unsigned int nr,521522 const unsigned long __percpu *addr)522523{523524 unsigned long __percpu *a = (unsigned long *)addr + nr / BITS_PER_LONG;···530529#endif531530}532531533533-static inline int x86_this_cpu_variable_test_bit(int nr,532532+static inline bool x86_this_cpu_variable_test_bit(int nr,534533 const unsigned long __percpu *addr)535534{536536- int oldbit;535535+ bool oldbit;537536538537 asm volatile("bt "__percpu_arg(2)",%1\n\t"539539- "sbb %0,%0"540540- : "=r" (oldbit)538538+ CC_SET(c)539539+ : CC_OUT(c) (oldbit)541540 : "m" (*(unsigned long *)addr), "Ir" (nr));542541543542 return oldbit;
···7171 while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL)7272 i++;73737474- if (i == 0)7575- return 0;7474+ if (!i)7575+ return -ENODEV;76767777 nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL);7878 if (!nb)
+2-2
arch/x86/kernel/cpu/rdrand.c
···3939 */4040#define SANITY_CHECK_LOOPS 841414242+#ifdef CONFIG_ARCH_RANDOM4243void x86_init_rdrand(struct cpuinfo_x86 *c)4344{4444-#ifdef CONFIG_ARCH_RANDOM4545 unsigned long tmp;4646 int i;4747···5555 return;5656 }5757 }5858-#endif5958}5959+#endif
···11#include <linux/compat.h>22#include <linux/uaccess.h>3344+/*55+ * The compat_siginfo_t structure and handing code is very easy66+ * to break in several ways. It must always be updated when new77+ * updates are made to the main siginfo_t, and88+ * copy_siginfo_to_user32() must be updated when the99+ * (arch-independent) copy_siginfo_to_user() is updated.1010+ *1111+ * It is also easy to put a new member in the compat_siginfo_t1212+ * which has implicit alignment which can move internal structure1313+ * alignment around breaking the ABI. This can happen if you,1414+ * for instance, put a plain 64-bit value in there.1515+ */1616+static inline void signal_compat_build_tests(void)1717+{1818+ int _sifields_offset = offsetof(compat_siginfo_t, _sifields);1919+2020+ /*2121+ * If adding a new si_code, there is probably new data in2222+ * the siginfo. Make sure folks bumping the si_code2323+ * limits also have to look at this code. Make sure any2424+ * new fields are handled in copy_siginfo_to_user32()!2525+ */2626+ BUILD_BUG_ON(NSIGILL != 8);2727+ BUILD_BUG_ON(NSIGFPE != 8);2828+ BUILD_BUG_ON(NSIGSEGV != 4);2929+ BUILD_BUG_ON(NSIGBUS != 5);3030+ BUILD_BUG_ON(NSIGTRAP != 4);3131+ BUILD_BUG_ON(NSIGCHLD != 6);3232+ BUILD_BUG_ON(NSIGSYS != 1);3333+3434+ /* This is part of the ABI and can never change in size: */3535+ BUILD_BUG_ON(sizeof(compat_siginfo_t) != 128);3636+ /*3737+ * The offsets of all the (unioned) si_fields are fixed3838+ * in the ABI, of course. Make sure none of them ever3939+ * move and are always at the beginning:4040+ */4141+ BUILD_BUG_ON(offsetof(compat_siginfo_t, _sifields) != 3 * sizeof(int));4242+#define CHECK_CSI_OFFSET(name) BUILD_BUG_ON(_sifields_offset != offsetof(compat_siginfo_t, _sifields.name))4343+4444+ /*4545+ * Ensure that the size of each si_field never changes.4646+ * If it does, it is a sign that the4747+ * copy_siginfo_to_user32() code below needs to updated4848+ * along with the size in the CHECK_SI_SIZE().4949+ *5050+ * We repeat this check for both the generic and compat5151+ * siginfos.5252+ *5353+ * Note: it is OK for these to grow as long as the whole5454+ * structure stays within the padding size (checked5555+ * above).5656+ */5757+#define CHECK_CSI_SIZE(name, size) BUILD_BUG_ON(size != sizeof(((compat_siginfo_t *)0)->_sifields.name))5858+#define CHECK_SI_SIZE(name, size) BUILD_BUG_ON(size != sizeof(((siginfo_t *)0)->_sifields.name))5959+6060+ CHECK_CSI_OFFSET(_kill);6161+ CHECK_CSI_SIZE (_kill, 2*sizeof(int));6262+ CHECK_SI_SIZE (_kill, 2*sizeof(int));6363+6464+ CHECK_CSI_OFFSET(_timer);6565+ CHECK_CSI_SIZE (_timer, 5*sizeof(int));6666+ CHECK_SI_SIZE (_timer, 6*sizeof(int));6767+6868+ CHECK_CSI_OFFSET(_rt);6969+ CHECK_CSI_SIZE (_rt, 3*sizeof(int));7070+ CHECK_SI_SIZE (_rt, 4*sizeof(int));7171+7272+ CHECK_CSI_OFFSET(_sigchld);7373+ CHECK_CSI_SIZE (_sigchld, 5*sizeof(int));7474+ CHECK_SI_SIZE (_sigchld, 8*sizeof(int));7575+7676+ CHECK_CSI_OFFSET(_sigchld_x32);7777+ CHECK_CSI_SIZE (_sigchld_x32, 7*sizeof(int));7878+ /* no _sigchld_x32 in the generic siginfo_t */7979+8080+ CHECK_CSI_OFFSET(_sigfault);8181+ CHECK_CSI_SIZE (_sigfault, 4*sizeof(int));8282+ CHECK_SI_SIZE (_sigfault, 8*sizeof(int));8383+8484+ CHECK_CSI_OFFSET(_sigpoll);8585+ CHECK_CSI_SIZE (_sigpoll, 2*sizeof(int));8686+ CHECK_SI_SIZE (_sigpoll, 4*sizeof(int));8787+8888+ CHECK_CSI_OFFSET(_sigsys);8989+ CHECK_CSI_SIZE (_sigsys, 3*sizeof(int));9090+ CHECK_SI_SIZE (_sigsys, 4*sizeof(int));9191+9292+ /* any new si_fields should be added here */9393+}9494+495int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)596{697 int err = 0;798 bool ia32 = test_thread_flag(TIF_IA32);9999+100100+ signal_compat_build_tests();81019102 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))10103 return -EFAULT;···12532 &to->_sifields._pad[0]);12633 switch (from->si_code >> 16) {12734 case __SI_FAULT >> 16:3535+ if (from->si_signo == SIGBUS &&3636+ (from->si_code == BUS_MCEERR_AR ||3737+ from->si_code == BUS_MCEERR_AO))3838+ put_user_ex(from->si_addr_lsb, &to->si_addr_lsb);3939+4040+ if (from->si_signo == SIGSEGV) {4141+ if (from->si_code == SEGV_BNDERR) {4242+ compat_uptr_t lower = (unsigned long)&to->si_lower;4343+ compat_uptr_t upper = (unsigned long)&to->si_upper;4444+ put_user_ex(lower, &to->si_lower);4545+ put_user_ex(upper, &to->si_upper);4646+ }4747+ if (from->si_code == SEGV_PKUERR)4848+ put_user_ex(from->si_pkey, &to->si_pkey);4949+ }12850 break;12951 case __SI_SYS >> 16:13052 put_user_ex(from->si_syscall, &to->si_syscall);
···44444545EXPORT_SYMBOL(csum_partial);46464747+EXPORT_SYMBOL(__sw_hweight32);4848+EXPORT_SYMBOL(__sw_hweight64);4949+4750/*4851 * Export string functions. We normally rely on gcc builtin for most of these,4952 * but gcc sometimes decides not to inline them.
···396396 return -ENODEV;397397398398 printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");399399+ acpi_irq_penalty_init();399400 pcibios_enable_irq = acpi_pci_irq_enable;400401 pcibios_disable_irq = acpi_pci_irq_disable;401402 x86_init.pci.init_irq = x86_init_noop;
+85-12
arch/x86/power/hibernate_64.c
···1919#include <asm/mtrr.h>2020#include <asm/sections.h>2121#include <asm/suspend.h>2222+#include <asm/tlbflush.h>22232324/* Defined in hibernate_asm_64.S */2425extern asmlinkage __visible int restore_image(void);···2928 * kernel's text (this value is passed in the image header).3029 */3130unsigned long restore_jump_address __visible;3131+unsigned long jump_address_phys;32323333/*3434 * Value of the cr3 register from before the hibernation (this value is passed···39374038pgd_t *temp_level4_pgt __visible;41394242-void *relocated_restore_code __visible;4040+unsigned long relocated_restore_code __visible;4141+4242+static int set_up_temporary_text_mapping(void)4343+{4444+ pmd_t *pmd;4545+ pud_t *pud;4646+4747+ /*4848+ * The new mapping only has to cover the page containing the image4949+ * kernel's entry point (jump_address_phys), because the switch over to5050+ * it is carried out by relocated code running from a page allocated5151+ * specifically for this purpose and covered by the identity mapping, so5252+ * the temporary kernel text mapping is only needed for the final jump.5353+ * Moreover, in that mapping the virtual address of the image kernel's5454+ * entry point must be the same as its virtual address in the image5555+ * kernel (restore_jump_address), so the image kernel's5656+ * restore_registers() code doesn't find itself in a different area of5757+ * the virtual address space after switching over to the original page5858+ * tables used by the image kernel.5959+ */6060+ pud = (pud_t *)get_safe_page(GFP_ATOMIC);6161+ if (!pud)6262+ return -ENOMEM;6363+6464+ pmd = (pmd_t *)get_safe_page(GFP_ATOMIC);6565+ if (!pmd)6666+ return -ENOMEM;6767+6868+ set_pmd(pmd + pmd_index(restore_jump_address),6969+ __pmd((jump_address_phys & PMD_MASK) | __PAGE_KERNEL_LARGE_EXEC));7070+ set_pud(pud + pud_index(restore_jump_address),7171+ __pud(__pa(pmd) | _KERNPG_TABLE));7272+ set_pgd(temp_level4_pgt + pgd_index(restore_jump_address),7373+ __pgd(__pa(pud) | _KERNPG_TABLE));7474+7575+ return 0;7676+}43774478static void *alloc_pgt_page(void *context)4579{···9759 if (!temp_level4_pgt)9860 return -ENOMEM;9961100100- /* It is safe to reuse the original kernel mapping */101101- set_pgd(temp_level4_pgt + pgd_index(__START_KERNEL_map),102102- init_level4_pgt[pgd_index(__START_KERNEL_map)]);6262+ /* Prepare a temporary mapping for the kernel text */6363+ result = set_up_temporary_text_mapping();6464+ if (result)6565+ return result;1036610467 /* Set up the direct mapping from scratch */10568 for (i = 0; i < nr_pfn_mapped; i++) {···11778 return 0;11879}119808181+static int relocate_restore_code(void)8282+{8383+ pgd_t *pgd;8484+ pud_t *pud;8585+8686+ relocated_restore_code = get_safe_page(GFP_ATOMIC);8787+ if (!relocated_restore_code)8888+ return -ENOMEM;8989+9090+ memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE);9191+9292+ /* Make the page containing the relocated code executable */9393+ pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code);9494+ pud = pud_offset(pgd, relocated_restore_code);9595+ if (pud_large(*pud)) {9696+ set_pud(pud, __pud(pud_val(*pud) & ~_PAGE_NX));9797+ } else {9898+ pmd_t *pmd = pmd_offset(pud, relocated_restore_code);9999+100100+ if (pmd_large(*pmd)) {101101+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_NX));102102+ } else {103103+ pte_t *pte = pte_offset_kernel(pmd, relocated_restore_code);104104+105105+ set_pte(pte, __pte(pte_val(*pte) & ~_PAGE_NX));106106+ }107107+ }108108+ __flush_tlb_all();109109+110110+ return 0;111111+}112112+120113int swsusp_arch_resume(void)121114{122115 int error;123116124117 /* We have got enough memory and from now on we cannot recover */125125- if ((error = set_up_temporary_mappings()))118118+ error = set_up_temporary_mappings();119119+ if (error)126120 return error;127121128128- relocated_restore_code = (void *)get_safe_page(GFP_ATOMIC);129129- if (!relocated_restore_code)130130- return -ENOMEM;131131- memcpy(relocated_restore_code, &core_restore_code,132132- &restore_registers - &core_restore_code);122122+ error = relocate_restore_code();123123+ if (error)124124+ return error;133125134126 restore_image();135127 return 0;···179109180110struct restore_data_record {181111 unsigned long jump_address;112112+ unsigned long jump_address_phys;182113 unsigned long cr3;183114 unsigned long magic;184115};185116186186-#define RESTORE_MAGIC 0x0123456789ABCDEFUL117117+#define RESTORE_MAGIC 0x123456789ABCDEF0UL187118188119/**189120 * arch_hibernation_header_save - populate the architecture specific part···197126198127 if (max_size < sizeof(struct restore_data_record))199128 return -EOVERFLOW;200200- rdr->jump_address = restore_jump_address;129129+ rdr->jump_address = (unsigned long)&restore_registers;130130+ rdr->jump_address_phys = __pa_symbol(&restore_registers);201131 rdr->cr3 = restore_cr3;202132 rdr->magic = RESTORE_MAGIC;203133 return 0;···214142 struct restore_data_record *rdr = addr;215143216144 restore_jump_address = rdr->jump_address;145145+ jump_address_phys = rdr->jump_address_phys;217146 restore_cr3 = rdr->cr3;218147 return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;219148}
+24-31
arch/x86/power/hibernate_asm_64.S
···4444 pushfq4545 popq pt_regs_flags(%rax)46464747- /* save the address of restore_registers */4848- movq $restore_registers, %rax4949- movq %rax, restore_jump_address(%rip)5047 /* save cr3 */5148 movq %cr3, %rax5249 movq %rax, restore_cr3(%rip)···5457ENDPROC(swsusp_arch_suspend)55585659ENTRY(restore_image)5757- /* switch to temporary page tables */5858- movq $__PAGE_OFFSET, %rdx5959- movq temp_level4_pgt(%rip), %rax6060- subq %rdx, %rax6161- movq %rax, %cr36262- /* Flush TLB */6363- movq mmu_cr4_features(%rip), %rax6464- movq %rax, %rdx6565- andq $~(X86_CR4_PGE), %rdx6666- movq %rdx, %cr4; # turn off PGE6767- movq %cr3, %rcx; # flush TLB6868- movq %rcx, %cr3;6969- movq %rax, %cr4; # turn PGE back on7070-7160 /* prepare to jump to the image kernel */7272- movq restore_jump_address(%rip), %rax7373- movq restore_cr3(%rip), %rbx6161+ movq restore_jump_address(%rip), %r86262+ movq restore_cr3(%rip), %r96363+6464+ /* prepare to switch to temporary page tables */6565+ movq temp_level4_pgt(%rip), %rax6666+ movq mmu_cr4_features(%rip), %rbx74677568 /* prepare to copy image data to their original locations */7669 movq restore_pblist(%rip), %rdx7070+7171+ /* jump to relocated restore code */7772 movq relocated_restore_code(%rip), %rcx7873 jmpq *%rcx79748075 /* code below has been relocated to a safe page */8176ENTRY(core_restore_code)7777+ /* switch to temporary page tables */7878+ movq $__PAGE_OFFSET, %rcx7979+ subq %rcx, %rax8080+ movq %rax, %cr38181+ /* flush TLB */8282+ movq %rbx, %rcx8383+ andq $~(X86_CR4_PGE), %rcx8484+ movq %rcx, %cr4; # turn off PGE8585+ movq %cr3, %rcx; # flush TLB8686+ movq %rcx, %cr3;8787+ movq %rbx, %cr4; # turn PGE back on8288.Lloop:8389 testq %rdx, %rdx8490 jz .Ldone···9696 /* progress to the next pbe */9797 movq pbe_next(%rdx), %rdx9898 jmp .Lloop9999+99100.Ldone:100101 /* jump to the restore_registers address from the image header */101101- jmpq *%rax102102- /*103103- * NOTE: This assumes that the boot kernel's text mapping covers the104104- * image kernel's page containing restore_registers and the address of105105- * this page is the same as in the image kernel's text mapping (it106106- * should always be true, because the text mapping is linear, starting107107- * from 0, and is supposed to cover the entire kernel text for every108108- * kernel).109109- *110110- * code below belongs to the image kernel111111- */102102+ jmpq *%r8112103104104+ /* code below belongs to the image kernel */105105+ .align PAGE_SIZE113106ENTRY(restore_registers)114107 FRAME_BEGIN115108 /* go back to the original page tables */116116- movq %rbx, %cr3109109+ movq %r9, %cr3117110118111 /* Flush TLB, including "global" things (vmalloc) */119112 movq mmu_cr4_features(%rip), %rax
+1-3
arch/x86/xen/enlighten.c
···521521522522 preempt_disable();523523524524- pagefault_disable(); /* Avoid warnings due to being atomic. */525525- __get_user(dummy, (unsigned char __user __force *)v);526526- pagefault_enable();524524+ probe_kernel_read(&dummy, v, 1);527525528526 if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0))529527 BUG();
+2
block/ioprio.c
···150150 if (ret)151151 goto out;152152 ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM);153153+ task_lock(p);153154 if (p->io_context)154155 ret = p->io_context->ioprio;156156+ task_unlock(p);155157out:156158 return ret;157159}
···4646#include "acnamesp.h"4747#include "acdispat.h"4848#include "actables.h"4949+#include "acinterp.h"49505051#define _COMPONENT ACPI_NAMESPACE5152ACPI_MODULE_NAME("nsload")···79788079 ACPI_FUNCTION_TRACE(ns_load_table);81808181+ acpi_ex_enter_interpreter();8282+8283 /*8384 * Parse the table and load the namespace with all named8485 * objects found within. Control methods are NOT parsed···9289 */9390 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);9491 if (ACPI_FAILURE(status)) {9595- return_ACPI_STATUS(status);9292+ goto unlock_interp;9693 }97949895 /* If table already loaded into namespace, just return */···133130134131unlock:135132 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);133133+unlock_interp:134134+ (void)acpi_ex_exit_interpreter();136135137136 if (ACPI_FAILURE(status)) {138137 return_ACPI_STATUS(status);
+2-7
drivers/acpi/acpica/nsparse.c
···4747#include "acparser.h"4848#include "acdispat.h"4949#include "actables.h"5050-#include "acinterp.h"51505251#define _COMPONENT ACPI_NAMESPACE5352ACPI_MODULE_NAME("nsparse")···170171171172 ACPI_FUNCTION_TRACE(ns_parse_table);172173173173- acpi_ex_enter_interpreter();174174-175174 /*176175 * AML Parse, pass 1177176 *···185188 status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS1,186189 table_index, start_node);187190 if (ACPI_FAILURE(status)) {188188- goto error_exit;191191+ return_ACPI_STATUS(status);189192 }190193191194 /*···201204 status = acpi_ns_one_complete_parse(ACPI_IMODE_LOAD_PASS2,202205 table_index, start_node);203206 if (ACPI_FAILURE(status)) {204204- goto error_exit;207207+ return_ACPI_STATUS(status);205208 }206209207207-error_exit:208208- acpi_ex_exit_interpreter();209210 return_ACPI_STATUS(status);210211}
+47-14
drivers/acpi/pci_link.c
···470470{471471 struct acpi_pci_link *link;472472 int penalty = 0;473473+ int i;473474474475 list_for_each_entry(link, &acpi_link_list, list) {475476 /*···479478 */480479 if (link->irq.active && link->irq.active == irq)481480 penalty += PIRQ_PENALTY_PCI_USING;482482- else {483483- int i;484481485485- /*486486- * If a link is inactive, penalize the IRQs it487487- * might use, but not as severely.488488- */489489- for (i = 0; i < link->irq.possible_count; i++)490490- if (link->irq.possible[i] == irq)491491- penalty += PIRQ_PENALTY_PCI_POSSIBLE /492492- link->irq.possible_count;493493- }482482+ /*483483+ * penalize the IRQs PCI might use, but not as severely.484484+ */485485+ for (i = 0; i < link->irq.possible_count; i++)486486+ if (link->irq.possible[i] == irq)487487+ penalty += PIRQ_PENALTY_PCI_POSSIBLE /488488+ link->irq.possible_count;494489 }495490496491 return penalty;···495498static int acpi_irq_get_penalty(int irq)496499{497500 int penalty = 0;498498-499499- if (irq < ACPI_MAX_ISA_IRQS)500500- penalty += acpi_isa_irq_penalty[irq];501501502502 /*503503 * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict···510516 penalty += PIRQ_PENALTY_PCI_USING;511517 }512518519519+ if (irq < ACPI_MAX_ISA_IRQS)520520+ return penalty + acpi_isa_irq_penalty[irq];521521+513522 penalty += acpi_irq_pci_sharing_penalty(irq);514523 return penalty;524524+}525525+526526+int __init acpi_irq_penalty_init(void)527527+{528528+ struct acpi_pci_link *link;529529+ int i;530530+531531+ /*532532+ * Update penalties to facilitate IRQ balancing.533533+ */534534+ list_for_each_entry(link, &acpi_link_list, list) {535535+536536+ /*537537+ * reflect the possible and active irqs in the penalty table --538538+ * useful for breaking ties.539539+ */540540+ if (link->irq.possible_count) {541541+ int penalty =542542+ PIRQ_PENALTY_PCI_POSSIBLE /543543+ link->irq.possible_count;544544+545545+ for (i = 0; i < link->irq.possible_count; i++) {546546+ if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS)547547+ acpi_isa_irq_penalty[link->irq.548548+ possible[i]] +=549549+ penalty;550550+ }551551+552552+ } else if (link->irq.active &&553553+ (link->irq.active < ACPI_MAX_ISA_IRQS)) {554554+ acpi_isa_irq_penalty[link->irq.active] +=555555+ PIRQ_PENALTY_PCI_POSSIBLE;556556+ }557557+ }558558+559559+ return 0;515560}516561517562static int acpi_irq_balance = -1; /* 0: static, 1: balance */
···2828 if (!desc && gpio_is_valid(gpio))2929 return -EPROBE_DEFER;30303131+ err = gpiod_request(desc, label);3232+ if (err)3333+ return err;3434+3135 if (flags & GPIOF_OPEN_DRAIN)3236 set_bit(FLAG_OPEN_DRAIN, &desc->flags);3337···40364137 if (flags & GPIOF_ACTIVE_LOW)4238 set_bit(FLAG_ACTIVE_LOW, &desc->flags);4343-4444- err = gpiod_request(desc, label);4545- if (err)4646- return err;47394840 if (flags & GPIOF_DIR_IN)4941 err = gpiod_direction_input(desc);
+16-36
drivers/gpio/gpiolib.c
···13521352 spin_lock_irqsave(&gpio_lock, flags);13531353 }13541354done:13551355- if (status < 0) {13561356- /* Clear flags that might have been set by the caller before13571357- * requesting the GPIO.13581358- */13591359- clear_bit(FLAG_ACTIVE_LOW, &desc->flags);13601360- clear_bit(FLAG_OPEN_DRAIN, &desc->flags);13611361- clear_bit(FLAG_OPEN_SOURCE, &desc->flags);13621362- }13631355 spin_unlock_irqrestore(&gpio_lock, flags);13641356 return status;13651357}···25792587}25802588EXPORT_SYMBOL_GPL(gpiod_get_optional);2581258925822582-/**25832583- * gpiod_parse_flags - helper function to parse GPIO lookup flags25842584- * @desc: gpio to be setup25852585- * @lflags: gpio_lookup_flags - returned from of_find_gpio() or25862586- * of_get_gpio_hog()25872587- *25882588- * Set the GPIO descriptor flags based on the given GPIO lookup flags.25892589- */25902590-static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags)25912591-{25922592- if (lflags & GPIO_ACTIVE_LOW)25932593- set_bit(FLAG_ACTIVE_LOW, &desc->flags);25942594- if (lflags & GPIO_OPEN_DRAIN)25952595- set_bit(FLAG_OPEN_DRAIN, &desc->flags);25962596- if (lflags & GPIO_OPEN_SOURCE)25972597- set_bit(FLAG_OPEN_SOURCE, &desc->flags);25982598-}2599259026002591/**26012592 * gpiod_configure_flags - helper function to configure a given GPIO26022593 * @desc: gpio whose value will be assigned26032594 * @con_id: function within the GPIO consumer25952595+ * @lflags: gpio_lookup_flags - returned from of_find_gpio() or25962596+ * of_get_gpio_hog()26042597 * @dflags: gpiod_flags - optional GPIO initialization flags26052598 *26062599 * Return 0 on success, -ENOENT if no GPIO has been assigned to the···25932616 * occurred while trying to acquire the GPIO.25942617 */25952618static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,25962596- enum gpiod_flags dflags)26192619+ unsigned long lflags, enum gpiod_flags dflags)25972620{25982621 int status;26222622+26232623+ if (lflags & GPIO_ACTIVE_LOW)26242624+ set_bit(FLAG_ACTIVE_LOW, &desc->flags);26252625+ if (lflags & GPIO_OPEN_DRAIN)26262626+ set_bit(FLAG_OPEN_DRAIN, &desc->flags);26272627+ if (lflags & GPIO_OPEN_SOURCE)26282628+ set_bit(FLAG_OPEN_SOURCE, &desc->flags);2599262926002630 /* No particular flag request, return here... */26012631 if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {···26702686 return desc;26712687 }2672268826732673- gpiod_parse_flags(desc, lookupflags);26742674-26752689 status = gpiod_request(desc, con_id);26762690 if (status < 0)26772691 return ERR_PTR(status);2678269226792679- status = gpiod_configure_flags(desc, con_id, flags);26932693+ status = gpiod_configure_flags(desc, con_id, lookupflags, flags);26802694 if (status < 0) {26812695 dev_dbg(dev, "setup of GPIO %s failed\n", con_id);26822696 gpiod_put(desc);···27302748 if (IS_ERR(desc))27312749 return desc;2732275027512751+ ret = gpiod_request(desc, NULL);27522752+ if (ret)27532753+ return ERR_PTR(ret);27542754+27332755 if (active_low)27342756 set_bit(FLAG_ACTIVE_LOW, &desc->flags);27352757···27432757 else27442758 set_bit(FLAG_OPEN_SOURCE, &desc->flags);27452759 }27462746-27472747- ret = gpiod_request(desc, NULL);27482748- if (ret)27492749- return ERR_PTR(ret);2750276027512761 return desc;27522762}···27962814 chip = gpiod_to_chip(desc);27972815 hwnum = gpio_chip_hwgpio(desc);2798281627992799- gpiod_parse_flags(desc, lflags);28002800-28012817 local_desc = gpiochip_request_own_desc(chip, hwnum, name);28022818 if (IS_ERR(local_desc)) {28032819 status = PTR_ERR(local_desc);···28042824 return status;28052825 }2806282628072807- status = gpiod_configure_flags(desc, name, dflags);28272827+ status = gpiod_configure_flags(desc, name, lflags, dflags);28082828 if (status < 0) {28092829 pr_err("setup of hog GPIO %s (chip %s, offset %d) failed, %d\n",28102830 name, chip->label, hwnum, status);
···15681568 break;15691569 }1570157015711571+ /*15721572+ * Order is important here to make sure any unity map requirements are15731573+ * fulfilled. The unity mappings are created and written to the device15741574+ * table during the amd_iommu_init_api() call.15751575+ *15761576+ * After that we call init_device_table_dma() to make sure any15771577+ * uninitialized DTE will block DMA, and in the end we flush the caches15781578+ * of all IOMMUs to make sure the changes to the device table are15791579+ * active.15801580+ */15811581+ ret = amd_iommu_init_api();15821582+15711583 init_device_table_dma();1572158415731585 for_each_iommu(iommu)15741586 iommu_flush_all_caches(iommu);15751575-15761576- ret = amd_iommu_init_api();1577158715781588 if (!ret)15791589 print_iommu_info();
+2-2
drivers/iommu/intel-iommu.c
···46024602 for (i = 0; i < g_num_of_iommus; i++) {46034603 struct intel_iommu *iommu = g_iommus[i];46044604 struct dmar_domain *domain;46054605- u16 did;46054605+ int did;4606460646074607 if (!iommu)46084608 continue;4609460946104610 for (did = 0; did < cap_ndoms(iommu->cap); did++) {46114611- domain = get_iommu_domain(iommu, did);46114611+ domain = get_iommu_domain(iommu, (u16)did);4612461246134613 if (!domain)46144614 continue;
···15841584 }1585158515861586 /* check for initial state */15871587+ new_slave->link = BOND_LINK_NOCHANGE;15871588 if (bond->params.miimon) {15881589 if (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS) {15891590 if (bond->params.updelay) {
···154154 writel(val, hw->hw_addr + reg);155155}156156157157-static bool e1000e_vlan_used(struct e1000_adapter *adapter)158158-{159159- u16 vid;160160-161161- for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)162162- return true;163163-164164- return false;165165-}166166-167157/**168158 * e1000_regdump - register printout routine169159 * @hw: pointer to the HW structure···3443345334443454 ew32(RCTL, rctl);3445345534463446- if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||34473447- e1000e_vlan_used(adapter))34563456+ if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)34483457 e1000e_vlan_strip_enable(adapter);34493458 else34503459 e1000e_vlan_strip_disable(adapter);···69146925 /* Jumbo frame workaround on 82579 and newer requires CRC be stripped */69156926 if ((hw->mac.type >= e1000_pch2lan) && (netdev->mtu > ETH_DATA_LEN))69166927 features &= ~NETIF_F_RXFCS;69286928+69296929+ /* Since there is no support for separate Rx/Tx vlan accel69306930+ * enable/disable make sure Tx flag is always in same state as Rx.69316931+ */69326932+ if (features & NETIF_F_HW_VLAN_CTAG_RX)69336933+ features |= NETIF_F_HW_VLAN_CTAG_TX;69346934+ else69356935+ features &= ~NETIF_F_HW_VLAN_CTAG_TX;6917693669186937 return features;69196938}
+2-2
drivers/net/ethernet/intel/ixgbevf/mbx.c
···8585static s32 ixgbevf_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size)8686{8787 struct ixgbe_mbx_info *mbx = &hw->mbx;8888- s32 ret_val = -IXGBE_ERR_MBX;8888+ s32 ret_val = IXGBE_ERR_MBX;89899090 if (!mbx->ops.read)9191 goto out;···111111static s32 ixgbevf_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size)112112{113113 struct ixgbe_mbx_info *mbx = &hw->mbx;114114- s32 ret_val = -IXGBE_ERR_MBX;114114+ s32 ret_val = IXGBE_ERR_MBX;115115116116 /* exit if either we can't write or there isn't a defined timeout */117117 if (!mbx->ops.write || !mbx->timeout)
···14221422 mlx5_pci_err_detected(dev->pdev, 0);14231423}1424142414251425-/* wait for the device to show vital signs. For now we check14261426- * that we can read the device ID and that the health buffer14271427- * shows a non zero value which is different than 0xffffffff14251425+/* wait for the device to show vital signs by waiting14261426+ * for the health counter to start counting.14281427 */14291429-static void wait_vital(struct pci_dev *pdev)14281428+static int wait_vital(struct pci_dev *pdev)14301429{14311430 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);14321431 struct mlx5_core_health *health = &dev->priv.health;14331432 const int niter = 100;14331433+ u32 last_count = 0;14341434 u32 count;14351435- u16 did;14361435 int i;14371437-14381438- /* Wait for firmware to be ready after reset */14391439- msleep(1000);14401440- for (i = 0; i < niter; i++) {14411441- if (pci_read_config_word(pdev, 2, &did)) {14421442- dev_warn(&pdev->dev, "failed reading config word\n");14431443- break;14441444- }14451445- if (did == pdev->device) {14461446- dev_info(&pdev->dev, "device ID correctly read after %d iterations\n", i);14471447- break;14481448- }14491449- msleep(50);14501450- }14511451- if (i == niter)14521452- dev_warn(&pdev->dev, "%s-%d: could not read device ID\n", __func__, __LINE__);1453143614541437 for (i = 0; i < niter; i++) {14551438 count = ioread32be(health->health_counter);14561439 if (count && count != 0xffffffff) {14571457- dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i);14581458- break;14401440+ if (last_count && last_count != count) {14411441+ dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i);14421442+ return 0;14431443+ }14441444+ last_count = count;14591445 }14601446 msleep(50);14611447 }1462144814631463- if (i == niter)14641464- dev_warn(&pdev->dev, "%s-%d: could not read device ID\n", __func__, __LINE__);14491449+ return -ETIMEDOUT;14651450}1466145114671452static void mlx5_pci_resume(struct pci_dev *pdev)···14581473 dev_info(&pdev->dev, "%s was called\n", __func__);1459147414601475 pci_save_state(pdev);14611461- wait_vital(pdev);14761476+ err = wait_vital(pdev);14771477+ if (err) {14781478+ dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__);14791479+ return;14801480+ }1462148114631482 err = mlx5_load_one(dev, priv);14641483 if (err)
···772772 tx_ring->tx_stats.tx_bytes += skb->len;773773 tx_ring->tx_stats.xmit_called++;774774775775+ /* Ensure writes are complete before HW fetches Tx descriptors */776776+ wmb();775777 qlcnic_update_cmd_producer(tx_ring);776778777779 return NETDEV_TX_OK;
+1-1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
···28042804 priv->tx_path_in_lpi_mode = true;28052805 if (status & CORE_IRQ_TX_PATH_EXIT_LPI_MODE)28062806 priv->tx_path_in_lpi_mode = false;28072807- if (status & CORE_IRQ_MTL_RX_OVERFLOW)28072807+ if (status & CORE_IRQ_MTL_RX_OVERFLOW && priv->hw->dma->set_rx_tail_ptr)28082808 priv->hw->dma->set_rx_tail_ptr(priv->ioaddr,28092809 priv->rx_tail_addr,28102810 STMMAC_CHAN0);
+7-2
drivers/net/geneve.c
···1072107210731073static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict)10741074{10751075+ struct geneve_dev *geneve = netdev_priv(dev);10751076 /* The max_mtu calculation does not take account of GENEVE10761077 * options, to avoid excluding potentially valid10771078 * configurations.10781079 */10791079- int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - sizeof(struct iphdr)10801080- - dev->hard_header_len;10801080+ int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - dev->hard_header_len;10811081+10821082+ if (geneve->remote.sa.sa_family == AF_INET6)10831083+ max_mtu -= sizeof(struct ipv6hdr);10841084+ else10851085+ max_mtu -= sizeof(struct iphdr);1081108610821087 if (new_mtu < 68)10831088 return -EINVAL;
+1
drivers/net/macsec.c
···26402640 u64_stats_update_begin(&secy_stats->syncp);26412641 secy_stats->stats.OutPktsUntagged++;26422642 u64_stats_update_end(&secy_stats->syncp);26432643+ skb->dev = macsec->real_dev;26432644 len = skb->len;26442645 ret = dev_queue_xmit(skb);26452646 count_tx(dev, ret, len);
+9-4
drivers/net/phy/dp83867.c
···57575858/* PHY CTRL bits */5959#define DP83867_PHYCR_FIFO_DEPTH_SHIFT 146060+#define DP83867_PHYCR_FIFO_DEPTH_MASK (3 << 14)60616162/* RGMIIDCTL bits */6263#define DP83867_RGMII_TX_CLK_DELAY_SHIFT 4···134133static int dp83867_config_init(struct phy_device *phydev)135134{136135 struct dp83867_private *dp83867;137137- int ret;138138- u16 val, delay;136136+ int ret, val;137137+ u16 delay;139138140139 if (!phydev->priv) {141140 dp83867 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83867),···152151 }153152154153 if (phy_interface_is_rgmii(phydev)) {155155- ret = phy_write(phydev, MII_DP83867_PHYCTRL,156156- (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT));154154+ val = phy_read(phydev, MII_DP83867_PHYCTRL);155155+ if (val < 0)156156+ return val;157157+ val &= ~DP83867_PHYCR_FIFO_DEPTH_MASK;158158+ val |= (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT);159159+ ret = phy_write(phydev, MII_DP83867_PHYCTRL, val);157160 if (ret)158161 return ret;159162 }
+7
drivers/net/usb/cdc_ncm.c
···854854 if (cdc_ncm_init(dev))855855 goto error2;856856857857+ /* Some firmwares need a pause here or they will silently fail858858+ * to set up the interface properly. This value was decided859859+ * empirically on a Sierra Wireless MC7455 running 02.08.02.00860860+ * firmware.861861+ */862862+ usleep_range(10000, 20000);863863+857864 /* configure data interface */858865 temp = usb_set_interface(dev->udev, iface_no, data_altsetting);859866 if (temp) {
···395395 dev->hard_mtu = net->mtu + net->hard_header_len;396396 if (dev->rx_urb_size == old_hard_mtu) {397397 dev->rx_urb_size = dev->hard_mtu;398398- if (dev->rx_urb_size > old_rx_urb_size)398398+ if (dev->rx_urb_size > old_rx_urb_size) {399399+ usbnet_pause_rx(dev);399400 usbnet_unlink_rx_urbs(dev);401401+ usbnet_resume_rx(dev);402402+ }400403 }401404402405 /* max qlen depend on hard_mtu and rx_urb_size */···15111508 } else if (netif_running (dev->net) &&15121509 netif_device_present (dev->net) &&15131510 netif_carrier_ok(dev->net) &&15141514- !timer_pending (&dev->delay) &&15151515- !test_bit (EVENT_RX_HALT, &dev->flags)) {15111511+ !timer_pending(&dev->delay) &&15121512+ !test_bit(EVENT_RX_PAUSED, &dev->flags) &&15131513+ !test_bit(EVENT_RX_HALT, &dev->flags)) {15161514 int temp = dev->rxq.qlen;1517151515181516 if (temp < RX_QLEN(dev)) {
+7-1
drivers/platform/chrome/cros_ec_dev.c
···151151 goto exit;152152 }153153154154+ if (u_cmd.outsize != s_cmd->outsize ||155155+ u_cmd.insize != s_cmd->insize) {156156+ ret = -EINVAL;157157+ goto exit;158158+ }159159+154160 s_cmd->command += ec->cmd_offset;155161 ret = cros_ec_cmd_xfer(ec->ec_dev, s_cmd);156162 /* Only copy data to userland if data was received. */157163 if (ret < 0)158164 goto exit;159165160160- if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + u_cmd.insize))166166+ if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + s_cmd->insize))161167 ret = -EFAULT;162168exit:163169 kfree(s_cmd);
···25482548 if (!vha->flags.online)25492549 return;2550255025512551- if (rsp->msix->cpuid != smp_processor_id()) {25512551+ if (rsp->msix && rsp->msix->cpuid != smp_processor_id()) {25522552 /* if kernel does not notify qla of IRQ's CPU change,25532553 * then set it here.25542554 */
+6-4
drivers/scsi/scsi_devinfo.c
···429429 * here, and we don't know what device it is430430 * trying to work with, leave it as-is.431431 */432432- vmax = 8; /* max length of vendor */432432+ vmax = sizeof(devinfo->vendor);433433 vskip = vendor;434434 while (vmax > 0 && *vskip == ' ') {435435 vmax--;···439439 while (vmax > 0 && vskip[vmax - 1] == ' ')440440 --vmax;441441442442- mmax = 16; /* max length of model */442442+ mmax = sizeof(devinfo->model);443443 mskip = model;444444 while (mmax > 0 && *mskip == ' ') {445445 mmax--;···455455 * Behave like the older version of get_device_flags.456456 */457457 if (memcmp(devinfo->vendor, vskip, vmax) ||458458- devinfo->vendor[vmax])458458+ (vmax < sizeof(devinfo->vendor) &&459459+ devinfo->vendor[vmax]))459460 continue;460461 if (memcmp(devinfo->model, mskip, mmax) ||461461- devinfo->model[mmax])462462+ (mmax < sizeof(devinfo->model) &&463463+ devinfo->model[mmax]))462464 continue;463465 return devinfo;464466 } else {
+3-32
drivers/xen/xen-acpi-processor.c
···423423424424 return 0;425425}426426-static int __init check_prereq(void)427427-{428428- struct cpuinfo_x86 *c = &cpu_data(0);429426430430- if (!xen_initial_domain())431431- return -ENODEV;432432-433433- if (!acpi_gbl_FADT.smi_command)434434- return -ENODEV;435435-436436- if (c->x86_vendor == X86_VENDOR_INTEL) {437437- if (!cpu_has(c, X86_FEATURE_EST))438438- return -ENODEV;439439-440440- return 0;441441- }442442- if (c->x86_vendor == X86_VENDOR_AMD) {443443- /* Copied from powernow-k8.h, can't include ../cpufreq/powernow444444- * as we get compile warnings for the static functions.445445- */446446-#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007447447-#define USE_HW_PSTATE 0x00000080448448- u32 eax, ebx, ecx, edx;449449- cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);450450- if ((edx & USE_HW_PSTATE) != USE_HW_PSTATE)451451- return -ENODEV;452452- return 0;453453- }454454- return -ENODEV;455455-}456427/* acpi_perf_data is a pointer to percpu data. */457428static struct acpi_processor_performance __percpu *acpi_perf_data;458429···480509static int __init xen_acpi_processor_init(void)481510{482511 unsigned int i;483483- int rc = check_prereq();512512+ int rc;484513485485- if (rc)486486- return rc;514514+ if (!xen_initial_domain())515515+ return -ENODEV;487516488517 nr_acpi_bits = get_max_acpi_id() + 1;489518 acpi_ids_done = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL);
···232232void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)233233{234234 void *ret;235235- struct xsd_sockmsg req_msg = *msg;235235+ enum xsd_sockmsg_type type = msg->type;236236 int err;237237238238- if (req_msg.type == XS_TRANSACTION_START)238238+ if (type == XS_TRANSACTION_START)239239 transaction_start();240240241241 mutex_lock(&xs_state.request_mutex);···249249250250 mutex_unlock(&xs_state.request_mutex);251251252252- if (IS_ERR(ret))253253- return ret;254254-255252 if ((msg->type == XS_TRANSACTION_END) ||256256- ((req_msg.type == XS_TRANSACTION_START) &&257257- (msg->type == XS_ERROR)))253253+ ((type == XS_TRANSACTION_START) && (msg->type == XS_ERROR)))258254 transaction_end();259255260256 return ret;
-2
fs/configfs/file.c
···357357358358 len = simple_write_to_buffer(buffer->bin_buffer,359359 buffer->bin_buffer_size, ppos, buf, count);360360- if (len > 0)361361- *ppos += len;362360out:363361 mutex_unlock(&buffer->mutex);364362 return len;
+4-4
fs/ecryptfs/crypto.c
···4545 * ecryptfs_to_hex4646 * @dst: Buffer to take hex character representation of contents of4747 * src; must be at least of size (src_size * 2)4848- * @src: Buffer to be converted to a hex string respresentation4848+ * @src: Buffer to be converted to a hex string representation4949 * @src_size: number of bytes to convert5050 */5151void ecryptfs_to_hex(char *dst, char *src, size_t src_size)···6060 * ecryptfs_from_hex6161 * @dst: Buffer to take the bytes from src hex; must be at least of6262 * size (src_size / 2)6363- * @src: Buffer to be converted from a hex string respresentation to raw value6363+ * @src: Buffer to be converted from a hex string representation to raw value6464 * @dst_size: size of dst buffer, or number of hex characters pairs to convert6565 */6666void ecryptfs_from_hex(char *dst, char *src, int dst_size)···953953};954954955955/* Add support for additional ciphers by adding elements here. The956956- * cipher_code is whatever OpenPGP applicatoins use to identify the956956+ * cipher_code is whatever OpenPGP applications use to identify the957957 * ciphers. List in order of probability. */958958static struct ecryptfs_cipher_code_str_map_elem959959ecryptfs_cipher_code_str_map[] = {···14101410 *14111411 * Common entry point for reading file metadata. From here, we could14121412 * retrieve the header information from the header region of the file,14131413- * the xattr region of the file, or some other repostory that is14131413+ * the xattr region of the file, or some other repository that is14141414 * stored separately from the file itself. The current implementation14151415 * supports retrieving the metadata information from the file contents14161416 * and from the xattr region.
+16-3
fs/ecryptfs/file.c
···169169 return rc;170170}171171172172+static int ecryptfs_mmap(struct file *file, struct vm_area_struct *vma)173173+{174174+ struct file *lower_file = ecryptfs_file_to_lower(file);175175+ /*176176+ * Don't allow mmap on top of file systems that don't support it177177+ * natively. If FILESYSTEM_MAX_STACK_DEPTH > 2 or ecryptfs178178+ * allows recursive mounting, this will need to be extended.179179+ */180180+ if (!lower_file->f_op->mmap)181181+ return -ENODEV;182182+ return generic_file_mmap(file, vma);183183+}184184+172185/**173186 * ecryptfs_open174174- * @inode: inode speciying file to open187187+ * @inode: inode specifying file to open175188 * @file: Structure to return filled in176189 *177190 * Opens the file specified by inode.···253240254241/**255242 * ecryptfs_dir_open256256- * @inode: inode speciying file to open243243+ * @inode: inode specifying file to open257244 * @file: Structure to return filled in258245 *259246 * Opens the file specified by inode.···416403#ifdef CONFIG_COMPAT417404 .compat_ioctl = ecryptfs_compat_ioctl,418405#endif419419- .mmap = generic_file_mmap,406406+ .mmap = ecryptfs_mmap,420407 .open = ecryptfs_open,421408 .flush = ecryptfs_flush,422409 .release = ecryptfs_release,
···78787979/* ACPI PCI Interrupt Link (pci_link.c) */80808181+int acpi_irq_penalty_init(void);8182int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,8283 int *polarity, char **name);8384int acpi_pci_link_free_irq(acpi_handle handle);
···629629 void *uout;630630 int uout_size;631631 mlx5_cmd_cbk_t callback;632632+ struct delayed_work cb_timeout_work;632633 void *context;633634 int idx;634635 struct completion done;
+6-6
include/linux/random.h
···9595#ifdef CONFIG_ARCH_RANDOM9696# include <asm/archrandom.h>9797#else9898-static inline int arch_get_random_long(unsigned long *v)9898+static inline bool arch_get_random_long(unsigned long *v)9999{100100 return 0;101101}102102-static inline int arch_get_random_int(unsigned int *v)102102+static inline bool arch_get_random_int(unsigned int *v)103103{104104 return 0;105105}106106-static inline int arch_has_random(void)106106+static inline bool arch_has_random(void)107107{108108 return 0;109109}110110-static inline int arch_get_random_seed_long(unsigned long *v)110110+static inline bool arch_get_random_seed_long(unsigned long *v)111111{112112 return 0;113113}114114-static inline int arch_get_random_seed_int(unsigned int *v)114114+static inline bool arch_get_random_seed_int(unsigned int *v)115115{116116 return 0;117117}118118-static inline int arch_has_random_seed(void)118118+static inline bool arch_has_random_seed(void)119119{120120 return 0;121121}
+20
include/linux/skbuff.h
···10621062}1063106310641064void __skb_get_hash(struct sk_buff *skb);10651065+u32 __skb_get_hash_symmetric(struct sk_buff *skb);10651066u32 skb_get_poff(const struct sk_buff *skb);10661067u32 __skb_get_poff(const struct sk_buff *skb, void *data,10671068 const struct flow_keys *keys, int hlen);···28682867 */28692868 if (skb->ip_summed == CHECKSUM_COMPLETE)28702869 skb->csum = csum_partial(start, len, skb->csum);28702870+}28712871+28722872+/**28732873+ * skb_push_rcsum - push skb and update receive checksum28742874+ * @skb: buffer to update28752875+ * @len: length of data pulled28762876+ *28772877+ * This function performs an skb_push on the packet and updates28782878+ * the CHECKSUM_COMPLETE checksum. It should be used on28792879+ * receive path processing instead of skb_push unless you know28802880+ * that the checksum difference is zero (e.g., a valid IP header)28812881+ * or you are setting ip_summed to CHECKSUM_NONE.28822882+ */28832883+static inline unsigned char *skb_push_rcsum(struct sk_buff *skb,28842884+ unsigned int len)28852885+{28862886+ skb_push(skb, len);28872887+ skb_postpush_rcsum(skb, skb->data, len);28882888+ return skb->data;28712889}2872289028732891/**
+6-1
include/net/bonding.h
···34343535#define BOND_DEFAULT_MIIMON 10036363737+#ifndef __long_aligned3838+#define __long_aligned __attribute__((aligned((sizeof(long)))))3939+#endif3740/*3841 * Less bad way to call ioctl from within the kernel; this needs to be3942 * done some other way to get the call out of interrupt context.···141138 struct reciprocal_value reciprocal_packets_per_slave;142139 u16 ad_actor_sys_prio;143140 u16 ad_user_port_key;144144- u8 ad_actor_system[ETH_ALEN];141141+142142+ /* 2 bytes of padding : see ether_addr_equal_64bits() */143143+ u8 ad_actor_system[ETH_ALEN + 2];145144};146145147146struct bond_parm_tbl {
···16781678 return event->state == PERF_EVENT_STATE_DEAD;16791679}1680168016811681-static inline int pmu_filter_match(struct perf_event *event)16811681+static inline int __pmu_filter_match(struct perf_event *event)16821682{16831683 struct pmu *pmu = event->pmu;16841684 return pmu->filter_match ? pmu->filter_match(event) : 1;16851685+}16861686+16871687+/*16881688+ * Check whether we should attempt to schedule an event group based on16891689+ * PMU-specific filtering. An event group can consist of HW and SW events,16901690+ * potentially with a SW leader, so we must check all the filters, to16911691+ * determine whether a group is schedulable:16921692+ */16931693+static inline int pmu_filter_match(struct perf_event *event)16941694+{16951695+ struct perf_event *child;16961696+16971697+ if (!__pmu_filter_match(event))16981698+ return 0;16991699+17001700+ list_for_each_entry(child, &event->sibling_list, group_entry) {17011701+ if (!__pmu_filter_match(child))17021702+ return 0;17031703+ }17041704+17051705+ return 1;16851706}1686170716871708static inline int
+22-24
kernel/sched/fair.c
···735735 }736736}737737738738-static inline unsigned long cfs_rq_runnable_load_avg(struct cfs_rq *cfs_rq);739739-static inline unsigned long cfs_rq_load_avg(struct cfs_rq *cfs_rq);740738#else741739void init_entity_runnable_average(struct sched_entity *se)742740{···2497249924982500#ifdef CONFIG_FAIR_GROUP_SCHED24992501# ifdef CONFIG_SMP25002500-static inline long calc_tg_weight(struct task_group *tg, struct cfs_rq *cfs_rq)25012501-{25022502- long tg_weight;25032503-25042504- /*25052505- * Use this CPU's real-time load instead of the last load contribution25062506- * as the updating of the contribution is delayed, and we will use the25072507- * the real-time load to calc the share. See update_tg_load_avg().25082508- */25092509- tg_weight = atomic_long_read(&tg->load_avg);25102510- tg_weight -= cfs_rq->tg_load_avg_contrib;25112511- tg_weight += cfs_rq->load.weight;25122512-25132513- return tg_weight;25142514-}25152515-25162502static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg)25172503{25182504 long tg_weight, load, shares;2519250525202520- tg_weight = calc_tg_weight(tg, cfs_rq);25212521- load = cfs_rq->load.weight;25062506+ /*25072507+ * This really should be: cfs_rq->avg.load_avg, but instead we use25082508+ * cfs_rq->load.weight, which is its upper bound. This helps ramp up25092509+ * the shares for small weight interactive tasks.25102510+ */25112511+ load = scale_load_down(cfs_rq->load.weight);25122512+25132513+ tg_weight = atomic_long_read(&tg->load_avg);25142514+25152515+ /* Ensure tg_weight >= load */25162516+ tg_weight -= cfs_rq->tg_load_avg_contrib;25172517+ tg_weight += load;2522251825232519 shares = (tg->shares * load);25242520 if (tg_weight)···25312539 return tg->shares;25322540}25332541# endif /* CONFIG_SMP */25422542+25342543static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,25352544 unsigned long weight)25362545{···49394946 return wl;4940494749414948 for_each_sched_entity(se) {49424942- long w, W;49494949+ struct cfs_rq *cfs_rq = se->my_q;49504950+ long W, w = cfs_rq_load_avg(cfs_rq);4943495149444944- tg = se->my_q->tg;49524952+ tg = cfs_rq->tg;4945495349464954 /*49474955 * W = @wg + \Sum rw_j49484956 */49494949- W = wg + calc_tg_weight(tg, se->my_q);49574957+ W = wg + atomic_long_read(&tg->load_avg);49584958+49594959+ /* Ensure \Sum rw_j >= rw_i */49604960+ W -= cfs_rq->tg_load_avg_contrib;49614961+ W += w;4950496249514963 /*49524964 * w = rw_i + @wl49534965 */49544954- w = cfs_rq_load_avg(se->my_q) + wl;49664966+ w += wl;4955496749564968 /*49574969 * wl = S * s'_i; see (2)
-5
lib/Makefile
···1515KCOV_INSTRUMENT_list_debug.o := n1616KCOV_INSTRUMENT_debugobjects.o := n1717KCOV_INSTRUMENT_dynamic_debug.o := n1818-# Kernel does not boot if we instrument this file as it uses custom calling1919-# convention (see CONFIG_ARCH_HWEIGHT_CFLAGS).2020-KCOV_INSTRUMENT_hweight.o := n21182219lib-y := ctype.o string.o vsprintf.o cmdline.o \2320 rbtree.o radix-tree.o dump_stack.o timerqueue.o\···7174obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o7275obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o73767474-GCOV_PROFILE_hweight.o := n7575-CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))7677obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o77787879obj-$(CONFIG_BTREE) += btree.o
+4
lib/hweight.c
···99 * The Hamming Weight of a number is the total number of bits set in it.1010 */11111212+#ifndef __HAVE_ARCH_SW_HWEIGHT1213unsigned int __sw_hweight32(unsigned int w)1314{1415#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER···2625#endif2726}2827EXPORT_SYMBOL(__sw_hweight32);2828+#endif29293030unsigned int __sw_hweight16(unsigned int w)3131{···4543}4644EXPORT_SYMBOL(__sw_hweight8);47454646+#ifndef __HAVE_ARCH_SW_HWEIGHT4847unsigned long __sw_hweight64(__u64 w)4948{5049#if BITS_PER_LONG == 32···6865#endif6966}7067EXPORT_SYMBOL(__sw_hweight64);6868+#endif
+1-1
net/bridge/br_netfilter_hooks.c
···700700br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,701701 int (*output)(struct net *, struct sock *, struct sk_buff *))702702{703703- unsigned int mtu = ip_skb_dst_mtu(skb);703703+ unsigned int mtu = ip_skb_dst_mtu(sk, skb);704704 struct iphdr *iph = ip_hdr(skb);705705706706 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
···30163016EXPORT_SYMBOL_GPL(skb_append_pagefrags);3017301730183018/**30193019- * skb_push_rcsum - push skb and update receive checksum30203020- * @skb: buffer to update30213021- * @len: length of data pulled30223022- *30233023- * This function performs an skb_push on the packet and updates30243024- * the CHECKSUM_COMPLETE checksum. It should be used on30253025- * receive path processing instead of skb_push unless you know30263026- * that the checksum difference is zero (e.g., a valid IP header)30273027- * or you are setting ip_summed to CHECKSUM_NONE.30283028- */30293029-static unsigned char *skb_push_rcsum(struct sk_buff *skb, unsigned len)30303030-{30313031- skb_push(skb, len);30323032- skb_postpush_rcsum(skb, skb->data, len);30333033- return skb->data;30343034-}30353035-30363036-/**30373019 * skb_pull_rcsum - pull skb and update receive checksum30383020 * @skb: buffer to update30393021 * @len: length of data pulled
···13411341 struct sk_buff *skb,13421342 unsigned int num)13431343{13441344- return reciprocal_scale(skb_get_hash(skb), num);13441344+ return reciprocal_scale(__skb_get_hash_symmetric(skb), num);13451345}1346134613471347static unsigned int fanout_demux_lb(struct packet_fanout *f,
+3-2
net/rds/tcp.c
···616616617617 ret = rds_tcp_recv_init();618618 if (ret)619619- goto out_slab;619619+ goto out_pernet;620620621621 ret = rds_trans_register(&rds_tcp_transport);622622 if (ret)···628628629629out_recv:630630 rds_tcp_recv_exit();631631-out_slab:631631+out_pernet:632632 unregister_pernet_subsys(&rds_tcp_net_ops);633633+out_slab:633634 kmem_cache_destroy(rds_tcp_conn_slab);634635out:635636 return ret;
+1-1
net/sched/act_mirred.c
···181181182182 if (!(at & AT_EGRESS)) {183183 if (m->tcfm_ok_push)184184- skb_push(skb2, skb->mac_len);184184+ skb_push_rcsum(skb2, skb->mac_len);185185 }186186187187 /* mirror is always swallowed */
···226226 if (!tty->disc_data)227227 return -ENODEV;228228229229+ tty->receive_room = 16;229230 if (tty->ops->write(tty, v253_init, len) != len) {230231 ret = -EIO;231232 goto err;
+20
sound/soc/codecs/hdac_hdmi.c
···14741474 * exit, we call pm_runtime_suspend() so that will do for us14751475 */14761476 hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdac.dev));14771477+ if (!hlink) {14781478+ dev_err(&edev->hdac.dev, "hdac link not found\n");14791479+ return -EIO;14801480+ }14811481+14771482 snd_hdac_ext_bus_link_get(edev->ebus, hlink);1478148314791484 ret = create_fill_widget_route_map(dapm);···1639163416401635 /* hold the ref while we probe */16411636 hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdac.dev));16371637+ if (!hlink) {16381638+ dev_err(&edev->hdac.dev, "hdac link not found\n");16391639+ return -EIO;16401640+ }16411641+16421642 snd_hdac_ext_bus_link_get(edev->ebus, hlink);1643164316441644 hdmi_priv = devm_kzalloc(&codec->dev, sizeof(*hdmi_priv), GFP_KERNEL);···17541744 }1755174517561746 hlink = snd_hdac_ext_bus_get_link(ebus, dev_name(dev));17471747+ if (!hlink) {17481748+ dev_err(dev, "hdac link not found\n");17491749+ return -EIO;17501750+ }17511751+17571752 snd_hdac_ext_bus_link_put(ebus, hlink);1758175317591754 return 0;···17801765 return 0;1781176617821767 hlink = snd_hdac_ext_bus_get_link(ebus, dev_name(dev));17681768+ if (!hlink) {17691769+ dev_err(dev, "hdac link not found\n");17701770+ return -EIO;17711771+ }17721772+17831773 snd_hdac_ext_bus_link_get(ebus, hlink);1784177417851775 err = snd_hdac_display_power(bus, true);
···182182 case SNDRV_PCM_TRIGGER_START:183183 if (stream->compr_ops->stream_start)184184 return stream->compr_ops->stream_start(sst->dev, stream->id);185185+ break;185186 case SNDRV_PCM_TRIGGER_STOP:186187 if (stream->compr_ops->stream_drop)187188 return stream->compr_ops->stream_drop(sst->dev, stream->id);189189+ break;188190 case SND_COMPR_TRIGGER_DRAIN:189191 if (stream->compr_ops->stream_drain)190192 return stream->compr_ops->stream_drain(sst->dev, stream->id);193193+ break;191194 case SND_COMPR_TRIGGER_PARTIAL_DRAIN:192195 if (stream->compr_ops->stream_partial_drain)193196 return stream->compr_ops->stream_partial_drain(sst->dev, stream->id);197197+ break;194198 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:195199 if (stream->compr_ops->stream_pause)196200 return stream->compr_ops->stream_pause(sst->dev, stream->id);201201+ break;197202 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:198203 if (stream->compr_ops->stream_pause_release)199204 return stream->compr_ops->stream_pause_release(sst->dev, stream->id);200200- default:201201- return -EINVAL;205205+ break;202206 }207207+ return -EINVAL;203208}204209205210static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
+1
sound/soc/intel/skylake/bxt-sst.c
···291291 sst_dsp_mailbox_init(sst, (BXT_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ),292292 SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);293293294294+ INIT_LIST_HEAD(&sst->module_list);294295 ret = skl_ipc_init(dev, skl);295296 if (ret)296297 return ret;