[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/35] hw/arm/aspeed: Use arm_write_bootloader() to write the boot
From: |
Peter Maydell |
Subject: |
[PULL 29/35] hw/arm/aspeed: Use arm_write_bootloader() to write the bootloader |
Date: |
Tue, 2 May 2023 13:14:53 +0100 |
From: Cédric Le Goater <clg@kaod.org>
When writing the secondary-CPU stub boot loader code to the guest,
use arm_write_bootloader() instead of directly calling
rom_add_blob_fixed(). This fixes a bug on big-endian hosts, because
arm_write_bootloader() will correctly byte-swap the host-byte-order
array values into the guest-byte-order to write into the guest
memory.
Cc: qemu-stable@nongnu.org
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20230424152717.1333930-3-peter.maydell@linaro.org
[PMM: Moved the "make arm_write_bootloader() function public" part
to its own patch; updated commit message to note that this fixes
an actual bug; adjust to the API changes noted in previous commit]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/aspeed.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index c1f2b9cfcab..0b29028fe11 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -200,33 +200,35 @@ struct AspeedMachineState {
static void aspeed_write_smpboot(ARMCPU *cpu,
const struct arm_boot_info *info)
{
- static const uint32_t poll_mailbox_ready[] = {
+ AddressSpace *as = arm_boot_address_space(cpu, info);
+ static const ARMInsnFixup poll_mailbox_ready[] = {
/*
* r2 = per-cpu go sign value
* r1 = AST_SMP_MBOX_FIELD_ENTRY
* r0 = AST_SMP_MBOX_FIELD_GOSIGN
*/
- 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5 */
- 0xe21000ff, /* ands r0, r0, #255 */
- 0xe59f201c, /* ldr r2, [pc, #28] */
- 0xe1822000, /* orr r2, r2, r0 */
+ { 0xee100fb0 }, /* mrc p15, 0, r0, c0, c0, 5 */
+ { 0xe21000ff }, /* ands r0, r0, #255 */
+ { 0xe59f201c }, /* ldr r2, [pc, #28] */
+ { 0xe1822000 }, /* orr r2, r2, r0 */
- 0xe59f1018, /* ldr r1, [pc, #24] */
- 0xe59f0018, /* ldr r0, [pc, #24] */
+ { 0xe59f1018 }, /* ldr r1, [pc, #24] */
+ { 0xe59f0018 }, /* ldr r0, [pc, #24] */
- 0xe320f002, /* wfe */
- 0xe5904000, /* ldr r4, [r0] */
- 0xe1520004, /* cmp r2, r4 */
- 0x1afffffb, /* bne <wfe> */
- 0xe591f000, /* ldr pc, [r1] */
- AST_SMP_MBOX_GOSIGN,
- AST_SMP_MBOX_FIELD_ENTRY,
- AST_SMP_MBOX_FIELD_GOSIGN,
+ { 0xe320f002 }, /* wfe */
+ { 0xe5904000 }, /* ldr r4, [r0] */
+ { 0xe1520004 }, /* cmp r2, r4 */
+ { 0x1afffffb }, /* bne <wfe> */
+ { 0xe591f000 }, /* ldr pc, [r1] */
+ { AST_SMP_MBOX_GOSIGN },
+ { AST_SMP_MBOX_FIELD_ENTRY },
+ { AST_SMP_MBOX_FIELD_GOSIGN },
+ { 0, FIXUP_TERMINATOR }
};
+ static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
- rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
- sizeof(poll_mailbox_ready),
- info->smp_loader_start);
+ arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start,
+ poll_mailbox_ready, fixupcontext);
}
static void aspeed_reset_secondary(ARMCPU *cpu,
--
2.34.1
- [PULL 12/35] tests/qtest: Restrict tpm-tis-i2c-test to CONFIG_TCG, (continued)
- [PULL 12/35] tests/qtest: Restrict tpm-tis-i2c-test to CONFIG_TCG, Peter Maydell, 2023/05/02
- [PULL 13/35] gitlab-ci: Check building KVM-only aarch64 target, Peter Maydell, 2023/05/02
- [PULL 17/35] softmmu: Don't use 'singlestep' global in QMP and HMP commands, Peter Maydell, 2023/05/02
- [PULL 21/35] Document that -singlestep command line option is deprecated, Peter Maydell, 2023/05/02
- [PULL 18/35] accel/tcg: Use one_insn_per_tb global instead of old singlestep global, Peter Maydell, 2023/05/02
- [PULL 11/35] arm/Kconfig: Do not build TCG-only boards on a KVM-only build, Peter Maydell, 2023/05/02
- [PULL 29/35] hw/arm/aspeed: Use arm_write_bootloader() to write the bootloader,
Peter Maydell <=
- [PULL 20/35] bsd-user: Add '-one-insn-per-tb' option equivalent to '-singlestep', Peter Maydell, 2023/05/02
- [PULL 19/35] linux-user: Add '-one-insn-per-tb' option equivalent to '-singlestep', Peter Maydell, 2023/05/02
- [PULL 07/35] target/arm: move cpu_tcg to tcg/cpu32.c, Peter Maydell, 2023/05/02
- [PULL 30/35] hw/arm/raspi: Use arm_write_bootloader() to write boot code, Peter Maydell, 2023/05/02
- [PULL 34/35] hw/sd/allwinner-sdhost: Correctly byteswap descriptor fields, Peter Maydell, 2023/05/02
- [PULL 35/35] hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields, Peter Maydell, 2023/05/02
- Re: [PULL 00/35] target-arm queue, Richard Henderson, 2023/05/02