From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alistair Francis" <alistair@alistair23.me>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>, "Hao Wu" <wuhaotsh@google.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Joel Stanley" <joel@jms.id.au>,
qemu-arm@nongnu.org,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Steven Lee" <steven_lee@aspeedtech.com>,
"Tyrone Ting" <kfting@nuvoton.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Cédric Le Goater" <clg@kaod.org>,
"Jamin Lin" <jamin_lin@aspeedtech.com>,
"Troy Lee" <leetroy@gmail.com>, "Anton Johansson" <anjo@rev.ng>
Subject: [PATCH 2/3] hw/arm: Have arm_write_bootloader() take a ARMCPU argument
Date: Tue, 1 Oct 2024 00:12:03 +0200 [thread overview]
Message-ID: <20240930221205.59101-3-philmd@linaro.org> (raw)
In-Reply-To: <20240930221205.59101-1-philmd@linaro.org>
The next commit will replace tswap32() calls by stl_endian_p()
ones in bootloader.c. In order to do that, we'll need to know
the vCPU endianness. This information is retrievable with
arm_cpu_code_is_big_endian(), but we need to access CPUARMState.
As a first step, pass ARMCPU as argument to arm_write_bootloader()
so it'll be able to access cpu->env.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/arm/boot.h | 9 ++++++---
hw/arm/aspeed.c | 3 +--
hw/arm/boot.c | 9 +++++----
hw/arm/raspi.c | 4 ++--
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
index 80c492d742..3d1226ab00 100644
--- a/include/hw/arm/boot.h
+++ b/include/hw/arm/boot.h
@@ -206,13 +206,15 @@ typedef struct ARMInsnFixup {
/**
* arm_write_bootloader - write a bootloader to guest memory
* @name: name of the bootloader blob
- * @as: AddressSpace to write the bootloader
+ * @cpu: handle to the first CPU object
+ * @info: handle to the boot info struct
* @addr: guest address to write it
* @insns: the blob to be loaded
* @fixupcontext: context to be used for any fixups in @insns
*
* Write a bootloader to guest memory at address @addr in the address
- * space @as. @name is the name to use for the resulting ROM blob, so
+ * space returned by @arm_boot_address_space().
+ * @name is the name to use for the resulting ROM blob, so
* it should be unique in the system and reasonably identifiable for debugging.
*
* @insns must be an array of ARMInsnFixup structs, each of which has
@@ -228,7 +230,8 @@ typedef struct ARMInsnFixup {
* the entries that @insns refers to.
*/
void arm_write_bootloader(const char *name,
- AddressSpace *as, hwaddr addr,
+ ARMCPU *cpu, const struct arm_boot_info *info,
+ hwaddr addr,
const ARMInsnFixup *insns,
const uint32_t *fixupcontext);
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index cf0c6c580b..cf5fb92238 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -217,7 +217,6 @@ struct AspeedMachineState {
static void aspeed_write_smpboot(ARMCPU *cpu,
const struct arm_boot_info *info)
{
- AddressSpace *as = arm_boot_address_space(cpu, info);
static const ARMInsnFixup poll_mailbox_ready[] = {
/*
* r2 = per-cpu go sign value
@@ -244,7 +243,7 @@ static void aspeed_write_smpboot(ARMCPU *cpu,
};
static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
- arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start,
+ arm_write_bootloader("aspeed.smpboot", cpu, info, info->smp_loader_start,
poll_mailbox_ready, fixupcontext);
}
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 5301d8d318..6efd21f9c2 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -131,10 +131,12 @@ static const ARMInsnFixup smpboot[] = {
};
void arm_write_bootloader(const char *name,
- AddressSpace *as, hwaddr addr,
+ ARMCPU *cpu, const struct arm_boot_info *info,
+ hwaddr addr,
const ARMInsnFixup *insns,
const uint32_t *fixupcontext)
{
+ AddressSpace *as = arm_boot_address_space(cpu, info);
/* Fix up the specified bootloader fragment and write it into
* guest memory using rom_add_blob_fixed(). fixupcontext is
* an array giving the values to write in for the fixup types
@@ -185,7 +187,6 @@ static void default_write_secondary(ARMCPU *cpu,
const struct arm_boot_info *info)
{
uint32_t fixupcontext[FIXUP_MAX];
- AddressSpace *as = arm_boot_address_space(cpu, info);
fixupcontext[FIXUP_GIC_CPU_IF] = info->gic_cpu_if_addr;
fixupcontext[FIXUP_BOOTREG] = info->smp_bootreg_addr;
@@ -195,7 +196,7 @@ static void default_write_secondary(ARMCPU *cpu,
fixupcontext[FIXUP_DSB] = CP15_DSB_INSN;
}
- arm_write_bootloader("smpboot", as, info->smp_loader_start,
+ arm_write_bootloader("smpboot", cpu, info, info->smp_loader_start,
smpboot, fixupcontext);
}
@@ -1128,7 +1129,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
fixupcontext[FIXUP_ENTRYPOINT_LO] = entry;
fixupcontext[FIXUP_ENTRYPOINT_HI] = entry >> 32;
- arm_write_bootloader("bootloader", as, info->loader_start,
+ arm_write_bootloader("bootloader", cpu, info, info->loader_start,
primary_loader, fixupcontext);
if (info->write_board_setup) {
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index a7a662f40d..84fffe2a02 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -137,7 +137,7 @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0
|| (BOARDSETUP_ADDR >> 4) >= 0x100);
- arm_write_bootloader("raspi_smpboot", arm_boot_address_space(cpu, info),
+ arm_write_bootloader("raspi_smpboot", cpu, info,
info->smp_loader_start, smpboot, fixupcontext);
}
@@ -172,7 +172,7 @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
0, 0, 0, 0
};
- arm_write_bootloader("raspi_smpboot", as, info->smp_loader_start,
+ arm_write_bootloader("raspi_smpboot", cpu, info, info->smp_loader_start,
smpboot, fixupcontext);
rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables),
SPINTABLE_ADDR, as);
--
2.45.2
next prev parent reply other threads:[~2024-09-30 22:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 22:12 [PATCH 0/3] hw/arm: Replace tswap32() by stl_endian_p() Philippe Mathieu-Daudé
2024-09-30 22:12 ` [PATCH 1/3] target/arm: Expose arm_cpu_code_is_big_endian() prototype in 'cpu.h' Philippe Mathieu-Daudé
2024-09-30 22:12 ` Philippe Mathieu-Daudé [this message]
2024-09-30 22:12 ` [PATCH 3/3] hw/arm: Replace tswap32() calls by target agnostic stl_endian_p() Philippe Mathieu-Daudé
2024-10-01 9:35 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240930221205.59101-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alistair@alistair23.me \
--cc=andrew@codeconstruct.com.au \
--cc=anjo@rev.ng \
--cc=clg@kaod.org \
--cc=edgar.iglesias@gmail.com \
--cc=i.mitsyanko@gmail.com \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=kfting@nuvoton.com \
--cc=laurent@vivier.eu \
--cc=leetroy@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steven_lee@aspeedtech.com \
--cc=thuth@redhat.com \
--cc=wuhaotsh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).