1. 18 Jul, 2017 1 commit
    • Michael Ellerman's avatar
      powerpc/mm: Mark __init memory no-execute when STRICT_KERNEL_RWX=y · 029d9252
      Michael Ellerman authored
      Currently even with STRICT_KERNEL_RWX we leave the __init text marked
      executable after init, which is bad.
      
      Add a hook to mark it NX (no-execute) before we free it, and implement
      it for radix and hash.
      
      Note that we use __init_end as the end address, not _einittext,
      because overlaps_kernel_text() uses __init_end, because there are
      additional executable sections other than .init.text between
      __init_begin and __init_end.
      
      Tested on radix and hash with:
      
        0:mon> p $__init_begin
        *** 400 exception occurred
      
      Fixes: 1e0fc9d1
      
       ("powerpc/Kconfig: Enable STRICT_KERNEL_RWX for some configs")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      029d9252
  2. 02 Jul, 2017 1 commit
  3. 27 Apr, 2017 1 commit
  4. 12 Apr, 2017 1 commit
    • Michael Ellerman's avatar
      powerpc/mm: Fix swapper_pg_dir size on 64-bit hash w/64K pages · 03dfee6d
      Michael Ellerman authored
      Recently in commit f6eedbba ("powerpc/mm/hash: Increase VA range to 128TB"),
      we increased H_PGD_INDEX_SIZE to 15 when we're building with 64K pages. This
      makes it larger than RADIX_PGD_INDEX_SIZE (13), which means the logic to
      calculate MAX_PGD_INDEX_SIZE in book3s/64/pgtable.h is wrong.
      
      The end result is that the PGD (Page Global Directory, ie top level page table)
      of the kernel (aka. swapper_pg_dir), is too small.
      
      This generally doesn't lead to a crash, as we don't use the full range in normal
      operation. However if we try to dump the kernel pagetables we can trigger a
      crash because we walk off the end of the pgd into other memory and eventually
      try to dereference something bogus:
      
        $ cat /sys/kernel/debug/kernel_pagetables
        Unable to handle kernel paging request for data at address 0xe8fece0000000000
        Faulting instruction address: 0xc000000000072314
        cpu 0xc: Vector: 380 (Data SLB Access) at [c0000000daa13890]
            pc: c000000000072314: ptdump_show+0x164/0x430
            lr: c000000000072550: ptdump_show+0x3a0/0x430
           dar: e802cf0000000000
        seq_read+0xf8/0x560
        full_proxy_read+0x84/0xc0
        __vfs_read+0x6c/0x1d0
        vfs_read+0xbc/0x1b0
        SyS_read+0x6c/0x110
        system_call+0x38/0xfc
      
      The root cause is that MAX_PGD_INDEX_SIZE isn't actually computed to be
      the max of H_PGD_INDEX_SIZE or RADIX_PGD_INDEX_SIZE. To fix that move
      the calculation into asm-offsets.c where we can do it easily using
      max().
      
      Fixes: f6eedbba
      
       ("powerpc/mm/hash: Increase VA range to 128TB")
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      03dfee6d
  5. 31 Mar, 2017 5 commits
  6. 10 Mar, 2017 2 commits
  7. 09 Mar, 2017 1 commit
  8. 25 Feb, 2017 1 commit
  9. 15 Feb, 2017 1 commit
  10. 13 Dec, 2016 2 commits
  11. 10 Dec, 2016 1 commit
    • Christophe Leroy's avatar
      powerpc: port 64 bits pgtable_cache to 32 bits · 9b081e10
      Christophe Leroy authored
      
      
      Today powerpc64 uses a set of pgtable_caches while powerpc32 uses
      standard pages when using 4k pages and a single pgtable_cache
      if using other size pages.
      
      In preparation of implementing huge pages on the 8xx, this patch
      replaces the specific powerpc32 handling by the 64 bits approach.
      
      This is done by:
      * moving 64 bits pgtable_cache_add() and pgtable_cache_init()
      in a new file called init-common.c
      * modifying pgtable_cache_init() to also handle the case
      without PMD
      * removing the 32 bits version of pgtable_cache_add() and
      pgtable_cache_init()
      * copying related header contents from 64 bits into both the
      book3s/32 and nohash/32 header files
      
      On the 8xx, the following cache sizes will be used:
      * 4k pages mode:
      - PGT_CACHE(10) for PGD
      - PGT_CACHE(3) for 512k hugepage tables
      * 16k pages mode:
      - PGT_CACHE(6) for PGD
      - PGT_CACHE(7) for 512k hugepage tables
      - PGT_CACHE(3) for 8M hugepage tables
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: default avatarScott Wood <oss@buserror.net>
      9b081e10
  12. 28 Nov, 2016 2 commits
  13. 22 Sep, 2016 1 commit
  14. 13 Sep, 2016 1 commit
  15. 17 Jul, 2016 1 commit
    • Aneesh Kumar K.V's avatar
      powerpc/mm: use _raw variant of page table accessors · 66c570f5
      Aneesh Kumar K.V authored
      
      
      This switch few of the page table accessor to use the __raw variant
      and does the cpu to big endian conversion of constants. This helps in
      generating better code.
      
      For ex: a pgd_none(pgd) check with and without fix is listed below
      
      Without fix:
      ------------
         2240:	20 00 61 eb 	ld      r27,32(r1)
      /* PGD level */
      typedef struct { __be64 pgd; } pgd_t;
      static inline unsigned long pgd_val(pgd_t x)
      {
      	return be64_to_cpu(x.pgd);
      
          2244:	22 00 66 78 	rldicl  r6,r3,32,32
          2248:	3e 40 7d 54 	rotlwi  r29,r3,8
          224c:	0e c0 7d 50 	rlwimi  r29,r3,24,0,7
          2250:	3e 40 c5 54 	rotlwi  r5,r6,8
          2254:	2e c4 7d 50 	rlwimi  r29,r3,24,16,23
          2258:	0e c0 c5 50 	rlwimi  r5,r6,24,0,7
          225c:	2e c4 c5 50 	rlwimi  r5,r6,24,16,23
          2260:	c6 07 bd 7b 	rldicr  r29,r29,32,31
          2264:	78 2b bd 7f 	or      r29,r29,r5
      		if (pgd_none(pgd))
          2268:	00 00 bd 2f 	cmpdi   cr7,r29,0
          226c:	54 03 9e 41 	beq     cr7,25c0 <__get_user_pages_fast+0x500>
      
      With fix:
      ---------
          2370:	20 00 61 eb 	ld      r27,32(r1)
      		if (pgd_none(pgd))
          2374:	00 00 bd 2f 	cmpdi   cr7,r29,0
          2378:	a8 03 9e 41 	beq     cr7,2720 <__get_user_pages_fast+0x530>
      			break;
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Acked-by: default avatarBalbir Singh <bsingharora@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      66c570f5
  16. 30 Jun, 2016 1 commit
  17. 20 May, 2016 1 commit
    • Hugh Dickins's avatar
      arch: fix has_transparent_hugepage() · fd8cfd30
      Hugh Dickins authored
      
      
      I've just discovered that the useful-sounding has_transparent_hugepage()
      is actually an architecture-dependent minefield: on some arches it only
      builds if CONFIG_TRANSPARENT_HUGEPAGE=y, on others it's also there when
      not, but on some of those (arm and arm64) it then gives the wrong
      answer; and on mips alone it's marked __init, which would crash if
      called later (but so far it has not been called later).
      
      Straighten this out: make it available to all configs, with a sensible
      default in asm-generic/pgtable.h, removing its definitions from those
      arches (arc, arm, arm64, sparc, tile) which are served by the default,
      adding #define has_transparent_hugepage has_transparent_hugepage to
      those (mips, powerpc, s390, x86) which need to override the default at
      runtime, and removing the __init from mips (but maybe that kind of code
      should be avoided after init: set a static variable the first time it's
      called).
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Andres Lagar-Cavilla <andreslc@google.com>
      Cc: Yang Shi <yang.shi@linaro.org>
      Cc: Ning Qu <quning@gmail.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: Vineet Gupta <vgupta@synopsys.com>		[arch/arc]
      Acked-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>	[arch/s390]
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fd8cfd30
  18. 11 May, 2016 8 commits
  19. 01 May, 2016 8 commits