Skip to contentSkip to conversation

tcg/x86_64: declare MO_ATOM_WITHIN16 host atomicity support

PATCH In review Andrew Jones 2 participants 3 messages Jul 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcg/x86_64: declare MO_ATOM_WITHIN16 host atomicity support

Just like aarch64's prepare_host_addr(), x86_64 should use MO_ATOM_WITHIN16 for the memop when it's capable. Unlike aarch64, which needs to check a CPU feature, x86 has been capable since P6 family processors and newer (see Intel SDM Vol. 3 §11.1.1).

Since a 16-byte aligned region always fits within a 16-byte multiple sized cache line (x86_64 implementations always have cache lines of at least 64 bytes), then this enables riscv cpu models with Zama16b to use the fast path, just as cpu models without Zama16b do.

---
 tcg/x86_64/tcg-target.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/x86_64/tcg-target.c.inc +1 -1
index 92251f832738..99b6559eed88 100644
@@ -1934,7 +1934,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
         *h = x86_guest_base;
     }
     h->base = addr;
-    h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_IFALIGN, s_bits == MO_128);
+    h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_WITHIN16, s_bits == MO_128);
     a_mask = (1 << h->aa.align) - 1;
 
     if (tcg_use_softmmu) {
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Andrew Jones

Just like aarch64's prepare_host_addr(), x86_64 should use MO_ATOM_WITHIN16 for the memop when it's capable. Unlike aarch64, which needs to check a CPU feature, x86 has been capable since P6 family processors and newer (see Intel SDM Vol. 3 §11.1.1).

Since a 16-byte aligned region always fits within a 16-byte multiple sized cache line (x86_64 implementations always have cache lines of at least 64 bytes), then this enables riscv cpu models with Zama16b to use the fast path, just as cpu models without Zama16b do.

---
  tcg/x86_64/tcg-target.c.inc | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tcg/x86_64/tcg-target.c.inc +0 -0
index 92251f832738..99b6559eed88 100644

tcg/x86_64/tcg-target.c.inc static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, · line 1940

Quoted 8 lines
tcg/x86_64/tcg-target.c.inc +1 -1
@@ -1934,7 +1934,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
          *h = x86_guest_base;
      }
      h->base = addr;
-    h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_IFALIGN, s_bits == MO_128);
+    h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_WITHIN16, s_bits == MO_128);
      a_mask = (1 << h->aa.align) - 1;
 
      if (tcg_use_softmmu) {

You should update both uses of atom_and_align_for_opc.

With that,

r~

#2 lore raw
Quoted 33 lines · Richard Henderson
Quoted 21 lines · Andrew Jones

Just like aarch64's prepare_host_addr(), x86_64 should use MO_ATOM_WITHIN16 for the memop when it's capable. Unlike aarch64, which needs to check a CPU feature, x86 has been capable since P6 family processors and newer (see Intel SDM Vol. 3 §11.1.1).

Since a 16-byte aligned region always fits within a 16-byte multiple sized cache line (x86_64 implementations always have cache lines of at least 64 bytes), then this enables riscv cpu models with Zama16b to use the fast path, just as cpu models without Zama16b do.

---
  tcg/x86_64/tcg-target.c.inc | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
tcg/x86_64/tcg-target.c.inc +0 -0
index 92251f832738..99b6559eed88 100644

tcg/x86_64/tcg-target.c.inc static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, · line 1940

Quoted 8 lines
tcg/x86_64/tcg-target.c.inc +1 -1
@@ -1934,7 +1934,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, 
 HostAddress *h,
           *h = x86_guest_base;
       }
       h->base = addr;
-    h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_IFALIGN, s_bits == MO_128);
+    h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_WITHIN16, s_bits == MO_128);
       a_mask = (1 << h->aa.align) - 1;
       if (tcg_use_softmmu) {

You should update both uses of atom_and_align_for_opc.

Quoted 2 lines

With that,

I'll update this myself and queue for today's PR.

r~