1. 06 Jan, 2019 3 commits
  2. 04 Jan, 2019 2 commits
    • Joel Fernandes (Google)'s avatar
      mm: treewide: remove unused address argument from pte_alloc functions · 4cf58924
      Joel Fernandes (Google) authored
      Patch series "Add support for fast mremap".
      
      This series speeds up the mremap(2) syscall by copying page tables at
      the PMD level even for non-THP systems.  There is concern that the extra
      'address' argument that mremap passes to pte_alloc may do something
      subtle architecture related in the future that may make the scheme not
      work.  Also we find that there is no point in passing the 'address' to
      pte_alloc since its unused.  This patch therefore removes this argument
      tree-wide resulting in a nice negative diff as well.  Also ensuring
      along the way that the enabled architectures do not do anything funky
      with the 'address' argument that goes unnoticed by the optimization.
      
      Build and boot tested on x86-64.  Build tested on arm64.  The config
      enablement patch for arm64 will be posted in the future after more
      testing.
      
      The changes were obtained by applying the following Coccinelle script.
      (thanks Julia for answering all Coccinelle questions!).
      Following fix ups were done manually:
      * Removal of address argument from  pte_fragment_alloc
      * Removal of pte_alloc_one_fast definitions from m68k and microblaze.
      
      // Options: --include-headers --no-includes
      // Note: I split the 'identifier fn' line, so if you are manually
      // running it, please unsplit it so it runs for you.
      
      virtual patch
      
      @pte_alloc_func_def depends on patch exists@
      identifier E2;
      identifier fn =~
      "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
      type T2;
      @@
      
       fn(...
      - , T2 E2
       )
       { ... }
      
      @pte_alloc_func_proto_noarg depends on patch exists@
      type T1, T2, T3, T4;
      identifier fn =~ "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
      @@
      
      (
      - T3 fn(T1, T2);
      + T3 fn(T1);
      |
      - T3 fn(T1, T2, T4);
      + T3 fn(T1, T2);
      )
      
      @pte_alloc_func_proto depends on patch exists@
      identifier E1, E2, E4;
      type T1, T2, T3, T4;
      identifier fn =~
      "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
      @@
      
      (
      - T3 fn(T1 E1, T2 E2);
      + T3 fn(T1 E1);
      |
      - T3 fn(T1 E1, T2 E2, T4 E4);
      + T3 fn(T1 E1, T2 E2);
      )
      
      @pte_alloc_func_call depends on patch exists@
      expression E2;
      identifier fn =~
      "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
      @@
      
       fn(...
      -,  E2
       )
      
      @pte_alloc_macro depends on patch exists@
      identifier fn =~
      "^(__pte_alloc|pte_alloc_one|pte_alloc|__pte_alloc_kernel|pte_alloc_one_kernel)$";
      identifier a, b, c;
      expression e;
      position p;
      @@
      
      (
      - #define fn(a, b, c) e
      + #define fn(a, b) e
      |
      - #define fn(a, b) e
      + #define fn(a) e
      )
      
      Link: http://lkml.kernel.org/r/20181108181201.88826-2-joelaf@google.comSigned-off-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      Suggested-by: default avatarKirill A. Shutemov <kirill@shutemov.name>
      Acked-by: default avatarKirill A. Shutemov <kirill@shutemov.name>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Julia Lawall <Julia.Lawall@lip6.fr>
      Cc: Kirill A. Shutemov <kirill@shutemov.name>
      Cc: William Kucharski <william.kucharski@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4cf58924
    • Linus Torvalds's avatar
      Remove 'type' argument from access_ok() function · 96d4f267
      Linus Torvalds authored
      Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
      of the user address range verification function since we got rid of the
      old racy i386-only code to walk page tables by hand.
      
      It existed because the original 80386 would not honor the write protect
      bit when in kernel mode, so you had to do COW by hand before doing any
      user access.  But we haven't supported that in a long time, and these
      days the 'type' argument is a purely historical artifact.
      
      A discussion about extending 'user_access_begin()' to do the range
      checking resulted this patch, because there is no way we're going to
      move the old VERIFY_xyz interface to that model.  And it's best done at
      the end of the merge window when I've done most of my merges, so let's
      just get this done once and for all.
      
      This patch was mostly done with a sed-script, with manual fix-ups for
      the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
      
      There were a couple of notable cases:
      
       - csky still had the old "verify_area()" name as an alias.
      
       - the iter_iov code had magical hardcoded knowledge of the actual
         values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
         really used it)
      
       - microblaze used the type argument for a debug printout
      
      but other than those oddities this should be a total no-op patch.
      
      I tried to fix up all architectures, did fairly extensive grepping for
      access_ok() uses, and the changes are trivial, but I may have missed
      something.  Any missed conversion should be trivially fixable, though.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      96d4f267
  3. 28 Dec, 2018 1 commit
  4. 20 Dec, 2018 2 commits
    • Max Filippov's avatar
      xtensa: implement jump_label support · 64711f9a
      Max Filippov authored
      Use 3-byte 'nop' and 'j' instructions that are always present. Don't let
      assembler mark a spot right after patchable 'j' instruction as
      unreachable and later put literals or padding bytes there. Add separate
      implementations of patch_text for SMP and UP cases, avoiding use of
      atomics on UP.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      64711f9a
    • Christoph Hellwig's avatar
      dma-mapping: zero memory returned from dma_alloc_* · 518a2f19
      Christoph Hellwig authored
      If we want to map memory from the DMA allocator to userspace it must be
      zeroed at allocation time to prevent stale data leaks.   We already do
      this on most common architectures, but some architectures don't do this
      yet, fix them up, either by passing GFP_ZERO when we use the normal page
      allocator or doing a manual memset otherwise.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
      Acked-by: Sam Ravnborg <sam@ravnborg.org> [sparc]
      518a2f19
  5. 17 Dec, 2018 10 commits
  6. 13 Dec, 2018 1 commit
  7. 06 Dec, 2018 1 commit
  8. 05 Dec, 2018 2 commits
    • Max Filippov's avatar
      xtensa: don't use l32r opcode directly · 03760270
      Max Filippov authored
      xtensa assembler is capable of representing register loads with either
      movi + addmi, l32r or const16, depending on the core configuration.
      Don't use '.literal' and 'l32r' directly in the code, use 'movi' and let
      the assembler relax them.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      03760270
    • Max Filippov's avatar
      xtensa: xtfpga.dtsi: fix dtc warnings about SPI · f37598be
      Max Filippov authored
      Rename SPI controller node in the XTFPGA DTS to spi@...
      This fixes the following build warnings:
      
      arch/xtensa/boot/dts/kc705_nommu.dtb: Warning (spi_bus_bridge):
       /soc/spi-master@0d0a0000: node name for SPI buses should be 'spi'
      arch/xtensa/boot/dts/kc705_nommu.dtb: Warning (spi_bus_reg):
       Failed prerequisite 'spi_bus_bridge'
      arch/xtensa/boot/dts/lx200mx.dtb: Warning (spi_bus_bridge):
       /soc/spi-master@0d0a0000: node name for SPI buses should be 'spi'
      arch/xtensa/boot/dts/lx200mx.dtb: Warning (spi_bus_reg):
       Failed prerequisite 'spi_bus_bridge'
      arch/xtensa/boot/dts/kc705.dtb: Warning (spi_bus_bridge):
       /soc/spi-master@0d0a0000: node name for SPI buses should be 'spi'
      arch/xtensa/boot/dts/kc705.dtb: Warning (spi_bus_reg):
       Failed prerequisite 'spi_bus_bridge'
      arch/xtensa/boot/dts/ml605.dtb: Warning (spi_bus_bridge):
       /soc/spi-master@0d0a0000: node name for SPI buses should be 'spi'
      arch/xtensa/boot/dts/ml605.dtb: Warning (spi_bus_reg):
       Failed prerequisite 'spi_bus_bridge'
      arch/xtensa/boot/dts/lx60.dtb: Warning (spi_bus_bridge):
       /soc/spi-master@0d0a0000: node name for SPI buses should be 'spi'
      arch/xtensa/boot/dts/lx60.dtb: Warning (spi_bus_reg):
       Failed prerequisite 'spi_bus_bridge'
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      f37598be
  9. 04 Dec, 2018 3 commits
  10. 03 Dec, 2018 9 commits
    • Max Filippov's avatar
      xtensa: drop unused declarations from elf.h · c066cc8a
      Max Filippov authored
      do_copy_regs, do_restore_regs, do_save_fpregs and do_restore_fpregs are
      not used or implemented by xtensa, drop these declarations from the
      arch/xtensa/include/asm/elf.h
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      c066cc8a
    • Max Filippov's avatar
      xtensa: clean up syscall.h · 58b17c55
      Max Filippov authored
      Drop non-existent/unneeded function declarations, add header guard.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      58b17c55
    • Max Filippov's avatar
      xtensa: drop unused coprocessor helper functions · 3ffc2df9
      Max Filippov authored
      coprocessor_save, coprocessor_load and coprocessor_restore are neither
      used nor exported for use by modules. Drop them.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      3ffc2df9
    • Max Filippov's avatar
      xtensa: drop custom PTRACE_{PEEK,POKE}{TEXT,DATA} · 633f1ffb
      Max Filippov authored
      Custom implementations of these ptrace calls are the same as generic
      implementations. Drop custom code and use generic.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      633f1ffb
    • Max Filippov's avatar
      xtensa: drop unused field from the struct exc_table · 44ba57a2
      Max Filippov authored
      exc_table::syscall_save and corresponding macro EXC_TABLE_SYSCALL_SAVE
      have never been used by the xtensa code. Drop them.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      44ba57a2
    • Max Filippov's avatar
      xtensa: drop fast_syscall_kernel · 8ed3a542
      Max Filippov authored
      There must be no xtensa-specific syscalls from the kernel code: register
      spilling uses call+entry sequence and atomics have proper function
      implementations. Drop fast_syscall_xtensa.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      8ed3a542
    • Firoz Khan's avatar
      xtensa: generate uapi header and syscall table header files · 5eacadb5
      Firoz Khan authored
      System call table generation script must be run to gener-
      ate unistd_32.h and syscall_table.h files. This patch will
      have changes which will invokes the script.
      
      This patch will generate unistd_32.h and syscall_table.h
      files by the syscall table generation script invoked by
      xtensa/Makefile and the generated files against the removed
      files must be identical.
      
      The generated uapi header file will be included in uapi/-
      asm/unistd.h and generated system call table header file
      will be included by kernel/syscall.c file.
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      5eacadb5
    • Firoz Khan's avatar
      xtensa: add system call table generation support · c7914ef6
      Firoz Khan authored
      The system call tables are in different format in all
      architecture and it will be difficult to manually add,
      modify or delete the syscall table entries in the res-
      pective files. To make it easy by keeping a script and
      which will generate the uapi header and syscall table
      file. This change will also help to unify the implemen-
      tation across all architectures.
      
      The system call table generation script is added in
      kernel/syscalls directory which contain the scripts to
      generate both uapi header file and system call table
      files. The syscall.tbl will be input for the scripts.
      
      syscall.tbl contains the list of available system calls
      along with system call number and corresponding entry
      point. Add a new system call in this architecture will
      be possible by adding new entry in the syscall.tbl file.
      
      Adding a new table entry consisting of:
        	- System call number.
      	- ABI.
      	- System call name.
      	- Entry point name.
      
      syscallhdr.sh and syscalltbl.sh will generate uapi header
      unistd_32.h and syscall_table.h files respectively. Both
      .sh files will parse the content syscall.tbl to generate
      the header and table files. unistd_32.h will be included
      by uapi/asm/unistd.h and syscall_table.h is included by
      kernel/syscall.c - the real system call table.
      
      ARM, s390 and x86 architecuture does have similar support.
      I leverage their implementation to come up with a generic
      solution.
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      c7914ef6
    • Firoz Khan's avatar
      xtensa: add __NR_syscalls along with __NR_syscall_count · a86067f5
      Firoz Khan authored
      __NR_syscall_count macro holds the number of system call
      exist in xtensa architecture. We have to change the value
      of __NR_syscall_count, if we add or delete a system call.
      
      One of the patch in this patch series has a script which
      will generate a uapi header based on syscall.tbl file.
      The syscall.tbl file contains the total number of system
      calls information. So we have two option to update __NR-
      _syscall_count value.
      
      1. Update __NR_syscall_count in asm/unistd.h manually by
         counting the no.of system calls. No need to update __NR-
         _syscall_count until we either add a new system call or
         delete existing system call.
      
      2. We can keep this feature it above mentioned script,
         that will count the number of syscalls and keep it in
         a generated file. In this case we don't need to expli-
         citly update __NR_syscall_count in asm/unistd.h file.
      
      The 2nd option will be the recommended one. For that, I
      added the __NR_syscalls macro in uapi/asm/unistd.h.
      The macro __NR_syscalls also added for making the name
      convention same across all architecture. While __NR_syscalls
      isn't strictly part of the uapi, having it as part of the
      generated header to simplifies the implementation. We also
      need to enclose this macro with #ifdef __KERNEL__ to avoid
      side effects.
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      [Max: Drop __NR_syscall_count completely, use __NR_syscalls instead]
      a86067f5
  11. 01 Dec, 2018 1 commit
  12. 27 Nov, 2018 3 commits
    • Max Filippov's avatar
      xtensa: fix coprocessor part of ptrace_{get,set}xregs · 38a35a78
      Max Filippov authored
      Layout of coprocessor registers in the elf_xtregs_t and
      xtregs_coprocessor_t may be different due to alignment. Thus it is not
      always possible to copy data between the xtregs_coprocessor_t structure
      and the elf_xtregs_t and get correct values for all registers.
      Use a table of offsets and sizes of individual coprocessor register
      groups to do coprocessor context copying in the ptrace_getxregs and
      ptrace_setxregs.
      This fixes incorrect coprocessor register values reading from the user
      process by the native gdb on an xtensa core with multiple coprocessors
      and registers with high alignment requirements.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      38a35a78
    • Max Filippov's avatar
      xtensa: fix coprocessor context offset definitions · 03bc996a
      Max Filippov authored
      Coprocessor context offsets are used by the assembly code that moves
      coprocessor context between the individual fields of the
      thread_info::xtregs_cp structure and coprocessor registers.
      This fixes coprocessor context clobbering on flushing and reloading
      during normal user code execution and user process debugging in the
      presence of more than one coprocessor in the core configuration.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      03bc996a
    • Max Filippov's avatar
      xtensa: enable coprocessors that are being flushed · 2958b666
      Max Filippov authored
      coprocessor_flush_all may be called from a context of a thread that is
      different from the thread being flushed. In that case contents of the
      cpenable special register may not match ti->cpenable of the target
      thread, resulting in unhandled coprocessor exception in the kernel
      context.
      Set cpenable special register to the ti->cpenable of the target register
      for the duration of the flush and restore it afterwards.
      This fixes the following crash caused by coprocessor register inspection
      in native gdb:
      
        (gdb) p/x $w0
        Illegal instruction in kernel: sig: 9 [#1] PREEMPT
        Call Trace:
          ___might_sleep+0x184/0x1a4
          __might_sleep+0x41/0xac
          exit_signals+0x14/0x218
          do_exit+0xc9/0x8b8
          die+0x99/0xa0
          do_illegal_instruction+0x18/0x6c
          common_exception+0x77/0x77
          coprocessor_flush+0x16/0x3c
          arch_ptrace+0x46c/0x674
          sys_ptrace+0x2ce/0x3b4
          system_call+0x54/0x80
          common_exception+0x77/0x77
        note: gdb[100] exited with preempt_count 1
        Killed
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      2958b666
  13. 23 Nov, 2018 2 commits