[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/34] spapr: Use address from elf parser for kernel address
From: |
Daniel Henrique Barboza |
Subject: |
[PULL 03/34] spapr: Use address from elf parser for kernel address |
Date: |
Thu, 26 May 2022 18:37:44 -0300 |
From: Alexey Kardashevskiy <aik@ozlabs.ru>
tl;dr: This allows Big Endian zImage booting via -kernel + x-vof=on.
QEMU loads the kernel at 0x400000 by default which works most of
the time as Linux kernels are relocatable, 64bit and compiled with "-pie"
(position independent code). This works for a little endian zImage too.
However a big endian zImage is compiled without -pie, is 32bit, linked to
0x4000000 so current QEMU ends up loading it at
0x4400000 but keeps spapr->kernel_addr unchanged so booting fails.
This uses the kernel address returned from load_elf().
If the default kernel_addr is used, there is no change in behavior (as
translate_kernel_address() takes care of this), which is:
LE/BE vmlinux and LE zImage boot, BE zImage does not.
If the VM created with "-machine kernel-addr=0,x-vof=on", then QEMU
prints a warning and BE zImage boots.
Note #1: SLOF (x-vof=off) still cannot boot a big endian zImage as
SLOF enables MSR_SF for everything loaded by QEMU and this leads to early
crash of 32bit zImage.
Note #2: BE/LE vmlinux images set MSR_SF in early boot so these just work;
a LE zImage restores MSR_SF after every CI call and we are lucky enough
not to crash before the first CI call.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Tested-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Message-Id: <20220504065536.3534488-1-aik@ozlabs.ru>
[danielhb: use PRIx64 instead of lx in warn_report]
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/spapr.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d112b85b4f..fd4942e881 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2975,14 +2975,16 @@ static void spapr_machine_init(MachineState *machine)
}
if (kernel_filename) {
+ uint64_t loaded_addr = 0;
+
spapr->kernel_size = load_elf(kernel_filename, NULL,
translate_kernel_address, spapr,
- NULL, NULL, NULL, NULL, 1,
+ NULL, &loaded_addr, NULL, NULL, 1,
PPC_ELF_MACHINE, 0, 0);
if (spapr->kernel_size == ELF_LOAD_WRONG_ENDIAN) {
spapr->kernel_size = load_elf(kernel_filename, NULL,
translate_kernel_address, spapr,
- NULL, NULL, NULL, NULL, 0,
+ NULL, &loaded_addr, NULL, NULL, 0,
PPC_ELF_MACHINE, 0, 0);
spapr->kernel_le = spapr->kernel_size > 0;
}
@@ -2992,6 +2994,13 @@ static void spapr_machine_init(MachineState *machine)
exit(1);
}
+ if (spapr->kernel_addr != loaded_addr) {
+ warn_report("spapr: kernel_addr changed from 0x%"PRIx64
+ " to 0x%"PRIx64,
+ spapr->kernel_addr, loaded_addr);
+ spapr->kernel_addr = loaded_addr;
+ }
+
/* load initrd */
if (initrd_filename) {
/* Try to locate the initrd in the gap between the kernel
--
2.36.1
- [PULL 00/34] ppc queue, Daniel Henrique Barboza, 2022/05/26
- [PULL 01/34] pseries: allow setting stdout-path even on machines with a VGA, Daniel Henrique Barboza, 2022/05/26
- [PULL 02/34] hw/ppc/e500: Remove unused BINARY_DEVICE_TREE_FILE, Daniel Henrique Barboza, 2022/05/26
- [PULL 03/34] spapr: Use address from elf parser for kernel address,
Daniel Henrique Barboza <=
- [PULL 04/34] spapr/docs: Add a few words about x-vof, Daniel Henrique Barboza, 2022/05/26
- [PULL 05/34] mos6522: fix linking error when CONFIG_MOS6522 is not set, Daniel Henrique Barboza, 2022/05/26
- [PULL 06/34] target/ppc: Fix tlbie, Daniel Henrique Barboza, 2022/05/26
- [PULL 07/34] target/ppc: Fix FPSCR.FI bit being cleared when it shouldn't, Daniel Henrique Barboza, 2022/05/26
- [PULL 09/34] target/ppc: Rename sfprf to sfifprf where it's also used as set fi flag, Daniel Henrique Barboza, 2022/05/26
- [PULL 10/34] pnv/xive2: Don't overwrite PC registers when writing TCTXT registers, Daniel Henrique Barboza, 2022/05/26
- [PULL 08/34] target/ppc: Fix FPSCR.FI changing in float_overflow_excp(), Daniel Henrique Barboza, 2022/05/26
- [PULL 11/34] target/ppc: declare darn32/darn64 helpers with TCG_CALL_NO_RWG, Daniel Henrique Barboza, 2022/05/26
- [PULL 13/34] target/ppc: use TCG_CALL_NO_RWG in BCD helpers, Daniel Henrique Barboza, 2022/05/26
- [PULL 15/34] target/ppc: Use TCG_CALL_NO_RWG_SE in fsel helper, Daniel Henrique Barboza, 2022/05/26