* [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296)
@ 2017-09-21 11:06 Alex Bennée
2017-09-21 11:09 ` Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alex Bennée @ 2017-09-21 11:06 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Alex Bennée, Richard Jones, Paolo Bonzini,
Paolo Bonzini, Peter Crosthwaite, Richard Henderson
The mmio path (see exec.c:prepare_mmio_access) already protects itself
against recursive locking and it makes sense to do the same for
io_readx/writex. Otherwise any helper running in the BQL context will
assert when it attempts to write to device memory as in the case of
the bug report.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
CC: Richard Jones <rjones@redhat.com>
CC: Paolo Bonzini <bonzini@gnu.org>
---
accel/tcg/cputlb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index e72415a882..bcbcc4db6c 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -765,7 +765,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
cpu->mem_io_vaddr = addr;
- if (mr->global_locking) {
+ if (mr->global_locking && !qemu_mutex_iothread_locked()) {
qemu_mutex_lock_iothread();
locked = true;
}
@@ -800,7 +800,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
cpu->mem_io_vaddr = addr;
cpu->mem_io_pc = retaddr;
- if (mr->global_locking) {
+ if (mr->global_locking && !qemu_mutex_iothread_locked()) {
qemu_mutex_lock_iothread();
locked = true;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296)
2017-09-21 11:06 [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296) Alex Bennée
@ 2017-09-21 11:09 ` Peter Maydell
2017-09-25 18:22 ` Richard Henderson
2017-09-25 20:53 ` Michael Roth
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2017-09-21 11:09 UTC (permalink / raw)
To: Alex Bennée
Cc: QEMU Developers, Richard Jones, Paolo Bonzini, Paolo Bonzini,
Peter Crosthwaite, Richard Henderson
On 21 September 2017 at 12:06, Alex Bennée <alex.bennee@linaro.org> wrote:
> The mmio path (see exec.c:prepare_mmio_access) already protects itself
> against recursive locking and it makes sense to do the same for
> io_readx/writex. Otherwise any helper running in the BQL context will
> assert when it attempts to write to device memory as in the case of
> the bug report.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> CC: Richard Jones <rjones@redhat.com>
> CC: Paolo Bonzini <bonzini@gnu.org>
Seems worth:
Cc: qemu-stable@nongnu.org
> ---
> accel/tcg/cputlb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index e72415a882..bcbcc4db6c 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -765,7 +765,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
>
> cpu->mem_io_vaddr = addr;
>
> - if (mr->global_locking) {
> + if (mr->global_locking && !qemu_mutex_iothread_locked()) {
> qemu_mutex_lock_iothread();
> locked = true;
> }
> @@ -800,7 +800,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
> cpu->mem_io_vaddr = addr;
> cpu->mem_io_pc = retaddr;
>
> - if (mr->global_locking) {
> + if (mr->global_locking && !qemu_mutex_iothread_locked()) {
> qemu_mutex_lock_iothread();
> locked = true;
> }
> --
> 2.14.1
Seems to fix the similar problem that I ran into with my work-in-progress
v8M blxns/secure-return code.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296)
2017-09-21 11:06 [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296) Alex Bennée
2017-09-21 11:09 ` Peter Maydell
@ 2017-09-25 18:22 ` Richard Henderson
2017-09-25 20:53 ` Michael Roth
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2017-09-25 18:22 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: peter.maydell, Paolo Bonzini, Peter Crosthwaite, Richard Jones,
Paolo Bonzini, Richard Henderson
On 09/21/2017 04:06 AM, Alex Bennée wrote:
> The mmio path (see exec.c:prepare_mmio_access) already protects itself
> against recursive locking and it makes sense to do the same for
> io_readx/writex. Otherwise any helper running in the BQL context will
> assert when it attempts to write to device memory as in the case of
> the bug report.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> CC: Richard Jones <rjones@redhat.com>
> CC: Paolo Bonzini <bonzini@gnu.org>
> ---
> accel/tcg/cputlb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
I guess I'll queue this through tcg-next?
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296)
2017-09-21 11:06 [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296) Alex Bennée
2017-09-21 11:09 ` Peter Maydell
2017-09-25 18:22 ` Richard Henderson
@ 2017-09-25 20:53 ` Michael Roth
2 siblings, 0 replies; 4+ messages in thread
From: Michael Roth @ 2017-09-25 20:53 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: peter.maydell, Paolo Bonzini, Peter Crosthwaite, Richard Jones,
Paolo Bonzini, Richard Henderson
Quoting Alex Bennée (2017-09-21 06:06:25)
> The mmio path (see exec.c:prepare_mmio_access) already protects itself
> against recursive locking and it makes sense to do the same for
> io_readx/writex. Otherwise any helper running in the BQL context will
> assert when it attempts to write to device memory as in the case of
> the bug report.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> CC: Richard Jones <rjones@redhat.com>
> CC: Paolo Bonzini <bonzini@gnu.org>
FYI: this patch has been tagged for stable 2.10.1, but is not yet
upstream. Patch freeze for 2.10.1 is September 27th.
> ---
> accel/tcg/cputlb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index e72415a882..bcbcc4db6c 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -765,7 +765,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
>
> cpu->mem_io_vaddr = addr;
>
> - if (mr->global_locking) {
> + if (mr->global_locking && !qemu_mutex_iothread_locked()) {
> qemu_mutex_lock_iothread();
> locked = true;
> }
> @@ -800,7 +800,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
> cpu->mem_io_vaddr = addr;
> cpu->mem_io_pc = retaddr;
>
> - if (mr->global_locking) {
> + if (mr->global_locking && !qemu_mutex_iothread_locked()) {
> qemu_mutex_lock_iothread();
> locked = true;
> }
> --
> 2.14.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-25 20:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 11:06 [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296) Alex Bennée
2017-09-21 11:09 ` Peter Maydell
2017-09-25 18:22 ` Richard Henderson
2017-09-25 20:53 ` Michael Roth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.