qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>,
	 Daniel Henrique Barboza <danielhb413@gmail.com>,
	 Nicholas Piggin <npiggin@gmail.com>,
	 "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	qemu-ppc@nongnu.org,  Anton Johansson <anjo@rev.ng>
Subject: Re: [PATCH 2/3] hw/ppc/sam460ex: Replace tswap32() by stl_endian_p()
Date: Mon, 30 Sep 2024 15:49:08 +0200 (CEST)	[thread overview]
Message-ID: <cb4ef447-11e5-bdb2-d433-12ffdba6bb4c@eik.bme.hu> (raw)
In-Reply-To: <20240930125323.54671-3-philmd@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2028 bytes --]

On Mon, 30 Sep 2024, Philippe Mathieu-Daudé wrote:
> Replace the target-specific tswap32() call by stl_endian_p()
> which does the same but takes the endianness as argument, thus
> is target-agnostic.
> Get the vCPU endianness calling ppc_cpu_is_big_endian().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/ppc/sam460ex.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 8dc75fb9f0..6257ddbec6 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -248,10 +248,11 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env,
> static void main_cpu_reset(void *opaque)
> {
>     PowerPCCPU *cpu = opaque;
> +    CPUState *cs = CPU(cpu);
>     CPUPPCState *env = &cpu->env;
>     struct boot_info *bi = env->load_info;
>
> -    cpu_reset(CPU(cpu));
> +    cpu_reset(cs);
>
>     /* either we have a kernel to boot or we jump to U-Boot */
>     if (bi->entry != UBOOT_ENTRY) {
> @@ -261,7 +262,7 @@ static void main_cpu_reset(void *opaque)
>
>         /* Create a mapping for the kernel.  */
>         mmubooke_create_initial_mapping(env, 0, 0);
> -        env->gpr[6] = tswap32(EPAPR_MAGIC);
> +        stl_endian_p(ppc_cpu_is_big_endian(cs), &env->gpr[6], EPAPR_MAGIC);

I think this slightly changes behaviour even if getting the same result. 
The ppc_cpu_is_big_endian() checks the CPU bit for current mode while 
previously tswap32 only checks for host endianness vs. big endian which is 
the default mode for PPC which is what the CPU is in during boot where 
this data is used. So even with checking the bit it'd be the same but the 
check is not needed. I think you could/should just have hard coded big 
endian here to preserve the current behaviour.

(There were some discussion a while back if this EPAPR_MAGIC is correct or 
needed at all but preserving current behaviour is a good enough for now.)

Regards,
BALATON Zoltan

>         env->gpr[7] = (16 * MiB) - 8; /* bi->ima_size; */
>
>     } else {
>

  reply	other threads:[~2024-09-30 13:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 12:53 [PATCH 0/3] hw/ppc: Replace tswap32() by stl_endian_p() Philippe Mathieu-Daudé
2024-09-30 12:53 ` [PATCH 1/3] target/ppc: Expose ppc_cpu_is_big_endian() prototype in 'cpu.h' Philippe Mathieu-Daudé
2024-09-30 12:53 ` [PATCH 2/3] hw/ppc/sam460ex: Replace tswap32() by stl_endian_p() Philippe Mathieu-Daudé
2024-09-30 13:49   ` BALATON Zoltan [this message]
2024-09-30 12:53 ` [PATCH 3/3] hw/ppc/virtex_ml507: " Philippe Mathieu-Daudé
2024-09-30 13:50   ` BALATON Zoltan

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=cb4ef447-11e5-bdb2-d433-12ffdba6bb4c@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=anjo@rev.ng \
    --cc=danielhb413@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.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).