25 Jan, 2021

1 commit


13 Jan, 2021

1 commit

  • [ Upstream commit 87dbc209ea04645fd2351981f09eff5d23f8e2e9 ]

    Make mandatory in include/asm-generic/Kbuild and
    remove all arch/*/include/asm/local64.h arch-specific files since they
    only #include .

    This fixes build errors on arch/c6x/ and arch/nios2/ for
    block/blk-iocost.c.

    Build-tested on 21 of 25 arch-es. (tools problems on the others)

    Yes, we could even rename to
    and change all #includes to use
    instead.

    Link: https://lkml.kernel.org/r/20201227024446.17018-1-rdunlap@infradead.org
    Signed-off-by: Randy Dunlap
    Suggested-by: Christoph Hellwig
    Reviewed-by: Masahiro Yamada
    Cc: Jens Axboe
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Aurelien Jacquiot
    Cc: Peter Zijlstra
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Randy Dunlap
     

22 Dec, 2020

1 commit

  • To enable seccomp constant action bitmaps, we need to have a static
    mapping to the audit architecture and system call table size. Add these
    for csky.

    Signed-off-by: YiFei Zhu
    Signed-off-by: Kees Cook
    Link: https://lore.kernel.org/r/f9219026d4803b22f3e57e3768b4e42e004ef236.1605101222.git.yifeifz2@illinois.edu
    (cherry picked from commit 6e9ae6f98809e0d123ff4d769ba2e6f652119138)
    Signed-off-by: Jeff Vander Stoep
    Bug: 176068146
    Change-Id: I1fea89150f06be98ea4ee4357ad441e60aa6589f

    YiFei Zhu
     

26 Oct, 2020

1 commit

  • Use a more generic form for __section that requires quotes to avoid
    complications with clang and gcc differences.

    Remove the quote operator # from compiler_attributes.h __section macro.

    Convert all unquoted __section(foo) uses to quoted __section("foo").
    Also convert __attribute__((section("foo"))) uses to __section("foo")
    even if the __attribute__ has multiple list entry forms.

    Conversion done using the script at:

    https://lore.kernel.org/lkml/75393e5ddc272dc7403de74d645e6c6e0f4e70eb.camel@perches.com/2-convert_section.pl

    Signed-off-by: Joe Perches
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Miguel Ojeda
    Signed-off-by: Linus Torvalds

    Joe Perches
     

13 Aug, 2020

1 commit

  • 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
     

08 Aug, 2020

1 commit

  • Most architectures define pgd_free() as a wrapper for free_page().

    Provide a generic version in asm-generic/pgalloc.h and enable its use for
    most architectures.

    Signed-off-by: Mike Rapoport
    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: Joerg Roedel
    Cc: Max Filippov
    Cc: Peter Zijlstra (Intel)
    Cc: Satheesh Rajendran
    Cc: Stafford Horne
    Cc: Stephen Rothwell
    Cc: Steven Rostedt
    Cc: Matthew Wilcox
    Link: http://lkml.kernel.org/r/20200627143453.31835-7-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

31 Jul, 2020

5 commits

  • Running work in hardware interrupt context for csky. Implement:
    - arch_irq_work_raise()
    - arch_irq_work_has_interrupt()

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • - Seperate different trap functions
    - Add trap_no()
    - Remove panic code print
    - Redesign die_if_kerenl to die with riscv's
    - Print exact trap info for app segment fault

    [ 17.389321] gzip[126]: unhandled signal 11 code 0x3 at 0x0007835a in busybox[8000+d4000]
    [ 17.393882]
    [ 17.393882] CURRENT PROCESS:
    [ 17.393882]
    [ 17.394309] COMM=gzip PID=126
    [ 17.394513] TEXT=00008000-000db2e4 DATA=000dcf14-000dd1ad BSS=000dd1ad-000ff000
    [ 17.395499] USER-STACK=7f888e50 KERNEL-STACK=bf130300
    [ 17.395499]
    [ 17.396801] PC: 0x0007835a (0x7835a)
    [ 17.397048] LR: 0x000058b4 (0x58b4)
    [ 17.397285] SP: 0xbe519f68
    [ 17.397555] orig_a0: 0x00002852
    [ 17.397886] PSR: 0x00020341
    [ 17.398356] a0: 0x00002852 a1: 0x000f2f5a a2: 0x0000d7ae a3: 0x0000005d
    [ 17.399289] r4: 0x000de150 r5: 0x00000002 r6: 0x00000102 r7: 0x00007efa
    [ 17.399800] r8: 0x7f888bc4 r9: 0x00000001 r10: 0x000002eb r11: 0x0000aac1
    [ 17.400166] r12: 0x00002ef2 r13: 0x00000007 r15: 0x000058b4
    [ 17.400531] r16: 0x0000004c r17: 0x00000031 r18: 0x000f5816 r19: 0x000e8068
    [ 17.401006] r20: 0x000f5818 r21: 0x000e8068 r22: 0x000f5918 r23: 0x90000000
    [ 17.401721] r24: 0x00000031 r25: 0x000000c8 r26: 0x00000000 r27: 0x00000000
    [ 17.402199] r28: 0x2ac2a000 r29: 0x00000000 r30: 0x00000000 tls: 0x2aadbaa8
    [ 17.402686] hi: 0x00120340 lo: 0x7f888bec
    /etc/init.ci/ntfs3g_run: line 61: 126 Segmentation fault gzip -c -9 /mnt/test.bin > /mnt/test_bin.gz

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • Inspired by the commit 42d038c4fb00 ("arm64: Add support for function
    error injection"), this patch supports function error injection for
    csky.

    This patch mainly support two functions: one is regs_set_return_value()
    which is used to overwrite the return value; the another function is
    override_function_with_return() which is to override the probed
    function returning and jump to its caller.

    Test log:

    cd /sys/kernel/debug/fail_function/
    echo sys_clone > inject
    echo 100 > probability
    echo 1 > interval
    ls /
    [ 108.644163] FAULT_INJECTION: forcing a failure.
    [ 108.644163] name fail_function, interval 1, probability 100, space 0, times 1
    [ 108.647799] CPU: 0 PID: 104 Comm: sh Not tainted 5.8.0-rc5+ #46
    [ 108.648384] Call Trace:
    [ 108.649339] [] walk_stackframe+0x0/0xf0
    [ 108.649679] [] show_stack+0x32/0x5c
    [ 108.649927] [] dump_stack+0x6e/0x9c
    [ 108.650271] [] should_fail+0x15e/0x1ac
    [ 108.650720] [] fei_kprobe_handler+0x28/0x5c
    [ 108.651519] [] kprobe_breakpoint_handler+0x144/0x1cc
    [ 108.652289] [] trap_c+0x8e/0x110
    [ 108.652816] [] csky_trap+0x5c/0x70
    -sh: can't fork: Invalid argument

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • secure_computing() is called first in syscall_trace_enter() so that
    a system call will be aborted quickly without doing succeeding syscall
    tracing if seccomp rules want to deny that system call.

    TODO:
    - Update https://github.com/seccomp/libseccomp csky support

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • These are used nowhere in the tree (except for some architectures which
    define them for their own use) and were already removed for other
    architectures in:

    commit 6474924e2b5d ("arch: remove unused macro/function thread_saved_pc()")
    commit c17c02040bf0 ("arch: remove unused *_segments() macros/functions")

    Remove them from arch/csky as well.

    Signed-off-by: Tobias Klauser
    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Tobias Klauser
     

10 Jun, 2020

3 commits

  • All architectures define pte_index() as

    (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)

    and all architectures define pte_offset_kernel() as an entry in the array
    of PTEs indexed by the pte_index().

    For the most architectures the pte_offset_kernel() implementation relies
    on the availability of pmd_page_vaddr() that converts a PMD entry value to
    the virtual address of the page containing PTEs array.

    Let's move x86 definitions of the PTE accessors to the generic place in
    and then simply drop the respective definitions from the
    other architectures.

    The architectures that didn't provide pmd_page_vaddr() are updated to have
    that defined.

    The generic implementation of pte_offset_kernel() can be overridden by an
    architecture and alpha makes use of this because it has special ordering
    requirements for its version of pte_offset_kernel().

    [rppt@linux.ibm.com: v2]
    Link: http://lkml.kernel.org/r/20200514170327.31389-11-rppt@kernel.org
    [rppt@linux.ibm.com: update]
    Link: http://lkml.kernel.org/r/20200514170327.31389-12-rppt@kernel.org
    [rppt@linux.ibm.com: update]
    Link: http://lkml.kernel.org/r/20200514170327.31389-13-rppt@kernel.org
    [akpm@linux-foundation.org: fix x86 warning]
    [sfr@canb.auug.org.au: fix powerpc build]
    Link: http://lkml.kernel.org/r/20200607153443.GB738695@linux.ibm.com

    Signed-off-by: Mike Rapoport
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brian Cain
    Cc: Catalin Marinas
    Cc: Chris Zankel
    Cc: "David S. Miller"
    Cc: Geert Uytterhoeven
    Cc: Greentime Hu
    Cc: Greg Ungerer
    Cc: Guan Xuetao
    Cc: Guo Ren
    Cc: Heiko Carstens
    Cc: Helge Deller
    Cc: Ingo Molnar
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Matthew Wilcox
    Cc: Matt Turner
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Nick Hu
    Cc: Paul Walmsley
    Cc: Richard Weinberger
    Cc: Rich Felker
    Cc: Russell King
    Cc: Stafford Horne
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Cc: Vincent Chen
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: http://lkml.kernel.org/r/20200514170327.31389-10-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     
  • All architectures use pXd_index() to get an entry in the page table page
    corresponding to a virtual address.

    Align csky with other architectures.

    Signed-off-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brian Cain
    Cc: Catalin Marinas
    Cc: Chris Zankel
    Cc: "David S. Miller"
    Cc: Geert Uytterhoeven
    Cc: Greentime Hu
    Cc: Greg Ungerer
    Cc: Guan Xuetao
    Cc: Guo Ren
    Cc: Heiko Carstens
    Cc: Helge Deller
    Cc: Ingo Molnar
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Matthew Wilcox
    Cc: Matt Turner
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Nick Hu
    Cc: Paul Walmsley
    Cc: Richard Weinberger
    Cc: Rich Felker
    Cc: Russell King
    Cc: Stafford Horne
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Cc: Vincent Chen
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: http://lkml.kernel.org/r/20200514170327.31389-5-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     
  • The include/linux/pgtable.h is going to be the home of generic page table
    manipulation functions.

    Start with moving asm-generic/pgtable.h to include/linux/pgtable.h and
    make the latter include asm/pgtable.h.

    Signed-off-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brian Cain
    Cc: Catalin Marinas
    Cc: Chris Zankel
    Cc: "David S. Miller"
    Cc: Geert Uytterhoeven
    Cc: Greentime Hu
    Cc: Greg Ungerer
    Cc: Guan Xuetao
    Cc: Guo Ren
    Cc: Heiko Carstens
    Cc: Helge Deller
    Cc: Ingo Molnar
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Matthew Wilcox
    Cc: Matt Turner
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Nick Hu
    Cc: Paul Walmsley
    Cc: Richard Weinberger
    Cc: Rich Felker
    Cc: Russell King
    Cc: Stafford Horne
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Cc: Vincent Chen
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: http://lkml.kernel.org/r/20200514170327.31389-3-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

05 Jun, 2020

6 commits

  • Most architectures define kmap_prot to be PAGE_KERNEL.

    Let sparc and xtensa define there own and define PAGE_KERNEL as the
    default if not overridden.

    [akpm@linux-foundation.org: coding style fixes]
    Suggested-by: Christoph Hellwig
    Signed-off-by: Ira Weiny
    Signed-off-by: Andrew Morton
    Cc: Al Viro
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Christian König
    Cc: Chris Zankel
    Cc: Daniel Vetter
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: "David S. Miller"
    Cc: Helge Deller
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Max Filippov
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20200507150004.1423069-16-ira.weiny@intel.com
    Signed-off-by: Linus Torvalds

    Ira Weiny
     
  • kmap_atomic_to_page() has no callers and is only defined on 1 arch and
    declared on another. Remove it.

    Suggested-by: Al Viro
    Signed-off-by: Ira Weiny
    Signed-off-by: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Christian König
    Cc: Christoph Hellwig
    Cc: Chris Zankel
    Cc: Daniel Vetter
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: "David S. Miller"
    Cc: Helge Deller
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Max Filippov
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20200507150004.1423069-13-ira.weiny@intel.com
    Signed-off-by: Linus Torvalds

    Ira Weiny
     
  • Every single architecture (including !CONFIG_HIGHMEM) calls...

    pagefault_enable();
    preempt_enable();

    ... before returning from __kunmap_atomic(). Lift this code into the
    kunmap_atomic() macro.

    While we are at it rename __kunmap_atomic() to kunmap_atomic_high() to
    be consistent.

    [ira.weiny@intel.com: don't enable pagefault/preempt twice]
    Link: http://lkml.kernel.org/r/20200518184843.3029640-1-ira.weiny@intel.com
    [akpm@linux-foundation.org: coding style fixes]
    Signed-off-by: Ira Weiny
    Signed-off-by: Andrew Morton
    Reviewed-by: Christoph Hellwig
    Cc: Al Viro
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Christian König
    Cc: Chris Zankel
    Cc: Daniel Vetter
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: "David S. Miller"
    Cc: Helge Deller
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Max Filippov
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Guenter Roeck
    Link: http://lkml.kernel.org/r/20200507150004.1423069-8-ira.weiny@intel.com
    Signed-off-by: Linus Torvalds

    Ira Weiny
     
  • Every arch has the same code to ensure atomic operations and a check for
    !HIGHMEM page.

    Remove the duplicate code by defining a core kmap_atomic() which only
    calls the arch specific kmap_atomic_high() when the page is high memory.

    [akpm@linux-foundation.org: coding style fixes]
    Signed-off-by: Ira Weiny
    Signed-off-by: Andrew Morton
    Reviewed-by: Christoph Hellwig
    Cc: Al Viro
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Christian König
    Cc: Chris Zankel
    Cc: Daniel Vetter
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: "David S. Miller"
    Cc: Helge Deller
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Max Filippov
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20200507150004.1423069-7-ira.weiny@intel.com
    Signed-off-by: Linus Torvalds

    Ira Weiny
     
  • All architectures do exactly the same thing for kunmap(); remove all the
    duplicate definitions and lift the call to the core.

    This also has the benefit of changing kmap_unmap() on a number of
    architectures to be an inline call rather than an actual function.

    [akpm@linux-foundation.org: fix CONFIG_HIGHMEM=n build on various architectures]
    Signed-off-by: Ira Weiny
    Signed-off-by: Andrew Morton
    Reviewed-by: Christoph Hellwig
    Cc: Al Viro
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Christian König
    Cc: Chris Zankel
    Cc: Daniel Vetter
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: "David S. Miller"
    Cc: Helge Deller
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Max Filippov
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20200507150004.1423069-5-ira.weiny@intel.com
    Signed-off-by: Linus Torvalds

    Ira Weiny
     
  • The kmap code for all the architectures is almost 100% identical.

    Lift the common code to the core. Use ARCH_HAS_KMAP_FLUSH_TLB to indicate
    if an arch defines kmap_flush_tlb() and call if if needed.

    This also has the benefit of changing kmap() on a number of architectures
    to be an inline call rather than an actual function.

    Signed-off-by: Ira Weiny
    Signed-off-by: Andrew Morton
    Reviewed-by: Christoph Hellwig
    Cc: Al Viro
    Cc: Andy Lutomirski
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Christian König
    Cc: Chris Zankel
    Cc: Daniel Vetter
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: "David S. Miller"
    Cc: Helge Deller
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Max Filippov
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20200507150004.1423069-4-ira.weiny@intel.com
    Signed-off-by: Linus Torvalds

    Ira Weiny
     

28 May, 2020

1 commit

  • There is no fixup or feature in the patch, we only cleanup with:

    - Remove unnecessary reg used (r11, r12), just use r9 & r10 &
    syscallid regs as temp useage.
    - Add _TIF_SYSCALL_WORK and _TIF_WORK_MASK to gather macros.

    Signed-off-by: Guo Ren

    Guo Ren
     

15 May, 2020

2 commits

  • If raw_copy_from_user(to, from, N) returns K, callers expect
    the first N - K bytes starting at to to have been replaced with
    the contents of corresponding area starting at from and the last
    K bytes of destination *left* *unmodified*.

    What arch/sky/lib/usercopy.c is doing is broken - it can lead to e.g.
    data corruption on write(2).

    raw_copy_to_user() is inaccurate about return value, which is a bug,
    but consequences are less drastic than for raw_copy_from_user().
    And just what are those access_ok() doing in there? I mean, look into
    linux/uaccess.h; that's where we do that check (as well as zero tail
    on failure in the callers that need zeroing).

    AFAICS, all of that shouldn't be hard to fix; something like a patch
    below might make a useful starting point.

    I would suggest moving these macros into usercopy.c (they are never
    used anywhere else) and possibly expanding them there; if you leave
    them alive, please at least rename __copy_user_zeroing(). Again,
    it must not zero anything on failed read.

    Said that, I'm not sure we won't be better off simply turning
    usercopy.c into usercopy.S - all that is left there is a couple of
    functions, each consisting only of inline asm.

    Guo Ren reply:

    Yes, raw_copy_from_user is wrong, it's no need zeroing code.

    unsigned long _copy_from_user(void *to, const void __user *from,
    unsigned long n)
    {
    unsigned long res = n;
    might_fault();
    if (likely(access_ok(from, n))) {
    kasan_check_write(to, n);
    res = raw_copy_from_user(to, from, n);
    }
    if (unlikely(res))
    memset(to + (n - res), 0, res);
    return res;
    }
    EXPORT_SYMBOL(_copy_from_user);

    You are right and access_ok() should be removed.

    but, how about:
    do {
    ...
    "2: stw %3, (%1, 0) \n" \
    + " subi %0, 4 \n" \
    "9: stw %4, (%1, 4) \n" \
    + " subi %0, 4 \n" \
    "10: stw %5, (%1, 8) \n" \
    + " subi %0, 4 \n" \
    "11: stw %6, (%1, 12) \n" \
    + " subi %0, 4 \n" \
    " addi %2, 16 \n" \
    " addi %1, 16 \n" \

    Don't expand __ex_table

    AI Viro reply:

    Hey, I've no idea about the instruction scheduling on csky -
    if that doesn't slow the things down, all the better. It's just
    that copy_to_user() and friends are on fairly hot codepaths,
    and in quite a few situations they will dominate the speed of
    e.g. read(2). So I tried to keep the fast path unchanged.
    Up to the architecture maintainers, obviously. Which would be
    you...

    As for the fixups size increase (__ex_table size is unchanged)...
    You have each of those macros expanded exactly once.
    So the size is not a serious argument, IMO - useless complexity
    would be, if it is, in fact, useless; the size... not really,
    especially since those extra subi will at least offset it.

    Again, up to you - asm optimizations of (essentially)
    memcpy()-style loops are tricky and can depend upon the
    fairly subtle details of architecture. So even on something
    I know reasonably well I would resort to direct experiments
    if I can't pass the buck to architecture maintainers.

    It *is* worth optimizing - this is where read() from a file
    that is already in page cache spends most of the time, etc.

    Guo Ren reply:

    Thx, after fixup some typo “sub %0, 4”, apply the patch.

    TODO:
    - user copy/from codes are still need optimizing.

    Signed-off-by: Al Viro
    Signed-off-by: Guo Ren

    Al Viro
     
  • The gdbmacros.txt use sp in thread_struct, but csky use ksp. This
    cause bttnobp fail to excute.

    TODO:
    - Still couldn't display the contents of stack.

    Signed-off-by: Guo Ren

    Guo Ren
     

13 May, 2020

3 commits

  • All processes' PSR could success from SETUP_MMU, so need set it
    in INIT_THREAD again.

    And use a3 instead of r7 in __switch_to for code convention.

    Signed-off-by: Guo Ren

    Guo Ren
     
  • The implementation of show_stack will panic with wrong fp:

    addr = *fp++;

    because the fp isn't checked properly.

    The current implementations of show_stack, wchan and stack_trace
    haven't been designed properly, so just deprecate them.

    This patch is a reference to riscv's way, all codes are modified from
    arm's. The patch is passed with:

    - cat /proc//stack
    - cat /proc//wchan
    - echo c > /proc/sysrq-trigger

    Signed-off-by: Guo Ren

    Guo Ren
     
  • This bug is from uprobe signal definition in thread_info.h. The
    instruction (andi) of abiv1 immediate is smaller than abiv2, then
    it will cause:

    AS arch/csky/kernel/entry.o
    arch/csky/kernel/entry.S: Assembler messages:
    arch/csky/kernel/entry.S:224: Error: Operand 2 immediate is overflow.

    Signed-off-by: Guo Ren

    Guo Ren
     

11 Apr, 2020

2 commits

  • Currently there are many platforms that dont enable ARCH_HAS_PTE_SPECIAL
    but required to define quite similar fallback stubs for special page
    table entry helpers such as pte_special() and pte_mkspecial(), as they
    get build in generic MM without a config check. This creates two
    generic fallback stub definitions for these helpers, eliminating much
    code duplication.

    mips platform has a special case where pte_special() and pte_mkspecial()
    visibility is wider than what ARCH_HAS_PTE_SPECIAL enablement requires.
    This restricts those symbol visibility in order to avoid redefinitions
    which is now exposed through this new generic stubs and subsequent build
    failure. arm platform set_pte_at() definition needs to be moved into a
    C file just to prevent a build failure.

    [anshuman.khandual@arm.com: use defined(CONFIG_ARCH_HAS_PTE_SPECIAL) in mips per Thomas]
    Link: http://lkml.kernel.org/r/1583851924-21603-1-git-send-email-anshuman.khandual@arm.com
    Signed-off-by: Anshuman Khandual
    Signed-off-by: Andrew Morton
    Acked-by: Guo Ren [csky]
    Acked-by: Geert Uytterhoeven [m68k]
    Acked-by: Stafford Horne [openrisc]
    Acked-by: Helge Deller [parisc]
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Russell King
    Cc: Brian Cain
    Cc: Tony Luck
    Cc: Fenghua Yu
    Cc: Sam Creasey
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: Nick Hu
    Cc: Greentime Hu
    Cc: Vincent Chen
    Cc: Ley Foon Tan
    Cc: Jonas Bonn
    Cc: Stefan Kristiansson
    Cc: "James E.J. Bottomley"
    Cc: "David S. Miller"
    Cc: Jeff Dike
    Cc: Richard Weinberger
    Cc: Anton Ivanov
    Cc: Guan Xuetao
    Cc: Chris Zankel
    Cc: Max Filippov
    Cc: Thomas Bogendoerfer
    Link: http://lkml.kernel.org/r/1583802551-15406-1-git-send-email-anshuman.khandual@arm.com
    Signed-off-by: Linus Torvalds

    Anshuman Khandual
     
  • There are many platforms with exact same value for VM_DATA_DEFAULT_FLAGS
    This creates a default value for VM_DATA_DEFAULT_FLAGS in line with the
    existing VM_STACK_DEFAULT_FLAGS. While here, also define some more
    macros with standard VMA access flag combinations that are used
    frequently across many platforms. Apart from simplification, this
    reduces code duplication as well.

    Signed-off-by: Anshuman Khandual
    Signed-off-by: Andrew Morton
    Reviewed-by: Vlastimil Babka
    Acked-by: Geert Uytterhoeven
    Cc: Richard Henderson
    Cc: Vineet Gupta
    Cc: Russell King
    Cc: Catalin Marinas
    Cc: Mark Salter
    Cc: Guo Ren
    Cc: Yoshinori Sato
    Cc: Brian Cain
    Cc: Tony Luck
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: Nick Hu
    Cc: Ley Foon Tan
    Cc: Jonas Bonn
    Cc: "James E.J. Bottomley"
    Cc: Michael Ellerman
    Cc: Paul Walmsley
    Cc: Heiko Carstens
    Cc: Rich Felker
    Cc: "David S. Miller"
    Cc: Guan Xuetao
    Cc: Thomas Gleixner
    Cc: Jeff Dike
    Cc: Chris Zankel
    Link: http://lkml.kernel.org/r/1583391014-8170-2-git-send-email-anshuman.khandual@arm.com
    Signed-off-by: Linus Torvalds

    Anshuman Khandual
     

07 Apr, 2020

1 commit

  • Pull csky updates from Guo Ren:

    - Add kproobes/uprobes support

    - Add lockdep, rseq, gcov support

    - Fixup init_fpu

    - Fixup ftrace_modify deadlock

    - Fixup speculative execution on IO area

    * tag 'csky-for-linus-5.7-rc1' of git://github.com/c-sky/csky-linux:
    csky: Fixup cpu speculative execution to IO area
    csky: Add uprobes support
    csky: Add kprobes supported
    csky: Enable LOCKDEP_SUPPORT
    csky: Enable the gcov function
    csky: Fixup get wrong psr value from phyical reg
    csky/ftrace: Fixup ftrace_modify_code deadlock without CPU_HAS_ICACHE_INS
    csky: Implement ftrace with regs
    csky: Add support for restartable sequence
    csky: Implement ptrace regs and stack API
    csky: Fixup init_fpu compile warning with __init

    Linus Torvalds
     

03 Apr, 2020

3 commits

  • This patch adds support for uprobes on csky architecture.

    Just like kprobe, it support single-step and simulate instructions.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann
    Cc: Steven Rostedt (VMware)

    Guo Ren
     
  • This patch enable kprobes, kretprobes, ftrace interface. It utilized
    software breakpoint and single step debug exceptions, instructions
    simulation on csky.

    We use USR_BKPT replace origin instruction, and the kprobe handler
    prepares an excutable memory slot for out-of-line execution with a
    copy of the original instruction being probed. Most of instructions
    could be executed by single-step, but some instructions need origin
    pc value to execute and we need software simulate these instructions.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann
    Cc: Steven Rostedt (VMware)

    Guo Ren
     
  • Change a header to mandatory-y if both of the following are met:

    [1] At least one architecture (except um) specifies it as generic-y in
    arch/*/include/asm/Kbuild

    [2] Every architecture (except um) either has its own implementation
    (arch/*/include/asm/*.h) or specifies it as generic-y in
    arch/*/include/asm/Kbuild

    This commit was generated by the following shell script.

    ----------------------------------->8-----------------------------------

    arches=$(cd arch; ls -1 | sed -e '/Kconfig/d' -e '/um/d')

    tmpfile=$(mktemp)

    grep "^mandatory-y +=" include/asm-generic/Kbuild > $tmpfile

    find arch -path 'arch/*/include/asm/Kbuild' |
    xargs sed -n 's/^generic-y += \(.*\)/\1/p' | sort -u |
    while read header
    do
    mandatory=yes

    for arch in $arches
    do
    if ! grep -q "generic-y += $header" arch/$arch/include/asm/Kbuild &&
    ! [ -f arch/$arch/include/asm/$header ]; then
    mandatory=no
    break
    fi
    done

    if [ "$mandatory" = yes ]; then
    echo "mandatory-y += $header" >> $tmpfile

    for arch in $arches
    do
    sed -i "/generic-y += $header/d" arch/$arch/include/asm/Kbuild
    done
    fi

    done

    sed -i '/^mandatory-y +=/d' include/asm-generic/Kbuild

    LANG=C sort $tmpfile >> include/asm-generic/Kbuild

    ----------------------------------->8-----------------------------------

    One obvious benefit is the diff stat:

    25 files changed, 52 insertions(+), 557 deletions(-)

    It is tedious to list generic-y for each arch that needs it.

    So, mandatory-y works like a fallback default (by just wrapping
    asm-generic one) when arch does not have a specific header
    implementation.

    See the following commits:

    def3f7cefe4e81c296090e1722a76551142c227c
    a1b39bae16a62ce4aae02d958224f19316d98b24

    It is tedious to convert headers one by one, so I processed by a shell
    script.

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Andrew Morton
    Cc: Michal Simek
    Cc: Christoph Hellwig
    Cc: Arnd Bergmann
    Link: http://lkml.kernel.org/r/20200210175452.5030-1-masahiroy@kernel.org
    Signed-off-by: Linus Torvalds

    Masahiro Yamada
     

01 Apr, 2020

1 commit


21 Mar, 2020

1 commit

  • The defconfig compiles without linux/mm.h. With mm.h included the
    include chain leands to:
    | CC kernel/locking/percpu-rwsem.o
    | In file included from include/linux/huge_mm.h:8,
    | from include/linux/mm.h:567,
    | from arch/csky/include/asm/uaccess.h:,
    | from include/linux/uaccess.h:11,
    | from include/linux/sched/task.h:11,
    | from include/linux/sched/signal.h:9,
    | from include/linux/rcuwait.h:6,
    | from include/linux/percpu-rwsem.h:8,
    | from kernel/locking/percpu-rwsem.c:6:
    | include/linux/fs.h:1422:29: error: array type has incomplete element type 'struct percpu_rw_semaphore'
    | 1422 | struct percpu_rw_semaphore rw_sem[SB_FREEZE_LEVELS];

    once rcuwait.h includes linux/sched/signal.h.

    Remove the linux/mm.h include.

    Reported-by: kbuild test robot
    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Thomas Gleixner
    Signed-off-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20200321113241.434999165@linutronix.de

    Sebastian Andrzej Siewior
     

08 Mar, 2020

2 commits

  • This patch implements FTRACE_WITH_REGS for csky, which allows a traced
    function's arguments (and some other registers) to be captured into a
    struct pt_regs, allowing these to be inspected and/or modified.

    Signed-off-by: Guo Ren

    Guo Ren
     
  • Needed for kprobes support. Copied and adapted from Patrick's patch,
    but it has been modified for csky's pt_regs.

    ref:
    https://lore.kernel.org/linux-riscv/1572919114-3886-2-git-send-email-vincent.chen@sifive.com/raw

    Signed-off-by: Guo Ren
    Cc: Patrick Staehlin

    Guo Ren
     

21 Feb, 2020

4 commits