From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Subject: [PULL 05/14] target/i386: fix hang when using slow path for ptw_setl
Date: Fri, 15 Nov 2024 12:58:40 -0800 [thread overview]
Message-ID: <20241115205849.266094-6-richard.henderson@linaro.org> (raw)
In-Reply-To: <20241115205849.266094-1-richard.henderson@linaro.org>
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
When instrumenting memory accesses for plugin, we force memory accesses
to use the slow path for mmu [1]. This create a situation where we end
up calling ptw_setl_slow. This was fixed recently in [2] but the issue
still could appear out of plugins use case.
Since this function gets called during a cpu_exec, start_exclusive then
hangs. This exclusive section was introduced initially for security
reasons [3].
I suspect this code path was never triggered, because ptw_setl_slow
would always be called transitively from cpu_exec, resulting in a hang.
[1] https://gitlab.com/qemu-project/qemu/-/commit/6d03226b42247b68ab2f0b3663e0f624335a4055
[2] https://gitlab.com/qemu-project/qemu/-/commit/115ade42d50144c15b74368d32dc734ea277d853
[3] https://gitlab.com/qemu-project/qemu/-/issues/279
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2566
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20241025175857.2554252-2-pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/tcg/sysemu/excp_helper.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c
index 02d3486421..b1f40040f8 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -107,6 +107,10 @@ static bool ptw_setl_slow(const PTETranslate *in, uint32_t old, uint32_t new)
{
uint32_t cmp;
+ CPUState *cpu = env_cpu(in->env);
+ /* We are in cpu_exec, and start_exclusive can't be called directly.*/
+ g_assert(cpu->running);
+ cpu_exec_end(cpu);
/* Does x86 really perform a rmw cycle on mmio for ptw? */
start_exclusive();
cmp = cpu_ldl_mmuidx_ra(in->env, in->gaddr, in->ptw_idx, 0);
@@ -114,6 +118,7 @@ static bool ptw_setl_slow(const PTETranslate *in, uint32_t old, uint32_t new)
cpu_stl_mmuidx_ra(in->env, in->gaddr, new, in->ptw_idx, 0);
}
end_exclusive();
+ cpu_exec_start(cpu);
return cmp == old;
}
--
2.43.0
next prev parent reply other threads:[~2024-11-15 21:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 20:58 [PULL 00/14] tcg + linux-user patch queue Richard Henderson
2024-11-15 20:58 ` [PULL 01/14] linux-user: Fix setreuid and setregid to use direct syscalls Richard Henderson
2024-11-15 20:58 ` [PULL 02/14] accel/tcg: Fix user-only probe_access_internal plugin check Richard Henderson
2024-11-15 20:58 ` [PULL 03/14] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR Richard Henderson
2024-11-15 20:58 ` [PULL 04/14] tests/tcg: Test that sigreturn() does not corrupt the signal mask Richard Henderson
2024-11-15 20:58 ` Richard Henderson [this message]
2024-11-15 20:58 ` [PULL 06/14] cpu: ensure we don't call start_exclusive from cpu_exec Richard Henderson
2024-11-15 20:58 ` [PULL 07/14] linux-user: Honor elf alignment when placing images Richard Henderson
2024-11-15 20:58 ` [PULL 08/14] linux-user: Drop image_info.alignment Richard Henderson
2024-11-15 20:58 ` [PULL 09/14] linux-user/aarch64: Reduce vdso alignment to 4k Richard Henderson
2024-11-15 20:58 ` [PULL 10/14] linux-user/arm: " Richard Henderson
2024-11-15 20:58 ` [PULL 11/14] linux-user/loongarch64: " Richard Henderson
2024-11-15 20:58 ` [PULL 12/14] linux-user/ppc: " Richard Henderson
2024-11-15 20:58 ` [PULL 13/14] linux-user/arm: Select vdso for be8 and be32 modes Richard Henderson
2024-11-15 20:58 ` [PULL 14/14] tcg: Allow top bit of SIMD_DATA_BITS to be set in simd_desc() Richard Henderson
2024-11-16 10:39 ` [PULL 00/14] tcg + linux-user patch queue Peter Maydell
2024-11-16 16:38 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241115205849.266094-6-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).