From: WANG Xuerui <[email protected]>

LoongArch64 v1.1 has native 128-bit LL/SC capability through the
`sc.q` instruction, and [GCC uses it since 16.1.0][1]. So for
`-march=la64v1.1` (and equivalents such as `-march=la664` or just
`-mscq`) configurations the following happens:

- `CONFIG_ATOMIC128` is set,
- in `host/include/generic/host/atomic128-cas.h.inc`, `HAVE_CMPXCHG128`
  is set to `1`,
- in `accel/tcg/ldst_atomicity.c.inc`, code paths invoking
  `store_atom_insert_al16` are enabled,
- this errors out because of the explicit
  `host/include/loongarch64/host/store-insert-al16.h.inc` override.

This doesn't affect `-march=la64v1.0` builds because the `atomic128`
probe, when code-generated without `sc.q` support, correctly fails to
link without libatomic.

Simply removing the override is enough to make QEMU build and run
correctly on `sc.q`-enabled hosts. The override was introduced in 2023,
in commit adc8467e697d ("host/include/loongarch64: Add atomic16 load
and store"), when it was true that no existing LoongArch implementation
could perform 128-bit LL/SC nor CAS at that time. It is no longer the
case since LA664 with LoongArch64 v1.1.

[1]: 
https://github.com/gcc-mirror/gcc/blob/releases/gcc-16.1.0/gcc/config/loongarch/sync.md#L784

Cc: [email protected]
Cc: Richard Henderson <[email protected]>
Fixes: adc8467e697d ("host/include/loongarch64: Add atomic16 load and store")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4767
Signed-off-by: WANG Xuerui <[email protected]>
---
 .../include/loongarch64/host/store-insert-al16.h.inc | 12 ------------
 1 file changed, 12 deletions(-)
 delete mode 100644 host/include/loongarch64/host/store-insert-al16.h.inc

diff --git a/host/include/loongarch64/host/store-insert-al16.h.inc 
b/host/include/loongarch64/host/store-insert-al16.h.inc
deleted file mode 100644
index 919fd8d74404..000000000000
--- a/host/include/loongarch64/host/store-insert-al16.h.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-or-later
- * Atomic store insert into 128-bit, LoongArch version.
- */
-
-#ifndef LOONGARCH_STORE_INSERT_AL16_H
-#define LOONGARCH_STORE_INSERT_AL16_H
-
-void store_atom_insert_al16(Int128 *ps, Int128 val, Int128 msk)
-    QEMU_ERROR("unsupported atomic");
-
-#endif /* LOONGARCH_STORE_INSERT_AL16_H */
-- 
2.55.0


Reply via email to