1. 19 Feb, 2019 1 commit
  2. 17 Feb, 2019 1 commit
    • Michael Ellerman's avatar
      powerpc/64s: Fix possible corruption on big endian due to pgd/pud_present() · a5800762
      Michael Ellerman authored
      In v4.20 we changed our pgd/pud_present() to check for _PAGE_PRESENT
      rather than just checking that the value is non-zero, e.g.:
      
        static inline int pgd_present(pgd_t pgd)
        {
       -       return !pgd_none(pgd);
       +       return (pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
        }
      
      Unfortunately this is broken on big endian, as the result of the
      bitwise & is truncated to int, which is always zero because
      _PAGE_PRESENT is 0x8000000000000000ul. This means pgd_present() and
      pud_present() are always false at compile time, and the compiler
      elides the subsequent code.
      
      Remarkably with that bug present we are still able to boot and run
      with few noticeable effects. However under some work loads we are able
      to trigger a warning in the ext4 code:
      
        WARNING: CPU: 11 PID: 29593 at fs/ext4/inode.c:3927 .ext4_set_page_dirty+0x70/0xb0
        CPU: 11 PID: 29593 Comm: debugedit Not tainted 4.20.0-rc1 #1
        ...
        NIP .ext4_set_page_dirty+0x70/0xb0
        LR  .set_page_dirty+0xa0/0x150
        Call Trace:
         .set_page_dirty+0xa0/0x150
         .unmap_page_range+0xbf0/0xe10
         .unmap_vmas+0x84/0x130
         .unmap_region+0xe8/0x190
         .__do_munmap+0x2f0/0x510
         .__vm_munmap+0x80/0x110
         .__se_sys_munmap+0x14/0x30
         system_call+0x5c/0x70
      
      The fix is simple, we need to convert the result of the bitwise & to
      an int before returning it.
      
      Thanks to Erhard, Jan Kara and Aneesh for help with debugging.
      
      Fixes: da7ad366 ("powerpc/mm/book3s: Update pmd_present to look at _PAGE_PRESENT bit")
      Cc: stable@vger.kernel.org # v4.20+
      Reported-by: default avatarErhard F. <erhard_f@mailbox.org>
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a5800762
  3. 06 Feb, 2019 2 commits
  4. 05 Feb, 2019 7 commits
  5. 04 Feb, 2019 1 commit
  6. 03 Feb, 2019 2 commits
  7. 01 Feb, 2019 1 commit
  8. 31 Jan, 2019 7 commits
    • Oliver O'Halloran's avatar
      powerpc/papr_scm: Use the correct bind address · 5a3840a4
      Oliver O'Halloran authored
      When binding an SCM volume to a physical address the hypervisor has the
      option to return early with a continue token with the expectation that
      the guest will resume the bind operation until it completes. A quirk of
      this interface is that the bind address will only be returned by the
      first bind h-call and the subsequent calls will return
      0xFFFF_FFFF_FFFF_FFFF for the bind address.
      
      We currently do not save the address returned by the first h-call. As a
      result we will use the junk address as the base of the bound region if
      the hypervisor decides to split the bind across multiple h-calls. This
      bug was found when testing with very large SCM volumes where the bind
      process would take more time than they hypervisor's internal h-call time
      limit would allow. This patch fixes the issue by saving the bind address
      from the first call.
      
      Cc: stable@vger.kernel.org
      Fixes: b5beae5e ("powerpc/pseries: Add driver for PAPR SCM regions")
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      5a3840a4
    • Aneesh Kumar K.V's avatar
      powerpc/radix: Fix kernel crash with mremap() · 579b9239
      Aneesh Kumar K.V authored
      With support for split pmd lock, we use pmd page pmd_huge_pte pointer
      to store the deposited page table. In those config when we move page
      tables we need to make sure we move the deposited page table to the
      correct pmd page. Otherwise this can result in crash when we withdraw
      of deposited page table because we can find the pmd_huge_pte NULL.
      
      eg:
      
        __split_huge_pmd+0x1070/0x1940
        __split_huge_pmd+0xe34/0x1940 (unreliable)
        vma_adjust_trans_huge+0x110/0x1c0
        __vma_adjust+0x2b4/0x9b0
        __split_vma+0x1b8/0x280
        __do_munmap+0x13c/0x550
        sys_mremap+0x220/0x7e0
        system_call+0x5c/0x70
      
      Fixes: 675d9952 ("powerpc/book3s64: Enable split pmd ptlock.")
      Cc: stable@vger.kernel.org # v4.18+
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      579b9239
    • Joe Lawrence's avatar
      powerpc/livepatch: return -ERRNO values in save_stack_trace_tsk_reliable() · 3de27dcf
      Joe Lawrence authored
      To match its x86 counterpart, save_stack_trace_tsk_reliable() should
      return -EINVAL in cases that it is currently returning 1.  No caller is
      currently differentiating non-zero error codes, but let's keep the
      arch-specific implementations consistent.
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      3de27dcf
    • Joe Lawrence's avatar
      powerpc/livepatch: small cleanups in save_stack_trace_tsk_reliable() · 29a77bbb
      Joe Lawrence authored
      Mostly cosmetic changes:
      
      - Group common stack pointer code at the top
      - Simplify the first frame logic
      - Code stackframe iteration into for...loop construct
      - Check for trace->nr_entries overflow before adding any into the array
      Suggested-by: default avatarNicolai Stange <nstange@suse.de>
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      29a77bbb
    • Joe Lawrence's avatar
      powerpc/livepatch: relax reliable stack tracer checks for first-frame · 18be3760
      Joe Lawrence authored
      The bottom-most stack frame (the first to be unwound) may be largely
      uninitialized, for the "Power Architecture 64-Bit ELF V2 ABI" only
      requires its backchain pointer to be set.
      
      The reliable stack tracer should be careful when verifying this frame:
      skip checks on STACK_FRAME_LR_SAVE and STACK_FRAME_MARKER offsets that
      may contain uninitialized residual data.
      
      Fixes: df78d3f6 ("powerpc/livepatch: Implement reliable stack tracing for the consistency model")
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      18be3760
    • Nicolai Stange's avatar
      powerpc/64s: Make reliable stacktrace dependency clearer · a50d3250
      Nicolai Stange authored
      Make the HAVE_RELIABLE_STACKTRACE Kconfig option depend on
      PPC_BOOK3S_64 for documentation purposes. Before this patch, it
      depended on PPC64 && CPU_LITTLE_ENDIAN and because CPU_LITTLE_ENDIAN
      implies PPC_BOOK3S_64, there's no functional change here.
      Signed-off-by: default avatarNicolai Stange <nstange@suse.de>
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      [mpe: Split out of larger patch]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a50d3250
    • Nicolai Stange's avatar
      powerpc/64s: Clear on-stack exception marker upon exception return · eddd0b33
      Nicolai Stange authored
      The ppc64 specific implementation of the reliable stacktracer,
      save_stack_trace_tsk_reliable(), bails out and reports an "unreliable
      trace" whenever it finds an exception frame on the stack. Stack frames
      are classified as exception frames if the STACK_FRAME_REGS_MARKER
      magic, as written by exception prologues, is found at a particular
      location.
      
      However, as observed by Joe Lawrence, it is possible in practice that
      non-exception stack frames can alias with prior exception frames and
      thus, that the reliable stacktracer can find a stale
      STACK_FRAME_REGS_MARKER on the stack. It in turn falsely reports an
      unreliable stacktrace and blocks any live patching transition to
      finish. Said condition lasts until the stack frame is
      overwritten/initialized by function call or other means.
      
      In principle, we could mitigate this by making the exception frame
      classification condition in save_stack_trace_tsk_reliable() stronger:
      in addition to testing for STACK_FRAME_REGS_MARKER, we could also take
      into account that for all exceptions executing on the kernel stack
        - their stack frames's backlink pointers always match what is saved
          in their pt_regs instance's ->gpr[1] slot and that
        - their exception frame size equals STACK_INT_FRAME_SIZE, a value
          uncommonly large for non-exception frames.
      
      However, while these are currently true, relying on them would make
      the reliable stacktrace implementation more sensitive towards future
      changes in the exception entry code. Note that false negatives, i.e.
      not detecting exception frames, would silently break the live patching
      consistency model.
      
      Furthermore, certain other places (diagnostic stacktraces, perf, xmon)
      rely on STACK_FRAME_REGS_MARKER as well.
      
      Make the exception exit code clear the on-stack
      STACK_FRAME_REGS_MARKER for those exceptions running on the "normal"
      kernel stack and returning to kernelspace: because the topmost frame
      is ignored by the reliable stack tracer anyway, returns to userspace
      don't need to take care of clearing the marker.
      
      Furthermore, as I don't have the ability to test this on Book 3E or 32
      bits, limit the change to Book 3S and 64 bits.
      
      Fixes: df78d3f6 ("powerpc/livepatch: Implement reliable stack tracing for the consistency model")
      Reported-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Signed-off-by: default avatarNicolai Stange <nstange@suse.de>
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      eddd0b33
  9. 30 Jan, 2019 8 commits
  10. 15 Jan, 2019 10 commits