Skip to content
Snippets Groups Projects
  1. May 03, 2019
  2. Apr 15, 2019
  3. Apr 06, 2019
    • Helge Deller's avatar
      parisc: Detect QEMU earlier in boot process · d006e95b
      Helge Deller authored
      
      While adding LASI support to QEMU, I noticed that the QEMU detection in
      the kernel happens much too late. For example, when a LASI chip is found
      by the kernel, it registers the LASI LED driver as well.  But when we
      run on QEMU it makes sense to avoid spending unnecessary CPU cycles, so
      we need to access the running_on_QEMU flag earlier than before.
      
      This patch now makes the QEMU detection the fist task of the Linux
      kernel by moving it to where the kernel enters the C-coding.
      
      Fixes: 310d8278 ("parisc: qemu idle sleep support")
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org # v4.14+
      d006e95b
  4. Feb 21, 2019
  5. Feb 06, 2019
    • Arnd Bergmann's avatar
      y2038: add 64-bit time_t syscalls to all 32-bit architectures · 48166e6e
      Arnd Bergmann authored
      
      This adds 21 new system calls on each ABI that has 32-bit time_t
      today. All of these have the exact same semantics as their existing
      counterparts, and the new ones all have macro names that end in 'time64'
      for clarification.
      
      This gets us to the point of being able to safely use a C library
      that has 64-bit time_t in user space. There are still a couple of
      loose ends to tie up in various areas of the code, but this is the
      big one, and should be entirely uncontroversial at this point.
      
      In particular, there are four system calls (getitimer, setitimer,
      waitid, and getrusage) that don't have a 64-bit counterpart yet,
      but these can all be safely implemented in the C library by wrapping
      around the existing system calls because the 32-bit time_t they
      pass only counts elapsed time, not time since the epoch. They
      will be dealt with later.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      48166e6e
    • Arnd Bergmann's avatar
      y2038: rename old time and utime syscalls · d33c577c
      Arnd Bergmann authored
      
      The time, stime, utime, utimes, and futimesat system calls are only
      used on older architectures, and we do not provide y2038 safe variants
      of them, as they are replaced by clock_gettime64, clock_settime64,
      and utimensat_time64.
      
      However, for consistency it seems better to have the 32-bit architectures
      that still use them call the "time32" entry points (leaving the
      traditional handlers for the 64-bit architectures), like we do for system
      calls that now require two versions.
      
      Note: We used to always define __ARCH_WANT_SYS_TIME and
      __ARCH_WANT_SYS_UTIME and only set __ARCH_WANT_COMPAT_SYS_TIME and
      __ARCH_WANT_SYS_UTIME32 for compat mode on 64-bit kernels. Now this is
      reversed: only 64-bit architectures set __ARCH_WANT_SYS_TIME/UTIME, while
      we need __ARCH_WANT_SYS_TIME32/UTIME32 for 32-bit architectures and compat
      mode. The resulting asm/unistd.h changes look a bit counterintuitive.
      
      This is only a cleanup patch and it should not change any behavior.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      d33c577c
    • Arnd Bergmann's avatar
      y2038: use time32 syscall names on 32-bit · 00bf25d6
      Arnd Bergmann authored
      
      This is the big flip, where all 32-bit architectures set COMPAT_32BIT_TIME
      and use the _time32 system calls from the former compat layer instead
      of the system calls that take __kernel_timespec and similar arguments.
      
      The temporary redirects for __kernel_timespec, __kernel_itimerspec
      and __kernel_timex can get removed with this.
      
      It would be easy to split this commit by architecture, but with the new
      generated system call tables, it's easy enough to do it all at once,
      which makes it a little easier to check that the changes are the same
      in each table.
      
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      00bf25d6
    • Arnd Bergmann's avatar
      y2038: syscalls: rename y2038 compat syscalls · 8dabe724
      Arnd Bergmann authored
      
      A lot of system calls that pass a time_t somewhere have an implementation
      using a COMPAT_SYSCALL_DEFINEx() on 64-bit architectures, and have
      been reworked so that this implementation can now be used on 32-bit
      architectures as well.
      
      The missing step is to redefine them using the regular SYSCALL_DEFINEx()
      to get them out of the compat namespace and make it possible to build them
      on 32-bit architectures.
      
      Any system call that ends in 'time' gets a '32' suffix on its name for
      that version, while the others get a '_time32' suffix, to distinguish
      them from the normal version, which takes a 64-bit time argument in the
      future.
      
      In this step, only 64-bit architectures are changed, doing this rename
      first lets us avoid touching the 32-bit architectures twice.
      
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      8dabe724
  6. Jan 25, 2019
  7. Dec 20, 2018
    • 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
  8. Dec 13, 2018
  9. Dec 10, 2018
    • Firoz Khan's avatar
      parisc: generate uapi header and system call table files · 575afc4d
      Firoz Khan authored
      
      System call table generation script must be run to gener-
      ate unistd_32/64.h and syscall_table_32/64/c32.h files.
      This patch will have changes which will invokes the script.
      
      This patch will generate unistd_32/64.h and syscall_table-
      _32/64/c32.h files by the syscall table generation script
      invoked by parisc/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.S file.
      
      Signed-off-by: default avatarFiroz Khan <firoz.khan@linaro.org>
      Acked-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      575afc4d
    • Firoz Khan's avatar
      parisc: add system call table generation support · 85e69701
      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.
      	- Compat entry name, if required.
      
      syscallhdr.sh and syscalltbl.sh will generate uapi header
      unistd_32/64.h and syscall_table_32/64/c32.h files respect-
      ively. Both .sh files will parse the content syscall.tbl
      to generate the header and table files. unistd_32/64.h will
      be included by uapi/asm/unistd.h and syscall_table_32/64/-
      c32.h is included by kernel/syscall.S - 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>
      Acked-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      85e69701
    • Helge Deller's avatar
      parisc: Split out alternative live patching code · 8cc28269
      Helge Deller authored
      
      Move the alternative implemenation coding to alternative.c and add code to
      patch modules while loading.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      8cc28269
  10. Nov 28, 2018
    • Steven Rostedt (VMware)'s avatar
      parisc: function_graph: Simplify with function_graph_enter() · a87532c7
      Steven Rostedt (VMware) authored
      
      The function_graph_enter() function does the work of calling the function
      graph hook function and the management of the shadow stack, simplifying the
      work done in the architecture dependent prepare_ftrace_return().
      
      Have parisc use the new code, and remove the shadow stack management as well as
      having to set up the trace structure.
      
      This is needed to prepare for a fix of a design bug on how the curr_ret_stack
      is used.
      
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: linux-parisc@vger.kernel.org
      Cc: stable@kernel.org
      Fixes: 03274a3f ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      a87532c7
  11. Nov 06, 2018
    • John David Anglin's avatar
      parisc: Revert "Release spinlocks using ordered store" · 86d4d068
      John David Anglin authored
      
      This reverts commit d27dfa13.
      
      Unfortunately, this patch needs to be reverted.  We need the full sync
      barrier and not the limited barrier provided by using an ordered store.
      The sync ensures that all accesses and cache purge instructions that
      follow the sync are performed after all such instructions prior the sync
      instruction have completed executing.
      
      The patch breaks the rwlock implementation in glibc.  This caused the
      test-lock application in the libprelude testsuite to hang.  With the
      change reverted, the test runs correctly and the libprelude package
      builds successfully.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      86d4d068
  12. Oct 26, 2018
  13. Oct 20, 2018
    • Helge Deller's avatar
      e543b3a6
    • John David Anglin's avatar
      parisc: Optimze cache flush algorithms · 4c5fe5db
      John David Anglin authored
      
      The attached patch implements three optimizations:
      
      1) Loops in flush_user_dcache_range_asm, flush_kernel_dcache_range_asm,
      purge_kernel_dcache_range_asm, flush_user_icache_range_asm, and
      flush_kernel_icache_range_asm are unrolled to reduce branch overhead.
      
      2) The static branch prediction for cmpb instructions in pacache.S have
      been reviewed and the operand order adjusted where necessary.
      
      3) For flush routines in cache.c, we purge rather flush when we have no
      context.  The pdc instruction at level 0 is not required to write back
      dirty lines to memory. This provides a performance improvement over the
      fdc instruction if the feature is implemented.
      
      Version 2 adds alternative patching.
      
      The patch provides an average improvement of about 2%.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      4c5fe5db
  14. Oct 19, 2018
  15. Oct 17, 2018
    • Helge Deller's avatar
      parisc: Add alternative coding infrastructure · 3847dab7
      Helge Deller authored
      
      This patch adds the necessary code to patch a running kernel at runtime
      to improve performance.
      
      The current implementation offers a few optimizations variants:
      
      - When running a SMP kernel on a single UP processor, unwanted assembler
        statements like locking functions are overwritten with NOPs. When
        multiple instructions shall be skipped, one branch instruction is used
        instead of multiple nop instructions.
      
      - In the UP case, some pdtlb and pitlb instructions are patched to
        become pdtlb,l and pitlb,l which only flushes the CPU-local tlb
        entries instead of broadcasting the flush to other CPUs in the system
        and thus may improve performance.
      
      - fic and fdc instructions are skipped if no I- or D-caches are
        installed.  This should speed up qemu emulation and cacheless systems.
      
      - If no cache coherence is needed for IO operations, the relevant fdc
        and sync instructions in the sba and ccio drivers are replaced by
        nops.
      
      - On systems which share I- and D-TLBs and thus don't have a seperate
        instruction TLB, the pitlb instruction is replaced by a nop.
      
      Live-patching is done early in the boot process, just after having run
      the system inventory. No drivers are running and thus no external
      interrupts should arrive. So the hope is that no TLB exceptions will
      occur during the patching. If this turns out to be wrong we will
      probably need to do the patching in real-mode.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      3847dab7
    • John David Anglin's avatar
      parisc: Fix address in HPMC IVA · 1138b671
      John David Anglin authored
      
      Helge noticed that the address of the os_hpmc handler was not being
      correctly calculated in the hpmc macro.  As a result, PDCE_CHECK would
      fail to call os_hpmc:
      
      <Cpu2> e800009802e00000  0000000000000000  CC_ERR_CHECK_HPMC
      <Cpu2> 37000f7302e00000  8040004000000000  CC_ERR_CPU_CHECK_SUMMARY
      <Cpu2> f600105e02e00000  fffffff0f0c00000  CC_MC_HPMC_MONARCH_SELECTED
      <Cpu2> 140003b202e00000  000000000000000b  CC_ERR_HPMC_STATE_ENTRY
      <Cpu2> 5600100b02e00000  00000000000001a0  CC_MC_OS_HPMC_LEN_ERR
      <Cpu2> 5600106402e00000  fffffff0f0438e70  CC_MC_BR_TO_OS_HPMC_FAILED
      <Cpu2> e800009802e00000  0000000000000000  CC_ERR_CHECK_HPMC
      <Cpu2> 37000f7302e00000  8040004000000000  CC_ERR_CPU_CHECK_SUMMARY
      <Cpu2> 4000109f02e00000  0000000000000000  CC_MC_HPMC_INITIATED
      <Cpu2> 4000101902e00000  0000000000000000  CC_MC_MULTIPLE_HPMCS
      <Cpu2> 030010d502e00000  0000000000000000  CC_CPU_STOP
      
      The address problem can be seen by dumping the fault vector:
      
      0000000040159000 <fault_vector_20>:
          40159000:   63 6f 77 73     stb r15,-2447(dp)
          40159004:   20 63 61 6e     ldil L%b747000,r3
          40159008:   20 66 6c 79     ldil L%-1c3b3000,r3
              ...
          40159020:   08 00 02 40     nop
          40159024:   20 6e 60 02     ldil L%15d000,r3
          40159028:   34 63 00 00     ldo 0(r3),r3
          4015902c:   e8 60 c0 02     bv,n r0(r3)
          40159030:   08 00 02 40     nop
          40159034:   00 00 00 00     break 0,0
          40159038:   c0 00 70 00     bb,*< r0,sar,40159840 <fault_vector_20+0x840>
          4015903c:   00 00 00 00     break 0,0
      
      Location 40159038 should contain the physical address of os_hpmc:
      
      000000004015d000 <os_hpmc>:
          4015d000:   08 1a 02 43     copy r26,r3
          4015d004:   01 c0 08 a4     mfctl iva,r4
          4015d008:   48 85 00 68     ldw 34(r4),r5
      
      This patch moves the address setup into initialize_ivt to resolve the
      above problem.  I tested the change by dumping the HPMC entry after setup:
      
      0000000040209020:  8000240
      0000000040209024: 206a2004
      0000000040209028: 34630ac0
      000000004020902c: e860c002
      0000000040209030:  8000240
      0000000040209034: 1bdddce6
      0000000040209038:   15d000
      000000004020903c:      1a0
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      1138b671
    • Helge Deller's avatar
      parisc: Fix exported address of os_hpmc handler · 99a3ae51
      Helge Deller authored
      
      In the C-code we need to put the physical address of the hpmc handler in
      the interrupt vector table (IVA) in order to get HPMCs working.  Since
      on parisc64 function pointers are indirect (in fact they are function
      descriptors) we instead export the address as variable and not as
      function.
      
      This reverts a small part of commit f39cce65 ("parisc: Add
      cfi_startproc and cfi_endproc to assembly code").
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: <stable@vger.kernel.org>    [4.9+]
      99a3ae51
    • John David Anglin's avatar
      parisc: Purge TLB entries after updating page table entry and set page accessed flag in TLB handler · 4dd5b673
      John David Anglin authored
      
      This patch may resolve some races in TLB handling.  Hopefully, TLB
      inserts are accesses and protected by spin lock.
      
      If not, we may need to IPI calls and do local purges on PA 2.0.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      4dd5b673
    • John David Anglin's avatar
      parisc: Release spinlocks using ordered store · d27dfa13
      John David Anglin authored
      
      This patch updates the spin unlock code to use an ordered store with
      release semanatics.  All prior accesses are guaranteed to be performed
      before an ordered store is performed.
      
      Using an ordered store is significantly faster than using the sync
      memory barrier.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      d27dfa13
    • Helge Deller's avatar
      parisc: Clean up crash header output · e98bc5ee
      Helge Deller authored
      
      On kernel crash, this is the current output:
      Kernel Fault: Code=26 (Data memory access rights trap) regs=(ptrval) (Addr=00000004)
      
      Drop the address of regs, it's of no use for debugging, and show the
      faulty address without parenthesis.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      e98bc5ee
    • John David Anglin's avatar
      parisc: Remove PTE load and fault check from L2_ptep macro · 32a7901f
      John David Anglin authored
      
      This change removes the PTE load and present check from the L2_ptep
      macro.  The load and check for kernel pages is now done in the tlb_lock
      macro.  This avoids a double load and check for user pages.  The load
      and check for user pages is now done inside the lock so the fault
      handler can't be called while the entry is being updated.  This version
      uses an ordered store to release the lock when the page table entry
      isn't present.  It also corrects the check in the non SMP case.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      32a7901f
    • John David Anglin's avatar
      parisc: Reorder TLB flush timing calculation · a886c979
      John David Anglin authored
      
      On boot (mostly reboot), my c8000 sometimes crashes after it prints the
      TLB flush threshold.  The lockup is hard.  The front LED flashes red and
      the box must be unplugged to reset the error.
      
      I noticed that when the crash occurs the TLB flush threshold is about
      one quarter what it is on a successful boot.  If I disabled the
      calculation, the crash didn't occur.  There also seemed to be a timing
      dependency affecting the crash.  I finally realized that the
      flush_tlb_all() timing test runs just after the secondary CPUs are
      started.  There seems to be a problem with running flush_tlb_all() too
      soon after the CPUs are started.
      
      The timing for the range test always seemed okay.  So, I reversed the
      order of the two timing tests and I haven't had a crash at this point so
      far.
      
      I added a couple of information messages which I have left to help with
      diagnosis if the problem should appear on another machine.
      
      This version reduces the minimum TLB flush threshold to 16 KiB.
      
      Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      a886c979
    • Helge Deller's avatar
      parisc: Use PARISC_ITLB_TRAP constant in entry.S · cd2b8520
      Helge Deller authored
      
      Fixes: 5b00ca0b ("parisc: Restore possibility to execute 64-bit applications")
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      cd2b8520
Loading