qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 for-2.10 3/3] target/arm: Require alignment f


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH v2 for-2.10 3/3] target/arm: Require alignment for load exclusive
Date: Tue, 15 Aug 2017 12:56:34 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hi Richard,

On 08/15/2017 11:57 AM, Richard Henderson wrote:
From: Alistair Francis <address@hidden>

Acording to the ARM ARM exclusive loads require the same allignment as
exclusive stores. Let's update the memops used for the load to match
that of the store. This adds the alignment requirement to the memops.

Reviewed-by: Edgar E. Iglesias <address@hidden>
Signed-off-by: Alistair Francis <address@hidden>
[rth: Require 16-byte alignment for 64-bit LDXP.]
Signed-off-by: Richard Henderson <address@hidden>
---
  target/arm/translate-a64.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index eac545e4f2..2200e25be0 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -1861,7 +1861,7 @@ static void gen_load_exclusive(DisasContext *s, int rt, 
int rt2,
          g_assert(size >= 2);
          if (size == 2) {
              /* The pair must be single-copy atomic for the doubleword.  */
-            memop |= MO_64;
+            memop |= MO_64 | MO_ALIGN;

isn't MO_ALIGN_8 enough?

              tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx, memop);
              if (s->be_data == MO_LE) {
                  tcg_gen_extract_i64(cpu_reg(s, rt), cpu_exclusive_val, 0, 32);
@@ -1871,10 +1871,11 @@ static void gen_load_exclusive(DisasContext *s, int rt, 
int rt2,
                  tcg_gen_extract_i64(cpu_reg(s, rt2), cpu_exclusive_val, 0, 
32);
              }
          } else {
-            /* The pair must be single-copy atomic for *each* doubleword,
-               but not the entire quadword.  */
+            /* The pair must be single-copy atomic for *each* doubleword, not
+               the entire quadword, however it must be quadword aligned.  */
              memop |= MO_64;
-            tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx, memop);
+            tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx,
+                                memop | MO_ALIGN_16);

ok

TCGv_i64 addr2 = tcg_temp_new_i64();
              tcg_gen_addi_i64(addr2, addr, 8);
@@ -1885,7 +1886,7 @@ static void gen_load_exclusive(DisasContext *s, int rt, 
int rt2,
              tcg_gen_mov_i64(cpu_reg(s, rt2), cpu_exclusive_high);
          }
      } else {
-        memop |= size;
+        memop |= size | MO_ALIGN;

MO_ALIGN_8 here too?

          tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx, memop);
          tcg_gen_mov_i64(cpu_reg(s, rt), cpu_exclusive_val);
      }


Regards,

Phil.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]