qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: laurent.desnogues@gmail.com, peter.maydell@linaro.org,
	alex.bennee@linaro.org, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH 06/11] target/arm: Fix sign-extension in sve do_ldr/do_str
Date: Wed,  8 Aug 2018 20:40:28 -0700	[thread overview]
Message-ID: <20180809034033.10579-7-richard.henderson@linaro.org> (raw)
In-Reply-To: <20180809034033.10579-1-richard.henderson@linaro.org>

The expression (int) imm + (uint32_t) len_align turns into uint32_t
and thus with negative imm produces a memory operation at the wrong
offset.  None of the numbers involved are particularly large, so
change everything to use int.

Cc: qemu-stable@nongnu.org (3.0.1)
Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/translate-sve.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
index 89efc80ee7..9e63b5f8e5 100644
--- a/target/arm/translate-sve.c
+++ b/target/arm/translate-sve.c
@@ -4372,12 +4372,11 @@ static bool trans_UCVTF_dd(DisasContext *s, arg_rpr_esz *a, uint32_t insn)
  * The load should begin at the address Rn + IMM.
  */
 
-static void do_ldr(DisasContext *s, uint32_t vofs, uint32_t len,
-                   int rn, int imm)
+static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
 {
-    uint32_t len_align = QEMU_ALIGN_DOWN(len, 8);
-    uint32_t len_remain = len % 8;
-    uint32_t nparts = len / 8 + ctpop8(len_remain);
+    int len_align = QEMU_ALIGN_DOWN(len, 8);
+    int len_remain = len % 8;
+    int nparts = len / 8 + ctpop8(len_remain);
     int midx = get_mem_index(s);
     TCGv_i64 addr, t0, t1;
 
@@ -4458,12 +4457,11 @@ static void do_ldr(DisasContext *s, uint32_t vofs, uint32_t len,
 }
 
 /* Similarly for stores.  */
-static void do_str(DisasContext *s, uint32_t vofs, uint32_t len,
-                   int rn, int imm)
+static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
 {
-    uint32_t len_align = QEMU_ALIGN_DOWN(len, 8);
-    uint32_t len_remain = len % 8;
-    uint32_t nparts = len / 8 + ctpop8(len_remain);
+    int len_align = QEMU_ALIGN_DOWN(len, 8);
+    int len_remain = len % 8;
+    int nparts = len / 8 + ctpop8(len_remain);
     int midx = get_mem_index(s);
     TCGv_i64 addr, t0;
 
-- 
2.17.1

  parent reply	other threads:[~2018-08-09  3:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09  3:40 [Qemu-devel] [PATCH 00/11] target/arm: sve linux-user patches Richard Henderson
2018-08-09  3:40 ` [Qemu-devel] [PATCH 01/11] target/arm: Fix sign of sve_cmpeq_ppzw/sve_cmpne_ppzw Richard Henderson
2018-08-09  3:40 ` [Qemu-devel] [PATCH 02/11] target/arm: Fix typo in do_sat_addsub_64 Richard Henderson
2018-08-09  9:12   ` Alex Bennée
2018-08-09  3:40 ` [Qemu-devel] [PATCH 03/11] target/arm: Reorganize SVE WHILE Richard Henderson
2018-08-09  9:48   ` Alex Bennée
2018-08-09  3:40 ` [Qemu-devel] [PATCH 04/11] target/arm: Fix typo in helper_sve_movz_d Richard Henderson
2018-08-09  3:40 ` [Qemu-devel] [PATCH 05/11] target/arm: Fix typo in helper_sve_ld1hss_r Richard Henderson
2018-08-09 10:09   ` Alex Bennée
2018-08-09  3:40 ` Richard Henderson [this message]
2018-08-09  5:28   ` [Qemu-devel] [PATCH 06/11] target/arm: Fix sign-extension in sve do_ldr/do_str Laurent Desnogues
2018-08-09 11:00   ` Alex Bennée
2018-08-09  3:40 ` [Qemu-devel] [PATCH 07/11] target/arm: Fix offset for LD1R instructions Richard Henderson
2018-08-09  5:28   ` Laurent Desnogues
2018-08-09  3:40 ` [Qemu-devel] [PATCH 08/11] target/arm: Fix offset scaling for LD_zprr and ST_zprr Richard Henderson
2018-08-09  5:29   ` Laurent Desnogues
2018-08-09  3:40 ` [Qemu-devel] [PATCH 09/11] target/arm: Reformat integer register dump Richard Henderson
2018-08-09 10:12   ` Alex Bennée
2018-08-09 10:58   ` Alex Bennée
2018-08-09  3:40 ` [Qemu-devel] [PATCH 10/11] target/arm: Dump SVE state if enabled Richard Henderson
2018-08-09 10:55   ` Alex Bennée
2018-08-09  3:40 ` [Qemu-devel] [PATCH 11/11] target/arm: Add sve-max-vq cpu property to -cpu max Richard Henderson
2018-08-09 11:00   ` Alex Bennée
2018-08-16 12:11 ` [Qemu-devel] [PATCH 00/11] target/arm: sve linux-user patches 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=20180809034033.10579-7-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=laurent.desnogues@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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).