From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com
Subject: [Qemu-devel] [PULL 1/6] memory: unregister AddressSpace MemoryListener within BQL
Date: Tue, 10 Feb 2015 11:37:16 -0700 [thread overview]
Message-ID: <20150210183716.26101.26293.stgit@gimli.home> (raw)
In-Reply-To: <20150210183106.26101.78658.stgit@gimli.home>
From: Paolo Bonzini <pbonzini@redhat.com>
address_space_destroy_dispatch is called from an RCU callback and hence
outside the iothread mutex (BQL). However, after address_space_destroy
no new accesses can hit the destroyed AddressSpace so it is not necessary
to observe changes to the memory map. Move the memory_listener_unregister
call earlier, to make it thread-safe again.
Reported-by: Alex Williamson <alex.williamson@redhat.com>
Fixes: 374f2981d1f10bc4307f250f24b2a7ddb9b14be0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
exec.c | 6 +++++-
include/exec/memory-internal.h | 1 +
memory.c | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/exec.c b/exec.c
index 6b79ad1..6dff7bc 100644
--- a/exec.c
+++ b/exec.c
@@ -2059,11 +2059,15 @@ void address_space_init_dispatch(AddressSpace *as)
memory_listener_register(&as->dispatch_listener, as);
}
+void address_space_unregister(AddressSpace *as)
+{
+ memory_listener_unregister(&as->dispatch_listener);
+}
+
void address_space_destroy_dispatch(AddressSpace *as)
{
AddressSpaceDispatch *d = as->dispatch;
- memory_listener_unregister(&as->dispatch_listener);
g_free(d);
as->dispatch = NULL;
}
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
index 25c43c0..fb467ac 100644
--- a/include/exec/memory-internal.h
+++ b/include/exec/memory-internal.h
@@ -23,6 +23,7 @@
typedef struct AddressSpaceDispatch AddressSpaceDispatch;
void address_space_init_dispatch(AddressSpace *as);
+void address_space_unregister(AddressSpace *as);
void address_space_destroy_dispatch(AddressSpace *as);
extern const MemoryRegionOps unassigned_mem_ops;
diff --git a/memory.c b/memory.c
index 9b91243..130152c 100644
--- a/memory.c
+++ b/memory.c
@@ -1978,6 +1978,7 @@ void address_space_destroy(AddressSpace *as)
as->root = NULL;
memory_region_transaction_commit();
QTAILQ_REMOVE(&address_spaces, as, address_spaces_link);
+ address_space_unregister(as);
/* At this point, as->dispatch and as->current_map are dummy
* entries that the guest should never use. Wait for the old
next prev parent reply other threads:[~2015-02-10 18:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 18:37 [Qemu-devel] [PULL 0/6] vfio fixes Alex Williamson
2015-02-10 18:37 ` Alex Williamson [this message]
2015-02-10 18:37 ` [Qemu-devel] [PULL 2/6] vfio: cleanup vfio_get_device error path, remove vfio_populate_device callback Alex Williamson
2015-02-10 18:37 ` [Qemu-devel] [PULL 3/6] vfio: free dynamically-allocated data in instance_finalize Alex Williamson
2015-02-10 18:37 ` [Qemu-devel] [PULL 4/6] vfio: unmap and free BAR " Alex Williamson
2015-02-10 18:37 ` [Qemu-devel] [PULL 5/6] vfio: Use vfio type1 v2 IOMMU interface Alex Williamson
2015-02-10 18:37 ` [Qemu-devel] [PULL 6/6] vfio: Fix debug message compile error Alex Williamson
2015-02-11 6:03 ` [Qemu-devel] [PULL 0/6] vfio fixes Peter Maydell
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=20150210183716.26101.26293.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--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).