27 Apr, 2015

1 commit

  • Pull arch/cris updates from Jesper Nilsson:
    "Some much needed love for the CRIS-port.

    There's a bunch of changes this time, giving the CRISv32 port a bit of
    modern makeover with device-tree, irq domain and gpiolib support, and
    more switchover to generic frameworks.

    Some small fixes and removal of the theoretical SMP support brings up
    the rear"

    * tag 'cris-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper/cris:
    cris: fix integer overflow in ELF_ET_DYN_BASE
    CRISv32: use GENERIC_SCHED_CLOCK
    CRISv32: use MMIO clocksource
    CRISv32: use generic clockevents
    CRIS: use generic headers via Kbuild
    CRIS: use generic cmpxchg.h
    CRIS: use generic atomic.h
    CRIS: use generic atomic bitops
    CRISv10: remove redundant macros from system.h
    CRIS: remove SMP code
    CRISv32: don't enable irqs in INIT_THREAD
    CRISv32: handle multiple signals
    CRISv32: prevent bogus restarts on sigreturn
    CRISv32: don't attempt syscall restart on irq exit
    Add binding documentation for CRIS
    CRIS: add Axis 88 board device tree
    CRISv32: add device tree support
    CRISv32: add irq domains support
    CRIS: enable GPIOLIB

    Linus Torvalds
     

16 Apr, 2015

3 commits

  • Merge second patchbomb from Andrew Morton:

    - the rest of MM

    - various misc bits

    - add ability to run /sbin/reboot at reboot time

    - printk/vsprintf changes

    - fiddle with seq_printf() return value

    * akpm: (114 commits)
    parisc: remove use of seq_printf return value
    lru_cache: remove use of seq_printf return value
    tracing: remove use of seq_printf return value
    cgroup: remove use of seq_printf return value
    proc: remove use of seq_printf return value
    s390: remove use of seq_printf return value
    cris fasttimer: remove use of seq_printf return value
    cris: remove use of seq_printf return value
    openrisc: remove use of seq_printf return value
    ARM: plat-pxa: remove use of seq_printf return value
    nios2: cpuinfo: remove use of seq_printf return value
    microblaze: mb: remove use of seq_printf return value
    ipc: remove use of seq_printf return value
    rtc: remove use of seq_printf return value
    power: wakeup: remove use of seq_printf return value
    x86: mtrr: if: remove use of seq_printf return value
    linux/bitmap.h: improve BITMAP_{LAST,FIRST}_WORD_MASK
    MAINTAINERS: CREDITS: remove Stefano Brivio from B43
    .mailmap: add Ricardo Ribalda
    CREDITS: add Ricardo Ribalda Delgado
    ...

    Linus Torvalds
     
  • The seq_printf return value, because it's frequently misused,
    will eventually be converted to void.

    See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
    seq_has_overflowed() and make public")

    Miscellanea:

    o Coalesce formats, realign arguments

    Signed-off-by: Joe Perches
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • The seq_printf return value, because it's frequently misused,
    will eventually be converted to void.

    See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
    seq_has_overflowed() and make public")

    Signed-off-by: Joe Perches
    Acked-by: Jesper Nilsson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

13 Apr, 2015

1 commit


25 Mar, 2015

18 commits

  • Almost all arches define ELF_ET_DYN_BASE as 2/3 of TASK_SIZE.
    Though it seems that some architectures do this in a wrong way.
    The problem is that 2*TASK_SIZE may overflow 32-bits so
    the real ELF_ET_DYN_BASE becomes wrong.
    Fix this overflow by dividing TASK_SIZE prior to multiplying:
    (TASK_SIZE / 3 * 2)

    Signed-off-by: Andrey Ryabinin
    Signed-off-by: Jesper Nilsson

    Andrey Ryabinin
     
  • Provide a fast sched clock using the free-running timer and the generic
    sched_clock infrastructure.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Use a generic MMIO clocksource and get rid of some lines of code.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Implement a oneshot-capable clockevents device so we get support for
    things like hrtimers and NOHZ.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Delete headers which do nothing but include the asm-generic versions and
    use Kbuild magic instead.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • CRIS can use asm-generic's cmpxchg.h

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • CRIS can use asm-generic's atomic.h.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • The generic atomic bitops are the same as the CRIS-specific ones.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • All of these are either unused or already provided by other headers, so
    they can be removed.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • The CRIS SMP code cannot be built since there is no (and appears to
    never have been) a CONFIG_SMP Kconfig option in arch/cris/. Remove it.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • INIT_THREAD enables interrupts in the thread_struct's saved flags. This
    means that interrupts get enabled in the middle of context_switch()
    while switching to new tasks that get forked off the init task during
    boot. Don't do this.

    Fixes the following splat on boot with spinlock debugging on:

    BUG: spinlock cpu recursion on CPU#0, swapper/2
    lock: runqueues+0x0/0x47c, .magic: dead4ead, .owner: swapper/0,
    .owner_cpu: 0
    CPU: 0 PID: 2 Comm: swapper Not tainted 3.19.0-08796-ga747b55 #285

    Call Trace:
    [] spin_bug+0x2a/0x36
    [] do_raw_spin_lock+0xa2/0x126
    [] _raw_spin_lock+0x20/0x2a
    [] scheduler_tick+0x22/0x76
    [] update_process_times+0x5e/0x72
    [] timer_interrupt+0x4e/0x6a
    [] handle_irq_event_percpu+0x54/0xf2
    [] handle_irq_event+0x50/0x74
    [] handle_simple_irq+0x6c/0xbe
    [] generic_handle_irq+0x2a/0x36
    [] do_IRQ+0x38/0x84
    [] crisv32_do_IRQ+0x54/0x60
    [] IRQ0x4b_interrupt+0x34/0x3c
    [] __schedule+0x24a/0x532
    [] ret_from_kernel_thread+0x0/0x14

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Al Viro noted that CRIS fails to handle multiple signals.

    This fixes the problem for CRISv32 by making it use a C work_pending
    handling loop similar to the ARM implementation in 0a267fa6a15d41c
    ("ARM: 7472/1: pull all work_pending logics into C function").

    This also happens to fixes the warnings which currently trigger on
    CRISv32 due to do_signal() being called with interrupts disabled.

    Test case (should die of the SIGSEGV which gets raised when setting up
    the stack for SIGALRM, but instead reaches and executes the _exit(1)):

    #include
    #include
    #include
    #include

    static void handler(int sig) { }

    int main(int argc, char *argv[])
    {
    int ret;
    struct itimerval t1 = { .it_value = {1} };
    stack_t ss = {
    .ss_sp = NULL,
    .ss_size = SIGSTKSZ,
    };
    struct sigaction action = {
    .sa_handler = handler,
    .sa_flags = SA_ONSTACK,
    };

    ret = sigaltstack(&ss, NULL);
    if (ret < 0)
    err(1, "sigaltstack");

    sigaction(SIGALRM, &action, NULL);
    setitimer(ITIMER_REAL, &t1, NULL);

    pause();

    _exit(1);

    return 0;
    }

    Reported-by: Al Viro
    Link: http://lkml.kernel.org/r/20121208074429.GC4939@ZenIV.linux.org.uk
    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Al Viro noted that CRIS is vulnerable to bogus restarts on sigreturn.

    The fixes CRISv32 by using regs->exs as an additional indicator to
    whether we should attempt to restart the syscall or not. EXS is only
    used in the sigtrap handling, and in that path we already have r9 (the
    other indicator, which indicates if we're in a syscall or not) cleared.

    Test case, a port of Al's ARM version from 653d48b22166db2d8 ("arm: fix
    really nasty sigreturn bug"):

    #include
    #include
    #include
    #include
    #include

    void f(int n)
    {
    register int r10 asm ("r10") = n;

    __asm__ __volatile__(
    "ba 1f \n"
    "nop \n"
    "break 8 \n"
    "1: ba . \n"
    "nop \n"
    :
    : "r" (r10)
    : "memory");
    }

    void handler1(int sig) { }
    void handler2(int sig) { raise(1); }
    void handler3(int sig) { exit(0); }

    int main(int argc, char *argv[])
    {
    struct sigaction s = {.sa_handler = handler2};
    struct itimerval t1 = { .it_value = {1} };
    struct itimerval t2 = { .it_value = {2} };

    signal(1, handler1);

    sigemptyset(&s.sa_mask);
    sigaddset(&s.sa_mask, 1);
    sigaction(SIGALRM, &s, NULL);

    signal(SIGVTALRM, handler3);

    setitimer(ITIMER_REAL, &t1, NULL);
    setitimer(ITIMER_VIRTUAL, &t2, NULL);

    f(-513); /* -ERESTARTNOINTR */

    return 0;
    }

    Reported-by: Al Viro
    Link: http://lkml.kernel.org/r/20121208074429.GC4939@ZenIV.linux.org.uk
    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • r9 is used to determine whether syscall restarting must be performed or
    not. Unfortunately, r9 is never set to zero in the non-syscall path,
    and r9 is on top of that a callee-saved register which can be set to
    non-zero by the C functions that are called during IRQ handling.

    This means that if r10 (used for the syscall return value) is one of the
    -ERESTART* values when a hardware interrupt occurs which leads to a
    signal being delivered to the process, the kernel will "restart" a
    syscall which never occurred. This will lead to the PC being moved back
    by 2 on return to user space.

    Fix the problem by setting r9 to zero in the interrupt path.

    Test case (should loop forever but ends up executing the break 8 trap
    instruction):

    #include
    #include
    #include

    void f(int n)
    {
    register int r9 asm ("r9") = 1;
    register int r10 asm ("r10") = n;

    __asm__ __volatile__(
    "ba 1f \n"
    "nop \n"
    "break 8 \n"
    "1: ba . \n"
    "nop \n"
    :
    : "r" (r9), "r" (r10)
    : "memory");
    }

    void handler1(int sig) { }

    int main(int argc, char *argv[])
    {
    struct itimerval t1 = { .it_value = {1} };

    signal(SIGALRM, handler1);
    setitimer(ITIMER_REAL, &t1, NULL);

    f(-513); /* -ERESTARTNOINTR */

    return 0;
    }

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Add a minimal device tree for the ETRAX FS SoC and the Axis 88 developer
    board.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Add support for booting CRISv32 with a built-in device tree.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Add support for IRQ domains to the CRISv32 interrupt controller.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     
  • Enable GPIOLIB on CRIS so that we can use the generic GPIO APIs.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Jesper Nilsson

    Rabin Vincent
     

16 Feb, 2015

1 commit

  • Pull CRIS changes from Jesper Nilsson.

    * tag 'cris-for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper/cris:
    CRIS: Whitespace cleanup
    CRIS: macro whitespace fixes in uaccess.h
    CRIS: uaccess: fix sparse errors
    CRISv32: Remove unnecessary KERN_INFO from sync_serial
    CRIS: Fix missing NR_CPUS in menuconfig
    CRISv32: Avoid warning of unused variable
    CRIS: Avoid warning in cris mm/fault.c
    CRIS: Export csum_partial_copy_nocheck

    Linus Torvalds
     

15 Feb, 2015

4 commits


13 Feb, 2015

1 commit

  • If an attacker can cause a controlled kernel stack overflow, overwriting
    the restart block is a very juicy exploit target. This is because the
    restart_block is held in the same memory allocation as the kernel stack.

    Moving the restart block to struct task_struct prevents this exploit by
    making the restart_block harder to locate.

    Note that there are other fields in thread_info that are also easy
    targets, at least on some architectures.

    It's also a decent simplification, since the restart code is more or less
    identical on all architectures.

    [james.hogan@imgtec.com: metag: align thread_info::supervisor_stack]
    Signed-off-by: Andy Lutomirski
    Cc: Thomas Gleixner
    Cc: Al Viro
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: Kees Cook
    Cc: David Miller
    Acked-by: Richard Weinberger
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Vineet Gupta
    Cc: Russell King
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: Haavard Skinnemoen
    Cc: Hans-Christian Egtvedt
    Cc: Steven Miao
    Cc: Mark Salter
    Cc: Aurelien Jacquiot
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: David Howells
    Cc: Richard Kuo
    Cc: "Luck, Tony"
    Cc: Geert Uytterhoeven
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: Jonas Bonn
    Cc: "James E.J. Bottomley"
    Cc: Helge Deller
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Acked-by: Michael Ellerman (powerpc)
    Tested-by: Michael Ellerman (powerpc)
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Chen Liqin
    Cc: Lennox Wu
    Cc: Chris Metcalf
    Cc: Guan Xuetao
    Cc: Chris Zankel
    Cc: Max Filippov
    Cc: Oleg Nesterov
    Cc: Guenter Roeck
    Signed-off-by: James Hogan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Lutomirski
     

12 Feb, 2015

1 commit

  • LKP has triggered a compiler warning after my recent patch "mm: account
    pmd page tables to the process":

    mm/mmap.c: In function 'exit_mmap':
    >> mm/mmap.c:2857:2: warning: right shift count >= width of type [enabled by default]

    The code:

    > 2857 WARN_ON(mm_nr_pmds(mm) >
    2858 round_up(FIRST_USER_ADDRESS, PUD_SIZE) >> PUD_SHIFT);

    In this, on tile, we have FIRST_USER_ADDRESS defined as 0. round_up() has
    the same type -- int. PUD_SHIFT.

    I think the best way to fix it is to define FIRST_USER_ADDRESS as unsigned
    long. On every arch for consistency.

    Signed-off-by: Kirill A. Shutemov
    Reported-by: Wu Fengguang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

11 Feb, 2015

1 commit


30 Jan, 2015

1 commit

  • The core VM already knows about VM_FAULT_SIGBUS, but cannot return a
    "you should SIGSEGV" error, because the SIGSEGV case was generally
    handled by the caller - usually the architecture fault handler.

    That results in lots of duplication - all the architecture fault
    handlers end up doing very similar "look up vma, check permissions, do
    retries etc" - but it generally works. However, there are cases where
    the VM actually wants to SIGSEGV, and applications _expect_ SIGSEGV.

    In particular, when accessing the stack guard page, libsigsegv expects a
    SIGSEGV. And it usually got one, because the stack growth is handled by
    that duplicated architecture fault handler.

    However, when the generic VM layer started propagating the error return
    from the stack expansion in commit fee7e49d4514 ("mm: propagate error
    from stack expansion even for guard page"), that now exposed the
    existing VM_FAULT_SIGBUS result to user space. And user space really
    expected SIGSEGV, not SIGBUS.

    To fix that case, we need to add a VM_FAULT_SIGSEGV, and teach all those
    duplicate architecture fault handlers about it. They all already have
    the code to handle SIGSEGV, so it's about just tying that new return
    value to the existing code, but it's all a bit annoying.

    This is the mindless minimal patch to do this. A more extensive patch
    would be to try to gather up the mostly shared fault handling logic into
    one generic helper routine, and long-term we really should do that
    cleanup.

    Just from this patch, you can generally see that most architectures just
    copied (directly or indirectly) the old x86 way of doing things, but in
    the meantime that original x86 model has been improved to hold the VM
    semaphore for shorter times etc and to handle VM_FAULT_RETRY and other
    "newer" things, so it would be a good idea to bring all those
    improvements to the generic case and teach other architectures about
    them too.

    Reported-and-tested-by: Takashi Iwai
    Tested-by: Jan Engelhardt
    Acked-by: Heiko Carstens # "s390 still compiles and boots"
    Cc: linux-arch@vger.kernel.org
    Cc: stable@vger.kernel.org
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

29 Jan, 2015

4 commits


26 Jan, 2015

1 commit


20 Jan, 2015

2 commits

  • Convert file->f_dentry->d_inode to file_inode() so as to get layered
    filesystems right.

    Found with: git grep '[.>]f_dentry'

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     
  • Nothing needs the module pointer any more, and the next patch will
    call it from RCU, where the module itself might no longer exist.
    Removing the arg is the safest approach.

    This just codifies the use of the module_alloc/module_free pattern
    which ftrace and bpf use.

    Signed-off-by: Rusty Russell
    Acked-by: Alexei Starovoitov
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: Ralf Baechle
    Cc: Ley Foon Tan
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Steven Rostedt
    Cc: x86@kernel.org
    Cc: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: Masami Hiramatsu
    Cc: linux-cris-kernel@axis.com
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Cc: nios2-dev@lists.rocketboards.org
    Cc: linuxppc-dev@lists.ozlabs.org
    Cc: sparclinux@vger.kernel.org
    Cc: netdev@vger.kernel.org

    Rusty Russell
     

20 Dec, 2014

1 commit