From 28f362be6e7f45ea9b7a57a08555c4c784f36198 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 15 Oct 2012 20:30:28 +0200 Subject: memory: Make eventfd adhere to device endianness Our memory API MMIO regions know the concept of device endianness. This is used to automatically swap endianness between devices and host CPU, depending on whether buses in between would swizzle the bits. The ioeventfd value comparison does not adhere to that semantic though. Probably because nobody has been running ioeventfd on a BE platform and the only device implementing ioeventfd right now is LE (PCI) based. So add swizzling to ioeventfd registration / deletion to make the rest of the code as consistent as possible. Thanks a lot to Michael Tsirkin to point me towards the right direction. Signed-off-by: Alexander Graf Signed-off-by: Avi Kivity --- memory.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 4f3ade06dd..d2f2fd66fb 100644 --- a/memory.c +++ b/memory.c @@ -1217,6 +1217,7 @@ void memory_region_add_eventfd(MemoryRegion *mr, }; unsigned i; + adjust_endianness(mr, &mrfd.data, size); memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) { @@ -1248,6 +1249,7 @@ void memory_region_del_eventfd(MemoryRegion *mr, }; unsigned i; + adjust_endianness(mr, &mrfd.data, size); memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) { -- cgit v1.2.3 From 2be0e25f4b6a4f91e39388cc365bbe53b56ab62a Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 17 Oct 2012 17:14:41 +0200 Subject: memory: abort if a memory region is destroyed during a transaction Destroying a memory region is illegal within a transaction, as until the transaction is committed, the memory core may hold references to the region. Add an assert to check for violations of this rule. Signed-off-by: Avi Kivity --- memory.c | 1 + 1 file changed, 1 insertion(+) (limited to 'memory.c') diff --git a/memory.c b/memory.c index d2f2fd66fb..94049a797d 100644 --- a/memory.c +++ b/memory.c @@ -1022,6 +1022,7 @@ void memory_region_init_reservation(MemoryRegion *mr, void memory_region_destroy(MemoryRegion *mr) { assert(QTAILQ_EMPTY(&mr->subregions)); + assert(memory_region_transaction_depth == 0); mr->destructor(mr); memory_region_clear_coalescing(mr); g_free((char *)mr->name); -- cgit v1.2.3