diff mbox

mambo: Add a reservation for the initramfs

Message ID 20170519061648.21543-1-oohall@gmail.com
State Accepted
Headers show

Commit Message

Oliver O'Halloran May 19, 2017, 6:16 a.m. UTC
On most systems the initramfs is loaded inside the part of memory
reserved for the OS [0x0-0x30000000] and skiboot will never touch it.
On mambo it's loaded at 0x80000000 and if you're unlucky skiboot can
allocate over the top of it and corrupt the initramfs blob.

There might be the downside that the kernel cannot re-use the initramfs
memory since it's marked as reserved, but the kernel might also free it
anyway.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 external/mambo/skiboot.tcl | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Ellerman May 29, 2017, 4:41 a.m. UTC | #1
Oliver O'Halloran <oohall@gmail.com> writes:

> On most systems the initramfs is loaded inside the part of memory
> reserved for the OS [0x0-0x30000000] and skiboot will never touch it.
> On mambo it's loaded at 0x80000000 and if you're unlucky skiboot can
> allocate over the top of it and corrupt the initramfs blob.
>
> There might be the downside that the kernel cannot re-use the initramfs
> memory since it's marked as reserved, but the kernel might also free it
> anyway.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
>
> diff --git a/external/mambo/skiboot.tcl b/external/mambo/skiboot.tcl
> index 1b74c9bc5f3d..40e4107bf9a5 100644
> --- a/external/mambo/skiboot.tcl
> +++ b/external/mambo/skiboot.tcl
> @@ -216,6 +216,11 @@ mysim of addprop $reserved_memory int "#size-cells" 2
>  mysim of addprop $reserved_memory int "#address-cells" 2
>  mysim of addprop $reserved_memory empty "ranges" ""
>  
> +set initramfs_res [mysim of addchild $reserved_memory "initramfs" ""]
> +set reg [list $cpio_start $cpio_size ]
> +mysim of addprop $initramfs_res array64 "reg" reg
> +mysim of addprop $initramfs_res empty "name" "initramfs"

For me booting on mambo is broken as of 65612f120735 ("mem_region: Add
reserved regions after memory init").

This fixes it for me.

Tested-by: Michael Ellerman <mpe@ellerman.id.au>

cheers
Stewart Smith June 8, 2017, 7:42 a.m. UTC | #2
Michael Ellerman <mpe@ellerman.id.au> writes:
> Oliver O'Halloran <oohall@gmail.com> writes:
>> On most systems the initramfs is loaded inside the part of memory
>> reserved for the OS [0x0-0x30000000] and skiboot will never touch it.
>> On mambo it's loaded at 0x80000000 and if you're unlucky skiboot can
>> allocate over the top of it and corrupt the initramfs blob.
>>
>> There might be the downside that the kernel cannot re-use the initramfs
>> memory since it's marked as reserved, but the kernel might also free it
>> anyway.
>>
>> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
>>
>> diff --git a/external/mambo/skiboot.tcl b/external/mambo/skiboot.tcl
>> index 1b74c9bc5f3d..40e4107bf9a5 100644
>> --- a/external/mambo/skiboot.tcl
>> +++ b/external/mambo/skiboot.tcl
>> @@ -216,6 +216,11 @@ mysim of addprop $reserved_memory int "#size-cells" 2
>>  mysim of addprop $reserved_memory int "#address-cells" 2
>>  mysim of addprop $reserved_memory empty "ranges" ""
>>  
>> +set initramfs_res [mysim of addchild $reserved_memory "initramfs" ""]
>> +set reg [list $cpio_start $cpio_size ]
>> +mysim of addprop $initramfs_res array64 "reg" reg
>> +mysim of addprop $initramfs_res empty "name" "initramfs"
>
> For me booting on mambo is broken as of 65612f120735 ("mem_region: Add
> reserved regions after memory init").
>
> This fixes it for me.
>
> Tested-by: Michael Ellerman <mpe@ellerman.id.au>

I merged it, and then merged in
https://patchwork.ozlabs.org/patch/772847/ so that it unbroke 'make
check' as cpio_size wasn't defined in the case where we didn't have an
initramfs specfied... although hopefully I didn't then break the
initramfs case.

So.... hopefully all fixed now as of
9e888546f1ec322ac74b1e58b670d294ae3ea4fc - but emojis of disappointment
in brokenness are accepted.
diff mbox

Patch

diff --git a/external/mambo/skiboot.tcl b/external/mambo/skiboot.tcl
index 1b74c9bc5f3d..40e4107bf9a5 100644
--- a/external/mambo/skiboot.tcl
+++ b/external/mambo/skiboot.tcl
@@ -216,6 +216,11 @@  mysim of addprop $reserved_memory int "#size-cells" 2
 mysim of addprop $reserved_memory int "#address-cells" 2
 mysim of addprop $reserved_memory empty "ranges" ""
 
+set initramfs_res [mysim of addchild $reserved_memory "initramfs" ""]
+set reg [list $cpio_start $cpio_size ]
+mysim of addprop $initramfs_res array64 "reg" reg
+mysim of addprop $initramfs_res empty "name" "initramfs"
+
 set fake_nvram_node [mysim of addchild $reserved_memory "ibm,fake-nvram" ""]
 set reg [list $fake_nvram_start $fake_nvram_size ]
 mysim of addprop $fake_nvram_node array64 "reg" reg