24 Nov, 2020

1 commit

  • We call arch_cpu_idle() with RCU disabled, but then use
    local_irq_{en,dis}able(), which invokes tracing, which relies on RCU.

    Switch all arch_cpu_idle() implementations to use
    raw_local_irq_{en,dis}able() and carefully manage the
    lockdep,rcu,tracing state like we do in entry.

    (XXX: we really should change arch_cpu_idle() to not return with
    interrupts enabled)

    Reported-by: Sven Schnelle
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Mark Rutland
    Tested-by: Mark Rutland
    Link: https://lkml.kernel.org/r/20201120114925.594122626@infradead.org

    Peter Zijlstra
     

24 Oct, 2020

1 commit

  • Pull arch task_work cleanups from Jens Axboe:
    "Two cleanups that don't fit other categories:

    - Finally get the task_work_add() cleanup done properly, so we don't
    have random 0/1/false/true/TWA_SIGNAL confusing use cases. Updates
    all callers, and also fixes up the documentation for
    task_work_add().

    - While working on some TIF related changes for 5.11, this
    TIF_NOTIFY_RESUME cleanup fell out of that. Remove some arch
    duplication for how that is handled"

    * tag 'arch-cleanup-2020-10-22' of git://git.kernel.dk/linux-block:
    task_work: cleanup notification modes
    tracehook: clear TIF_NOTIFY_RESUME in tracehook_notify_resume()

    Linus Torvalds
     

23 Oct, 2020

1 commit

  • Pull initial set_fs() removal from Al Viro:
    "Christoph's set_fs base series + fixups"

    * 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Allow a NULL pos pointer to __kernel_read
    fs: Allow a NULL pos pointer to __kernel_write
    powerpc: remove address space overrides using set_fs()
    powerpc: use non-set_fs based maccess routines
    x86: remove address space overrides using set_fs()
    x86: make TASK_SIZE_MAX usable from assembly code
    x86: move PAGE_OFFSET, TASK_SIZE & friends to page_{32,64}_types.h
    lkdtm: remove set_fs-based tests
    test_bitmap: remove user bitmap tests
    uaccess: add infrastructure for kernel builds with set_fs()
    fs: don't allow splice read/write without explicit ops
    fs: don't allow kernel reads and writes without iter ops
    sysctl: Convert to iter interfaces
    proc: add a read_iter method to proc proc_ops
    proc: cleanup the compat vs no compat file ops
    proc: remove a level of indentation in proc_get_inode

    Linus Torvalds
     

18 Oct, 2020

1 commit


16 Oct, 2020

1 commit

  • Pull dma-mapping updates from Christoph Hellwig:

    - rework the non-coherent DMA allocator

    - move private definitions out of

    - lower CMA_ALIGNMENT (Paul Cercueil)

    - remove the omap1 dma address translation in favor of the common code

    - make dma-direct aware of multiple dma offset ranges (Jim Quinlan)

    - support per-node DMA CMA areas (Barry Song)

    - increase the default seg boundary limit (Nicolin Chen)

    - misc fixes (Robin Murphy, Thomas Tai, Xu Wang)

    - various cleanups

    * tag 'dma-mapping-5.10' of git://git.infradead.org/users/hch/dma-mapping: (63 commits)
    ARM/ixp4xx: add a missing include of dma-map-ops.h
    dma-direct: simplify the DMA_ATTR_NO_KERNEL_MAPPING handling
    dma-direct: factor out a dma_direct_alloc_from_pool helper
    dma-direct check for highmem pages in dma_direct_alloc_pages
    dma-mapping: merge into
    dma-mapping: move large parts of to kernel/dma
    dma-mapping: move dma-debug.h to kernel/dma/
    dma-mapping: remove
    dma-mapping: merge into
    dma-contiguous: remove dma_contiguous_set_default
    dma-contiguous: remove dev_set_cma_area
    dma-contiguous: remove dma_declare_contiguous
    dma-mapping: split
    cma: decrease CMA_ALIGNMENT lower limit to 2
    firewire-ohci: use dma_alloc_pages
    dma-iommu: implement ->alloc_noncoherent
    dma-mapping: add new {alloc,free}_noncoherent dma_map_ops methods
    dma-mapping: add a new dma_alloc_pages API
    dma-mapping: remove dma_cache_sync
    53c700: convert to dma_alloc_noncoherent
    ...

    Linus Torvalds
     

14 Oct, 2020

2 commits

  • There are several occurrences of the following pattern:

    for_each_memblock(memory, reg) {
    start = __pfn_to_phys(memblock_region_memory_base_pfn(reg);
    end = __pfn_to_phys(memblock_region_memory_end_pfn(reg));

    /* do something with start and end */
    }

    Using for_each_mem_range() iterator is more appropriate in such cases and
    allows simpler and cleaner code.

    [akpm@linux-foundation.org: fix arch/arm/mm/pmsa-v7.c build]
    [rppt@linux.ibm.com: mips: fix cavium-octeon build caused by memblock refactoring]
    Link: http://lkml.kernel.org/r/20200827124549.GD167163@linux.ibm.com

    Signed-off-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Baoquan He
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Catalin Marinas
    Cc: Christoph Hellwig
    Cc: Daniel Axtens
    Cc: Dave Hansen
    Cc: Emil Renner Berthing
    Cc: Hari Bathini
    Cc: Ingo Molnar
    Cc: Ingo Molnar
    Cc: Jonathan Cameron
    Cc: Marek Szyprowski
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Miguel Ojeda
    Cc: Palmer Dabbelt
    Cc: Paul Mackerras
    Cc: Paul Walmsley
    Cc: Peter Zijlstra
    Cc: Russell King
    Cc: Stafford Horne
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: https://lkml.kernel.org/r/20200818151634.14343-13-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     
  • Instead of traversing memblock.memory regions to find memory_start and
    memory_end, simply query memblock_{start,end}_of_DRAM().

    Signed-off-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Acked-by: Stafford Horne
    Cc: Andy Lutomirski
    Cc: Baoquan He
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Catalin Marinas
    Cc: Christoph Hellwig
    Cc: Daniel Axtens
    Cc: Dave Hansen
    Cc: Emil Renner Berthing
    Cc: Hari Bathini
    Cc: Ingo Molnar
    Cc: Ingo Molnar
    Cc: Jonathan Cameron
    Cc: Marek Szyprowski
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Miguel Ojeda
    Cc: Palmer Dabbelt
    Cc: Paul Mackerras
    Cc: Paul Walmsley
    Cc: Peter Zijlstra
    Cc: Russell King
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: https://lkml.kernel.org/r/20200818151634.14343-6-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

13 Oct, 2020

1 commit

  • Pull orphan section checking from Ingo Molnar:
    "Orphan link sections were a long-standing source of obscure bugs,
    because the heuristics that various linkers & compilers use to handle
    them (include these bits into the output image vs discarding them
    silently) are both highly idiosyncratic and also version dependent.

    Instead of this historically problematic mess, this tree by Kees Cook
    (et al) adds build time asserts and build time warnings if there's any
    orphan section in the kernel or if a section is not sized as expected.

    And because we relied on so many silent assumptions in this area, fix
    a metric ton of dependencies and some outright bugs related to this,
    before we can finally enable the checks on the x86, ARM and ARM64
    platforms"

    * tag 'core-build-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits)
    x86/boot/compressed: Warn on orphan section placement
    x86/build: Warn on orphan section placement
    arm/boot: Warn on orphan section placement
    arm/build: Warn on orphan section placement
    arm64/build: Warn on orphan section placement
    x86/boot/compressed: Add missing debugging sections to output
    x86/boot/compressed: Remove, discard, or assert for unwanted sections
    x86/boot/compressed: Reorganize zero-size section asserts
    x86/build: Add asserts for unwanted sections
    x86/build: Enforce an empty .got.plt section
    x86/asm: Avoid generating unused kprobe sections
    arm/boot: Handle all sections explicitly
    arm/build: Assert for unwanted sections
    arm/build: Add missing sections
    arm/build: Explicitly keep .ARM.attributes sections
    arm/build: Refactor linker script headers
    arm64/build: Assert for unwanted sections
    arm64/build: Add missing DWARF sections
    arm64/build: Use common DISCARDS in linker script
    arm64/build: Remove .eh_frame* sections due to unwind tables
    ...

    Linus Torvalds
     

06 Oct, 2020

1 commit


13 Sep, 2020

1 commit

  • Pull OpenRISC fixes from Stafford Horne:
    "Fixes for compile issues pointed out by kbuild and one bug I found in
    initrd with the 5.9 patches"

    * tag 'for-linus' of git://github.com/openrisc/linux:
    openrisc: Fix issue with get_user for 64-bit values
    openrisc: Fix cache API compile issue when not inlining
    openrisc: Reserve memblock for initrd

    Linus Torvalds
     

12 Sep, 2020

1 commit

  • A build failure was raised by kbuild with the following error.

    drivers/android/binder.c: Assembler messages:
    drivers/android/binder.c:3861: Error: unrecognized keyword/register name `l.lwz ?ap,4(r24)'
    drivers/android/binder.c:3866: Error: unrecognized keyword/register name `l.addi ?ap,r0,0'

    The issue is with 64-bit get_user() calls on openrisc. I traced this to
    a problem where in the internally in the get_user macros there is a cast
    to long __gu_val this causes GCC to think the get_user call is 32-bit.
    This binder code is really long and GCC allocates register r30, which
    triggers the issue. The 64-bit get_user asm tries to get the 64-bit pair
    register, which for r30 overflows the general register names and returns
    the dummy register ?ap.

    The fix here is to move the temporary variables into the asm macros. We
    use a 32-bit __gu_tmp for 32-bit and smaller macro and a 64-bit tmp in
    the 64-bit macro. The cast in the 64-bit macro has a trick of casting
    through __typeof__((x)-(x)) which avoids the below warning. This was
    barrowed from riscv.

    arch/openrisc/include/asm/uaccess.h:240:8: warning: cast to pointer from integer of different size

    I tested this in a small unit test to check reading between 64-bit and
    32-bit pointers to 64-bit and 32-bit values in all combinations. Also I
    ran make C=1 to confirm no new sparse warnings came up. It all looks
    clean to me.

    Link: https://lore.kernel.org/lkml/202008200453.ohnhqkjQ%25lkp@intel.com/
    Signed-off-by: Stafford Horne
    Reviewed-by: Luc Van Oostenryck

    Stafford Horne
     

09 Sep, 2020

1 commit

  • Add a CONFIG_SET_FS option that is selected by architecturess that
    implement set_fs, which is all of them initially. If the option is not
    set stubs for routines related to overriding the address space are
    provided so that architectures can start to opt out of providing set_fs.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Kees Cook
    Signed-off-by: Al Viro

    Christoph Hellwig
     

07 Sep, 2020

2 commits

  • I found this when compiling a kbuild random config with GCC 11. The
    config enables CONFIG_DEBUG_SECTION_MISMATCH, which sets CFLAGS
    -fno-inline-functions-called-once. This causes the call to cache_loop in
    cache.c to not be inlined causing the below compile error.

    In file included from arch/openrisc/mm/cache.c:13:
    arch/openrisc/mm/cache.c: In function 'cache_loop':
    ./arch/openrisc/include/asm/spr.h:16:27: warning: 'asm' operand 0 probably does not match constraints
    16 | #define mtspr(_spr, _val) __asm__ __volatile__ ( \
    | ^~~~~~~
    arch/openrisc/mm/cache.c:25:3: note: in expansion of macro 'mtspr'
    25 | mtspr(reg, line);
    | ^~~~~
    ./arch/openrisc/include/asm/spr.h:16:27: error: impossible constraint in 'asm'
    16 | #define mtspr(_spr, _val) __asm__ __volatile__ ( \
    | ^~~~~~~
    arch/openrisc/mm/cache.c:25:3: note: in expansion of macro 'mtspr'
    25 | mtspr(reg, line);
    | ^~~~~
    make[1]: *** [scripts/Makefile.build:283: arch/openrisc/mm/cache.o] Error 1

    The asm constraint "K" requires a immediate constant argument to mtspr,
    however because of no inlining a register argument is passed causing a
    failure. Fix this by using __always_inline.

    Link: https://lore.kernel.org/lkml/202008200453.ohnhqkjQ%25lkp@intel.com/
    Signed-off-by: Stafford Horne

    Stafford Horne
     
  • Recently OpenRISC added support for external initrd images, but I found
    some instability when using larger buildroot initrd images. It turned
    out that I forgot to reserve the memblock space for the initrd image.

    This patch fixes the instability issue by reserving memblock space.

    Fixes: ff6c923dbec3 ("openrisc: Add support for external initrd images")
    Signed-off-by: Stafford Horne
    Reviewed-by: Mike Rapoport

    Stafford Horne
     

01 Sep, 2020

1 commit

  • The .comment section doesn't belong in STABS_DEBUG. Split it out into a
    new macro named ELF_DETAILS. This will gain other non-debug sections
    that need to be accounted for when linking with --orphan-handling=warn.

    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org
    Link: https://lore.kernel.org/r/20200821194310.3089815-5-keescook@chromium.org

    Kees Cook
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

15 Aug, 2020

1 commit

  • Pull OpenRISC updates from Stafford Horne:
    "A few patches all over the place during this cycle, mostly bug and
    sparse warning fixes for OpenRISC, but a few enhancements too. Note,
    there are 2 non OpenRISC specific fixups.

    Non OpenRISC fixes:

    - In init we need to align the init_task correctly to fix an issue
    with MUTEX_FLAGS, reviewed by Peter Z. No one picked this up so I
    kept it on my tree.

    - In asm-generic/io.h I fixed up some sparse warnings, OK'd by Arnd.
    Arnd asked to merge it via my tree.

    OpenRISC fixes:

    - Many fixes for OpenRISC sprase warnings.

    - Add support OpenRISC SMP tlb flushing rather than always flushing
    the entire TLB on every CPU.

    - Fix bug when dumping stack via /proc/xxx/stack of user threads"

    * tag 'for-linus' of git://github.com/openrisc/linux:
    openrisc: uaccess: Add user address space check to access_ok
    openrisc: signal: Fix sparse address space warnings
    openrisc: uaccess: Remove unused macro __addr_ok
    openrisc: uaccess: Use static inline function in access_ok
    openrisc: uaccess: Fix sparse address space warnings
    openrisc: io: Fixup defines and move include to the end
    asm-generic/io.h: Fix sparse warnings on big-endian architectures
    openrisc: Implement proper SMP tlb flushing
    openrisc: Fix oops caused when dumping stack
    openrisc: Add support for external initrd images
    init: Align init_task to avoid conflict with MUTEX_FLAGS
    openrisc: fix __user in raw_copy_to_user()'s prototype

    Linus Torvalds
     

13 Aug, 2020

3 commits

  • Use the general page fault accounting by passing regs into
    handle_mm_fault(). It naturally solve the issue of multiple page fault
    accounting when page fault retry happened.

    Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the
    other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in
    handle_mm_fault().

    Signed-off-by: Peter Xu
    Signed-off-by: Andrew Morton
    Acked-by: Stafford Horne
    Cc: Jonas Bonn
    Cc: Stefan Kristiansson
    Link: http://lkml.kernel.org/r/20200707225021.200906-15-peterx@redhat.com
    Signed-off-by: Linus Torvalds

    Peter Xu
     
  • Patch series "mm: Page fault accounting cleanups", v5.

    This is v5 of the pf accounting cleanup series. It originates from Gerald
    Schaefer's report on an issue a week ago regarding to incorrect page fault
    accountings for retried page fault after commit 4064b9827063 ("mm: allow
    VM_FAULT_RETRY for multiple times"):

    https://lore.kernel.org/lkml/20200610174811.44b94525@thinkpad/

    What this series did:

    - Correct page fault accounting: we do accounting for a page fault
    (no matter whether it's from #PF handling, or gup, or anything else)
    only with the one that completed the fault. For example, page fault
    retries should not be counted in page fault counters. Same to the
    perf events.

    - Unify definition of PERF_COUNT_SW_PAGE_FAULTS: currently this perf
    event is used in an adhoc way across different archs.

    Case (1): for many archs it's done at the entry of a page fault
    handler, so that it will also cover e.g. errornous faults.

    Case (2): for some other archs, it is only accounted when the page
    fault is resolved successfully.

    Case (3): there're still quite some archs that have not enabled
    this perf event.

    Since this series will touch merely all the archs, we unify this
    perf event to always follow case (1), which is the one that makes most
    sense. And since we moved the accounting into handle_mm_fault, the
    other two MAJ/MIN perf events are well taken care of naturally.

    - Unify definition of "major faults": the definition of "major
    fault" is slightly changed when used in accounting (not
    VM_FAULT_MAJOR). More information in patch 1.

    - Always account the page fault onto the one that triggered the page
    fault. This does not matter much for #PF handlings, but mostly for
    gup. More information on this in patch 25.

    Patchset layout:

    Patch 1: Introduced the accounting in handle_mm_fault(), not enabled.
    Patch 2-23: Enable the new accounting for arch #PF handlers one by one.
    Patch 24: Enable the new accounting for the rest outliers (gup, iommu, etc.)
    Patch 25: Cleanup GUP task_struct pointer since it's not needed any more

    This patch (of 25):

    This is a preparation patch to move page fault accountings into the
    general code in handle_mm_fault(). This includes both the per task
    flt_maj/flt_min counters, and the major/minor page fault perf events. To
    do this, the pt_regs pointer is passed into handle_mm_fault().

    PERF_COUNT_SW_PAGE_FAULTS should still be kept in per-arch page fault
    handlers.

    So far, all the pt_regs pointer that passed into handle_mm_fault() is
    NULL, which means this patch should have no intented functional change.

    Suggested-by: Linus Torvalds
    Signed-off-by: Peter Xu
    Signed-off-by: Andrew Morton
    Cc: Albert Ou
    Cc: Alexander Gordeev
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Brian Cain
    Cc: Catalin Marinas
    Cc: Christian Borntraeger
    Cc: Chris Zankel
    Cc: Dave Hansen
    Cc: David S. Miller
    Cc: Geert Uytterhoeven
    Cc: Gerald Schaefer
    Cc: Greentime Hu
    Cc: Guo Ren
    Cc: Heiko Carstens
    Cc: Helge Deller
    Cc: H. Peter Anvin
    Cc: Ingo Molnar
    Cc: Ivan Kokshaysky
    Cc: James E.J. Bottomley
    Cc: John Hubbard
    Cc: Jonas Bonn
    Cc: Ley Foon Tan
    Cc: "Luck, Tony"
    Cc: Matt Turner
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Nick Hu
    Cc: Palmer Dabbelt
    Cc: Paul Mackerras
    Cc: Paul Walmsley
    Cc: Pekka Enberg
    Cc: Peter Zijlstra
    Cc: Richard Henderson
    Cc: Rich Felker
    Cc: Russell King
    Cc: Stafford Horne
    Cc: Stefan Kristiansson
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Vasily Gorbik
    Cc: Vincent Chen
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: http://lkml.kernel.org/r/20200707225021.200906-1-peterx@redhat.com
    Link: http://lkml.kernel.org/r/20200707225021.200906-2-peterx@redhat.com
    Signed-off-by: Linus Torvalds

    Peter Xu
     
  • segment_eq is only used to implement uaccess_kernel. Just open code
    uaccess_kernel in the arch uaccess headers and remove one layer of
    indirection.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Acked-by: Linus Torvalds
    Acked-by: Greentime Hu
    Acked-by: Geert Uytterhoeven
    Cc: Nick Hu
    Cc: Vincent Chen
    Cc: Paul Walmsley
    Cc: Palmer Dabbelt
    Link: http://lkml.kernel.org/r/20200710135706.537715-5-hch@lst.de
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

10 Aug, 2020

1 commit

  • Pull regset conversion fix from Al Viro:
    "Fix a regression from an unnoticed bisect hazard in the regset series.

    A bunch of old (aout, originally) primitives used by coredumps became
    dead code after fdpic conversion to regsets. Removal of that dead code
    had been the first commit in the followups to regset series;
    unfortunately, it happened to hide the bisect hazard on sh (extern for
    fpregs_get() had not been updated in the main series when it should
    have been; followup simply made fpregs_get() static). And without that
    followup commit this bisect hazard became breakage in the mainline"

    Tested-by: John Paul Adrian Glaubitz

    * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    kill unused dump_fpu() instances

    Linus Torvalds
     

09 Aug, 2020

5 commits

  • Now that __user annotations are fixed for openrisc uaccess api's we can
    add checking to the access_ok macro. This patch adds the __chk_user_ptr
    check, on normal builds the added check is a nop.

    Signed-off-by: Stafford Horne
    Reviewed-by: Luc Van Oostenryck

    Stafford Horne
     
  • The __user annotations in signal.c were mostly missing. The missing
    annotations caused the warnings listed below. This patch fixes them up
    by adding the __user annotations.

    arch/openrisc/kernel/signal.c:71:38: warning: incorrect type in initializer (different address spaces)
    arch/openrisc/kernel/signal.c:71:38: expected struct rt_sigframe *frame
    arch/openrisc/kernel/signal.c:71:38: got struct rt_sigframe [noderef] __user *
    arch/openrisc/kernel/signal.c:82:14: warning: incorrect type in argument 1 (different address spaces)
    arch/openrisc/kernel/signal.c:82:14: expected void const volatile [noderef] __user *
    arch/openrisc/kernel/signal.c:82:14: got struct rt_sigframe *frame
    arch/openrisc/kernel/signal.c:84:37: warning: incorrect type in argument 2 (different address spaces)
    arch/openrisc/kernel/signal.c:84:37: expected void const [noderef] __user *from
    arch/openrisc/kernel/signal.c:84:37: got struct sigset_t *
    arch/openrisc/kernel/signal.c:89:39: warning: incorrect type in argument 2 (different address spaces)
    arch/openrisc/kernel/signal.c:89:39: expected struct sigcontext [noderef] __user *sc
    arch/openrisc/kernel/signal.c:89:39: got struct sigcontext *
    arch/openrisc/kernel/signal.c:92:31: warning: incorrect type in argument 1 (different address spaces)
    arch/openrisc/kernel/signal.c:92:31: expected struct sigaltstack const [noderef] [usertype] __user *
    arch/openrisc/kernel/signal.c:92:31: got struct sigaltstack *
    arch/openrisc/kernel/signal.c:158:15: warning: incorrect type in assignment (different address spaces)
    arch/openrisc/kernel/signal.c:158:15: expected struct rt_sigframe *frame
    arch/openrisc/kernel/signal.c:158:15: got void [noderef] __user *
    arch/openrisc/kernel/signal.c:160:14: warning: incorrect type in argument 1 (different address spaces)
    arch/openrisc/kernel/signal.c:160:14: expected void const volatile [noderef] __user *
    arch/openrisc/kernel/signal.c:160:14: got struct rt_sigframe *frame
    arch/openrisc/kernel/signal.c:165:46: warning: incorrect type in argument 1 (different address spaces)
    arch/openrisc/kernel/signal.c:165:46: expected struct siginfo [noderef] [usertype] __user *to
    arch/openrisc/kernel/signal.c:165:46: got struct siginfo *
    arch/openrisc/kernel/signal.c:170:33: warning: incorrect type in argument 1 (different address spaces)
    arch/openrisc/kernel/signal.c:170:33: expected struct sigaltstack [noderef] [usertype] __user *
    arch/openrisc/kernel/signal.c:170:33: got struct sigaltstack *
    arch/openrisc/kernel/signal.c:171:40: warning: incorrect type in argument 2 (different address spaces)
    arch/openrisc/kernel/signal.c:171:40: expected struct sigcontext [noderef] __user *sc
    arch/openrisc/kernel/signal.c:171:40: got struct sigcontext *
    arch/openrisc/kernel/signal.c:173:32: warning: incorrect type in argument 1 (different address spaces)
    arch/openrisc/kernel/signal.c:173:32: expected void [noderef] __user *to
    arch/openrisc/kernel/signal.c:173:32: got struct sigset_t *

    Signed-off-by: Stafford Horne
    Reviewed-by: Luc Van Oostenryck

    Stafford Horne
     
  • Since commit b48b2c3e5043 ("openrisc: use generic strnlen_user()
    function") the macro __addr_ok is no longer used. It is safe to remove
    so this patch removes it.

    Signed-off-by: Stafford Horne

    Stafford Horne
     
  • As suggested by Linus when reviewing commit 9cb2feb4d21d
    ("arch/openrisc: Fix issues with access_ok()") last year; making
    __range_ok an inline function also fixes the used twice issue that the
    commit was fixing. I agree it's a good cleanup. This patch addresses
    that as I am currently working on the access_ok macro to fixup sparse
    annotations in OpenRISC.

    Suggested-by: Linus Torvalds
    Signed-off-by: Stafford Horne
    Reviewed-by: Luc Van Oostenryck

    Stafford Horne
     
  • The OpenRISC user access functions put_user(), get_user() and
    clear_user() were missing proper sparse annotations. This generated
    warnings like the below.

    This patch adds the annotations to fix the warnings.

    Example warnings:

    net/ipv4/ip_sockglue.c:759:29: warning: incorrect type in argument 1 (different address spaces)
    net/ipv4/ip_sockglue.c:759:29: expected void const volatile [noderef] __user *
    net/ipv4/ip_sockglue.c:759:29: got int const *__gu_addr
    net/ipv4/ip_sockglue.c:764:29: warning: incorrect type in initializer (different address spaces)
    net/ipv4/ip_sockglue.c:764:29: expected unsigned char const *__gu_addr
    net/ipv4/ip_sockglue.c:764:29: got unsigned char [noderef] __user *

    Signed-off-by: Stafford Horne
    Reviewed-by: Luc Van Oostenryck

    Stafford Horne
     

08 Aug, 2020

4 commits

  • Merge misc updates from Andrew Morton:

    - a few MM hotfixes

    - kthread, tools, scripts, ntfs and ocfs2

    - some of MM

    Subsystems affected by this patch series: kthread, tools, scripts, ntfs,
    ocfs2 and mm (hofixes, pagealloc, slab-generic, slab, slub, kcsan,
    debug, pagecache, gup, swap, shmem, memcg, pagemap, mremap, mincore,
    sparsemem, vmalloc, kasan, pagealloc, hugetlb and vmscan).

    * emailed patches from Andrew Morton : (162 commits)
    mm: vmscan: consistent update to pgrefill
    mm/vmscan.c: fix typo
    khugepaged: khugepaged_test_exit() check mmget_still_valid()
    khugepaged: retract_page_tables() remember to test exit
    khugepaged: collapse_pte_mapped_thp() protect the pmd lock
    khugepaged: collapse_pte_mapped_thp() flush the right range
    mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible
    mm: thp: replace HTTP links with HTTPS ones
    mm/page_alloc: fix memalloc_nocma_{save/restore} APIs
    mm/page_alloc.c: skip setting nodemask when we are in interrupt
    mm/page_alloc: fallbacks at most has 3 elements
    mm/page_alloc: silence a KASAN false positive
    mm/page_alloc.c: remove unnecessary end_bitidx for [set|get]_pfnblock_flags_mask()
    mm/page_alloc.c: simplify pageblock bitmap access
    mm/page_alloc.c: extract the common part in pfn_to_bitidx()
    mm/page_alloc.c: replace the definition of NR_MIGRATETYPE_BITS with PB_migratetype_bits
    mm/shuffle: remove dynamic reconfiguration
    mm/memory_hotplug: document why shuffle_zone() is relevant
    mm/page_alloc: remove nr_free_pagecache_pages()
    mm: remove vm_total_pages
    ...

    Linus Torvalds
     
  • Replace pte_alloc_one(), pte_free() and pte_free_kernel() with the generic
    implementation. The only actual functional change is the addition of
    __GFP_ACCOUT for the allocation of the user page tables.

    The pte_alloc_one_kernel() is kept back because its implementation on
    openrisc is different than the generic one.

    Signed-off-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Reviewed-by: Pekka Enberg
    Acked-by: Stafford Horne
    Cc: Abdul Haleem
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Christophe Leroy
    Cc: Joerg Roedel
    Cc: Joerg Roedel
    Cc: Max Filippov
    Cc: Peter Zijlstra (Intel)
    Cc: Satheesh Rajendran
    Cc: Stephen Rothwell
    Cc: Steven Rostedt
    Cc: Geert Uytterhoeven
    Cc: Matthew Wilcox
    Link: http://lkml.kernel.org/r/20200627143453.31835-3-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     
  • Patch series "mm: cleanup usage of "

    Most architectures have very similar versions of pXd_alloc_one() and
    pXd_free_one() for intermediate levels of page table. These patches add
    generic versions of these functions in and enable
    use of the generic functions where appropriate.

    In addition, functions declared and defined in headers are
    used mostly by core mm and early mm initialization in arch and there is no
    actual reason to have the included all over the place.
    The first patch in this series removes unneeded includes of

    In the end it didn't work out as neatly as I hoped and moving
    pXd_alloc_track() definitions to would require
    unnecessary changes to arches that have custom page table allocations, so
    I've decided to move lib/ioremap.c to mm/ and make pgalloc-track.h local
    to mm/.

    This patch (of 8):

    In most cases header is required only for allocations of
    page table memory. Most of the .c files that include that header do not
    use symbols declared in and do not require that header.

    As for the other header files that used to include , it is
    possible to move that include into the .c file that actually uses symbols
    from and drop the include from the header file.

    The process was somewhat automated using

    sed -i -E '/[
    Signed-off-by: Andrew Morton
    Reviewed-by: Pekka Enberg
    Acked-by: Geert Uytterhoeven [m68k]
    Cc: Abdul Haleem
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Christophe Leroy
    Cc: Joerg Roedel
    Cc: Max Filippov
    Cc: Peter Zijlstra
    Cc: Satheesh Rajendran
    Cc: Stafford Horne
    Cc: Stephen Rothwell
    Cc: Steven Rostedt
    Cc: Joerg Roedel
    Cc: Matthew Wilcox
    Link: http://lkml.kernel.org/r/20200627143453.31835-1-rppt@kernel.org
    Link: http://lkml.kernel.org/r/20200627143453.31835-2-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     
  • Pull ptrace regset updates from Al Viro:
    "Internal regset API changes:

    - regularize copy_regset_{to,from}_user() callers

    - switch to saner calling conventions for ->get()

    - kill user_regset_copyout()

    The ->put() side of things will have to wait for the next cycle,
    unfortunately.

    The balance is about -1KLoC and replacements for ->get() instances are
    a lot saner"

    * 'work.regset' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (41 commits)
    regset: kill user_regset_copyout{,_zero}()
    regset(): kill ->get_size()
    regset: kill ->get()
    csky: switch to ->regset_get()
    xtensa: switch to ->regset_get()
    parisc: switch to ->regset_get()
    nds32: switch to ->regset_get()
    nios2: switch to ->regset_get()
    hexagon: switch to ->regset_get()
    h8300: switch to ->regset_get()
    openrisc: switch to ->regset_get()
    riscv: switch to ->regset_get()
    c6x: switch to ->regset_get()
    ia64: switch to ->regset_get()
    arc: switch to ->regset_get()
    arm: switch to ->regset_get()
    sh: convert to ->regset_get()
    arm64: switch to ->regset_get()
    mips: switch to ->regset_get()
    sparc: switch to ->regset_get()
    ...

    Linus Torvalds
     

06 Aug, 2020

1 commit

  • This didn't seem to cause any issues, but while working on fixing up
    sparse annotations for OpenRISC I noticed this. This patch moves the
    include of asm-generic/io.h to the end of the file. Also, we add
    defines of ioremap and iounmap, that way we don't get duplicate
    definitions from asm-generic/io.h.

    Signed-off-by: Stafford Horne

    Stafford Horne
     

05 Aug, 2020

1 commit

  • Pull fork cleanups from Christian Brauner:
    "This is cleanup series from when we reworked a chunk of the process
    creation paths in the kernel and switched to struct
    {kernel_}clone_args.

    High-level this does two main things:

    - Remove the double export of both do_fork() and _do_fork() where
    do_fork() used the incosistent legacy clone calling convention.

    Now we only export _do_fork() which is based on struct
    kernel_clone_args.

    - Remove the copy_thread_tls()/copy_thread() split making the
    architecture specific HAVE_COYP_THREAD_TLS config option obsolete.

    This switches all remaining architectures to select
    HAVE_COPY_THREAD_TLS and thus to the copy_thread_tls() calling
    convention. The current split makes the process creation codepaths
    more convoluted than they need to be. Each architecture has their own
    copy_thread() function unless it selects HAVE_COPY_THREAD_TLS then it
    has a copy_thread_tls() function.

    The split is not needed anymore nowadays, all architectures support
    CLONE_SETTLS but quite a few of them never bothered to select
    HAVE_COPY_THREAD_TLS and instead simply continued to use copy_thread()
    and use the old calling convention. Removing this split cleans up the
    process creation codepaths and paves the way for implementing clone3()
    on such architectures since it requires the copy_thread_tls() calling
    convention.

    After having made each architectures support copy_thread_tls() this
    series simply renames that function back to copy_thread(). It also
    switches all architectures that call do_fork() directly over to
    _do_fork() and the struct kernel_clone_args calling convention. This
    is a corollary of switching the architectures that did not yet support
    it over to copy_thread_tls() since do_fork() is conditional on not
    supporting copy_thread_tls() (Mostly because it lacks a separate
    argument for tls which is trivial to fix but there's no need for this
    function to exist.).

    The do_fork() removal is in itself already useful as it allows to to
    remove the export of both do_fork() and _do_fork() we currently have
    in favor of only _do_fork(). This has already been discussed back when
    we added clone3(). The legacy clone() calling convention is - as is
    probably well-known - somewhat odd:

    #
    # ABI hall of shame
    #
    config CLONE_BACKWARDS
    config CLONE_BACKWARDS2
    config CLONE_BACKWARDS3

    that is aggravated by the fact that some architectures such as sparc
    follow the CLONE_BACKWARDSx calling convention but don't really select
    the corresponding config option since they call do_fork() directly.

    So do_fork() enforces a somewhat arbitrary calling convention in the
    first place that doesn't really help the individual architectures that
    deviate from it. They can thus simply be switched to _do_fork()
    enforcing a single calling convention. (I really hope that any new
    architectures will __not__ try to implement their own calling
    conventions...)

    Most architectures already have made a similar switch (m68k comes to
    mind).

    Overall this removes more code than it adds even with a good portion
    of added comments. It simplifies a chunk of arch specific assembly
    either by moving the code into C or by simply rewriting the assembly.

    Architectures that have been touched in non-trivial ways have all been
    actually boot and stress tested: sparc and ia64 have been tested with
    Debian 9 images. They are the two architectures which have been
    touched the most. All non-trivial changes to architectures have seen
    acks from the relevant maintainers. nios2 with a custom built
    buildroot image. h8300 I couldn't get something bootable to test on
    but the changes have been fairly automatic and I'm sure we'll hear
    people yell if I broke something there.

    All other architectures that have been touched in trivial ways have
    been compile tested for each single patch of the series via git rebase
    -x "make ..." v5.8-rc2. arm{64} and x86{_64} have been boot tested
    even though they have just been trivially touched (removal of the
    HAVE_COPY_THREAD_TLS macro from their Kconfig) because well they are
    basically "core architectures" and since it is trivial to get your
    hands on a useable image"

    * tag 'fork-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux:
    arch: rename copy_thread_tls() back to copy_thread()
    arch: remove HAVE_COPY_THREAD_TLS
    unicore: switch to copy_thread_tls()
    sh: switch to copy_thread_tls()
    nds32: switch to copy_thread_tls()
    microblaze: switch to copy_thread_tls()
    hexagon: switch to copy_thread_tls()
    c6x: switch to copy_thread_tls()
    alpha: switch to copy_thread_tls()
    fork: remove do_fork()
    h8300: select HAVE_COPY_THREAD_TLS, switch to kernel_clone_args
    nios2: enable HAVE_COPY_THREAD_TLS, switch to kernel_clone_args
    ia64: enable HAVE_COPY_THREAD_TLS, switch to kernel_clone_args
    sparc: unconditionally enable HAVE_COPY_THREAD_TLS
    sparc: share process creation helpers between sparc and sparc64
    sparc64: enable HAVE_COPY_THREAD_TLS
    fork: fold legacy_clone_args_valid() into _do_fork()

    Linus Torvalds
     

04 Aug, 2020

4 commits

  • Up until now when flushing pages from the TLB on SMP OpenRISC was always
    resorting to flush the entire TLB on all CPUs. This patch adds the
    mechanics for flushing specific ranges and pages based on the usage.

    The function switch_mm is updated to account for cpu usage by updating
    mm_struct's cpumask. This is used in the SMP flush routines.

    This mostly follows the riscv implementation.

    Signed-off-by: Stafford Horne

    Stafford Horne
     
  • When dumping a stack with 'cat /proc/#/stack' the kernel would oops.
    For example:

    # cat /proc/690/stack
    Unable to handle kernel access
    at virtual address 0x7fc60f58

    Oops#: 0000
    CPU #: 0
    PC: c00097fc SR: 0000807f SP: d6f09b9c
    GPR00: 00000000 GPR01: d6f09b9c GPR02: d6f09bb8 GPR03: d6f09bc4
    GPR04: 7fc60f5c GPR05: c00099b4 GPR06: 00000000 GPR07: d6f09ba3
    GPR08: ffffff00 GPR09: c0009804 GPR10: d6f08000 GPR11: 00000000
    GPR12: ffffe000 GPR13: dbb86000 GPR14: 00000001 GPR15: dbb86250
    GPR16: 7fc60f63 GPR17: 00000f5c GPR18: d6f09bc4 GPR19: 00000000
    GPR20: c00099b4 GPR21: ffffffc0 GPR22: 00000000 GPR23: 00000000
    GPR24: 00000001 GPR25: 000002c6 GPR26: d78b6850 GPR27: 00000001
    GPR28: 00000000 GPR29: dbb86000 GPR30: ffffffff GPR31: dbb862fc
    RES: 00000000 oGPR11: ffffffff
    Process cat (pid: 702, stackpage=d79d6000)

    Stack:
    Call trace:
    [] save_stack_trace_tsk+0x40/0x74
    [] stack_trace_save_tsk+0x44/0x58
    [] proc_pid_stack+0xd0/0x13c
    [] proc_single_show+0x6c/0xf0
    [] seq_read+0x1b4/0x688
    [] do_iter_read+0x208/0x248
    [] vfs_readv+0x64/0x90

    This was caused by the stack trace code in save_stack_trace_tsk using
    the wrong stack pointer. It was using the user stack pointer instead of
    the kernel stack pointer. Fix this by using the right stack.

    Also for good measure we add try_get_task_stack/put_task_stack to ensure
    the task is not lost while we are walking it's stack.

    Fixes: eecac38b0423a ("openrisc: support framepointers and STACKTRACE_SUPPORT")
    Signed-off-by: Stafford Horne

    Stafford Horne
     
  • In OpenRISC we set the initrd_start and initrd_end based on the symbols
    we setup in vmlinux.lds.S. However, this is not needed if we use the
    generic linker description in INIT_DATA_SECTION.

    Removing our own initrd setup reduces code, but also the generic code
    supports loading external initrd images. A bootloader can load a rootfs
    image into memory and we can configure devicetree to load it with:

    chosen {
    bootargs = "earlycon";
    stdout-path = "uart0:115200";
    linux,initrd-start = < 0x08000100 >;
    linux,initrd-end = < 0x08200000 >;
    };

    Reported-by: Mateusz Holenko
    Signed-off-by: Stafford Horne

    Stafford Horne
     
  • raw_copy_to_user()'s prototype seems to be a copy & paste of
    raw_copy_from_user() and as such has the __user annotation
    in the 'from' argument instead of the 'to'.

    So, move the __user annotation in the prototype to the 'to'.

    Reported-by: kernel test robot
    Signed-off-by: Luc Van Oostenryck
    Signed-off-by: Stafford Horne

    Luc Van Oostenryck
     

28 Jul, 2020

2 commits


05 Jul, 2020

2 commits

  • Now that HAVE_COPY_THREAD_TLS has been removed, rename copy_thread_tls()
    back simply copy_thread(). It's a simpler name, and doesn't imply that only
    tls is copied here. This finishes an outstanding chunk of internal process
    creation work since we've added clone3().

    Cc: linux-arch@vger.kernel.org
    Acked-by: Thomas Bogendoerfer A
    Acked-by: Stafford Horne
    Acked-by: Greentime Hu
    Acked-by: Geert Uytterhoeven A
    Reviewed-by: Kees Cook
    Signed-off-by: Christian Brauner

    Christian Brauner
     
  • All architectures support copy_thread_tls() now, so remove the legacy
    copy_thread() function and the HAVE_COPY_THREAD_TLS config option. Everyone
    uses the same process creation calling convention based on
    copy_thread_tls() and struct kernel_clone_args. This will make it easier to
    maintain the core process creation code under kernel/, simplifies the
    callpaths and makes the identical for all architectures.

    Cc: linux-arch@vger.kernel.org
    Acked-by: Thomas Bogendoerfer
    Acked-by: Greentime Hu
    Acked-by: Geert Uytterhoeven
    Reviewed-by: Kees Cook
    Signed-off-by: Christian Brauner

    Christian Brauner