• Michael Ellerman's avatar
    powerpc/mm/radix: Only add X for pages overlapping kernel text · 9abcc981
    Michael Ellerman authored
    Currently we map the whole linear mapping with PAGE_KERNEL_X. Instead we
    should check if the page overlaps the kernel text and only then add
    PAGE_KERNEL_X.
    
    Note that we still use 1G pages if they're available, so this will
    typically still result in a 1G executable page at KERNELBASE. So this fix is
    primarily useful for catching stray branches to high linear mapping addresses.
    
    Without this patch, we can execute at 1G in xmon using:
    
      0:mon> m c000000040000000
      c000000040000000  00 l
      c000000040000000  00000000 01006038
      c000000040000004  00000000 2000804e
      c000000040000008  00000000 x
      0:mon> di c000000040000000
      c000000040000000  38600001      li      r3,1
      c000000040000004  4e800020      blr
      0:mon> p c000000040000000
      return value is 0x1
    
    After we get a 400 as expected:
    
      0:mon> p c000000040000000
      *** 400 exception occurred
    
    Fixes: 2bfd65e4 ("powerpc/mm/radix: Add radix callbacks for early init routines")
    Cc: stable@vger.kernel.org # v4.7+
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    Acked-by: default avatarBalbir Singh <bsingharora@gmail.com>
    9abcc981
pgtable-radix.c 19 KB