aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-08-10 08:37:14 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-08-10 10:59:24 -0700
commit6a2c23ddeb5bc8883c227ce1a3ff22e9978291af (patch)
tree77ad1258da6d415d10ba0c44416247476f1cfb52 /tests
parent64d3be986f9e2379bc688bf1d0aca0557e0035ca (diff)
downloadqemu-6a2c23ddeb5bc8883c227ce1a3ff22e9978291af.zip
qemu-6a2c23ddeb5bc8883c227ce1a3ff22e9978291af.tar.gz
qemu-6a2c23ddeb5bc8883c227ce1a3ff22e9978291af.tar.bz2
accel/tcg: Avoid reading too much in load_atom_{2,4}
When load_atom_extract_al16_or_al8 is inexpensive, we want to use it early, in order to avoid the overhead of required_atomicity. However, we must not read past the end of the page. If there are more than 8 bytes remaining, then both the "aligned 16" and "aligned 8" paths align down so that the read has at least 16 bytes remaining on the page. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/tcg/aarch64/Makefile.target2
-rw-r--r--tests/tcg/aarch64/lse2-fault.c38
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 617f821..681dfa0 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -9,7 +9,7 @@ AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
VPATH += $(AARCH64_SRC)
# Base architecture tests
-AARCH64_TESTS=fcvt pcalign-a64
+AARCH64_TESTS=fcvt pcalign-a64 lse2-fault
fcvt: LDFLAGS+=-lm
diff --git a/tests/tcg/aarch64/lse2-fault.c b/tests/tcg/aarch64/lse2-fault.c
new file mode 100644
index 0000000..2187219
--- /dev/null
+++ b/tests/tcg/aarch64/lse2-fault.c
@@ -0,0 +1,38 @@
+#include <sys/mman.h>
+#include <sys/shm.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int main()
+{
+ int psize = getpagesize();
+ int id;
+ void *p;
+
+ /*
+ * We need a shared mapping to enter CF_PARALLEL mode.
+ * The easiest way to get that is shmat.
+ */
+ id = shmget(IPC_PRIVATE, 2 * psize, IPC_CREAT | 0600);
+ if (id < 0) {
+ perror("shmget");
+ return 2;
+ }
+ p = shmat(id, NULL, 0);
+ if (p == MAP_FAILED) {
+ perror("shmat");
+ return 2;
+ }
+
+ /* Protect the second page. */
+ if (mprotect(p + psize, psize, PROT_NONE) < 0) {
+ perror("mprotect");
+ return 2;
+ }
+
+ /*
+ * Load 4 bytes, 6 bytes from the end of the page.
+ * On success this will load 0 from the newly allocated shm.
+ */
+ return *(int *)(p + psize - 6);
+}