Commit graph

279 commits

Author SHA1 Message Date
Rabin Vincent 7f0144e777 CRIS: fix switch_mm() lockdep splat
With lockdep support implemented on CRISv32, we get the following splat.
switch_mm() can be called both from the scheduler() (with interrupts
disabled) and from flush_old_exec (via activate_mm()), with interrupts
enabled.  Fix it by disabling interrupts in activate_mm(), similar to
powerpc and hexagon.

 t======================================================
 [ INFO: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected ]
 3.19.0-08802-g20bc9f1-dirty #323 Not tainted
 ------------------------------------------------------
 init/1 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
  (mmu_context_lock){+.+...}, at: [<c0009290>] switch_mm+0x22/0xc6

 and this task is already holding:
  (&rq->lock){-.-.-.}, at: [<c01a0756>] __schedule+0x5e/0x648
 which would create a new lock dependency:
  (&rq->lock){-.-.-.} -> (mmu_context_lock){+.+...}

 but this new dependency connects a HARDIRQ-irq-safe lock:
  (&rq->lock){-.-.-.}
 ... which became HARDIRQ-irq-safe at:
   [<c002b03c>] scheduler_tick+0x28/0x5e
   [<c0007c6c>] timer_interrupt+0x4e/0x6a
   [<c0043ac4>] handle_irq_event_percpu+0x54/0x13c
   [<c004343c>] generic_handle_irq+0x2a/0x36

 to a HARDIRQ-irq-unsafe lock:
  (mmu_context_lock){+.+...}
 ... which became HARDIRQ-irq-unsafe at:
 ...  [<c0039e60>] __lock_acquire+0x8f8/0x1d9c
   [<c0009290>] switch_mm+0x22/0xc6
   [<c009c260>] flush_old_exec+0x500/0x5d4
   [<c00da4c6>] load_elf_phdrs+0x7a/0x84
   [<c00dbdb0>] load_elf_binary+0x21c/0x13b4
   [<c009cdb6>] do_execve+0x22/0x2c
   [<c001dcf2>] ____call_usermodehelper+0x0/0x154
   [<c000581e>] ret_from_kernel_thread+0xe/0x14

 other info that might help us debug this:

  Possible interrupt unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(mmu_context_lock);
                                local_irq_disable();
                                lock(&rq->lock);
                                lock(mmu_context_lock);
   <Interrupt>
     lock(&rq->lock);

  *** DEADLOCK ***

 1 lock held by init/1:
  #0:  (&rq->lock){-.-.-.}, at: [<c01a0756>] __schedule+0x5e/0x648

 Call Trace:
 [<c019fe9e>] printk+0x0/0x4e
 [<c00368f8>] print_shortest_lock_dependencies+0x0/0x15c
 [<c0048628>] print_stack_trace+0x0/0x88
 [<c0038912>] __lock_is_held+0x3e/0x5e
 [<c003b894>] lock_acquire+0x8a/0xcc
 [<c01a50c4>] _raw_spin_lock+0x44/0x7a
 [<c0009290>] switch_mm+0x22/0xc6
 [<c01a06f8>] __schedule+0x0/0x648
 [<c01a0d76>] schedule+0x36/0x7c
 [<c0037d04>] trace_hardirqs_on+0x0/0x1e
 [<c0004e18>] do_work_pending+0x30/0xd4
 [<c000591a>] _work_pending+0xe/0x12

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:50 +02:00
Rabin Vincent aa6f4d2b65 CRIS: add STACKTRACE_SUPPORT
Add stacktrace support, which is required for lockdep and tracing.  The
stack tracing simply looks at all kernel text symbols found on the
stack, similar to the trap stack dumping code, which can also be
converted to use this.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:50 +02:00
Rabin Vincent 20ae247399 CRIS: UAPI: use generic types.h
CRIS' types.h is functionally identical to the asm-generic version.

Effective diff:

 +#ifndef _ASM_GENERIC_TYPES_H
 +#define _ASM_GENERIC_TYPES_H
 +
  #include <asm-generic/int-ll64.h>
 +
 +#endif

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:48 +02:00
Rabin Vincent 258a9ff66c CRIS: UAPI: use generic shmbuf.h
CRIS' shmbuf.h is equivalent to the asm-generic verison.

Effective diff:

 -#ifndef _CRIS_SHMBUF_H
 -#define _CRIS_SHMBUF_H
 +#ifndef __ASM_GENERIC_SHMBUF_H
 +#define __ASM_GENERIC_SHMBUF_H
 +
 +#include <asm/bitsperlong.h>

  	struct ipc64_perm	shm_perm;
  	size_t			shm_segsz;
  	__kernel_time_t		shm_atime;
 +#if __BITS_PER_LONG != 64
  	unsigned long		__unused1;
 +#endif
  	__kernel_time_t		shm_dtime;
 +#if __BITS_PER_LONG != 64
  	unsigned long		__unused2;
 +#endif
  	__kernel_time_t		shm_ctime;
 +#if __BITS_PER_LONG != 64
  	unsigned long		__unused3;
 +#endif
  	__kernel_pid_t		shm_cpid;
  	__kernel_pid_t		shm_lpid;
 -	unsigned long		shm_nattch;
 -	unsigned long		__unused4;
 -	unsigned long		__unused5;
 +	__kernel_ulong_t	shm_nattch;
 +	__kernel_ulong_t	__unused4;
 +	__kernel_ulong_t	__unused5;
  };

  struct shminfo64 {
 -	unsigned long	shmmax;
 -	unsigned long	shmmin;
 -	unsigned long	shmmni;
 -	unsigned long	shmseg;
 -	unsigned long	shmall;
 -	unsigned long	__unused1;
 -	unsigned long	__unused2;
 -	unsigned long	__unused3;
 -	unsigned long	__unused4;
 +	__kernel_ulong_t	shmmax;
 +	__kernel_ulong_t	shmmin;
 +	__kernel_ulong_t	shmmni;
 +	__kernel_ulong_t	shmseg;
 +	__kernel_ulong_t	shmall;
 +	__kernel_ulong_t	__unused1;
 +	__kernel_ulong_t	__unused2;
 +	__kernel_ulong_t	__unused3;
 +	__kernel_ulong_t	__unused4;
  };

  #endif

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:48 +02:00
Rabin Vincent 74d94adb35 CRIS: UAPI: use generic msgbuf.h
CRIS' msgbuf.h is equivalent to the asm-generic version.

Effective diff:

 -#ifndef _CRIS_MSGBUF_H
 -#define _CRIS_MSGBUF_H
 -
 -
 +#ifndef __ASM_GENERIC_MSGBUF_H
 +#define __ASM_GENERIC_MSGBUF_H

 +#include <asm/bitsperlong.h>

  struct msqid64_ds {
  	struct ipc64_perm msg_perm;
  	__kernel_time_t msg_stime;
 +#if __BITS_PER_LONG != 64
  	unsigned long	__unused1;
 +#endif
  	__kernel_time_t msg_rtime;
 +#if __BITS_PER_LONG != 64
  	unsigned long	__unused2;
 +#endif
  	__kernel_time_t msg_ctime;
 +#if __BITS_PER_LONG != 64
  	unsigned long	__unused3;
 -	unsigned long  msg_cbytes;
 -	unsigned long  msg_qnum;
 -	unsigned long  msg_qbytes;
 +#endif
 +	__kernel_ulong_t msg_cbytes;
 +	__kernel_ulong_t msg_qnum;
 +	__kernel_ulong_t msg_qbytes;
  	__kernel_pid_t msg_lspid;
  	__kernel_pid_t msg_lrpid;
 -	unsigned long  __unused4;
 -	unsigned long  __unused5;
 +	__kernel_ulong_t __unused4;
 +	__kernel_ulong_t __unused5;
  };

  #endif

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:48 +02:00
Rabin Vincent 4526692251 CRIS: UAPI: use generic socket.h
CRIS' socket.h is equivalent to the asm-generic version.

Effective diff:

 -#ifndef _ASM_SOCKET_H
 -#define _ASM_SOCKET_H
 -
 -
 +#ifndef __ASM_GENERIC_SOCKET_H
 +#define __ASM_GENERIC_SOCKET_H

  #include <asm/sockios.h>

  #define SO_LINGER	13
  #define SO_BSDCOMPAT	14
  #define SO_REUSEPORT	15
 +#ifndef SO_PASSCRED
  #define SO_PASSCRED	16
  #define SO_PEERCRED	17
  #define SO_RCVLOWAT	18
  #define SO_SNDLOWAT	19
  #define SO_RCVTIMEO	20
  #define SO_SNDTIMEO	21
 +#endif

 #define SO_SECURITY_AUTHENTICATION		22

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:47 +02:00
Rabin Vincent 53789d25a0 CRIS: UAPI: use generic sembuf.h
CRIS's sembuf.h is equivalent to the asm-generic version.
Effective diff:

 -#ifndef _CRIS_SEMBUF_H
 -#define _CRIS_SEMBUF_H
 +#ifndef __ASM_GENERIC_SEMBUF_H
 +#define __ASM_GENERIC_SEMBUF_H

 +#include <asm/bitsperlong.h>

  struct semid64_ds {
  	struct ipc64_perm sem_perm;
  	__kernel_time_t	sem_otime;
 +#if __BITS_PER_LONG != 64
  	unsigned long	__unused1;
 +#endif
  	__kernel_time_t	sem_ctime;
 +#if __BITS_PER_LONG != 64
  	unsigned long	__unused2;
 +#endif
  	unsigned long	sem_nsems;
  	unsigned long	__unused3;
  	unsigned long	__unused4;

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:47 +02:00
Rabin Vincent c823b970b6 CRIS: UAPI: use generic sockios.h
CRIS' sockios.h is equivalent to the asm-generic version.

Effective diff:

 -#ifndef __ARCH_CRIS_SOCKIOS__
 -#define __ARCH_CRIS_SOCKIOS__
 +#ifndef __ASM_GENERIC_SOCKIOS_H
 +#define __ASM_GENERIC_SOCKIOS_H

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:46 +02:00
Rabin Vincent 889d74a4d4 CRIS: UAPI: use generic auxvec.h
CRIS's auxvec.h is empty just like the asm-generic version.

Effective diff:

 -#ifndef __ASMCRIS_AUXVEC_H
 -#define __ASMCRIS_AUXVEC_H
 +#ifndef __ASM_GENERIC_AUXVEC_H
 +#define __ASM_GENERIC_AUXVEC_H
 +

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:46 +02:00
Rabin Vincent 0c02fa2f4e CRIS: UAPI: use generic headers via Kbuild
Use Kbuild magic to include the generic headers.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:56:45 +02:00
Rabin Vincent 2493d3e28a CRIS: UAPI: fix elf.h export
CRIS userspace (uClibc for one) expects asm/elf.h to be exported but
this header appears to have gone missing at some point.  Move it to
uapi/ and export it.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:33:25 +02:00
Rabin Vincent 3a79a07537 CRIS: don't make asm/elf.h depend on asm/user.h
We're going to export asm/elf.h; remove its dependencies on the
non-exported asm/user.h and the unused asm/system.h include.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:33:25 +02:00
Rabin Vincent 835e417728 CRIS: UAPI: fix ptrace.h
The exported ptrace.h header on CRIS references an "arch" directory
which does not exist.  Fix this by having the variants in the same
directory and including them conditionally, similar to other
architectures.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-09-05 00:33:25 +02:00
Chen Gang ee59843cd2 CRIS: Wire up missing syscalls
The related warnings:

    CALL    scripts/checksyscalls.sh
  <stdin>:1229:2: warning: #warning syscall sched_setattr not implemented [-Wcpp]
  <stdin>:1232:2: warning: #warning syscall sched_getattr not implemented [-Wcpp]
  <stdin>:1235:2: warning: #warning syscall renameat2 not implemented [-Wcpp]
  <stdin>:1238:2: warning: #warning syscall seccomp not implemented [-Wcpp]
  <stdin>:1241:2: warning: #warning syscall getrandom not implemented [-Wcpp]
  <stdin>:1244:2: warning: #warning syscall memfd_create not implemented [-Wcpp]
  <stdin>:1247:2: warning: #warning syscall bpf not implemented [-Wcpp]
  <stdin>:1250:2: warning: #warning syscall execveat not implemented [-Wcpp]

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-09-05 00:33:25 +02:00
Rabin Vincent 98a725a57a CRISv32: add unreachable() to BUG()
Add an unreachable() in the BUG() implementations, to get rid of
several warnings similar to the one below:

 kernel/sched/core.c: In function 'pick_next_task':
 kernel/sched/core.c:2690:1: warning: control reaches end of non-void function [-Wreturn-type]

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-09-05 00:33:24 +02:00
Laurent Dufour f2abeef9fd mm: clean up per architecture MM hook header files
Commit 2ae416b142 ("mm: new mm hook framework") introduced an empty
header file (mm-arch-hooks.h) for every architecture, even those which
doesn't need to define mm hooks.

As suggested by Geert Uytterhoeven, this could be cleaned through the use
of a generic header file included via each per architecture
asm/include/Kbuild file.

The PowerPC architecture is not impacted here since this architecture has
to defined the arch_remap MM hook.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-07-17 16:39:53 -07:00
Linus Torvalds ad90fb9751 Merge branch 'for-4.2/sg' of git://git.kernel.dk/linux-block
Pull asm/scatterlist.h removal from Jens Axboe:
 "We don't have any specific arch scatterlist anymore, since parisc
  finally switched over.  Kill the include"

* 'for-4.2/sg' of git://git.kernel.dk/linux-block:
  remove scatterlist.h generation from arch Kbuild files
  remove <asm/scatterlist.h>
2015-06-25 15:22:36 -07:00
Laurent Dufour 2ae416b142 mm: new mm hook framework
CRIU is recreating the process memory layout by remapping the checkpointee
memory area on top of the current process (criu).  This includes remapping
the vDSO to the place it has at checkpoint time.

However some architectures like powerpc are keeping a reference to the
vDSO base address to build the signal return stack frame by calling the
vDSO sigreturn service.  So once the vDSO has been moved, this reference
is no more valid and the signal frame built later are not usable.

This patch serie is introducing a new mm hook framework, and a new
arch_remap hook which is called when mremap is done and the mm lock still
hold.  The next patch is adding the vDSO remap and unmap tracking to the
powerpc architecture.

This patch (of 3):

This patch introduces a new set of header file to manage mm hooks:
- per architecture empty header file (arch/x/include/asm/mm-arch-hooks.h)
- a generic header (include/linux/mm-arch-hooks.h)

The architecture which need to overwrite a hook as to redefine it in its
header file, while architecture which doesn't need have nothing to do.

The default hooks are defined in the generic header and are used in the
case the architecture is not defining it.

In a next step, mm hooks defined in include/asm-generic/mm_hooks.h should
be moved here.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-06-24 17:49:41 -07:00
Christoph Hellwig c546d5db75 remove scatterlist.h generation from arch Kbuild files
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
2015-05-19 09:14:34 -06:00
Christoph Hellwig 84be456f88 remove <asm/scatterlist.h>
We don't have any arch specific scatterlist now that parisc switched over
to the generic one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
2015-05-05 13:35:39 -06:00
Linus Torvalds 7f9f44308c CRIS changes for 4.1
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iEYEABECAAYFAlU70nMACgkQ31LbvUHyf1cYgwCfSmPhyLFmr0pGM/BxsVY7K1v6
 PaEAn2+7xfZV38E6hwrGMrT42ZvKyL6r
 =LHQU
 -----END PGP SIGNATURE-----

Merge tag 'cris-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper/cris

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
2015-04-26 13:31:05 -07:00
Richard Weinberger fa41b1c7df arch: Remove exec_domain from remaining archs
Signed-off-by: Richard Weinberger <richard@nod.at>
2015-04-12 21:03:30 +02:00
Andrey Ryabinin d939b52abe cris: fix integer overflow in ELF_ET_DYN_BASE
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 <a.ryabinin@samsung.com>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 11:35:12 +01:00
Rabin Vincent 16428f943d CRIS: use generic headers via Kbuild
Delete headers which do nothing but include the asm-generic versions and
use Kbuild magic instead.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:57:27 +01:00
Rabin Vincent f87a2f58e3 CRIS: use generic cmpxchg.h
CRIS can use asm-generic's cmpxchg.h

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:57:07 +01:00
Rabin Vincent e7db8a3c96 CRIS: use generic atomic.h
CRIS can use asm-generic's atomic.h.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:57:03 +01:00
Rabin Vincent f64751118b CRIS: use generic atomic bitops
The generic atomic bitops are the same as the CRIS-specific ones.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:55:35 +01:00
Rabin Vincent 3c2165f807 CRISv10: remove redundant macros from system.h
All of these are either unused or already provided by other headers, so
they can be removed.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:55:28 +01:00
Rabin Vincent 47a8f6fb34 CRIS: remove SMP code
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 <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:55:10 +01:00
Rabin Vincent 06aca92424 CRISv32: don't enable irqs in INIT_THREAD
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:
  [<c0032b80>] spin_bug+0x2a/0x36
  [<c0032c98>] do_raw_spin_lock+0xa2/0x126
  [<c01964b0>] _raw_spin_lock+0x20/0x2a
  [<c00286c8>] scheduler_tick+0x22/0x76
  [<c003db2c>] update_process_times+0x5e/0x72
  [<c0007a94>] timer_interrupt+0x4e/0x6a
  [<c00378d6>] handle_irq_event_percpu+0x54/0xf2
  [<c00379c4>] handle_irq_event+0x50/0x74
  [<c003988e>] handle_simple_irq+0x6c/0xbe
  [<c0037270>] generic_handle_irq+0x2a/0x36
  [<c0004c40>] do_IRQ+0x38/0x84
  [<c000662e>] crisv32_do_IRQ+0x54/0x60
  [<c0006204>] IRQ0x4b_interrupt+0x34/0x3c
  [<c0192baa>] __schedule+0x24a/0x532
  [<c00056b4>] ret_from_kernel_thread+0x0/0x14

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
2015-03-25 10:54:06 +01:00
Linus Torvalds 1fa185ebcb CRIS changes for 3.20
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iEYEABECAAYFAlTgZOMACgkQ31LbvUHyf1dBWgCfddXF7asJyWtL6o/4lPuDCS4T
 UbAAnR2w1qM6KlGvhjUqFgng4qadt3h+
 =tIwX
 -----END PGP SIGNATURE-----

Merge tag 'cris-for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper/cris

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
2015-02-15 18:02:02 -08:00
Jesper Nilsson 9987c19ed9 CRIS: Whitespace cleanup
No functional change, just clean up the most obvious.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-02-14 18:54:12 +01:00
Michael S. Tsirkin 83f1588e9f CRIS: macro whitespace fixes in uaccess.h
While working on arch/cris/include/asm/uaccess.h, I noticed
that some macros within this header are made harder to read because they
violate a coding style rule: space is missing after comma.

Fix it up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-02-14 18:54:04 +01:00
Michael S. Tsirkin 458e319245 CRIS: uaccess: fix sparse errors
virtio wants to read bitwise types from userspace using get_user.  At the
moment this triggers sparse errors, since the value is passed through an
integer.

Fix that up using __force.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2015-02-14 18:53:52 +01:00
Andy Lutomirski f56141e3e2 all arches, signal: move restart_block to struct task_struct
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 <luto@amacapital.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: David Miller <davem@davemloft.net>
Acked-by: Richard Weinberger <richard@nod.at>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Steven Miao <realmz6@gmail.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Tested-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Chen Liqin <liqin.linux@gmail.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-12 18:54:12 -08:00
Kirill A. Shutemov d016bf7ece mm: make FIRST_USER_ADDRESS unsigned long on all archs
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 <kirill.shutemov@linux.intel.com>
Reported-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-11 17:06:03 -08:00
Kirill A. Shutemov 103f3d9a26 cris: drop _PAGE_FILE and pte_file()-related helpers
We've replaced remap_file_pages(2) implementation with emulation.  Nobody
creates non-linear mapping anymore.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-10 14:30:32 -08:00
Jesper Nilsson a3199ad90a CRISv32: ETRAXFS: Fix recursive spinlock
Move pinmux alloc/dealloc code into functions that don't take
the spinlock so we can use from code that has the spinlock already.

CRISv32 has no working SMP, so spinlocks becomes a NOP,
so deadlock was never seen.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2014-12-20 00:06:04 +01:00
Sam Ravnborg 6eb64b8c64 CRIS: Fix headers_install
Fix headers_install by adjusting the path to arch files.
And delete unused Kbuild file.
Drop special handling of cris in the headers.sh script
as a nice side-effect.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Mikael Starvik <starvik@axis.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
2014-12-20 00:01:12 +01:00
Linus Torvalds 70e71ca0af Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller:

 1) New offloading infrastructure and example 'rocker' driver for
    offloading of switching and routing to hardware.

    This work was done by a large group of dedicated individuals, not
    limited to: Scott Feldman, Jiri Pirko, Thomas Graf, John Fastabend,
    Jamal Hadi Salim, Andy Gospodarek, Florian Fainelli, Roopa Prabhu

 2) Start making the networking operate on IOV iterators instead of
    modifying iov objects in-situ during transfers.  Thanks to Al Viro
    and Herbert Xu.

 3) A set of new netlink interfaces for the TIPC stack, from Richard
    Alpe.

 4) Remove unnecessary looping during ipv6 routing lookups, from Martin
    KaFai Lau.

 5) Add PAUSE frame generation support to gianfar driver, from Matei
    Pavaluca.

 6) Allow for larger reordering levels in TCP, which are easily
    achievable in the real world right now, from Eric Dumazet.

 7) Add a variable of napi_schedule that doesn't need to disable cpu
    interrupts, from Eric Dumazet.

 8) Use a doubly linked list to optimize neigh_parms_release(), from
    Nicolas Dichtel.

 9) Various enhancements to the kernel BPF verifier, and allow eBPF
    programs to actually be attached to sockets.  From Alexei
    Starovoitov.

10) Support TSO/LSO in sunvnet driver, from David L Stevens.

11) Allow controlling ECN usage via routing metrics, from Florian
    Westphal.

12) Remote checksum offload, from Tom Herbert.

13) Add split-header receive, BQL, and xmit_more support to amd-xgbe
    driver, from Thomas Lendacky.

14) Add MPLS support to openvswitch, from Simon Horman.

15) Support wildcard tunnel endpoints in ipv6 tunnels, from Steffen
    Klassert.

16) Do gro flushes on a per-device basis using a timer, from Eric
    Dumazet.  This tries to resolve the conflicting goals between the
    desired handling of bulk vs.  RPC-like traffic.

17) Allow userspace to ask for the CPU upon what a packet was
    received/steered, via SO_INCOMING_CPU.  From Eric Dumazet.

18) Limit GSO packets to half the current congestion window, from Eric
    Dumazet.

19) Add a generic helper so that all drivers set their RSS keys in a
    consistent way, from Eric Dumazet.

20) Add xmit_more support to enic driver, from Govindarajulu
    Varadarajan.

21) Add VLAN packet scheduler action, from Jiri Pirko.

22) Support configurable RSS hash functions via ethtool, from Eyal
    Perry.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1820 commits)
  Fix race condition between vxlan_sock_add and vxlan_sock_release
  net/macb: fix compilation warning for print_hex_dump() called with skb->mac_header
  net/mlx4: Add support for A0 steering
  net/mlx4: Refactor QUERY_PORT
  net/mlx4_core: Add explicit error message when rule doesn't meet configuration
  net/mlx4: Add A0 hybrid steering
  net/mlx4: Add mlx4_bitmap zone allocator
  net/mlx4: Add a check if there are too many reserved QPs
  net/mlx4: Change QP allocation scheme
  net/mlx4_core: Use tasklet for user-space CQ completion events
  net/mlx4_core: Mask out host side virtualization features for guests
  net/mlx4_en: Set csum level for encapsulated packets
  be2net: Export tunnel offloads only when a VxLAN tunnel is created
  gianfar: Fix dma check map error when DMA_API_DEBUG is enabled
  cxgb4/csiostor: Don't use MASTER_MUST for fw_hello call
  net: fec: only enable mdio interrupt before phy device link up
  net: fec: clear all interrupt events to support i.MX6SX
  net: fec: reset fep link status in suspend function
  net: sock: fix access via invalid file descriptor
  net: introduce helper macro for_each_cmsghdr
  ...
2014-12-11 14:27:06 -08:00
Daniel Borkmann 0cb6c969ed net, lib: kill arch_fast_hash library bits
As there are now no remaining users of arch_fast_hash(), lets kill
it entirely.

This basically reverts commit 71ae8aac3e ("lib: introduce arch
optimized hash library") and follow-up work, that is f.e., commit
237217546d ("lib: hash: follow-up fixups for arch hash"),
commit e3fec2f74f ("lib: Add missing arch generic-y entries for
asm-generic/hash.h") and last but not least commit 6a02652df5
("perf tools: Fix include for non x86 architectures").

Cc: Francesco Fusco <fusco@ntop.org>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-12-10 15:17:46 -05:00
Alexei Starovoitov 89aa075832 net: sock: allow eBPF programs to be attached to sockets
introduce new setsockopt() command:

setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd, sizeof(prog_fd))

where prog_fd was received from syscall bpf(BPF_PROG_LOAD, attr, ...)
and attr->prog_type == BPF_PROG_TYPE_SOCKET_FILTER

setsockopt() calls bpf_prog_get() which increments refcnt of the program,
so it doesn't get unloaded while socket is using the program.

The same eBPF program can be attached to multiple sockets.

User task exit automatically closes socket which calls sk_filter_uncharge()
which decrements refcnt of eBPF program

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-12-05 21:47:32 -08:00
Eric Dumazet 2c8c56e15d net: introduce SO_INCOMING_CPU
Alternative to RPS/RFS is to use hardware support for multiple
queues.

Then split a set of million of sockets into worker threads, each
one using epoll() to manage events on its own socket pool.

Ideally, we want one thread per RX/TX queue/cpu, but we have no way to
know after accept() or connect() on which queue/cpu a socket is managed.

We normally use one cpu per RX queue (IRQ smp_affinity being properly
set), so remembering on socket structure which cpu delivered last packet
is enough to solve the problem.

After accept(), connect(), or even file descriptor passing around
processes, applications can use :

 int cpu;
 socklen_t len = sizeof(cpu);

 getsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, &len);

And use this information to put the socket into the right silo
for optimal performance, as all networking stack should run
on the appropriate cpu, without need to send IPI (RPS/RFS).

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-11-11 13:00:06 -05:00
Will Deacon 62e8abf716 cris: io: implement dummy relaxed accessor macros for writes
write{b,w,l}_relaxed are implemented by some architectures in order to
permit memory-mapped I/O accesses with weaker barrier semantics than the
non-relaxed variants.

This patch adds dummy macros for the write accessors to Cris, in the same
vein as the dummy definitions for the relaxed read accessors.

Cc: Mikael Starvik <starvik@axis.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2014-10-20 18:49:17 +01:00
Linus Torvalds dbb885fecc Merge branch 'locking-arch-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull arch atomic cleanups from Ingo Molnar:
 "This is a series kept separate from the main locking tree, which
  cleans up and improves various details in the atomics type handling:

   - Remove the unused atomic_or_long() method

   - Consolidate and compress atomic ops implementations between
     architectures, to reduce linecount and to make it easier to add new
     ops.

   - Rewrite generic atomic support to only require cmpxchg() from an
     architecture - generate all other methods from that"

* 'locking-arch-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits)
  locking,arch: Use ACCESS_ONCE() instead of cast to volatile in atomic_read()
  locking, mips: Fix atomics
  locking, sparc64: Fix atomics
  locking,arch: Rewrite generic atomic support
  locking,arch,xtensa: Fold atomic_ops
  locking,arch,sparc: Fold atomic_ops
  locking,arch,sh: Fold atomic_ops
  locking,arch,powerpc: Fold atomic_ops
  locking,arch,parisc: Fold atomic_ops
  locking,arch,mn10300: Fold atomic_ops
  locking,arch,mips: Fold atomic_ops
  locking,arch,metag: Fold atomic_ops
  locking,arch,m68k: Fold atomic_ops
  locking,arch,m32r: Fold atomic_ops
  locking,arch,ia64: Fold atomic_ops
  locking,arch,hexagon: Fold atomic_ops
  locking,arch,cris: Fold atomic_ops
  locking,arch,avr32: Fold atomic_ops
  locking,arch,arm64: Fold atomic_ops
  locking,arch,arm: Fold atomic_ops
  ...
2014-10-13 15:48:00 +02:00
Geert Uytterhoeven 20882185da cris: use Kbuild logic to include <asm-generic/sections.h>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-10-09 22:25:45 -04:00
Pranith Kumar 2291059c85 locking,arch: Use ACCESS_ONCE() instead of cast to volatile in atomic_read()
Use the much more reader friendly ACCESS_ONCE() instead of the cast to volatile.
This is purely a stylistic change.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org
Link: http://lkml.kernel.org/r/1411482607-20948-1-git-send-email-bobby.prani@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-10-03 06:06:23 +02:00
Peter Zijlstra c5c38ef3d7 irq_work: Introduce arch_irq_work_has_interrupt()
The nohz full code needs irq work to trigger its own interrupt so that
the subsystem can work even when the tick is stopped.

Lets introduce arch_irq_work_has_interrupt() that archs can override to
tell about their support for this ability.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
2014-09-13 18:38:07 +02:00
Peter Zijlstra 7179e30ef6 locking,arch,cris: Fold atomic_ops
Many of the atomic op implementations are the same except for one
instruction; fold the lot into a few CPP macros and reduce LoC.

This also prepares for easy addition of new ops.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: linux-cris-kernel@axis.com
Link: http://lkml.kernel.org/r/20140508135852.104572724@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-08-14 12:48:06 +02:00
Laura Abbott 56106da793 lib/scatterlist: clean up useless architecture versions of scatterlist.h
There's no need to have an architecture version of scatterlist.h if the
only thing the file does is include asm-generic/scatterlist.h.  Switch to
the asm-generic versions directly.

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Cc: Lennox Wu <lennox.wu@gmail.com>
Cc: Chen Liqin <liqin.linux@gmail.com>,
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-08 15:57:26 -07:00