All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "BALATON Zoltan" <balaton@eik.bme.hu>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-ppc@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH v3 7/7] hw/ppc/epapr: Do not swap ePAPR magic value
Date: Thu, 19 Dec 2024 10:29:36 +1000	[thread overview]
Message-ID: <D6F93NM6OW2L.2FDO88L38PABR@gmail.com> (raw)
In-Reply-To: <277eeed4-0467-1529-f52d-2c128d8d46bb@eik.bme.hu>

On Thu Dec 19, 2024 at 5:18 AM AEST, BALATON Zoltan wrote:
> On Wed, 18 Dec 2024, Philippe Mathieu-Daudé wrote:
> > The ePAPR magic value in $r6 doesn't need to be byte swapped.
> >
> > See ePAPR-v1.1.pdf chapter 5.4.1 "Boot CPU Initial Register State"
> > and the following mailing-list thread:
> > https://lore.kernel.org/qemu-devel/CAFEAcA_NR4XW5DNL4nq7vnH4XRH5UWbhQCxuLyKqYk6_FCBrAA@mail.gmail.com/
> >
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > ---
> > hw/ppc/sam460ex.c     | 2 +-
> > hw/ppc/virtex_ml507.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> > index 78e2a46e753..db9c8f3fa6e 100644
> > --- a/hw/ppc/sam460ex.c
> > +++ b/hw/ppc/sam460ex.c
> > @@ -234,7 +234,7 @@ static void main_cpu_reset(void *opaque)
> >
> >         /* Create a mapping for the kernel.  */
> >         booke_set_tlb(&env->tlb.tlbe[0], 0, 0, 1 << 31);
> > -        env->gpr[6] = tswap32(EPAPR_MAGIC);
> > +        env->gpr[6] = EPAPR_MAGIC;
>
> I don't know how to test this (or if anything actually uses it).

The Linux kernel boot wrapper tests it AFAIKS. Does this mean
they never worked on LE hosts?

> not sure about is what endianness env->gpr is? It's a host array so maybe 
> it needs to match the host endianness which is little endian most of the 
> time as opposed to PPC big endian on this machine. So maybe tswap is wrong 
> but is removing it right? Maybe we need to only swap on LE hosts. I think 
> it's only used by Linux kernels so maybe trying to boot one could test 
> this change but I'm not sure.

Yes env->gpr is host-endian, and emulated target code will see
the same value that the host does. It can't be correct because
the machine running in emulation can't possibly know what endian
the host is.

I think we should just take it, it looks trivially correct
(always dangerous words when dealing with early boot code, lol).

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

>
> Regards,
> BALATON Zoltan
>
> >         env->gpr[7] = (16 * MiB) - 8; /* bi->ima_size; */
> >
> >     } else {
> > diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> > index f378e5c4a90..6197d31d88f 100644
> > --- a/hw/ppc/virtex_ml507.c
> > +++ b/hw/ppc/virtex_ml507.c
> > @@ -119,7 +119,7 @@ static void main_cpu_reset(void *opaque)
> >     /* Create a mapping spanning the 32bit addr space. */
> >     booke_set_tlb(&env->tlb.tlbe[0], 0, 0, 1U << 31);
> >     booke_set_tlb(&env->tlb.tlbe[1], 0x80000000, 0x80000000, 1U << 31);
> > -    env->gpr[6] = tswap32(EPAPR_MAGIC);
> > +    env->gpr[6] = EPAPR_MAGIC;
> >     env->gpr[7] = bi->ima_size;
> > }
> >
> >



  reply	other threads:[~2024-12-19  0:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 18:20 [PATCH v3 0/7] hw/ppc: Remove tswap() calls Philippe Mathieu-Daudé
2024-12-18 18:21 ` [PATCH v3 1/7] meson: Run some compiler checks using -Wno-unused-value Philippe Mathieu-Daudé
2024-12-19  0:37   ` Nicholas Piggin
2024-12-19 17:39     ` Philippe Mathieu-Daudé
2024-12-19 18:14       ` Richard Henderson
2024-12-18 18:21 ` [PATCH v3 2/7] hw/ppc/spapr: Convert HPTE() macro as hpte_get() method Philippe Mathieu-Daudé
2024-12-19  0:08   ` Nicholas Piggin
2024-12-19  6:31   ` Harsh Prateek Bora
2024-12-20 21:29     ` Philippe Mathieu-Daudé
2024-12-18 18:21 ` [PATCH v3 3/7] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method Philippe Mathieu-Daudé
2024-12-19  0:18   ` Nicholas Piggin
2024-12-18 18:21 ` [PATCH v3 4/7] hw/ppc/spapr: Convert HPTE_DIRTY() macro as hpte_is_dirty() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-19  6:52   ` Harsh Prateek Bora
2024-12-18 18:21 ` [PATCH v3 5/7] hw/ppc/spapr: Convert CLEAN_HPTE() macro as hpte_set_clean() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-19  6:56   ` Harsh Prateek Bora
2024-12-18 18:21 ` [PATCH v3 6/7] hw/ppc/spapr: Convert DIRTY_HPTE() macro as hpte_set_dirty() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-18 18:21 ` [PATCH v3 7/7] hw/ppc/epapr: Do not swap ePAPR magic value Philippe Mathieu-Daudé
2024-12-18 19:18   ` BALATON Zoltan
2024-12-19  0:29     ` Nicholas Piggin [this message]
2024-12-19  1:43       ` 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=D6F93NM6OW2L.2FDO88L38PABR@gmail.com \
    --to=npiggin@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=berrange@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=harshpb@linux.ibm.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.