qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Richard Henderson" <richard.henderson@linaro.org>,
	<qemu-ppc@nongnu.org>
Cc: <qemu-devel@nongnu.org>, "Glenn Miles" <milesg@linux.vnet.ibm.com>
Subject: Re: [PATCH] target/ppc: BHRB avoid using host pointer in translated code
Date: Tue, 20 Feb 2024 10:28:48 +1000	[thread overview]
Message-ID: <CZ9HBYZ004Q8.3ICH68L1E2IGQ@wheely> (raw)
In-Reply-To: <eed2094c-32f9-400d-951a-120c06bb58f9@linaro.org>

On Fri Feb 16, 2024 at 5:42 AM AEST, Richard Henderson wrote:
> On 2/15/24 07:15, Nicholas Piggin wrote:
> > diff --git a/target/ppc/machine.c b/target/ppc/machine.c
> > index 731dd8df35..3541cd83cd 100644
> > --- a/target/ppc/machine.c
> > +++ b/target/ppc/machine.c
> > @@ -724,7 +724,7 @@ static const VMStateDescription vmstate_bhrb = {
> >       .minimum_version_id = 1,
> >       .needed = bhrb_needed,
> >       .fields = (VMStateField[]) {
> > -        VMSTATE_UINTTL(env.bhrb_offset, PowerPCCPU),
> > +        VMSTATE_UINT32(env.bhrb_offset, PowerPCCPU),
>
> This requires a version bump.

In this case the first patch hasn't gone upstream yet.

> > diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> > index 81afc892de..05f0f1ac52 100644
> > --- a/target/ppc/translate.c
> > +++ b/target/ppc/translate.c
> > @@ -4167,21 +4167,24 @@ static void gen_rvwinkle(DisasContext *ctx)
> >   #endif /* defined(CONFIG_USER_ONLY) */
> >   }
> >   
> > -static inline TCGv gen_write_bhrb(TCGv base, TCGv offset, TCGv mask, TCGv value)
> > +static TCGv_i32 gen_write_bhrb(TCGv_i32 offset, TCGv_i32 mask, TCGv_i64 value)
> >   {
> > -    TCGv tmp = tcg_temp_new();
> > +    TCGv_ptr ptr = tcg_temp_new_ptr();
> > +    TCGv_i32 tmp = tcg_temp_new_i32();
> >   
> > -    /* add base and offset to get address of bhrb entry */
> > -    tcg_gen_add_tl(tmp, base, offset);
> > +    /* add base and offset to tcg_env to get address of bhrb entry */
> > +    tcg_gen_addi_i32(tmp, offset, offsetof(CPUPPCState, bhrb));
> > +    tcg_gen_ext_i32_ptr(ptr, tmp);
> > +    tcg_gen_add_ptr(ptr, ptr, tcg_env);
> >   
> >       /* store value into bhrb at bhrb_offset */
> > -    tcg_gen_st_i64(value, (TCGv_ptr)tmp, 0);
> > +    tcg_gen_st_i64(value, ptr, 0);
>
> Better to add the constant with the store offset.
>
>    tcg_gen_ext_i32_ptr(ptr, offset);
>    tcg_gen_add_ptr(ptr, ptr, tcg_env);
>    tcg_gen_st_i64(value, ptr, offsetof(bhrb));

Good suggestion thanks. Maybe in light of the fact I was wrong
about not using host pointer here, the original approach is
better and just needs a smaller fix for 32-bit hosts.

Thanks,
Nick


      reply	other threads:[~2024-02-20  0:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 17:15 [PATCH] target/ppc: BHRB avoid using host pointer in translated code Nicholas Piggin
2024-02-15 17:50 ` Peter Maydell
2024-02-20  0:35   ` Nicholas Piggin
2024-02-27 16:29     ` Miles Glenn
2024-02-15 19:42 ` Richard Henderson
2024-02-20  0:28   ` Nicholas Piggin [this message]

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=CZ9HBYZ004Q8.3ICH68L1E2IGQ@wheely \
    --to=npiggin@gmail.com \
    --cc=milesg@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.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).