Pull request: scottwood/linux.git next

Michael Ellerman mpe at ellerman.id.au
Wed Nov 13 20:23:21 AEDT 2019


Scott Wood <oss at buserror.net> writes:
> This contains KASLR support for book3e 32-bit.
>
> The following changes since commit 612ee81b9461475b5a5612c2e8d71559dd3c7920:
>
>   powerpc/papr_scm: Fix an off-by-one check in papr_scm_meta_{get, set} (2019-10-10 20:15:53 +1100)
>
> are available in the Git repository at:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/scottwood/linux.git next
>
> for you to fetch changes up to 9df1ef3f1376ec5d3a1b51a4546c94279bcd88ca:
>
>   powerpc/fsl_booke/32: Document KASLR implementation (2019-10-21 16:09:16 -0500)
>
> ----------------------------------------------------------------
> Jason Yan (12):
>       powerpc: unify definition of M_IF_NEEDED
>       powerpc: move memstart_addr and kernstart_addr to init-common.c
>       powerpc: introduce kernstart_virt_addr to store the kernel base
>       powerpc/fsl_booke/32: introduce create_kaslr_tlb_entry() helper
>       powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper
>       powerpc/fsl_booke/32: implement KASLR infrastructure

This commit breaks booting on the qemu mac99 machine, using pmac32_defconfig.

  $ qemu-system-ppc -nographic -vga none -M mac99 -m 1G -kernel vmlinux 
  >> =============================================================
  >> OpenBIOS 1.1 [Oct 5 2018 08:21]
  >> Configuration device id QEMU version 1 machine id 1
  >> CPUs: 1
  >> Memory: 1024M
  >> UUID: 00000000-0000-0000-0000-000000000000
  >> CPU type PowerPC,G4
  milliseconds isn't unique.
  Welcome to OpenBIOS v1.1 built on Oct 5 2018 08:21
  >> [ppc] Kernel already loaded (0x01000000 + 0x009d2920) (initrd 0x00000000 + 0x00000000)
  >> [ppc] Kernel command line: 
  >> switching to new context:
  OF stdout device is: /pci at f2000000/mac-io at c/escc at 13000/ch-a at 13020
  Preparing to boot Linux version 5.4.0-rc2-gcc49-05398-g4e1bb50 (michael at alpine1-p1) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #30 Wed Nov 13 15:07:39 AEDT 2019
  Detected machine type: 00000400
  command line: 
  memory layout at init:
    memory_limit : 00000000 (16 MB aligned)
    alloc_bottom : 019d7000
    alloc_top    : 30000000
    alloc_top_hi : 40000000
    rmo_top      : 30000000
    ram_top      : 40000000
  copying OF device tree...
  Building dt strings...
  Building dt structure...
  Device tree strings 0x019d8000 -> 0x019d70a4
  Device tree struct  0x019d9000 -> 0x3fde7eb0
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x01000000 ...

And no output after that.

The problematic hunk is the change to early_32.c:

diff --git a/arch/powerpc/kernel/early_32.c b/arch/powerpc/kernel/early_32.c
index 3482118ffe76..6f8689d7ca7b 100644
--- a/arch/powerpc/kernel/early_32.c
+++ b/arch/powerpc/kernel/early_32.c
@@ -22,7 +22,8 @@ notrace unsigned long __init early_init(unsigned long dt_ptr)
        unsigned long offset = reloc_offset();
 
        /* First zero the BSS */
-       memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
+       if (kernstart_virt_addr == KERNELBASE)
+               memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
 
        /*
         * Identify the CPU type and fix up code sections
@@ -32,5 +33,5 @@ notrace unsigned long __init early_init(unsigned long dt_ptr)
 
        apply_feature_fixups();
 
-       return KERNELBASE + offset;
+       return kernstart_virt_addr + offset;
 }


It needs to use PTRRELOC() for the kernstart_virt_addr accesses.

I've made that change and squashed it into the series. I've pushed that
as a branch to here:
  https://github.com/linuxppc/linux/commits/topic/kaslr-book3e32


That boots for me on qemu mac99.

Jason can you please test it on your setup with KASLR enabled to make
sure it still works.

cheers


More information about the Linuxppc-dev mailing list