qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target/ppc: Fix msync to do what hardware does
Date: Fri, 8 Feb 2019 16:34:19 +1100	[thread overview]
Message-ID: <20190208053417.GB12810@umbus.fritz.box> (raw)
In-Reply-To: <20190126150102.7AABC74569F@zero.eik.bme.hu>

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

On Sat, Jan 26, 2019 at 03:50:28PM +0100, BALATON Zoltan wrote:
> According to BookE docs, invalid bits (while undefined behaviour) should
> not raise exception but be ignored. This seems to be implementation
> dependent though and QEMU currently does what e500 CPUs do and raise
> exception for invalid bits. Unfortunately some versions of libstdc++
> (and so all programs compiled with it) have lwsync on PPC440 which is
> invalid but on real hardware it's just executed as msync ignoring the
> invalid bits (maybe that's why it got undetected) but they fail on QEMU.
> This patch changes invalid mask of msync to allow these programs to run
> but keep generating exception on e500 cores to follow what hardware does.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>

Applied to ppc-for-4.0, thanks.

> ---
>  target/ppc/translate.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index e169c43643..5429ceb1ab 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -6476,7 +6476,12 @@ static void gen_mbar(DisasContext *ctx)
>  /* msync replaces sync on 440 */
>  static void gen_msync_4xx(DisasContext *ctx)
>  {
> -    /* interpreted as no-op */
> +    /* Only e500 seems to treat reserved bits as invalid */
> +    if ((ctx->insns_flags2 & PPC2_BOOKE206) &&
> +        (ctx->opcode & 0x03FFF801)) {
> +        gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
> +    }
> +    /* otherwise interpreted as no-op */
>  }
>  
>  /* icbt */
> @@ -7054,11 +7059,11 @@ GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000E7C01, PPC_WRTEE),
>  GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC),
>  GEN_HANDLER_E(mbar, 0x1F, 0x16, 0x1a, 0x001FF801,
>                PPC_BOOKE, PPC2_BOOKE206),
> -GEN_HANDLER(msync_4xx, 0x1F, 0x16, 0x12, 0x03FFF801, PPC_BOOKE),
> +GEN_HANDLER(msync_4xx, 0x1F, 0x16, 0x12, 0x039FF801, PPC_BOOKE),
>  GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001,
>                 PPC_BOOKE, PPC2_BOOKE206),
>  GEN_HANDLER2(icbt_440, "icbt", 0x1F, 0x06, 0x08, 0x03E00001,
> -               PPC_440_SPEC),
> +             PPC_440_SPEC),
>  GEN_HANDLER(lvsl, 0x1f, 0x06, 0x00, 0x00000001, PPC_ALTIVEC),
>  GEN_HANDLER(lvsr, 0x1f, 0x06, 0x01, 0x00000001, PPC_ALTIVEC),
>  GEN_HANDLER(mfvscr, 0x04, 0x2, 0x18, 0x001ff800, PPC_ALTIVEC),

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2019-02-08  6:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-26 14:50 [Qemu-devel] [PATCH] target/ppc: Fix msync to do what hardware does BALATON Zoltan
2019-02-01 13:03 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
2019-02-08  5:34 ` David Gibson [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=20190208053417.GB12810@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=balaton@eik.bme.hu \
    --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 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).