From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, "Andrew Jeffery" <andrew@aj.id.au>,
"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
"Joel Stanley" <joel@jms.id.au>,
"Havard Skinnemoen" <hskinnemoen@google.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Cédric Le Goater" <clg@kaod.org>,
"Alistair Francis" <alistair@alistair23.me>,
qemu-arm@nongnu.org, "Tyrone Ting" <kfting@nuvoton.com>
Subject: Re: [PATCH 1/6] hw/arm/aspeed: Fix smpboot[] on big-endian hosts
Date: Tue, 3 Jan 2023 17:33:56 +0000 [thread overview]
Message-ID: <CAFEAcA9KD8WwPTKVQQUfAZxaqA=ASweZtJ=sAV0Vd8TkpqDBOw@mail.gmail.com> (raw)
In-Reply-To: <20221222215549.86872-2-philmd@linaro.org>
On Thu, 22 Dec 2022 at 21:56, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> ARM CPUs fetch instructions in little-endian.
>
> smpboot[] encoded instructions are written in little-endian.
> This is fine on little-endian host, but on big-endian ones
> the smpboot[] array ends swapped. Use the const_le32()
> macro so the instructions are always in little-endian in the
> smpboot[] array.
>
> Fixes: 9bb6d14081 ("aspeed: Add boot stub for smp booting")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/arm/aspeed.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 55f114ef72..adff9a0d73 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -194,22 +194,22 @@ static void aspeed_write_smpboot(ARMCPU *cpu,
> * 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 */
> + const_le32(0xee100fb0), /* mrc p15, 0, r0, c0, c0, 5 */
> + const_le32(0xe21000ff), /* ands r0, r0, #255 */
> + const_le32(0xe59f201c), /* ldr r2, [pc, #28] */
> + const_le32(0xe1822000), /* orr r2, r2, r0 */
>
> - 0xe59f1018, /* ldr r1, [pc, #24] */
> - 0xe59f0018, /* ldr r0, [pc, #24] */
> + const_le32(0xe59f1018), /* ldr r1, [pc, #24] */
> + const_le32(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,
> + const_le32(0xe320f002), /* wfe */
> + const_le32(0xe5904000), /* ldr r4, [r0] */
> + const_le32(0xe1520004), /* cmp r2, r4 */
> + const_le32(0x1afffffb), /* bne <wfe> */
> + const_le32(0xe591f000), /* ldr pc, [r1] */
> + const_le32(AST_SMP_MBOX_GOSIGN),
> + const_le32(AST_SMP_MBOX_FIELD_ENTRY),
> + const_le32(AST_SMP_MBOX_FIELD_GOSIGN)
> };
>
> rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
Can we use the write_bootloader() function, which handles the
endianness question correctly and is how other boards do the
"put a little lump of code into the guest" job ?
thanks
-- PMM
next prev parent reply other threads:[~2023-01-03 17:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 21:55 [PATCH 0/6] hw/arm: Fix smpboot[] on big-endian hosts and remove tswap32() Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 1/6] hw/arm/aspeed: Fix smpboot[] on big-endian hosts Philippe Mathieu-Daudé
2022-12-23 7:24 ` Cédric Le Goater
2023-01-03 17:33 ` Peter Maydell [this message]
2023-01-04 8:43 ` Cédric Le Goater
2023-01-04 22:35 ` Philippe Mathieu-Daudé
2023-01-04 23:25 ` Cédric Le Goater
2022-12-22 21:55 ` [PATCH 2/6] hw/arm/raspi: " Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 3/6] hw/arm/exynos4210: Remove tswap32() calls and constify smpboot[] Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 4/6] hw/arm/npcm7xx: " Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 5/6] hw/arm/xilinx_zynq: " Philippe Mathieu-Daudé
2022-12-23 3:54 ` Edgar E. Iglesias
2022-12-23 10:01 ` Philippe Mathieu-Daudé
2022-12-23 10:05 ` Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 6/6] hw/arm/boot: Remove tswap32() calls and constify board_setup_blob[] Philippe Mathieu-Daudé
2022-12-22 21:59 ` [PATCH 0/6] hw/arm: Fix smpboot[] on big-endian hosts and remove tswap32() Philippe Mathieu-Daudé
2022-12-24 23:32 ` Richard Henderson
2023-01-03 17:43 ` Peter Maydell
2023-01-04 22:51 ` Philippe Mathieu-Daudé
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='CAFEAcA9KD8WwPTKVQQUfAZxaqA=ASweZtJ=sAV0Vd8TkpqDBOw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=alistair@alistair23.me \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=edgar.iglesias@gmail.com \
--cc=hskinnemoen@google.com \
--cc=i.mitsyanko@gmail.com \
--cc=joel@jms.id.au \
--cc=kfting@nuvoton.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).