1. 02 Jan, 2018 1 commit
    • John Sperbeck's avatar
      powerpc/mm: Fix SEGV on mapped region to return SEGV_ACCERR · ecb101ae
      John Sperbeck authored
      The recent refactoring of the powerpc page fault handler in commit
      c3350602 ("powerpc/mm: Make bad_area* helper functions") caused
      access to protected memory regions to indicate SEGV_MAPERR instead of
      the traditional SEGV_ACCERR in the si_code field of a user-space
      signal handler. This can confuse debug libraries that temporarily
      change the protection of memory regions, and expect to use SEGV_ACCERR
      as an indication to restore access to a region.
      
      This commit restores the previous behavior. The following program
      exhibits the issue:
      
          $ ./repro read  || echo "FAILED"
          $ ./repro write || echo "FAILED"
          $ ./repro exec  || echo "FAILED"
      
          #include <stdio.h>
          #include <stdlib.h>
          #include <string.h>
          #include <unistd.h>
          #include <signal.h>
          #include <sys/mman.h>
          #include <assert.h>
      
          static void segv_handler(int n, siginfo_t *info, void *arg) {
                  _exit(info->si_code == SEGV_ACCERR ? 0 : 1);
          }
      
          int main(int argc, char **argv)
          {
                  void *p = NULL;
                  struct sigaction act = {
                          .sa_sigaction = segv_handler,
                          .sa_flags = SA_SIGINFO,
                  };
      
                  assert(argc == 2);
                  p = mmap(NULL, getpagesize(),
                          (strcmp(argv[1], "write") == 0) ? PROT_READ : 0,
                          MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
                  assert(p != MAP_FAILED);
      
                  assert(sigaction(SIGSEGV, &act, NULL) == 0);
                  if (strcmp(argv[1], "read") == 0)
                          printf("%c", *(unsigned char *)p);
                  else if (strcmp(argv[1], "write") == 0)
                          *(unsigned char *)p = 0;
                  else if (strcmp(argv[1], "exec") == 0)
                          ((void (*)(void))p)();
                  return 1;  /* failed to generate SEGV */
          }
      
      Fixes: c3350602
      
       ("powerpc/mm: Make bad_area* helper functions")
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: default avatarJohn Sperbeck <jsperbeck@google.com>
      Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      [mpe: Add commit references in change log]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ecb101ae
  2. 10 Aug, 2017 2 commits
  3. 03 Aug, 2017 19 commits
  4. 02 Aug, 2017 2 commits
  5. 02 Jun, 2017 4 commits
  6. 03 Apr, 2017 1 commit
    • Anton Blanchard's avatar
      powerpc: Avoid taking a data miss on every userspace instruction miss · a7a9dcd8
      Anton Blanchard authored
      
      
      Early on in do_page_fault() we call store_updates_sp(), regardless of
      the type of exception. For an instruction miss this doesn't make
      sense, because we only use this information to detect if a data miss
      is the result of a stack expansion instruction or not.
      
      Worse still, it results in a data miss within every userspace
      instruction miss handler, because we try and load the very instruction
      we are about to install a pte for!
      
      A simple exec microbenchmark runs 6% faster on POWER8 with this fix:
      
       #include <stdlib.h>
       #include <stdio.h>
       #include <unistd.h>
      
      int main(int argc, char *argv[])
      {
      	unsigned long left = atol(argv[1]);
      	char leftstr[16];
      
      	if (left-- == 0)
      		return 0;
      
      	sprintf(leftstr, "%ld", left);
      	execlp(argv[0], argv[0], leftstr, NULL);
      	perror("exec failed\n");
      
      	return 0;
      }
      
      Pass the number of iterations on the command line (eg 10000) and time
      how long it takes to execute.
      
      Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      a7a9dcd8
  7. 21 Mar, 2017 3 commits
  8. 02 Mar, 2017 1 commit
  9. 15 Feb, 2017 1 commit
    • Aneesh Kumar K.V's avatar
      powerpc/mm: Update PROTFAULT handling in the page fault path · 18061c17
      Aneesh Kumar K.V authored
      
      
      With radix, we can get page fault with DSISR_PROTFAULT value set in case of
      PROT_NONE or autonuma mapping. The PROT_NONE case in handled by the vma check
      where we consider the access bad. For autonuma we should fall through and fixup
      the access mask correctly.
      
      Without this patch we trigger the WARN_ON() on radix. This code moves that
      WARN_ON() within a radix_enabled() check. I also moved the WARN_ON() outside
      the if condition making it apply for all type of faults (exec/write/read). It
      is also conditionalized for book3s, because BOOK3E can also get a PROTFAULT to
      handle the D/I cache sync.
      
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      18061c17
  10. 08 Feb, 2017 1 commit
  11. 30 Nov, 2016 1 commit
  12. 25 Nov, 2016 1 commit
  13. 14 Nov, 2016 1 commit
  14. 19 Sep, 2016 1 commit
  15. 22 Aug, 2016 1 commit