qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: David Hildenbrand <david@redhat.com>,
	Peter Xu <peterx@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>,
	Peixiu Hou <phou@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [PATCH] system/physmem: mark io_mem_unassigned lockless
Date: Wed, 29 Oct 2025 22:56:17 +0100	[thread overview]
Message-ID: <5fdf4757-ba5f-4069-ab6a-8761f33f8ea7@linaro.org> (raw)
In-Reply-To: <20251029185224.420261-1-stefanha@redhat.com>

On 29/10/25 19:52, Stefan Hajnoczi wrote:
> When the Bus Master bit is disabled in a PCI device's Command Register,
> the device's DMA address space becomes unassigned memory (i.e. the
> io_mem_unassigned MemoryRegion).
> 
> This can lead to deadlocks with IOThreads since io_mem_unassigned
> accesses attempt to acquire the Big QEMU Lock (BQL). For example,
> virtio-pci devices deadlock in virtio_write_config() ->
> virtio_pci_stop_ioeventfd() when waiting for the IOThread while holding
> the BQL. The IOThread is unable to acquire the BQL but the vcpu thread
> won't release the BQL while waiting for the IOThread.
> 
> io_mem_unassigned is trivially thread-safe since it has no state, it
> simply rejects all load/store accesses. Therefore it is safe to enable
> lockless I/O on io_mem_unassigned to eliminate this deadlock.
> 
[...]
> Buglink: https://issues.redhat.com/browse/RHEL-71933
> Reported-by: Peixiu Hou <phou@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   system/physmem.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/system/physmem.c b/system/physmem.c
> index a340ca3e61..1dc2b46e12 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -3011,6 +3011,9 @@ static void io_mem_init(void)
>   {
>       memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, NULL,
>                             NULL, UINT64_MAX);
> +
> +    /* Trivially thread-safe since memory accesses are rejected */

Maybe duplicate the comment in unassigned_mem_ops[]. Regardless,

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> +    memory_region_enable_lockless_io(&io_mem_unassigned);
>   }



  reply	other threads:[~2025-10-29 21:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 18:52 [PATCH] system/physmem: mark io_mem_unassigned lockless Stefan Hajnoczi
2025-10-29 21:56 ` Philippe Mathieu-Daudé [this message]
2025-10-30 15:39 ` Peter Xu

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=5fdf4757-ba5f-4069-ab6a-8761f33f8ea7@linaro.org \
    --to=philmd@linaro.org \
    --cc=david@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=phou@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).