Re: [GIT PULL] core kernel fixes
The pull request you sent on Sat, 18 May 2019 10:51:11 +0200: > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git > core-urgent-for-linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/1335d9a1fb2abbe5022de3c517989cc7c7161dee Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 8ea58f1e8b11cca3087b294779bf5959bf89cc10 objtool: Allow AR to be overridden with HOSTAR This fixes a particularly thorny munmap() bug with MPX, plus fixes a host build environment assumption in objtool. Thanks, Ingo --> Dave Hansen (1): x86/mpx, mm/core: Fix recursive munmap() corruption Nathan Chancellor (1): objtool: Allow AR to be overridden with HOSTAR arch/powerpc/include/asm/mmu_context.h | 1 - arch/um/include/asm/mmu_context.h| 1 - arch/unicore32/include/asm/mmu_context.h | 1 - arch/x86/include/asm/mmu_context.h | 6 +++--- arch/x86/include/asm/mpx.h | 15 --- arch/x86/mm/mpx.c| 10 ++ include/asm-generic/mm_hooks.h | 1 - mm/mmap.c| 15 --- tools/objtool/Makefile | 3 ++- 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h index 6ee8195a2ffb..4a6dd3ba0b0b 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h @@ -237,7 +237,6 @@ extern void arch_exit_mmap(struct mm_struct *mm); #endif static inline void arch_unmap(struct mm_struct *mm, - struct vm_area_struct *vma, unsigned long start, unsigned long end) { if (start <= mm->context.vdso_base && mm->context.vdso_base < end) diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h index fca34b2177e2..9f4b4bb78120 100644 --- a/arch/um/include/asm/mmu_context.h +++ b/arch/um/include/asm/mmu_context.h @@ -22,7 +22,6 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) } extern void arch_exit_mmap(struct mm_struct *mm); static inline void arch_unmap(struct mm_struct *mm, - struct vm_area_struct *vma, unsigned long start, unsigned long end) { } diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h index 5c205a9cb5a6..9f06ea5466dd 100644 --- a/arch/unicore32/include/asm/mmu_context.h +++ b/arch/unicore32/include/asm/mmu_context.h @@ -88,7 +88,6 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm, } static inline void arch_unmap(struct mm_struct *mm, - struct vm_area_struct *vma, unsigned long start, unsigned long end) { } diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 93dff1963337..9024236693d2 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -278,8 +278,8 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, mpx_mm_init(mm); } -static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, - unsigned long start, unsigned long end) +static inline void arch_unmap(struct mm_struct *mm, unsigned long start, + unsigned long end) { /* * mpx_notify_unmap() goes and reads a rarely-hot @@ -299,7 +299,7 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, * consistently wrong. */ if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX))) - mpx_notify_unmap(mm, vma, start, end); + mpx_notify_unmap(mm, start, end); } /* diff --git a/arch/x86/include/asm/mpx.h b/arch/x86/include/asm/mpx.h index d0b1434fb0b6..143a5c193ed3 100644 --- a/arch/x86/include/asm/mpx.h +++ b/arch/x86/include/asm/mpx.h @@ -64,12 +64,15 @@ struct mpx_fault_info { }; #ifdef CONFIG_X86_INTEL_MPX -int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs); -int mpx_handle_bd_fault(void); + +extern int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs); +extern int mpx_handle_bd_fault(void); + static inline int kernel_managing_mpx_tables(struct mm_struct *mm) { return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR); } + static inline void mpx_mm_init(struct mm_struct *mm) { /* @@ -78,11 +81,10 @@ static inline void mpx_mm_init(struct mm_struct *mm) */ mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR; } -void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, - unsigned long start, unsigned long end); -unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, - unsigned long flags); +extern void mpx_notify_unmap(struct mm_struct *mm, unsigned long start, unsigned long end); +extern unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, unsigned long flags); + #else static inline int
Re: [GIT PULL] core kernel fixes
The pull request you sent on Thu, 16 May 2019 17:51:46 +0200: > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git > core-urgent-for-linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/b2ca74d32bba153a1507e6b7e36d3ec8a89311a1 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 2decec48b0fd28ffdbf4cc684bd04e735f0839dd objtool: Fix whitelist documentation typo A handful of objtool updates, plus a documentation addition for __ab_c_size(). Thanks, Ingo --> Josh Poimboeuf (2): objtool: Don't use ignore flag for fake jumps objtool: Fix function fallthrough detection Raphael Gault (1): objtool: Fix whitelist documentation typo Rasmus Villemoes (1): overflow.h: Add comment documenting __ab_c_size() include/linux/overflow.h | 8 ++-- tools/objtool/Documentation/stack-validation.txt | 2 +- tools/objtool/check.c| 11 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/linux/overflow.h b/include/linux/overflow.h index 40b48e2133cb..6534a727cadb 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h @@ -278,11 +278,15 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c) return bytes; } -static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c) +/* + * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for + * struct_size() below. + */ +static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c) { size_t bytes; - if (check_mul_overflow(n, size, )) + if (check_mul_overflow(a, b, )) return SIZE_MAX; if (check_add_overflow(bytes, c, )) return SIZE_MAX; diff --git a/tools/objtool/Documentation/stack-validation.txt b/tools/objtool/Documentation/stack-validation.txt index 3995735a878f..cd17ee022072 100644 --- a/tools/objtool/Documentation/stack-validation.txt +++ b/tools/objtool/Documentation/stack-validation.txt @@ -306,7 +306,7 @@ ignore it: - To skip validation of a file, add -OBJECT_FILES_NON_STANDARD_filename.o := n +OBJECT_FILES_NON_STANDARD_filename.o := y to the Makefile. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index ac743a1d53ab..7325d89ccad9 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -28,6 +28,8 @@ #include #include +#define FAKE_JUMP_OFFSET -1 + struct alternative { struct list_head list; struct instruction *insn; @@ -568,7 +570,7 @@ static int add_jump_destinations(struct objtool_file *file) insn->type != INSN_JUMP_UNCONDITIONAL) continue; - if (insn->ignore) + if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET) continue; rela = find_rela_by_dest_range(insn->sec, insn->offset, @@ -745,10 +747,10 @@ static int handle_group_alt(struct objtool_file *file, clear_insn_state(_jump->state); fake_jump->sec = special_alt->new_sec; - fake_jump->offset = -1; + fake_jump->offset = FAKE_JUMP_OFFSET; fake_jump->type = INSN_JUMP_UNCONDITIONAL; fake_jump->jump_dest = list_next_entry(last_orig_insn, list); - fake_jump->ignore = true; + fake_jump->func = orig_insn->func; } if (!special_alt->new_len) { @@ -1957,7 +1959,8 @@ static int validate_branch(struct objtool_file *file, struct instruction *first, return 1; } - func = insn->func ? insn->func->pfunc : NULL; + if (insn->func) + func = insn->func->pfunc; if (func && insn->ignore) { WARN_FUNC("BUG: why am I validating an ignored function?",
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 092b31aa2048cf7561a39697974adcd147fbb27b x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling This is mostly the copy_to_user_mcsafe() related fixes from Dan Williams, and an ORC fix for Clang. Thanks, Ingo --> Dan Williams (4): lib/iov_iter: Document _copy_to_iter_mcsafe() lib/iov_iter: Document _copy_to_iter_flushcache() lib/iov_iter: Fix pipe handling in _copy_to_iter_mcsafe() x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling Simon Ser (1): objtool: Use '.strtab' if '.shstrtab' doesn't exist, to support ORC tables on Clang arch/x86/Kconfig | 2 +- arch/x86/include/asm/uaccess_64.h | 7 +++- lib/iov_iter.c| 77 +-- tools/objtool/elf.c | 6 ++- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f1dbb4ee19d7..887d3a7bb646 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -63,7 +63,7 @@ config X86 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_REFCOUNT select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 - select ARCH_HAS_UACCESS_MCSAFE if X86_64 + select ARCH_HAS_UACCESS_MCSAFE if X86_64 && X86_MCE select ARCH_HAS_SET_MEMORY select ARCH_HAS_SG_CHAIN select ARCH_HAS_STRICT_KERNEL_RWX diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h index 62acb613114b..a9d637bc301d 100644 --- a/arch/x86/include/asm/uaccess_64.h +++ b/arch/x86/include/asm/uaccess_64.h @@ -52,7 +52,12 @@ copy_to_user_mcsafe(void *to, const void *from, unsigned len) unsigned long ret; __uaccess_begin(); - ret = memcpy_mcsafe(to, from, len); + /* +* Note, __memcpy_mcsafe() is explicitly used since it can +* handle exceptions / faults. memcpy_mcsafe() may fall back to +* memcpy() which lacks this handling. +*/ + ret = __memcpy_mcsafe(to, from, len); __uaccess_end(); return ret; } diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 7e43cd54c84c..8be175df3075 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -596,15 +596,70 @@ static unsigned long memcpy_mcsafe_to_page(struct page *page, size_t offset, return ret; } +static size_t copy_pipe_to_iter_mcsafe(const void *addr, size_t bytes, + struct iov_iter *i) +{ + struct pipe_inode_info *pipe = i->pipe; + size_t n, off, xfer = 0; + int idx; + + if (!sanity(i)) + return 0; + + bytes = n = push_pipe(i, bytes, , ); + if (unlikely(!n)) + return 0; + for ( ; n; idx = next_idx(idx, pipe), off = 0) { + size_t chunk = min_t(size_t, n, PAGE_SIZE - off); + unsigned long rem; + + rem = memcpy_mcsafe_to_page(pipe->bufs[idx].page, off, addr, + chunk); + i->idx = idx; + i->iov_offset = off + chunk - rem; + xfer += chunk - rem; + if (rem) + break; + n -= chunk; + addr += chunk; + } + i->count -= xfer; + return xfer; +} + +/** + * _copy_to_iter_mcsafe - copy to user with source-read error exception handling + * @addr: source kernel address + * @bytes: total transfer length + * @iter: destination iterator + * + * The pmem driver arranges for filesystem-dax to use this facility via + * dax_copy_to_iter() for protecting read/write to persistent memory. + * Unless / until an architecture can guarantee identical performance + * between _copy_to_iter_mcsafe() and _copy_to_iter() it would be a + * performance regression to switch more users to the mcsafe version. + * + * Otherwise, the main differences between this and typical _copy_to_iter(). + * + * * Typical tail/residue handling after a fault retries the copy + * byte-by-byte until the fault happens again. Re-triggering machine + * checks is potentially fatal so the implementation uses source + * alignment and poison alignment assumptions to avoid re-triggering + * hardware exceptions. + * + * * ITER_KVEC, ITER_PIPE, and ITER_BVEC can return short copies. + * Compare to copy_to_iter() where only ITER_IOVEC attempts might return + * a short copy. + * + * See MCSAFE_TEST for self-test. + */ size_t _copy_to_iter_mcsafe(const void *addr, size_t bytes, struct iov_iter *i) { const char *from = addr; unsigned long rem, curr_addr, s_addr = (unsigned long) addr; - if (unlikely(i->type & ITER_PIPE)) { - WARN_ON(1); - return 0; - } + if (unlikely(i->type & ITER_PIPE)) + return
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 092b31aa2048cf7561a39697974adcd147fbb27b x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling This is mostly the copy_to_user_mcsafe() related fixes from Dan Williams, and an ORC fix for Clang. Thanks, Ingo --> Dan Williams (4): lib/iov_iter: Document _copy_to_iter_mcsafe() lib/iov_iter: Document _copy_to_iter_flushcache() lib/iov_iter: Fix pipe handling in _copy_to_iter_mcsafe() x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling Simon Ser (1): objtool: Use '.strtab' if '.shstrtab' doesn't exist, to support ORC tables on Clang arch/x86/Kconfig | 2 +- arch/x86/include/asm/uaccess_64.h | 7 +++- lib/iov_iter.c| 77 +-- tools/objtool/elf.c | 6 ++- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f1dbb4ee19d7..887d3a7bb646 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -63,7 +63,7 @@ config X86 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_REFCOUNT select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 - select ARCH_HAS_UACCESS_MCSAFE if X86_64 + select ARCH_HAS_UACCESS_MCSAFE if X86_64 && X86_MCE select ARCH_HAS_SET_MEMORY select ARCH_HAS_SG_CHAIN select ARCH_HAS_STRICT_KERNEL_RWX diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h index 62acb613114b..a9d637bc301d 100644 --- a/arch/x86/include/asm/uaccess_64.h +++ b/arch/x86/include/asm/uaccess_64.h @@ -52,7 +52,12 @@ copy_to_user_mcsafe(void *to, const void *from, unsigned len) unsigned long ret; __uaccess_begin(); - ret = memcpy_mcsafe(to, from, len); + /* +* Note, __memcpy_mcsafe() is explicitly used since it can +* handle exceptions / faults. memcpy_mcsafe() may fall back to +* memcpy() which lacks this handling. +*/ + ret = __memcpy_mcsafe(to, from, len); __uaccess_end(); return ret; } diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 7e43cd54c84c..8be175df3075 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -596,15 +596,70 @@ static unsigned long memcpy_mcsafe_to_page(struct page *page, size_t offset, return ret; } +static size_t copy_pipe_to_iter_mcsafe(const void *addr, size_t bytes, + struct iov_iter *i) +{ + struct pipe_inode_info *pipe = i->pipe; + size_t n, off, xfer = 0; + int idx; + + if (!sanity(i)) + return 0; + + bytes = n = push_pipe(i, bytes, , ); + if (unlikely(!n)) + return 0; + for ( ; n; idx = next_idx(idx, pipe), off = 0) { + size_t chunk = min_t(size_t, n, PAGE_SIZE - off); + unsigned long rem; + + rem = memcpy_mcsafe_to_page(pipe->bufs[idx].page, off, addr, + chunk); + i->idx = idx; + i->iov_offset = off + chunk - rem; + xfer += chunk - rem; + if (rem) + break; + n -= chunk; + addr += chunk; + } + i->count -= xfer; + return xfer; +} + +/** + * _copy_to_iter_mcsafe - copy to user with source-read error exception handling + * @addr: source kernel address + * @bytes: total transfer length + * @iter: destination iterator + * + * The pmem driver arranges for filesystem-dax to use this facility via + * dax_copy_to_iter() for protecting read/write to persistent memory. + * Unless / until an architecture can guarantee identical performance + * between _copy_to_iter_mcsafe() and _copy_to_iter() it would be a + * performance regression to switch more users to the mcsafe version. + * + * Otherwise, the main differences between this and typical _copy_to_iter(). + * + * * Typical tail/residue handling after a fault retries the copy + * byte-by-byte until the fault happens again. Re-triggering machine + * checks is potentially fatal so the implementation uses source + * alignment and poison alignment assumptions to avoid re-triggering + * hardware exceptions. + * + * * ITER_KVEC, ITER_PIPE, and ITER_BVEC can return short copies. + * Compare to copy_to_iter() where only ITER_IOVEC attempts might return + * a short copy. + * + * See MCSAFE_TEST for self-test. + */ size_t _copy_to_iter_mcsafe(const void *addr, size_t bytes, struct iov_iter *i) { const char *from = addr; unsigned long rem, curr_addr, s_addr = (unsigned long) addr; - if (unlikely(i->type & ITER_PIPE)) { - WARN_ON(1); - return 0; - } + if (unlikely(i->type & ITER_PIPE)) + return
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 14c47b54b0d9389e3ca0718e805cdd90c5a4303a objtool: Fix 64-bit build on 32-bit host Two fixes: - objtool cross-build fixes - removal of an obsolete CPU-hotplug state name from comments. Thanks, Ingo --> Brendan Jackman (1): cpu/hotplug: Fix state name in takedown_cpu() comment Mikulas Patocka (1): objtool: Fix 64-bit build on 32-bit host kernel/cpu.c | 4 ++-- tools/objtool/Makefile | 8 +--- tools/objtool/orc_dump.c | 7 --- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 04892a82f6ac..2a885c5f2429 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -780,8 +780,8 @@ static int takedown_cpu(unsigned int cpu) BUG_ON(cpu_online(cpu)); /* -* The CPUHP_AP_SCHED_MIGRATE_DYING callback will have removed all -* runnable tasks from the cpu, there's only the idle task left now +* The teardown callback for CPUHP_AP_SCHED_STARTING will have removed +* all runnable tasks from the CPU, there's only the idle task left now * that the migration thread is done doing the stop_machine thing. * * Wait for the stop thread to go away. diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 0f94af3ccaaa..ae0272f9a091 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -7,9 +7,11 @@ ARCH := x86 endif # always use the host compiler -CC = gcc -LD = ld -AR = ar +HOSTCC ?= gcc +HOSTLD ?= ld +CC = $(HOSTCC) +LD = $(HOSTLD) +AR = ar ifeq ($(srctree),) srctree := $(patsubst %/,%,$(dir $(CURDIR))) diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index 36c5bf6a2675..c3343820916a 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -76,7 +76,8 @@ int orc_dump(const char *_objname) int fd, nr_entries, i, *orc_ip = NULL, orc_size = 0; struct orc_entry *orc = NULL; char *name; - unsigned long nr_sections, orc_ip_addr = 0; + size_t nr_sections; + Elf64_Addr orc_ip_addr = 0; size_t shstrtab_idx; Elf *elf; Elf_Scn *scn; @@ -187,10 +188,10 @@ int orc_dump(const char *_objname) return -1; } - printf("%s+%lx:", name, rela.r_addend); + printf("%s+%llx:", name, (unsigned long long)rela.r_addend); } else { - printf("%lx:", orc_ip_addr + (i * sizeof(int)) + orc_ip[i]); + printf("%llx:", (unsigned long long)(orc_ip_addr + (i * sizeof(int)) + orc_ip[i])); }
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 14c47b54b0d9389e3ca0718e805cdd90c5a4303a objtool: Fix 64-bit build on 32-bit host Two fixes: - objtool cross-build fixes - removal of an obsolete CPU-hotplug state name from comments. Thanks, Ingo --> Brendan Jackman (1): cpu/hotplug: Fix state name in takedown_cpu() comment Mikulas Patocka (1): objtool: Fix 64-bit build on 32-bit host kernel/cpu.c | 4 ++-- tools/objtool/Makefile | 8 +--- tools/objtool/orc_dump.c | 7 --- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 04892a82f6ac..2a885c5f2429 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -780,8 +780,8 @@ static int takedown_cpu(unsigned int cpu) BUG_ON(cpu_online(cpu)); /* -* The CPUHP_AP_SCHED_MIGRATE_DYING callback will have removed all -* runnable tasks from the cpu, there's only the idle task left now +* The teardown callback for CPUHP_AP_SCHED_STARTING will have removed +* all runnable tasks from the CPU, there's only the idle task left now * that the migration thread is done doing the stop_machine thing. * * Wait for the stop thread to go away. diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 0f94af3ccaaa..ae0272f9a091 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -7,9 +7,11 @@ ARCH := x86 endif # always use the host compiler -CC = gcc -LD = ld -AR = ar +HOSTCC ?= gcc +HOSTLD ?= ld +CC = $(HOSTCC) +LD = $(HOSTLD) +AR = ar ifeq ($(srctree),) srctree := $(patsubst %/,%,$(dir $(CURDIR))) diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index 36c5bf6a2675..c3343820916a 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -76,7 +76,8 @@ int orc_dump(const char *_objname) int fd, nr_entries, i, *orc_ip = NULL, orc_size = 0; struct orc_entry *orc = NULL; char *name; - unsigned long nr_sections, orc_ip_addr = 0; + size_t nr_sections; + Elf64_Addr orc_ip_addr = 0; size_t shstrtab_idx; Elf *elf; Elf_Scn *scn; @@ -187,10 +188,10 @@ int orc_dump(const char *_objname) return -1; } - printf("%s+%lx:", name, rela.r_addend); + printf("%s+%llx:", name, (unsigned long long)rela.r_addend); } else { - printf("%lx:", orc_ip_addr + (i * sizeof(int)) + orc_ip[i]); + printf("%llx:", (unsigned long long)(orc_ip_addr + (i * sizeof(int)) + orc_ip[i])); }
Re: [GIT PULL] core kernel fixes
On Sun, Nov 05, 2017 at 12:12:31PM -0800, Linus Torvalds wrote: > On Sun, Nov 5, 2017 at 11:53 AM, Josh Poimboeufwrote: > > > > The GCC manual says: > > > > "asm statements that have no output operands, including asm goto > >statements, are implicitly volatile." > > Hmm. Fair enough. > > And the manual does say that it can merge and duplicate those asms > (and suggests using "%=" to generate a unique number, but I guess > "%c0" with __COUNTER__ is equivalent). > > I think the gcc manual has changed. I'm pretty certain it used to say > that "volatile" asms would not be "moved significantly". They've > silently changed semantics before too, oh well. I had tried the '%=' thing before, because that was exactly what I needed. But alas, it's not supported by the older GCCs. -- Josh
Re: [GIT PULL] core kernel fixes
On Sun, Nov 05, 2017 at 12:12:31PM -0800, Linus Torvalds wrote: > On Sun, Nov 5, 2017 at 11:53 AM, Josh Poimboeuf wrote: > > > > The GCC manual says: > > > > "asm statements that have no output operands, including asm goto > >statements, are implicitly volatile." > > Hmm. Fair enough. > > And the manual does say that it can merge and duplicate those asms > (and suggests using "%=" to generate a unique number, but I guess > "%c0" with __COUNTER__ is equivalent). > > I think the gcc manual has changed. I'm pretty certain it used to say > that "volatile" asms would not be "moved significantly". They've > silently changed semantics before too, oh well. I had tried the '%=' thing before, because that was exactly what I needed. But alas, it's not supported by the older GCCs. -- Josh
Re: [GIT PULL] core kernel fixes
On Sun, Nov 5, 2017 at 11:53 AM, Josh Poimboeufwrote: > > The GCC manual says: > > "asm statements that have no output operands, including asm goto >statements, are implicitly volatile." Hmm. Fair enough. And the manual does say that it can merge and duplicate those asms (and suggests using "%=" to generate a unique number, but I guess "%c0" with __COUNTER__ is equivalent). I think the gcc manual has changed. I'm pretty certain it used to say that "volatile" asms would not be "moved significantly". They've silently changed semantics before too, oh well. Linus
Re: [GIT PULL] core kernel fixes
On Sun, Nov 5, 2017 at 11:53 AM, Josh Poimboeuf wrote: > > The GCC manual says: > > "asm statements that have no output operands, including asm goto >statements, are implicitly volatile." Hmm. Fair enough. And the manual does say that it can merge and duplicate those asms (and suggests using "%=" to generate a unique number, but I guess "%c0" with __COUNTER__ is equivalent). I think the gcc manual has changed. I'm pretty certain it used to say that "volatile" asms would not be "moved significantly". They've silently changed semantics before too, oh well. Linus
Re: [GIT PULL] core kernel fixes
On Sun, Nov 05, 2017 at 10:09:59AM -0800, Linus Torvalds wrote: > On Sun, Nov 5, 2017 at 6:33 AM, Ingo Molnarwrote: > > > > Please note that this pull request is RFC due to the top commit: > > > > ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), > > take 2 > > > > ... which is admittedly somewhat of an ad-hoc workaround for something the > > compiler should have done - if there's another solution we can try that. > > So I'm certainly ok with that workaround since apparently "asm > volatile" doesn't do it. > > That said, I think that if that asm needs to not be merged, it should > _also_ be marked as "volatile" - since that's the documented bit for > "not moved significantly". Of course, then because apparently that > isn't enough, the __COUNTER__ games are ok, but might really mention > an explicit comment in the code as to why they exist. Because right > now they look just odd and nonsensical. The GCC manual says: "asm statements that have no output operands, including asm goto statements, are implicitly volatile." Since these macros have input operands, but no output operands, I assume they're already implicitly volatile. But we can certainly make it explicit. And yes, a comment would be good. Something like so? diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 3672353a0acd..188ed9f65517 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -88,17 +88,22 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, /* Unreachable code */ #ifdef CONFIG_STACK_VALIDATION +/* + * These macros help objtool understand GCC code flow for unreachable code. + * The __COUNTER__ based labels are a hack to make each instance of the macros + * unique, to convince GCC not to merge duplicate inline asm statements. + */ #define annotate_reachable() ({ \ - asm("%c0:\n\t" \ - ".pushsection .discard.reachable\n\t" \ - ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ +".pushsection .discard.reachable\n\t" \ +".long %c0b - .\n\t" \ +".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define annotate_unreachable() ({ \ - asm("%c0:\n\t" \ - ".pushsection .discard.unreachable\n\t" \ - ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ +".pushsection .discard.unreachable\n\t"\ +".long %c0b - .\n\t" \ +".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define ASM_UNREACHABLE \ "999:\n\t" \
Re: [GIT PULL] core kernel fixes
On Sun, Nov 05, 2017 at 10:09:59AM -0800, Linus Torvalds wrote: > On Sun, Nov 5, 2017 at 6:33 AM, Ingo Molnar wrote: > > > > Please note that this pull request is RFC due to the top commit: > > > > ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), > > take 2 > > > > ... which is admittedly somewhat of an ad-hoc workaround for something the > > compiler should have done - if there's another solution we can try that. > > So I'm certainly ok with that workaround since apparently "asm > volatile" doesn't do it. > > That said, I think that if that asm needs to not be merged, it should > _also_ be marked as "volatile" - since that's the documented bit for > "not moved significantly". Of course, then because apparently that > isn't enough, the __COUNTER__ games are ok, but might really mention > an explicit comment in the code as to why they exist. Because right > now they look just odd and nonsensical. The GCC manual says: "asm statements that have no output operands, including asm goto statements, are implicitly volatile." Since these macros have input operands, but no output operands, I assume they're already implicitly volatile. But we can certainly make it explicit. And yes, a comment would be good. Something like so? diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 3672353a0acd..188ed9f65517 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -88,17 +88,22 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, /* Unreachable code */ #ifdef CONFIG_STACK_VALIDATION +/* + * These macros help objtool understand GCC code flow for unreachable code. + * The __COUNTER__ based labels are a hack to make each instance of the macros + * unique, to convince GCC not to merge duplicate inline asm statements. + */ #define annotate_reachable() ({ \ - asm("%c0:\n\t" \ - ".pushsection .discard.reachable\n\t" \ - ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ +".pushsection .discard.reachable\n\t" \ +".long %c0b - .\n\t" \ +".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define annotate_unreachable() ({ \ - asm("%c0:\n\t" \ - ".pushsection .discard.unreachable\n\t" \ - ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ +".pushsection .discard.unreachable\n\t"\ +".long %c0b - .\n\t" \ +".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define ASM_UNREACHABLE \ "999:\n\t" \
Re: [GIT PULL] core kernel fixes
On Sun, Nov 5, 2017 at 6:33 AM, Ingo Molnarwrote: > > Please note that this pull request is RFC due to the top commit: > > ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), > take 2 > > ... which is admittedly somewhat of an ad-hoc workaround for something the > compiler should have done - if there's another solution we can try that. So I'm certainly ok with that workaround since apparently "asm volatile" doesn't do it. That said, I think that if that asm needs to not be merged, it should _also_ be marked as "volatile" - since that's the documented bit for "not moved significantly". Of course, then because apparently that isn't enough, the __COUNTER__ games are ok, but might really mention an explicit comment in the code as to why they exist. Because right now they look just odd and nonsensical. Linus
Re: [GIT PULL] core kernel fixes
On Sun, Nov 5, 2017 at 6:33 AM, Ingo Molnar wrote: > > Please note that this pull request is RFC due to the top commit: > > ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), > take 2 > > ... which is admittedly somewhat of an ad-hoc workaround for something the > compiler should have done - if there's another solution we can try that. So I'm certainly ok with that workaround since apparently "asm volatile" doesn't do it. That said, I think that if that asm needs to not be merged, it should _also_ be marked as "volatile" - since that's the documented bit for "not moved significantly". Of course, then because apparently that isn't enough, the __COUNTER__ games are ok, but might really mention an explicit comment in the code as to why they exist. Because right now they look just odd and nonsensical. Linus
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: ec1e1b6109171d1890a437481c35b2b56d2327b8 objtool: Prevent GCC from merging annotate_unreachable(), take 2 Please note that this pull request is RFC due to the top commit: ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), take 2 ... which is admittedly somewhat of an ad-hoc workaround for something the compiler should have done - if there's another solution we can try that. The other changes: - futex race fixes - objtool build warning fix - two watchdog fixes: a crash fix (revert) and a /proc/sys/kernel/watchdog_thresh handling bug fix. Thanks, Ingo --> Don Zickus (1): watchdog/hardlockup/perf: Use atomics to track in-use cpu counter Josh Poimboeuf (2): objtool: Resync objtool's instruction decoder source code copy with the kernel's latest version objtool: Prevent GCC from merging annotate_unreachable(), take 2 Peter Zijlstra (1): futex: Fix more put_pi_state() vs. exit_pi_state_list() races Thomas Gleixner (1): watchdog/harclockup/perf: Revert a33d44843d45 ("watchdog/hardlockup/perf: Simplify deferred event destroy") include/linux/compiler.h | 4 ++-- kernel/futex.c| 23 --- kernel/watchdog_hld.c | 15 ++- tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk | 1 + 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index fd8697aa4f73..202710420d6d 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -191,13 +191,13 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, asm("%c0:\n\t" \ ".pushsection .discard.reachable\n\t" \ ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__LINE__)); \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define annotate_unreachable() ({ \ asm("%c0:\n\t" \ ".pushsection .discard.unreachable\n\t" \ ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__LINE__)); \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define ASM_UNREACHABLE \ "999:\n\t" \ diff --git a/kernel/futex.c b/kernel/futex.c index 0d638f008bb1..76ed5921117a 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -903,11 +903,27 @@ void exit_pi_state_list(struct task_struct *curr) */ raw_spin_lock_irq(>pi_lock); while (!list_empty(head)) { - next = head->next; pi_state = list_entry(next, struct futex_pi_state, list); key = pi_state->key; hb = hash_futex(); + + /* +* We can race against put_pi_state() removing itself from the +* list (a waiter going away). put_pi_state() will first +* decrement the reference count and then modify the list, so +* its possible to see the list entry but fail this reference +* acquire. +* +* In that case; drop the locks to let put_pi_state() make +* progress and retry the loop. +*/ + if (!atomic_inc_not_zero(_state->refcount)) { + raw_spin_unlock_irq(>pi_lock); + cpu_relax(); + raw_spin_lock_irq(>pi_lock); + continue; + } raw_spin_unlock_irq(>pi_lock); spin_lock(>lock); @@ -918,8 +934,10 @@ void exit_pi_state_list(struct task_struct *curr) * task still owns the PI-state: */ if (head->next != next) { + /* retain curr->pi_lock for the loop invariant */ raw_spin_unlock(_state->pi_mutex.wait_lock); spin_unlock(>lock); + put_pi_state(pi_state); continue; } @@ -927,9 +945,8 @@ void exit_pi_state_list(struct task_struct *curr) WARN_ON(list_empty(_state->list)); list_del_init(_state->list); pi_state->owner = NULL; - raw_spin_unlock(>pi_lock); - get_pi_state(pi_state); + raw_spin_unlock(>pi_lock);
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: ec1e1b6109171d1890a437481c35b2b56d2327b8 objtool: Prevent GCC from merging annotate_unreachable(), take 2 Please note that this pull request is RFC due to the top commit: ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), take 2 ... which is admittedly somewhat of an ad-hoc workaround for something the compiler should have done - if there's another solution we can try that. The other changes: - futex race fixes - objtool build warning fix - two watchdog fixes: a crash fix (revert) and a /proc/sys/kernel/watchdog_thresh handling bug fix. Thanks, Ingo --> Don Zickus (1): watchdog/hardlockup/perf: Use atomics to track in-use cpu counter Josh Poimboeuf (2): objtool: Resync objtool's instruction decoder source code copy with the kernel's latest version objtool: Prevent GCC from merging annotate_unreachable(), take 2 Peter Zijlstra (1): futex: Fix more put_pi_state() vs. exit_pi_state_list() races Thomas Gleixner (1): watchdog/harclockup/perf: Revert a33d44843d45 ("watchdog/hardlockup/perf: Simplify deferred event destroy") include/linux/compiler.h | 4 ++-- kernel/futex.c| 23 --- kernel/watchdog_hld.c | 15 ++- tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk | 1 + 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index fd8697aa4f73..202710420d6d 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -191,13 +191,13 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, asm("%c0:\n\t" \ ".pushsection .discard.reachable\n\t" \ ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__LINE__)); \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define annotate_unreachable() ({ \ asm("%c0:\n\t" \ ".pushsection .discard.unreachable\n\t" \ ".long %c0b - .\n\t"\ - ".popsection\n\t" : : "i" (__LINE__)); \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define ASM_UNREACHABLE \ "999:\n\t" \ diff --git a/kernel/futex.c b/kernel/futex.c index 0d638f008bb1..76ed5921117a 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -903,11 +903,27 @@ void exit_pi_state_list(struct task_struct *curr) */ raw_spin_lock_irq(>pi_lock); while (!list_empty(head)) { - next = head->next; pi_state = list_entry(next, struct futex_pi_state, list); key = pi_state->key; hb = hash_futex(); + + /* +* We can race against put_pi_state() removing itself from the +* list (a waiter going away). put_pi_state() will first +* decrement the reference count and then modify the list, so +* its possible to see the list entry but fail this reference +* acquire. +* +* In that case; drop the locks to let put_pi_state() make +* progress and retry the loop. +*/ + if (!atomic_inc_not_zero(_state->refcount)) { + raw_spin_unlock_irq(>pi_lock); + cpu_relax(); + raw_spin_lock_irq(>pi_lock); + continue; + } raw_spin_unlock_irq(>pi_lock); spin_lock(>lock); @@ -918,8 +934,10 @@ void exit_pi_state_list(struct task_struct *curr) * task still owns the PI-state: */ if (head->next != next) { + /* retain curr->pi_lock for the loop invariant */ raw_spin_unlock(_state->pi_mutex.wait_lock); spin_unlock(>lock); + put_pi_state(pi_state); continue; } @@ -927,9 +945,8 @@ void exit_pi_state_list(struct task_struct *curr) WARN_ON(list_empty(_state->list)); list_del_init(_state->list); pi_state->owner = NULL; - raw_spin_unlock(>pi_lock); - get_pi_state(pi_state); + raw_spin_unlock(>pi_lock);
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 325cdacd03c12629aa5f9ee2ace49b1f3dc184a8 debug: Fix WARN_ON_ONCE() for modules A fix to WARN_ON_ONCE() done by modules, plus a MAINTAINERS update. Thanks, Ingo --> Ingo Molnar (1): MAINTAINERS: Update the PTRACE entry Josh Poimboeuf (1): debug: Fix WARN_ON_ONCE() for modules MAINTAINERS | 6 +- arch/arm/include/asm/bug.h | 2 +- arch/arm64/include/asm/bug.h| 2 +- arch/blackfin/include/asm/bug.h | 4 ++-- arch/mn10300/include/asm/bug.h | 2 +- arch/parisc/include/asm/bug.h | 6 +++--- arch/powerpc/include/asm/bug.h | 8 arch/s390/include/asm/bug.h | 4 ++-- arch/sh/include/asm/bug.h | 4 ++-- arch/x86/include/asm/bug.h | 4 ++-- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index d357695ee4fe..cbe90323c35a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10355,7 +10355,6 @@ F: drivers/ptp/* F: include/linux/ptp_cl* PTRACE SUPPORT -M: Roland McGrathM: Oleg Nesterov S: Maintained F: include/asm-generic/syscall.h @@ -10363,7 +10362,12 @@ F: include/linux/ptrace.h F: include/linux/regset.h F: include/linux/tracehook.h F: include/uapi/linux/ptrace.h +F: include/uapi/linux/ptrace.h +F: include/asm-generic/ptrace.h F: kernel/ptrace.c +F: arch/*/ptrace*.c +F: arch/*/*/ptrace*.c +F: arch/*/include/asm/ptrace*.h PULSE8-CEC DRIVER M: Hans Verkuil diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h index 4e6e88a6b2f4..2244a94ed9c9 100644 --- a/arch/arm/include/asm/bug.h +++ b/arch/arm/include/asm/bug.h @@ -37,7 +37,7 @@ do { \ ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ "2:\t.asciz " #__file "\n" \ ".popsection\n" \ - ".pushsection __bug_table,\"a\"\n" \ + ".pushsection __bug_table,\"aw\"\n" \ ".align 2\n"\ "3:\t.word 1b, 2b\n"\ "\t.hword " #__line ", 0\n" \ diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h index 366448eb0fb7..a02a57186f56 100644 --- a/arch/arm64/include/asm/bug.h +++ b/arch/arm64/include/asm/bug.h @@ -36,7 +36,7 @@ #ifdef CONFIG_GENERIC_BUG #define __BUG_ENTRY(flags) \ - ".pushsection __bug_table,\"a\"\n\t"\ + ".pushsection __bug_table,\"aw\"\n\t" \ ".align 2\n\t" \ "0: .long 1f - 0b\n\t" \ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ diff --git a/arch/blackfin/include/asm/bug.h b/arch/blackfin/include/asm/bug.h index 8d9b1eba89c4..76b2e82ee730 100644 --- a/arch/blackfin/include/asm/bug.h +++ b/arch/blackfin/include/asm/bug.h @@ -21,7 +21,7 @@ #define _BUG_OR_WARN(flags)\ asm volatile( \ "1: .hword %0\n" \ - " .section __bug_table,\"a\",@progbits\n" \ + " .section __bug_table,\"aw\",@progbits\n"\ "2: .long 1b\n" \ " .long %1\n" \ " .short %2\n" \ @@ -38,7 +38,7 @@ #define _BUG_OR_WARN(flags)\ asm volatile( \ "1: .hword %0\n" \ - " .section __bug_table,\"a\",@progbits\n" \ + " .section __bug_table,\"aw\",@progbits\n"\ "2: .long 1b\n" \ " .short %1\n" \ " .org2b + %2\n" \ diff --git a/arch/mn10300/include/asm/bug.h b/arch/mn10300/include/asm/bug.h index aa6a38886391..811414fb002d 100644 --- a/arch/mn10300/include/asm/bug.h +++ b/arch/mn10300/include/asm/bug.h @@ -21,7 +21,7 @@ do { \ asm volatile( \ " syscall 15 \n" \ "0: \n" \ - "
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 325cdacd03c12629aa5f9ee2ace49b1f3dc184a8 debug: Fix WARN_ON_ONCE() for modules A fix to WARN_ON_ONCE() done by modules, plus a MAINTAINERS update. Thanks, Ingo --> Ingo Molnar (1): MAINTAINERS: Update the PTRACE entry Josh Poimboeuf (1): debug: Fix WARN_ON_ONCE() for modules MAINTAINERS | 6 +- arch/arm/include/asm/bug.h | 2 +- arch/arm64/include/asm/bug.h| 2 +- arch/blackfin/include/asm/bug.h | 4 ++-- arch/mn10300/include/asm/bug.h | 2 +- arch/parisc/include/asm/bug.h | 6 +++--- arch/powerpc/include/asm/bug.h | 8 arch/s390/include/asm/bug.h | 4 ++-- arch/sh/include/asm/bug.h | 4 ++-- arch/x86/include/asm/bug.h | 4 ++-- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index d357695ee4fe..cbe90323c35a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10355,7 +10355,6 @@ F: drivers/ptp/* F: include/linux/ptp_cl* PTRACE SUPPORT -M: Roland McGrath M: Oleg Nesterov S: Maintained F: include/asm-generic/syscall.h @@ -10363,7 +10362,12 @@ F: include/linux/ptrace.h F: include/linux/regset.h F: include/linux/tracehook.h F: include/uapi/linux/ptrace.h +F: include/uapi/linux/ptrace.h +F: include/asm-generic/ptrace.h F: kernel/ptrace.c +F: arch/*/ptrace*.c +F: arch/*/*/ptrace*.c +F: arch/*/include/asm/ptrace*.h PULSE8-CEC DRIVER M: Hans Verkuil diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h index 4e6e88a6b2f4..2244a94ed9c9 100644 --- a/arch/arm/include/asm/bug.h +++ b/arch/arm/include/asm/bug.h @@ -37,7 +37,7 @@ do { \ ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ "2:\t.asciz " #__file "\n" \ ".popsection\n" \ - ".pushsection __bug_table,\"a\"\n" \ + ".pushsection __bug_table,\"aw\"\n" \ ".align 2\n"\ "3:\t.word 1b, 2b\n"\ "\t.hword " #__line ", 0\n" \ diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h index 366448eb0fb7..a02a57186f56 100644 --- a/arch/arm64/include/asm/bug.h +++ b/arch/arm64/include/asm/bug.h @@ -36,7 +36,7 @@ #ifdef CONFIG_GENERIC_BUG #define __BUG_ENTRY(flags) \ - ".pushsection __bug_table,\"a\"\n\t"\ + ".pushsection __bug_table,\"aw\"\n\t" \ ".align 2\n\t" \ "0: .long 1f - 0b\n\t" \ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ diff --git a/arch/blackfin/include/asm/bug.h b/arch/blackfin/include/asm/bug.h index 8d9b1eba89c4..76b2e82ee730 100644 --- a/arch/blackfin/include/asm/bug.h +++ b/arch/blackfin/include/asm/bug.h @@ -21,7 +21,7 @@ #define _BUG_OR_WARN(flags)\ asm volatile( \ "1: .hword %0\n" \ - " .section __bug_table,\"a\",@progbits\n" \ + " .section __bug_table,\"aw\",@progbits\n"\ "2: .long 1b\n" \ " .long %1\n" \ " .short %2\n" \ @@ -38,7 +38,7 @@ #define _BUG_OR_WARN(flags)\ asm volatile( \ "1: .hword %0\n" \ - " .section __bug_table,\"a\",@progbits\n" \ + " .section __bug_table,\"aw\",@progbits\n"\ "2: .long 1b\n" \ " .short %1\n" \ " .org2b + %2\n" \ diff --git a/arch/mn10300/include/asm/bug.h b/arch/mn10300/include/asm/bug.h index aa6a38886391..811414fb002d 100644 --- a/arch/mn10300/include/asm/bug.h +++ b/arch/mn10300/include/asm/bug.h @@ -21,7 +21,7 @@ do { \ asm volatile( \ " syscall 15 \n" \ "0: \n" \ - " .section __bug_table,\"a\" \n" \ + "
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: a705e07b9c80df27b6bb12f7a4cd4cf4ed2f728b cpu/hotplug: Use distinct name for cpu_hotplug.dep_map A CPU hotplug debuggability fix and three objtool false positive warnings fixes for new GCC6 code generation patterns. Thanks, Ingo --> Joonas Lahtinen (1): cpu/hotplug: Use distinct name for cpu_hotplug.dep_map Josh Poimboeuf (3): objtool: Support '-mtune=atom' stack frame setup instruction objtool: Improve rare switch jump table pattern detection objtool: Skip all "unreachable instruction" warnings for gcov kernels kernel/cpu.c| 2 +- tools/objtool/arch/x86/decode.c | 9 ++ tools/objtool/builtin-check.c | 68 + 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 5df20d6d1520..29de1a9352c0 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -228,7 +228,7 @@ static struct { .wq = __WAIT_QUEUE_HEAD_INITIALIZER(cpu_hotplug.wq), .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock), #ifdef CONFIG_DEBUG_LOCK_ALLOC - .dep_map = {.name = "cpu_hotplug.lock" }, + .dep_map = STATIC_LOCKDEP_MAP_INIT("cpu_hotplug.dep_map", _hotplug.dep_map), #endif }; diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index c0c0b265e88e..b63a31be1218 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -98,6 +98,15 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, *type = INSN_FP_SETUP; break; + case 0x8d: + if (insn.rex_prefix.bytes && + insn.rex_prefix.bytes[0] == 0x48 && + insn.modrm.nbytes && insn.modrm.bytes[0] == 0x2c && + insn.sib.nbytes && insn.sib.bytes[0] == 0x24) + /* lea %(rsp), %rbp */ + *type = INSN_FP_SETUP; + break; + case 0x90: *type = INSN_NOP; break; diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 143b6cdd7f06..4490601a9235 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -97,6 +97,19 @@ static struct instruction *next_insn_same_sec(struct objtool_file *file, return next; } +static bool gcov_enabled(struct objtool_file *file) +{ + struct section *sec; + struct symbol *sym; + + list_for_each_entry(sec, >elf->sections, list) + list_for_each_entry(sym, >symbol_list, list) + if (!strncmp(sym->name, "__gcov_.", 8)) + return true; + + return false; +} + #define for_each_insn(file, insn) \ list_for_each_entry(insn, >insn_list, list) @@ -713,6 +726,7 @@ static struct rela *find_switch_table(struct objtool_file *file, struct instruction *insn) { struct rela *text_rela, *rodata_rela; + struct instruction *orig_insn = insn; text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); if (text_rela && text_rela->sym == file->rodata->sym) { @@ -733,10 +747,16 @@ static struct rela *find_switch_table(struct objtool_file *file, /* case 3 */ func_for_each_insn_continue_reverse(file, func, insn) { - if (insn->type == INSN_JUMP_UNCONDITIONAL || - insn->type == INSN_JUMP_DYNAMIC) + if (insn->type == INSN_JUMP_DYNAMIC) break; + /* allow small jumps within the range */ + if (insn->type == INSN_JUMP_UNCONDITIONAL && + insn->jump_dest && + (insn->jump_dest->offset <= insn->offset || +insn->jump_dest->offset >= orig_insn->offset)) + break; + text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); if (text_rela && text_rela->sym == file->rodata->sym) @@ -1034,34 +1054,6 @@ static int validate_branch(struct objtool_file *file, return 0; } -static bool is_gcov_insn(struct instruction *insn) -{ - struct rela *rela; - struct section *sec; - struct symbol *sym; - unsigned long offset; - - rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); - if (!rela) - return false; - - if (rela->sym->type != STT_SECTION) - return false; - - sec = rela->sym->sec; - offset = rela->addend + insn->offset + insn->len - rela->offset; - - list_for_each_entry(sym, >symbol_list, list) { - if (sym->type != STT_OBJECT) -
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: a705e07b9c80df27b6bb12f7a4cd4cf4ed2f728b cpu/hotplug: Use distinct name for cpu_hotplug.dep_map A CPU hotplug debuggability fix and three objtool false positive warnings fixes for new GCC6 code generation patterns. Thanks, Ingo --> Joonas Lahtinen (1): cpu/hotplug: Use distinct name for cpu_hotplug.dep_map Josh Poimboeuf (3): objtool: Support '-mtune=atom' stack frame setup instruction objtool: Improve rare switch jump table pattern detection objtool: Skip all "unreachable instruction" warnings for gcov kernels kernel/cpu.c| 2 +- tools/objtool/arch/x86/decode.c | 9 ++ tools/objtool/builtin-check.c | 68 + 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 5df20d6d1520..29de1a9352c0 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -228,7 +228,7 @@ static struct { .wq = __WAIT_QUEUE_HEAD_INITIALIZER(cpu_hotplug.wq), .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock), #ifdef CONFIG_DEBUG_LOCK_ALLOC - .dep_map = {.name = "cpu_hotplug.lock" }, + .dep_map = STATIC_LOCKDEP_MAP_INIT("cpu_hotplug.dep_map", _hotplug.dep_map), #endif }; diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index c0c0b265e88e..b63a31be1218 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -98,6 +98,15 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, *type = INSN_FP_SETUP; break; + case 0x8d: + if (insn.rex_prefix.bytes && + insn.rex_prefix.bytes[0] == 0x48 && + insn.modrm.nbytes && insn.modrm.bytes[0] == 0x2c && + insn.sib.nbytes && insn.sib.bytes[0] == 0x24) + /* lea %(rsp), %rbp */ + *type = INSN_FP_SETUP; + break; + case 0x90: *type = INSN_NOP; break; diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 143b6cdd7f06..4490601a9235 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -97,6 +97,19 @@ static struct instruction *next_insn_same_sec(struct objtool_file *file, return next; } +static bool gcov_enabled(struct objtool_file *file) +{ + struct section *sec; + struct symbol *sym; + + list_for_each_entry(sec, >elf->sections, list) + list_for_each_entry(sym, >symbol_list, list) + if (!strncmp(sym->name, "__gcov_.", 8)) + return true; + + return false; +} + #define for_each_insn(file, insn) \ list_for_each_entry(insn, >insn_list, list) @@ -713,6 +726,7 @@ static struct rela *find_switch_table(struct objtool_file *file, struct instruction *insn) { struct rela *text_rela, *rodata_rela; + struct instruction *orig_insn = insn; text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); if (text_rela && text_rela->sym == file->rodata->sym) { @@ -733,10 +747,16 @@ static struct rela *find_switch_table(struct objtool_file *file, /* case 3 */ func_for_each_insn_continue_reverse(file, func, insn) { - if (insn->type == INSN_JUMP_UNCONDITIONAL || - insn->type == INSN_JUMP_DYNAMIC) + if (insn->type == INSN_JUMP_DYNAMIC) break; + /* allow small jumps within the range */ + if (insn->type == INSN_JUMP_UNCONDITIONAL && + insn->jump_dest && + (insn->jump_dest->offset <= insn->offset || +insn->jump_dest->offset >= orig_insn->offset)) + break; + text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); if (text_rela && text_rela->sym == file->rodata->sym) @@ -1034,34 +1054,6 @@ static int validate_branch(struct objtool_file *file, return 0; } -static bool is_gcov_insn(struct instruction *insn) -{ - struct rela *rela; - struct section *sec; - struct symbol *sym; - unsigned long offset; - - rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); - if (!rela) - return false; - - if (rela->sym->type != STT_SECTION) - return false; - - sec = rela->sym->sec; - offset = rela->addend + insn->offset + insn->len - rela->offset; - - list_for_each_entry(sym, >symbol_list, list) { - if (sym->type != STT_OBJECT) -
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: a7c734140aa36413944eef0f8c660e0e2256357d cpu/hotplug: Keep enough storage space if SMP=n to avoid array out of bounds scribble Fix an objtool false positive plus an UP kernel memory corruption bug on certain configs. Thanks, Ingo --> Josh Poimboeuf (1): objtool: Fix STACK_FRAME_NON_STANDARD macro checking for function symbols Thomas Gleixner (1): cpu/hotplug: Keep enough storage space if SMP=n to avoid array out of bounds scribble kernel/cpu.c | 2 ++ tools/objtool/builtin-check.c | 8 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index d948e44c471e..7b61887f7ccd 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1201,6 +1201,8 @@ static struct cpuhp_step cpuhp_bp_states[] = { .teardown = takedown_cpu, .cant_stop = true, }, +#else + [CPUHP_BRINGUP_CPU] = { }, #endif }; diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index e8a1e69eb92c..25d803148f5c 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -122,10 +122,14 @@ static bool ignore_func(struct objtool_file *file, struct symbol *func) /* check for STACK_FRAME_NON_STANDARD */ if (file->whitelist && file->whitelist->rela) - list_for_each_entry(rela, >whitelist->rela->rela_list, list) - if (rela->sym->sec == func->sec && + list_for_each_entry(rela, >whitelist->rela->rela_list, list) { + if (rela->sym->type == STT_SECTION && + rela->sym->sec == func->sec && rela->addend == func->offset) return true; + if (rela->sym->type == STT_FUNC && rela->sym == func) + return true; + } /* check if it has a context switching instruction */ func_for_each_insn(file, func, insn)
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: a7c734140aa36413944eef0f8c660e0e2256357d cpu/hotplug: Keep enough storage space if SMP=n to avoid array out of bounds scribble Fix an objtool false positive plus an UP kernel memory corruption bug on certain configs. Thanks, Ingo --> Josh Poimboeuf (1): objtool: Fix STACK_FRAME_NON_STANDARD macro checking for function symbols Thomas Gleixner (1): cpu/hotplug: Keep enough storage space if SMP=n to avoid array out of bounds scribble kernel/cpu.c | 2 ++ tools/objtool/builtin-check.c | 8 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index d948e44c471e..7b61887f7ccd 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1201,6 +1201,8 @@ static struct cpuhp_step cpuhp_bp_states[] = { .teardown = takedown_cpu, .cant_stop = true, }, +#else + [CPUHP_BRINGUP_CPU] = { }, #endif }; diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index e8a1e69eb92c..25d803148f5c 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -122,10 +122,14 @@ static bool ignore_func(struct objtool_file *file, struct symbol *func) /* check for STACK_FRAME_NON_STANDARD */ if (file->whitelist && file->whitelist->rela) - list_for_each_entry(rela, >whitelist->rela->rela_list, list) - if (rela->sym->sec == func->sec && + list_for_each_entry(rela, >whitelist->rela->rela_list, list) { + if (rela->sym->type == STT_SECTION && + rela->sym->sec == func->sec && rela->addend == func->offset) return true; + if (rela->sym->type == STT_FUNC && rela->sym == func) + return true; + } /* check if it has a context switching instruction */ func_for_each_insn(file, func, insn)
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 353def94606fda16d9ae1761b4b0583286481ec5 MAINTAINERS: Update my email address This contains the nohz/atomic cleanup/fix for the fetch_or() ugliness you noted during the original nohz pull request, plus there's also misc fixes: - fix liblockdep build bug - fix uapi header build bug - print more lockdep hash collision info to help debug recent reports of hash collisions - update MAINTAINERS email address Thanks, Ingo --> Alfredo Alvarez Fernandez (1): locking/lockdep: Print chain_key collision information Denys Vlasenko (1): uapi/linux/stddef.h: Provide __always_inline to userspace headers Frederic Weisbecker (3): locking/atomic: Introduce atomic_fetch_or() timers/nohz: Convert tick dependency mask to atomic_t locking/atomic, sched: Unexport fetch_or() Masami Hiramatsu (1): MAINTAINERS: Update my email address Sedat Dilek (1): tools/lib/lockdep: Fix unsupported 'basename -s' in run_tests.sh MAINTAINERS| 2 +- include/linux/atomic.h | 34 +- include/linux/sched.h | 4 +-- include/uapi/linux/stddef.h| 4 +++ kernel/locking/lockdep.c | 79 -- kernel/sched/core.c| 18 ++ kernel/time/tick-sched.c | 61 kernel/time/tick-sched.h | 2 +- tools/lib/lockdep/run_tests.sh | 12 --- 9 files changed, 158 insertions(+), 58 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 378ebfff2d1f..ed121a5b9319 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6402,7 +6402,7 @@ KPROBES M: Ananth N MavinakayanahalliM: Anil S Keshavamurthy M: "David S. Miller" -M: Masami Hiramatsu +M: Masami Hiramatsu S: Maintained F: Documentation/kprobes.txt F: include/linux/kprobes.h diff --git a/include/linux/atomic.h b/include/linux/atomic.h index df4f369254c0..506c3531832e 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -559,25 +559,25 @@ static inline int atomic_dec_if_positive(atomic_t *v) #endif /** - * fetch_or - perform *ptr |= mask and return old value of *ptr - * @ptr: pointer to value - * @mask: mask to OR on the value - * - * cmpxchg based fetch_or, macro so it works for different integer types + * atomic_fetch_or - perform *p |= mask and return old value of *p + * @p: pointer to atomic_t + * @mask: mask to OR on the atomic_t */ -#ifndef fetch_or -#define fetch_or(ptr, mask)\ -({ typeof(*(ptr)) __old, __val = *(ptr); \ - for (;;) { \ - __old = cmpxchg((ptr), __val, __val | (mask)); \ - if (__old == __val) \ - break; \ - __val = __old; \ - } \ - __old; \ -}) -#endif +#ifndef atomic_fetch_or +static inline int atomic_fetch_or(atomic_t *p, int mask) +{ + int old, val = atomic_read(p); + + for (;;) { + old = atomic_cmpxchg(p, val, val | mask); + if (old == val) + break; + val = old; + } + return old; +} +#endif #ifdef CONFIG_GENERIC_ATOMIC64 #include diff --git a/include/linux/sched.h b/include/linux/sched.h index 60bba7e032dc..52c4847b05e2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -720,7 +720,7 @@ struct signal_struct { struct task_cputime cputime_expires; #ifdef CONFIG_NO_HZ_FULL - unsigned long tick_dep_mask; + atomic_t tick_dep_mask; #endif struct list_head cpu_timers[3]; @@ -1549,7 +1549,7 @@ struct task_struct { #endif #ifdef CONFIG_NO_HZ_FULL - unsigned long tick_dep_mask; + atomic_t tick_dep_mask; #endif unsigned long nvcsw, nivcsw; /* context switch counts */ u64 start_time; /* monotonic time in nsec */ diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index aa9f10428743..621fa8ac4425 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -1 +1,5 @@ #include + +#ifndef __always_inline +#define __always_inline inline +#endif diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 53ab2f85d77e..2324ba5310db 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2000,6 +2000,77 @@ static inline int
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 353def94606fda16d9ae1761b4b0583286481ec5 MAINTAINERS: Update my email address This contains the nohz/atomic cleanup/fix for the fetch_or() ugliness you noted during the original nohz pull request, plus there's also misc fixes: - fix liblockdep build bug - fix uapi header build bug - print more lockdep hash collision info to help debug recent reports of hash collisions - update MAINTAINERS email address Thanks, Ingo --> Alfredo Alvarez Fernandez (1): locking/lockdep: Print chain_key collision information Denys Vlasenko (1): uapi/linux/stddef.h: Provide __always_inline to userspace headers Frederic Weisbecker (3): locking/atomic: Introduce atomic_fetch_or() timers/nohz: Convert tick dependency mask to atomic_t locking/atomic, sched: Unexport fetch_or() Masami Hiramatsu (1): MAINTAINERS: Update my email address Sedat Dilek (1): tools/lib/lockdep: Fix unsupported 'basename -s' in run_tests.sh MAINTAINERS| 2 +- include/linux/atomic.h | 34 +- include/linux/sched.h | 4 +-- include/uapi/linux/stddef.h| 4 +++ kernel/locking/lockdep.c | 79 -- kernel/sched/core.c| 18 ++ kernel/time/tick-sched.c | 61 kernel/time/tick-sched.h | 2 +- tools/lib/lockdep/run_tests.sh | 12 --- 9 files changed, 158 insertions(+), 58 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 378ebfff2d1f..ed121a5b9319 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6402,7 +6402,7 @@ KPROBES M: Ananth N Mavinakayanahalli M: Anil S Keshavamurthy M: "David S. Miller" -M: Masami Hiramatsu +M: Masami Hiramatsu S: Maintained F: Documentation/kprobes.txt F: include/linux/kprobes.h diff --git a/include/linux/atomic.h b/include/linux/atomic.h index df4f369254c0..506c3531832e 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -559,25 +559,25 @@ static inline int atomic_dec_if_positive(atomic_t *v) #endif /** - * fetch_or - perform *ptr |= mask and return old value of *ptr - * @ptr: pointer to value - * @mask: mask to OR on the value - * - * cmpxchg based fetch_or, macro so it works for different integer types + * atomic_fetch_or - perform *p |= mask and return old value of *p + * @p: pointer to atomic_t + * @mask: mask to OR on the atomic_t */ -#ifndef fetch_or -#define fetch_or(ptr, mask)\ -({ typeof(*(ptr)) __old, __val = *(ptr); \ - for (;;) { \ - __old = cmpxchg((ptr), __val, __val | (mask)); \ - if (__old == __val) \ - break; \ - __val = __old; \ - } \ - __old; \ -}) -#endif +#ifndef atomic_fetch_or +static inline int atomic_fetch_or(atomic_t *p, int mask) +{ + int old, val = atomic_read(p); + + for (;;) { + old = atomic_cmpxchg(p, val, val | mask); + if (old == val) + break; + val = old; + } + return old; +} +#endif #ifdef CONFIG_GENERIC_ATOMIC64 #include diff --git a/include/linux/sched.h b/include/linux/sched.h index 60bba7e032dc..52c4847b05e2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -720,7 +720,7 @@ struct signal_struct { struct task_cputime cputime_expires; #ifdef CONFIG_NO_HZ_FULL - unsigned long tick_dep_mask; + atomic_t tick_dep_mask; #endif struct list_head cpu_timers[3]; @@ -1549,7 +1549,7 @@ struct task_struct { #endif #ifdef CONFIG_NO_HZ_FULL - unsigned long tick_dep_mask; + atomic_t tick_dep_mask; #endif unsigned long nvcsw, nivcsw; /* context switch counts */ u64 start_time; /* monotonic time in nsec */ diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index aa9f10428743..621fa8ac4425 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -1 +1,5 @@ #include + +#ifndef __always_inline +#define __always_inline inline +#endif diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 53ab2f85d77e..2324ba5310db 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2000,6 +2000,77 @@ static inline int get_first_held_lock(struct task_struct *curr, } /* + * Returns the next chain_key iteration + */ +static u64
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 135818bf494e6f8f7c9327d9d9e015f7548b6f8d Merge branch 'liblockdep-fixes-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux into core/urgent Two liblockdep fixes and a CPU hotplug race fix. Thanks, Ingo --> Baruch Siach (2): tools/liblockdep: ignore generated .so file tools/liblockdep: don't include host headers Lai Jiangshan (1): smpboot: Add missing get_online_cpus() in smpboot_register_percpu_thread() kernel/smpboot.c | 2 ++ tools/lib/lockdep/.gitignore | 1 + tools/lib/lockdep/Makefile | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tools/lib/lockdep/.gitignore diff --git a/kernel/smpboot.c b/kernel/smpboot.c index f032fb5284e3..40190f28db35 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -280,6 +280,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) unsigned int cpu; int ret = 0; + get_online_cpus(); mutex_lock(_threads_lock); for_each_online_cpu(cpu) { ret = __smpboot_create_thread(plug_thread, cpu); @@ -292,6 +293,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) list_add(_thread->list, _threads); out: mutex_unlock(_threads_lock); + put_online_cpus(); return ret; } EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread); diff --git a/tools/lib/lockdep/.gitignore b/tools/lib/lockdep/.gitignore new file mode 100644 index ..cc0e7a9f99e3 --- /dev/null +++ b/tools/lib/lockdep/.gitignore @@ -0,0 +1 @@ +liblockdep.so.* diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile index 52f9279c6c13..4b866c54f624 100644 --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile @@ -104,7 +104,7 @@ N = export Q VERBOSE -INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES) +INCLUDES = -I. -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES) # Set compile option CFLAGS if not set elsewhere CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 135818bf494e6f8f7c9327d9d9e015f7548b6f8d Merge branch 'liblockdep-fixes-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux into core/urgent Two liblockdep fixes and a CPU hotplug race fix. Thanks, Ingo -- Baruch Siach (2): tools/liblockdep: ignore generated .so file tools/liblockdep: don't include host headers Lai Jiangshan (1): smpboot: Add missing get_online_cpus() in smpboot_register_percpu_thread() kernel/smpboot.c | 2 ++ tools/lib/lockdep/.gitignore | 1 + tools/lib/lockdep/Makefile | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tools/lib/lockdep/.gitignore diff --git a/kernel/smpboot.c b/kernel/smpboot.c index f032fb5284e3..40190f28db35 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -280,6 +280,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) unsigned int cpu; int ret = 0; + get_online_cpus(); mutex_lock(smpboot_threads_lock); for_each_online_cpu(cpu) { ret = __smpboot_create_thread(plug_thread, cpu); @@ -292,6 +293,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) list_add(plug_thread-list, hotplug_threads); out: mutex_unlock(smpboot_threads_lock); + put_online_cpus(); return ret; } EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread); diff --git a/tools/lib/lockdep/.gitignore b/tools/lib/lockdep/.gitignore new file mode 100644 index ..cc0e7a9f99e3 --- /dev/null +++ b/tools/lib/lockdep/.gitignore @@ -0,0 +1 @@ +liblockdep.so.* diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile index 52f9279c6c13..4b866c54f624 100644 --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile @@ -104,7 +104,7 @@ N = export Q VERBOSE -INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES) +INCLUDES = -I. -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES) # Set compile option CFLAGS if not set elsewhere CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='$(LIBLOCKDEP_VERSION)' -rdynamic -O0 -g -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: fd0587339d80dd2fea5ead7f734676c9c618eace Documentation: Reflect the new location of the NMI watchdog info Two small fixes. Thanks, Ingo --> Jean Delvare (1): Documentation: Reflect the new location of the NMI watchdog info Michal Hocko (1): nohz: Fix idle ticks in cpu summary line of /proc/stat Documentation/00-INDEX | 4 ++-- fs/proc/stat.c | 14 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX index 49c0513..fec55dc 100644 --- a/Documentation/00-INDEX +++ b/Documentation/00-INDEX @@ -210,6 +210,8 @@ local_ops.txt - semantics and behavior of local atomic operations. lockdep-design.txt - documentation on the runtime locking correctness validator. +lockup-watchdogs.txt + - info on soft and hard lockup detectors (aka nmi_watchdog). logo.gif - full colour GIF image of Linux logo (penguin - Tux). logo.txt @@ -240,8 +242,6 @@ netlabel/ - directory with information on the NetLabel subsystem. networking/ - directory with info on various aspects of networking with Linux. -nmi_watchdog.txt - - info on NMI watchdog for SMP systems. nommu-mmap.txt - documentation about no-mmu memory mapping support. numastat.txt diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 64c3b31..e296572 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -45,10 +45,13 @@ static cputime64_t get_iowait_time(int cpu) static u64 get_idle_time(int cpu) { - u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL); + u64 idle, idle_time = -1ULL; + + if (cpu_online(cpu)) + idle_time = get_cpu_idle_time_us(cpu, NULL); if (idle_time == -1ULL) - /* !NO_HZ so we can rely on cpustat.idle */ + /* !NO_HZ or cpu offline so we can rely on cpustat.idle */ idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; else idle = usecs_to_cputime64(idle_time); @@ -58,10 +61,13 @@ static u64 get_idle_time(int cpu) static u64 get_iowait_time(int cpu) { - u64 iowait, iowait_time = get_cpu_iowait_time_us(cpu, NULL); + u64 iowait, iowait_time = -1ULL; + + if (cpu_online(cpu)) + iowait_time = get_cpu_iowait_time_us(cpu, NULL); if (iowait_time == -1ULL) - /* !NO_HZ so we can rely on cpustat.iowait */ + /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */ iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT]; else iowait = usecs_to_cputime64(iowait_time); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: fd0587339d80dd2fea5ead7f734676c9c618eace Documentation: Reflect the new location of the NMI watchdog info Two small fixes. Thanks, Ingo -- Jean Delvare (1): Documentation: Reflect the new location of the NMI watchdog info Michal Hocko (1): nohz: Fix idle ticks in cpu summary line of /proc/stat Documentation/00-INDEX | 4 ++-- fs/proc/stat.c | 14 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX index 49c0513..fec55dc 100644 --- a/Documentation/00-INDEX +++ b/Documentation/00-INDEX @@ -210,6 +210,8 @@ local_ops.txt - semantics and behavior of local atomic operations. lockdep-design.txt - documentation on the runtime locking correctness validator. +lockup-watchdogs.txt + - info on soft and hard lockup detectors (aka nmi_watchdog). logo.gif - full colour GIF image of Linux logo (penguin - Tux). logo.txt @@ -240,8 +242,6 @@ netlabel/ - directory with information on the NetLabel subsystem. networking/ - directory with info on various aspects of networking with Linux. -nmi_watchdog.txt - - info on NMI watchdog for SMP systems. nommu-mmap.txt - documentation about no-mmu memory mapping support. numastat.txt diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 64c3b31..e296572 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -45,10 +45,13 @@ static cputime64_t get_iowait_time(int cpu) static u64 get_idle_time(int cpu) { - u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL); + u64 idle, idle_time = -1ULL; + + if (cpu_online(cpu)) + idle_time = get_cpu_idle_time_us(cpu, NULL); if (idle_time == -1ULL) - /* !NO_HZ so we can rely on cpustat.idle */ + /* !NO_HZ or cpu offline so we can rely on cpustat.idle */ idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; else idle = usecs_to_cputime64(idle_time); @@ -58,10 +61,13 @@ static u64 get_idle_time(int cpu) static u64 get_iowait_time(int cpu) { - u64 iowait, iowait_time = get_cpu_iowait_time_us(cpu, NULL); + u64 iowait, iowait_time = -1ULL; + + if (cpu_online(cpu)) + iowait_time = get_cpu_iowait_time_us(cpu, NULL); if (iowait_time == -1ULL) - /* !NO_HZ so we can rely on cpustat.iowait */ + /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */ iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT]; else iowait = usecs_to_cputime64(iowait_time); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] core kernel fixes for v3.7
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: f784e8a7989c0da3062d04bfea3db90f41e8f738 task_work: Simplify the usage in ptrace_notify() and get_signal_to_deliver() This is a complex task_work series from Oleg that fixes the bug that this VFS commit tried to fix: d35abdb28824 hold task_lock around checks in keyctl but solves the problem without the lockup regression that d35abdb28824 introduced in v3.6. This series came late in v3.6 and I did not feel confident about it so late in the cycle. Might be worth backporting to -stable if it proves itself upstream. Thanks, Ingo --> Oleg Nesterov (4): task_work: Make task_work_add() lockless task_work: task_work_add() should not succeed after exit_task_work() task_work: Revert "hold task_lock around checks in keyctl" task_work: Simplify the usage in ptrace_notify() and get_signal_to_deliver() include/linux/task_work.h | 3 +- kernel/signal.c | 18 ++-- kernel/task_work.c| 111 +- security/keys/keyctl.c| 2 - 4 files changed, 66 insertions(+), 68 deletions(-) diff --git a/include/linux/task_work.h b/include/linux/task_work.h index fb46b03..ca5a1cf 100644 --- a/include/linux/task_work.h +++ b/include/linux/task_work.h @@ -18,8 +18,7 @@ void task_work_run(void); static inline void exit_task_work(struct task_struct *task) { - if (unlikely(task->task_works)) - task_work_run(); + task_work_run(); } #endif /* _LINUX_TASK_WORK_H */ diff --git a/kernel/signal.c b/kernel/signal.c index be4f856..2c681f1 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1971,13 +1971,8 @@ static void ptrace_do_notify(int signr, int exit_code, int why) void ptrace_notify(int exit_code) { BUG_ON((exit_code & (0x7f | ~0x)) != SIGTRAP); - if (unlikely(current->task_works)) { - if (test_and_clear_ti_thread_flag(current_thread_info(), - TIF_NOTIFY_RESUME)) { - smp_mb__after_clear_bit(); - task_work_run(); - } - } + if (unlikely(current->task_works)) + task_work_run(); spin_lock_irq(>sighand->siglock); ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED); @@ -2198,13 +2193,8 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct signal_struct *signal = current->signal; int signr; - if (unlikely(current->task_works)) { - if (test_and_clear_ti_thread_flag(current_thread_info(), - TIF_NOTIFY_RESUME)) { - smp_mb__after_clear_bit(); - task_work_run(); - } - } + if (unlikely(current->task_works)) + task_work_run(); if (unlikely(uprobe_deny_signal())) return 0; diff --git a/kernel/task_work.c b/kernel/task_work.c index d320d44..65bd3c9 100644 --- a/kernel/task_work.c +++ b/kernel/task_work.c @@ -2,26 +2,20 @@ #include #include +static struct callback_head work_exited; /* all we need is ->next == NULL */ + int -task_work_add(struct task_struct *task, struct callback_head *twork, bool notify) +task_work_add(struct task_struct *task, struct callback_head *work, bool notify) { - struct callback_head *last, *first; - unsigned long flags; + struct callback_head *head; - /* -* Not inserting the new work if the task has already passed -* exit_task_work() is the responisbility of callers. -*/ - raw_spin_lock_irqsave(>pi_lock, flags); - last = task->task_works; - first = last ? last->next : twork; - twork->next = first; - if (last) - last->next = twork; - task->task_works = twork; - raw_spin_unlock_irqrestore(>pi_lock, flags); + do { + head = ACCESS_ONCE(task->task_works); + if (unlikely(head == _exited)) + return -ESRCH; + work->next = head; + } while (cmpxchg(>task_works, head, work) != head); - /* test_and_set_bit() implies mb(), see tracehook_notify_resume(). */ if (notify) set_notify_resume(task); return 0; @@ -30,52 +24,69 @@ task_work_add(struct task_struct *task, struct callback_head *twork, bool notify struct callback_head * task_work_cancel(struct task_struct *task, task_work_func_t func) { + struct callback_head **pprev = >task_works; + struct callback_head *work = NULL; unsigned long flags; - struct callback_head *last, *res = NULL; - + /* +* If cmpxchg() fails we continue without updating pprev. +* Either we raced with
[GIT PULL] core kernel fixes for v3.7
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: f784e8a7989c0da3062d04bfea3db90f41e8f738 task_work: Simplify the usage in ptrace_notify() and get_signal_to_deliver() This is a complex task_work series from Oleg that fixes the bug that this VFS commit tried to fix: d35abdb28824 hold task_lock around checks in keyctl but solves the problem without the lockup regression that d35abdb28824 introduced in v3.6. This series came late in v3.6 and I did not feel confident about it so late in the cycle. Might be worth backporting to -stable if it proves itself upstream. Thanks, Ingo -- Oleg Nesterov (4): task_work: Make task_work_add() lockless task_work: task_work_add() should not succeed after exit_task_work() task_work: Revert hold task_lock around checks in keyctl task_work: Simplify the usage in ptrace_notify() and get_signal_to_deliver() include/linux/task_work.h | 3 +- kernel/signal.c | 18 ++-- kernel/task_work.c| 111 +- security/keys/keyctl.c| 2 - 4 files changed, 66 insertions(+), 68 deletions(-) diff --git a/include/linux/task_work.h b/include/linux/task_work.h index fb46b03..ca5a1cf 100644 --- a/include/linux/task_work.h +++ b/include/linux/task_work.h @@ -18,8 +18,7 @@ void task_work_run(void); static inline void exit_task_work(struct task_struct *task) { - if (unlikely(task-task_works)) - task_work_run(); + task_work_run(); } #endif /* _LINUX_TASK_WORK_H */ diff --git a/kernel/signal.c b/kernel/signal.c index be4f856..2c681f1 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1971,13 +1971,8 @@ static void ptrace_do_notify(int signr, int exit_code, int why) void ptrace_notify(int exit_code) { BUG_ON((exit_code (0x7f | ~0x)) != SIGTRAP); - if (unlikely(current-task_works)) { - if (test_and_clear_ti_thread_flag(current_thread_info(), - TIF_NOTIFY_RESUME)) { - smp_mb__after_clear_bit(); - task_work_run(); - } - } + if (unlikely(current-task_works)) + task_work_run(); spin_lock_irq(current-sighand-siglock); ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED); @@ -2198,13 +2193,8 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct signal_struct *signal = current-signal; int signr; - if (unlikely(current-task_works)) { - if (test_and_clear_ti_thread_flag(current_thread_info(), - TIF_NOTIFY_RESUME)) { - smp_mb__after_clear_bit(); - task_work_run(); - } - } + if (unlikely(current-task_works)) + task_work_run(); if (unlikely(uprobe_deny_signal())) return 0; diff --git a/kernel/task_work.c b/kernel/task_work.c index d320d44..65bd3c9 100644 --- a/kernel/task_work.c +++ b/kernel/task_work.c @@ -2,26 +2,20 @@ #include linux/task_work.h #include linux/tracehook.h +static struct callback_head work_exited; /* all we need is -next == NULL */ + int -task_work_add(struct task_struct *task, struct callback_head *twork, bool notify) +task_work_add(struct task_struct *task, struct callback_head *work, bool notify) { - struct callback_head *last, *first; - unsigned long flags; + struct callback_head *head; - /* -* Not inserting the new work if the task has already passed -* exit_task_work() is the responisbility of callers. -*/ - raw_spin_lock_irqsave(task-pi_lock, flags); - last = task-task_works; - first = last ? last-next : twork; - twork-next = first; - if (last) - last-next = twork; - task-task_works = twork; - raw_spin_unlock_irqrestore(task-pi_lock, flags); + do { + head = ACCESS_ONCE(task-task_works); + if (unlikely(head == work_exited)) + return -ESRCH; + work-next = head; + } while (cmpxchg(task-task_works, head, work) != head); - /* test_and_set_bit() implies mb(), see tracehook_notify_resume(). */ if (notify) set_notify_resume(task); return 0; @@ -30,52 +24,69 @@ task_work_add(struct task_struct *task, struct callback_head *twork, bool notify struct callback_head * task_work_cancel(struct task_struct *task, task_work_func_t func) { + struct callback_head **pprev = task-task_works; + struct callback_head *work = NULL; unsigned long flags; - struct callback_head *last, *res = NULL; - + /* +* If cmpxchg() fails we continue without updating pprev.
Re: [GIT PULL] core kernel fixes
On 08/03/2012 10:01 AM, Ingo Molnar wrote: > > * Darren Hart wrote: > >> On 08/03/2012 09:31 AM, Ingo Molnar wrote: >>> Linus, >>> >>> Please pull the latest core-urgent-for-linus git tree from: >>> >>>git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git >>> core-urgent-for-linus >>> >>>HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == >>> uaddr2 in futex_wait_requeue_pi() >>> >>> Various futex fixes for bugs Darren Hart found via his >>> testsuite. >>> >> >> Minor correction. I fixed two bugs reported by Dave Jones >> (found with his trinity test) and Dan Carpenter through static >> analysis. The other I found while debugging the first two. >> Credit where credit is due. > > Hm, from the wording of the changelogs I thought you were > running those tests. Please put such bug reporting info into the > changelog and/or add a Reported-by tag next time around - > testers are our most valuable contributors. I see the attribution of the testing I left only in the cover letter, my apologies, sloppy of me. I had followed Dave's request that I mention trinity and CC him on bugs found with trinity - but looking at that patch now, it doesn't attribute that well enough. I'll correct this in the future. -- Darren Hart Intel Open Source Technology Center Yocto Project - Technical Lead - Linux Kernel -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PULL] core kernel fixes
* Darren Hart wrote: > On 08/03/2012 09:31 AM, Ingo Molnar wrote: > > Linus, > > > > Please pull the latest core-urgent-for-linus git tree from: > > > >git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git > > core-urgent-for-linus > > > >HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == > > uaddr2 in futex_wait_requeue_pi() > > > > Various futex fixes for bugs Darren Hart found via his > > testsuite. > > > > Minor correction. I fixed two bugs reported by Dave Jones > (found with his trinity test) and Dan Carpenter through static > analysis. The other I found while debugging the first two. > Credit where credit is due. Hm, from the wording of the changelogs I thought you were running those tests. Please put such bug reporting info into the changelog and/or add a Reported-by tag next time around - testers are our most valuable contributors. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PULL] core kernel fixes
On 08/03/2012 09:31 AM, Ingo Molnar wrote: > Linus, > > Please pull the latest core-urgent-for-linus git tree from: > >git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git > core-urgent-for-linus > >HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == > uaddr2 in futex_wait_requeue_pi() > > Various futex fixes for bugs Darren Hart found via his > testsuite. > Minor correction. I fixed two bugs reported by Dave Jones (found with his trinity test) and Dan Carpenter through static analysis. The other I found while debugging the first two. Credit where credit is due. Thanks, -- Darren Hart Intel Open Source Technology Center Yocto Project - Technical Lead - Linux Kernel -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() Various futex fixes for bugs Darren Hart found via his testsuite. Thanks, Ingo --> Darren Hart (3): futex: Test for pi_mutex on fault in futex_wait_requeue_pi() futex: Fix bug in WARN_ON for NULL q.pi_state futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() kernel/futex.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index e2b0fb9..3717e7b 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2231,11 +2231,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb, * @uaddr2:the pi futex we will take prior to returning to user-space * * The caller will wait on uaddr and will be requeued by futex_requeue() to - * uaddr2 which must be PI aware. Normal wakeup will wake on uaddr2 and - * complete the acquisition of the rt_mutex prior to returning to userspace. - * This ensures the rt_mutex maintains an owner when it has waiters; without - * one, the pi logic wouldn't know which task to boost/deboost, if there was a - * need to. + * uaddr2 which must be PI aware and unique from uaddr. Normal wakeup will wake + * on uaddr2 and complete the acquisition of the rt_mutex prior to returning to + * userspace. This ensures the rt_mutex maintains an owner when it has waiters; + * without one, the pi logic would not know which task to boost/deboost, if + * there was a need to. * * We call schedule in futex_wait_queue_me() when we enqueue and return there * via the following: @@ -2272,6 +2272,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, struct futex_q q = futex_q_init; int res, ret; + if (uaddr == uaddr2) + return -EINVAL; + if (!bitset) return -EINVAL; @@ -2343,7 +2346,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, * signal. futex_unlock_pi() will not destroy the lock_ptr nor * the pi_state. */ - WARN_ON(!_state); + WARN_ON(!q.pi_state); pi_mutex = _state->pi_mutex; ret = rt_mutex_finish_proxy_lock(pi_mutex, to, _waiter, 1); debug_rt_mutex_free_waiter(_waiter); @@ -2370,7 +2373,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, * fault, unlock the rt_mutex and return the fault to userspace. */ if (ret == -EFAULT) { - if (rt_mutex_owner(pi_mutex) == current) + if (pi_mutex && rt_mutex_owner(pi_mutex) == current) rt_mutex_unlock(pi_mutex); } else if (ret == -EINTR) { /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[GIT PULL] core kernel fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() Various futex fixes for bugs Darren Hart found via his testsuite. Thanks, Ingo -- Darren Hart (3): futex: Test for pi_mutex on fault in futex_wait_requeue_pi() futex: Fix bug in WARN_ON for NULL q.pi_state futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() kernel/futex.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index e2b0fb9..3717e7b 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2231,11 +2231,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb, * @uaddr2:the pi futex we will take prior to returning to user-space * * The caller will wait on uaddr and will be requeued by futex_requeue() to - * uaddr2 which must be PI aware. Normal wakeup will wake on uaddr2 and - * complete the acquisition of the rt_mutex prior to returning to userspace. - * This ensures the rt_mutex maintains an owner when it has waiters; without - * one, the pi logic wouldn't know which task to boost/deboost, if there was a - * need to. + * uaddr2 which must be PI aware and unique from uaddr. Normal wakeup will wake + * on uaddr2 and complete the acquisition of the rt_mutex prior to returning to + * userspace. This ensures the rt_mutex maintains an owner when it has waiters; + * without one, the pi logic would not know which task to boost/deboost, if + * there was a need to. * * We call schedule in futex_wait_queue_me() when we enqueue and return there * via the following: @@ -2272,6 +2272,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, struct futex_q q = futex_q_init; int res, ret; + if (uaddr == uaddr2) + return -EINVAL; + if (!bitset) return -EINVAL; @@ -2343,7 +2346,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, * signal. futex_unlock_pi() will not destroy the lock_ptr nor * the pi_state. */ - WARN_ON(!q.pi_state); + WARN_ON(!q.pi_state); pi_mutex = q.pi_state-pi_mutex; ret = rt_mutex_finish_proxy_lock(pi_mutex, to, rt_waiter, 1); debug_rt_mutex_free_waiter(rt_waiter); @@ -2370,7 +2373,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, * fault, unlock the rt_mutex and return the fault to userspace. */ if (ret == -EFAULT) { - if (rt_mutex_owner(pi_mutex) == current) + if (pi_mutex rt_mutex_owner(pi_mutex) == current) rt_mutex_unlock(pi_mutex); } else if (ret == -EINTR) { /* -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PULL] core kernel fixes
On 08/03/2012 09:31 AM, Ingo Molnar wrote: Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() Various futex fixes for bugs Darren Hart found via his testsuite. Minor correction. I fixed two bugs reported by Dave Jones (found with his trinity test) and Dan Carpenter through static analysis. The other I found while debugging the first two. Credit where credit is due. Thanks, -- Darren Hart Intel Open Source Technology Center Yocto Project - Technical Lead - Linux Kernel -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PULL] core kernel fixes
* Darren Hart dvh...@linux.intel.com wrote: On 08/03/2012 09:31 AM, Ingo Molnar wrote: Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() Various futex fixes for bugs Darren Hart found via his testsuite. Minor correction. I fixed two bugs reported by Dave Jones (found with his trinity test) and Dan Carpenter through static analysis. The other I found while debugging the first two. Credit where credit is due. Hm, from the wording of the changelogs I thought you were running those tests. Please put such bug reporting info into the changelog and/or add a Reported-by tag next time around - testers are our most valuable contributors. Thanks, Ingo -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [GIT PULL] core kernel fixes
On 08/03/2012 10:01 AM, Ingo Molnar wrote: * Darren Hart dvh...@linux.intel.com wrote: On 08/03/2012 09:31 AM, Ingo Molnar wrote: Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus HEAD: 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi() Various futex fixes for bugs Darren Hart found via his testsuite. Minor correction. I fixed two bugs reported by Dave Jones (found with his trinity test) and Dan Carpenter through static analysis. The other I found while debugging the first two. Credit where credit is due. Hm, from the wording of the changelogs I thought you were running those tests. Please put such bug reporting info into the changelog and/or add a Reported-by tag next time around - testers are our most valuable contributors. I see the attribution of the testing I left only in the cover letter, my apologies, sloppy of me. I had followed Dave's request that I mention trinity and CC him on bugs found with trinity - but looking at that patch now, it doesn't attribute that well enough. I'll correct this in the future. -- Darren Hart Intel Open Source Technology Center Yocto Project - Technical Lead - Linux Kernel -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/