qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: Laurent Vivier <lvivier@redhat.com>,
	dgibson@redhat.com, thuth@redhat.com, qemu-ppc@nongnu.org,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] target-ppc: Multiple/String Word alignment exception
Date: Wed, 30 Mar 2016 19:13:00 +0200	[thread overview]
Message-ID: <1459357980-29330-1-git-send-email-lvivier@redhat.com> (raw)

If the processor is in little-endian mode, an alignment interrupt must
occur for the following instructions: lmw, stmw, lswi, lswx, stswi or stswx.

This is what happens with KVM, so change TCG to do the same.

As the instruction can be emulated by the kernel, enable the change
only in softmmu mode.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 target-ppc/translate.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 6f0e7b4..e33dcf7 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -3181,6 +3181,13 @@ static void gen_lmw(DisasContext *ctx)
 {
     TCGv t0;
     TCGv_i32 t1;
+#if !defined(CONFIG_USER_ONLY)
+    if (ctx->le_mode) {
+        gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
+        return;
+    }
+#endif
+
     gen_set_access_type(ctx, ACCESS_INT);
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
@@ -3197,6 +3204,13 @@ static void gen_stmw(DisasContext *ctx)
 {
     TCGv t0;
     TCGv_i32 t1;
+#if !defined(CONFIG_USER_ONLY)
+    if (ctx->le_mode) {
+        gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
+        return;
+    }
+#endif
+
     gen_set_access_type(ctx, ACCESS_INT);
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
@@ -3224,6 +3238,13 @@ static void gen_lswi(DisasContext *ctx)
     int start = rD(ctx->opcode);
     int ra = rA(ctx->opcode);
     int nr;
+#if !defined(CONFIG_USER_ONLY)
+    if (ctx->le_mode) {
+        gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
+        return;
+    }
+#endif
+
 
     if (nb == 0)
         nb = 32;
@@ -3252,6 +3273,13 @@ static void gen_lswx(DisasContext *ctx)
 {
     TCGv t0;
     TCGv_i32 t1, t2, t3;
+#if !defined(CONFIG_USER_ONLY)
+    if (ctx->le_mode) {
+        gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
+        return;
+    }
+#endif
+
     gen_set_access_type(ctx, ACCESS_INT);
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
@@ -3273,6 +3301,13 @@ static void gen_stswi(DisasContext *ctx)
     TCGv t0;
     TCGv_i32 t1, t2;
     int nb = NB(ctx->opcode);
+#if !defined(CONFIG_USER_ONLY)
+    if (ctx->le_mode) {
+        gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
+        return;
+    }
+#endif
+
     gen_set_access_type(ctx, ACCESS_INT);
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
@@ -3293,6 +3328,13 @@ static void gen_stswx(DisasContext *ctx)
 {
     TCGv t0;
     TCGv_i32 t1, t2;
+#if !defined(CONFIG_USER_ONLY)
+    if (ctx->le_mode) {
+        gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
+        return;
+    }
+#endif
+
     gen_set_access_type(ctx, ACCESS_INT);
     /* NIP cannot be restored if the memory exception comes from an helper */
     gen_update_nip(ctx, ctx->nip - 4);
-- 
2.5.5

             reply	other threads:[~2016-03-30 17:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 17:13 Laurent Vivier [this message]
2016-03-30 23:29 ` [Qemu-devel] [PATCH] target-ppc: Multiple/String Word alignment exception David Gibson
2016-03-31  0:53   ` Laurent Vivier
2016-03-31  6:54   ` Alexander Graf
2016-03-31  7:06     ` Laurent Vivier
2016-03-31  7:15       ` Alexander Graf
2016-03-31  7:39         ` Laurent Vivier
2016-03-31  8:50         ` Thomas Huth
2016-03-31  9:03           ` Alexander Graf
2016-03-31  9:18             ` Thomas Huth

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=1459357980-29330-1-git-send-email-lvivier@redhat.com \
    --to=lvivier@redhat.com \
    --cc=agraf@suse.de \
    --cc=dgibson@redhat.com \
    --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).