[SLOF] [PATCH] OF: Add a separate direct kernel loading word
Alexey Kardashevskiy
aik at ozlabs.ru
Tue Jul 19 14:20:28 AEST 2022
On 12/07/2022 10:46, Jordan Niethe wrote:
> Currently, go-64 is used for booting a kernel from qemu (i.e. -kernel).
> However, there is an expectation from users that this should be able to
> boot not just vmlinux kernels but things like Zimages too.
>
> The bootwrapper of a BE zImage is a 32-bit ELF. Attempting to load that
> with go-64 means that it will be ran with MSR_SF set (64-bit mode). This
> crashes early in boot (usually due to what should be 32-bit operations
> being done with 64-bit registers eventually leading to an incorrect
> address being generated and branched to).
>
> Note that our 64-bit payloads are prepared to enter with MSR_SF cleared
> and set it themselves very early.
>
> Add a new word named go-direct that will execute any simple payload
> in-place and will enter with MSR_SF cleared. This allows booting a BE
> zImage from qemu with -machine kernel-addr=0.
>
> Signed-off-by: Jordan Niethe <jniethe5 at gmail.com>
Thanks, applied.
> ---
> board-qemu/slof/OF.fs | 5 ++---
> slof/fs/boot.fs | 6 ++++++
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/board-qemu/slof/OF.fs b/board-qemu/slof/OF.fs
> index f0fc9c684b8e..3bcb2af94bdd 100644
> --- a/board-qemu/slof/OF.fs
> +++ b/board-qemu/slof/OF.fs
> @@ -303,10 +303,9 @@ set-default-console
> : (boot-ram)
> direct-ram-boot-size 0<> IF
> ." Booting from memory..." cr
> - s" go-args 2@ " evaluate
> - direct-ram-boot-base 0
> + s" direct-ram-boot-base to go-entry" evaluate
> s" true state-valid ! " evaluate
> - s" disable-watchdog go-64" evaluate
> + s" disable-watchdog go-direct" evaluate
> THEN
> ;
>
> diff --git a/slof/fs/boot.fs b/slof/fs/boot.fs
> index 6d16c54d2af4..a6dfdf3f6c1c 100644
> --- a/slof/fs/boot.fs
> +++ b/slof/fs/boot.fs
> @@ -112,6 +112,12 @@ defer go ( -- )
> claim-list elf-release 0 to claim-list
> ;
>
> +: go-direct ( -- )
> + 0 ciregs >r3 ! 0 ciregs >r4 ! 0 ciregs >r2 !
> + msr@ 7fffffffffffffff and 2000 or ciregs >srr1 !
> + go-args 2@ go-entry call-client
> +;
> +
> : set-le ( -- )
> 1 ciregs >r13 !
> ;
--
Alexey
More information about the SLOF
mailing list