diff mbox series

[v2] softmmu/memory: fix memory_region_ioeventfd_equal()

Message ID cf71a62eb04e61932ff8ffdd02e0b2aab4f495a0.camel@gmail.com
State Accepted
Commit e6ffd757829a0dcff649c99e6304a287cc6d0d27
Headers show
Series [v2] softmmu/memory: fix memory_region_ioeventfd_equal() | expand

Commit Message

Elena Afanasova Oct. 19, 2020, 8:20 p.m. UTC
Eventfd can be registered with a zero length when fast_mmio is true.
Handle this case properly when dispatching through QEMU.

Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
---
 softmmu/memory.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Stefan Hajnoczi Oct. 20, 2020, 3:40 p.m. UTC | #1
On Mon, Oct 19, 2020 at 01:20:13PM -0700, Elena Afanasova wrote:
> Eventfd can be registered with a zero length when fast_mmio is true.

> Handle this case properly when dispatching through QEMU.

> 

> Signed-off-by: Elena Afanasova <eafanasova@gmail.com>

> ---

>  softmmu/memory.c | 11 +++++++++--

>  1 file changed, 9 insertions(+), 2 deletions(-)


Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan
diff mbox series

Patch

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 403ff3abc9..4b5775ae5b 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -205,8 +205,15 @@  static bool memory_region_ioeventfd_before(MemoryRegionIoeventfd *a,
 static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd *a,
                                           MemoryRegionIoeventfd *b)
 {
-    return !memory_region_ioeventfd_before(a, b)
-        && !memory_region_ioeventfd_before(b, a);
+    if (int128_eq(a->addr.start, b->addr.start) &&
+        (!int128_nz(a->addr.size) || !int128_nz(b->addr.size) ||
+         (int128_eq(a->addr.size, b->addr.size) &&
+          (a->match_data == b->match_data) &&
+          ((a->match_data && (a->data == b->data)) || !a->match_data) &&
+          (a->e == b->e))))
+        return true;
+
+    return false;
 }
 
 /* Range of memory in the global map.  Addresses are absolute. */