qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, deller@gmx.de,
	John David Anglin <dave.anglin@bell.net>,
	svens@stackframe.org
Subject: [PULL v3 11/11] target/hppa: Allow, but diagnose, LDCW aligned only mod 4
Date: Fri, 24 Jan 2020 13:20:09 -1000	[thread overview]
Message-ID: <20200124232009.12928-12-richard.henderson@linaro.org> (raw)
In-Reply-To: <20200124232009.12928-1-richard.henderson@linaro.org>

The PA-RISC 1.1 specification says that LDCW must be aligned mod 16
or the operation is undefined.  However, real hardware only generates
an unaligned access trap for unaligned mod 4.

Match real hardware, but diagnose with GUEST_ERROR a violation of
the specification.

At the same time fix a bug in the initialization of mop, where the
size was specified twice, and another to free the zero temporary.

Tested-by: Helge Deller <deller@gmx.de>
Reported-by: Helge Deller <deller@gmx.de>
Suggested-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/hppa/helper.h    |  2 ++
 target/hppa/op_helper.c |  9 +++++++++
 target/hppa/translate.c | 15 ++++++++++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/target/hppa/helper.h b/target/hppa/helper.h
index 38d834ef6b..2d483aab58 100644
--- a/target/hppa/helper.h
+++ b/target/hppa/helper.h
@@ -17,6 +17,8 @@ DEF_HELPER_FLAGS_3(stby_b_parallel, TCG_CALL_NO_WG, void, env, tl, tr)
 DEF_HELPER_FLAGS_3(stby_e, TCG_CALL_NO_WG, void, env, tl, tr)
 DEF_HELPER_FLAGS_3(stby_e_parallel, TCG_CALL_NO_WG, void, env, tl, tr)
 
+DEF_HELPER_FLAGS_1(ldc_check, TCG_CALL_NO_RWG, void, tl)
+
 DEF_HELPER_FLAGS_4(probe, TCG_CALL_NO_WG, tr, env, tl, i32, i32)
 
 DEF_HELPER_FLAGS_1(loaded_fr0, TCG_CALL_NO_RWG, void, env)
diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c
index f0516e81f1..7823706e9c 100644
--- a/target/hppa/op_helper.c
+++ b/target/hppa/op_helper.c
@@ -153,6 +153,15 @@ void HELPER(stby_e_parallel)(CPUHPPAState *env, target_ulong addr,
     do_stby_e(env, addr, val, true, GETPC());
 }
 
+void HELPER(ldc_check)(target_ulong addr)
+{
+    if (unlikely(addr & 0xf)) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "Undefined ldc to unaligned address mod 16: "
+                      TARGET_FMT_lx "\n", addr);
+    }
+}
+
 target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr,
                           uint32_t level, uint32_t want)
 {
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index f25927aeca..52d7bea1ea 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -2942,7 +2942,7 @@ static bool trans_st(DisasContext *ctx, arg_ldst *a)
 
 static bool trans_ldc(DisasContext *ctx, arg_ldst *a)
 {
-    MemOp mop = MO_TEUL | MO_ALIGN_16 | a->size;
+    MemOp mop = MO_TE | MO_ALIGN | a->size;
     TCGv_reg zero, dest, ofs;
     TCGv_tl addr;
 
@@ -2958,8 +2958,21 @@ static bool trans_ldc(DisasContext *ctx, arg_ldst *a)
 
     form_gva(ctx, &addr, &ofs, a->b, a->x, a->scale ? a->size : 0,
              a->disp, a->sp, a->m, ctx->mmu_idx == MMU_PHYS_IDX);
+
+    /*
+     * For hppa1.1, LDCW is undefined unless aligned mod 16.
+     * However actual hardware succeeds with aligned mod 4.
+     * Detect this case and log a GUEST_ERROR.
+     *
+     * TODO: HPPA64 relaxes the over-alignment requirement
+     * with the ,co completer.
+     */
+    gen_helper_ldc_check(addr);
+
     zero = tcg_const_reg(0);
     tcg_gen_atomic_xchg_reg(dest, addr, zero, ctx->mmu_idx, mop);
+    tcg_temp_free(zero);
+
     if (a->m) {
         save_gpr(ctx, a->b, ofs);
     }
-- 
2.20.1



  parent reply	other threads:[~2020-01-24 23:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 23:19 [PULL v3 00/11] target/hppa patch queue Richard Henderson
2020-01-24 23:19 ` [PULL v3 01/11] hw/hppa/dino.c: Improve emulation of Dino PCI chip Richard Henderson
2020-01-24 23:20 ` [PULL v3 02/11] hppa: Add support for LASI chip with i82596 NIC Richard Henderson
2020-02-17 17:56   ` Peter Maydell
2020-03-02 19:23     ` Helge Deller
2020-03-02 19:31       ` Peter Maydell
2020-03-02 20:34         ` Helge Deller
2020-03-02 23:25           ` Philippe Mathieu-Daudé
2020-03-05 13:05   ` Philippe Mathieu-Daudé
2020-01-24 23:20 ` [PULL v3 03/11] ps2: accept 'Set Key Make and Break' commands Richard Henderson
2020-01-24 23:20 ` [PULL v3 04/11] hppa: add emulation of LASI PS2 controllers Richard Henderson
2020-02-18  8:29   ` Philippe Mathieu-Daudé
2020-01-24 23:20 ` [PULL v3 05/11] hppa: Switch to tulip NIC by default Richard Henderson
2020-01-24 23:20 ` [PULL v3 06/11] seabios-hppa: update to latest version Richard Henderson
2020-01-24 23:20 ` [PULL v3 07/11] hppa: Add emulation of Artist graphics Richard Henderson
2020-01-24 23:20 ` [PULL v3 08/11] hw/hppa/machine: Correctly check the firmware is in PDC range Richard Henderson
2020-01-24 23:20 ` [PULL v3 09/11] hw/hppa/machine: Restrict the total memory size to 3GB Richard Henderson
2020-01-24 23:20 ` [PULL v3 10/11] hw/hppa/machine: Map the PDC memory region with higher priority Richard Henderson
2020-01-24 23:20 ` Richard Henderson [this message]
2020-01-27 11:23 ` [PULL v3 00/11] target/hppa patch queue Peter Maydell

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=20200124232009.12928-12-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=dave.anglin@bell.net \
    --cc=deller@gmx.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=svens@stackframe.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).