aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-08-10 11:10:01 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-08-10 11:10:01 -0700
commit70b73990d5e2e8e1ce63274b6b85888bef2957aa (patch)
tree647cbac351bd02ec56698d662fff2f7145657685
parent64d3be986f9e2379bc688bf1d0aca0557e0035ca (diff)
parentf1b0f894c8c25f7ed24197ff130c7acb6b9fd6e7 (diff)
Merge tag 'pull-tcg-20230810' of https://gitlab.com/rth7680/qemu into staging
accel/tcg: Avoid reading too much in load_atom_{2,4} tests/tcg: ensure system-mode gdb tests start stopped gdbstub: more fixes for client Ctrl-C handling # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmTVJ4EdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+/iAf9EUojONGO1FQCUokR # +8kfHFaGH5R5U4v6Zd6xlwHt94iagW8s+DdpM/YdmgZFxQ5jglCCsLOXQYtJ/HPu # McKRv86Yr264ysrwYzTuyOLIC585UU0KzYbGBQvjCSeQ43Au5bR/3ec35Lwgm7OO # eukLdpmuD4QoSgBmVgkbziKH1zaX8NjgPoWGfFqxfzzWUZBfU4VfyLgGKw2gtqoz # fMTORiqbnzSvQfYINNJ0qBTyXWm0YmydDzaK6zfBrsCzdMk3JYksxgneItvqgRar # A5UAYUPhBPftIyTAnI3PQo+siyuaDhFRU9BwHb25a/pkuOUg8PBFO2HruseLmmdl # bPcnhQ== # =7c0w # -----END PGP SIGNATURE----- # gpg: Signature made Thu 10 Aug 2023 11:08:01 AM PDT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-tcg-20230810' of https://gitlab.com/rth7680/qemu: gdbstub: don't complain about preemptive ACK chars gdbstub: more fixes for client Ctrl-C handling tests/tcg: ensure system-mode gdb tests start stopped accel/tcg: Avoid reading too much in load_atom_{2,4} Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r--accel/tcg/ldst_atomicity.c.inc10
-rw-r--r--gdbstub/gdbstub.c10
-rw-r--r--gdbstub/trace-events1
-rwxr-xr-xtests/guest-debug/run-test.py9
-rw-r--r--tests/tcg/aarch64/Makefile.target2
-rw-r--r--tests/tcg/aarch64/lse2-fault.c38
6 files changed, 59 insertions, 11 deletions
diff --git a/accel/tcg/ldst_atomicity.c.inc b/accel/tcg/ldst_atomicity.c.inc
index e5c590a499..1b793e6935 100644
--- a/accel/tcg/ldst_atomicity.c.inc
+++ b/accel/tcg/ldst_atomicity.c.inc
@@ -404,7 +404,10 @@ static uint16_t load_atom_2(CPUArchState *env, uintptr_t ra,
return load_atomic2(pv);
}
if (HAVE_ATOMIC128_RO) {
- return load_atom_extract_al16_or_al8(pv, 2);
+ intptr_t left_in_page = -(pi | TARGET_PAGE_MASK);
+ if (likely(left_in_page > 8)) {
+ return load_atom_extract_al16_or_al8(pv, 2);
+ }
}
atmax = required_atomicity(env, pi, memop);
@@ -443,7 +446,10 @@ static uint32_t load_atom_4(CPUArchState *env, uintptr_t ra,
return load_atomic4(pv);
}
if (HAVE_ATOMIC128_RO) {
- return load_atom_extract_al16_or_al8(pv, 4);
+ intptr_t left_in_page = -(pi | TARGET_PAGE_MASK);
+ if (likely(left_in_page > 8)) {
+ return load_atom_extract_al16_or_al8(pv, 4);
+ }
}
atmax = required_atomicity(env, pi, memop);
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index e74ecc78cc..5f28d5cf57 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -2059,9 +2059,10 @@ void gdb_read_byte(uint8_t ch)
* here, but it does expect a stop reply.
*/
if (ch != 0x03) {
- warn_report("gdbstub: client sent packet while target running\n");
+ trace_gdbstub_err_unexpected_runpkt(ch);
+ } else {
+ gdbserver_state.allow_stop_reply = true;
}
- gdbserver_state.allow_stop_reply = true;
vm_stop(RUN_STATE_PAUSED);
} else
#endif
@@ -2073,6 +2074,11 @@ void gdb_read_byte(uint8_t ch)
gdbserver_state.line_buf_index = 0;
gdbserver_state.line_sum = 0;
gdbserver_state.state = RS_GETLINE;
+ } else if (ch == '+') {
+ /*
+ * do nothing, gdb may preemptively send out ACKs on
+ * initial connection
+ */
} else {
trace_gdbstub_err_garbage(ch);
}
diff --git a/gdbstub/trace-events b/gdbstub/trace-events
index 0c18a4d70a..7bc79a73c4 100644
--- a/gdbstub/trace-events
+++ b/gdbstub/trace-events
@@ -26,6 +26,7 @@ gdbstub_err_invalid_repeat(uint8_t ch) "got invalid RLE count: 0x%02x"
gdbstub_err_invalid_rle(void) "got invalid RLE sequence"
gdbstub_err_checksum_invalid(uint8_t ch) "got invalid command checksum digit: 0x%02x"
gdbstub_err_checksum_incorrect(uint8_t expected, uint8_t got) "got command packet with incorrect checksum, expected=0x%02x, received=0x%02x"
+gdbstub_err_unexpected_runpkt(uint8_t ch) "unexpected packet (0x%02x) while target running"
# softmmu.c
gdbstub_hit_watchpoint(const char *type, int cpu_gdb_index, uint64_t vaddr) "Watchpoint hit, type=\"%s\" cpu=%d, vaddr=0x%" PRIx64 ""
diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index de6106a5e5..a032e01f79 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -69,13 +69,10 @@ if __name__ == '__main__':
# Launch QEMU with binary
if "system" in args.qemu:
- cmd = "%s %s %s -gdb unix:path=%s,server=on" % (args.qemu,
- args.qargs,
- args.binary,
- socket_name)
+ cmd = f'{args.qemu} {args.qargs} {args.binary}' \
+ f' -S -gdb unix:path={socket_name},server=on'
else:
- cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name,
- args.binary)
+ cmd = f'{args.qemu} {args.qargs} -g {socket_name} {args.binary}'
log(output, "QEMU CMD: %s" % (cmd))
inferior = subprocess.Popen(shlex.split(cmd))
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 617f821613..681dfa077c 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 0000000000..2187219a08
--- /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);
+}