Commit 5c33a72bde for qemu.org
commit 5c33a72bdebe622200b5d81884e1a85090df6abc
Author: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Date: Fri Aug 21 14:40:32 2026 +0800
target/arm: Fix barrier polarity of A32 LDA load-acquire
The A32 and T32 load-acquire instructions LDA, LDAB and LDAH must be
ordered before the memory accesses that follow them, so their
translator has to emit a trailing barrier. op_lda() emits that barrier
with TCG_BAR_STRL instead of TCG_BAR_LDAQ, inverting the polarity:
TCG_BAR_STRL annotates a leading barrier ("previous ops will not be
delayed") and TCG_BAR_LDAQ a trailing one ("following ops will not come
forward"), as documented in include/tcg/tcg-mo.h.
The x86 and aarch64 backends only look at the TCG_MO_* bits, which the
wrong annotation does not affect, so the generated host code is
unchanged on those hosts. The annotation is still wrong: it violates
the TCG barrier contract, it lets the optimizer's barrier merging in
fold_mb() combine the barriers of an "LDA; STL" pair into a weaker one
than the correctly annotated form (STRL|STRL stays STRL instead of
LDAQ|STRL = SC), and it diverges from every other load-acquire
translation in the target, which all use TCG_BAR_LDAQ.
Fix the polarity.
Cc: qemu-stable@nongnu.org
Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
index 20a58a2413..442c34ce84 100644
--- a/target/arm/tcg/translate.c
+++ b/target/arm/tcg/translate.c
@@ -4458,7 +4458,7 @@ static bool op_lda(DisasContext *s, arg_LDA *a, MemOp mop)
disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel);
store_reg(s, a->rt, tmp);
- tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL);
+ tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ);
return true;
}