Skip to content

Commit b3f699c

Browse files
iamjpnaik
authored andcommitted
OF: Add a separate direct kernel loading word
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 <[email protected]> Signed-off-by: Alexey Kardashevskiy <[email protected]>
1 parent 5b4c5ac commit b3f699c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

board-qemu/slof/OF.fs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,9 @@ set-default-console
303303
: (boot-ram)
304304
direct-ram-boot-size 0<> IF
305305
." Booting from memory..." cr
306-
s" go-args 2@ " evaluate
307-
direct-ram-boot-base 0
306+
s" direct-ram-boot-base to go-entry" evaluate
308307
s" true state-valid ! " evaluate
309-
s" disable-watchdog go-64" evaluate
308+
s" disable-watchdog go-direct" evaluate
310309
THEN
311310
;
312311

slof/fs/boot.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ defer go ( -- )
112112
claim-list elf-release 0 to claim-list
113113
;
114114

115+
: go-direct ( -- )
116+
0 ciregs >r3 ! 0 ciregs >r4 ! 0 ciregs >r2 !
117+
msr@ 7fffffffffffffff and 2000 or ciregs >srr1 !
118+
go-args 2@ go-entry call-client
119+
;
120+
115121
: set-le ( -- )
116122
1 ciregs >r13 !
117123
;

0 commit comments

Comments
 (0)