Skip to content

Commit

Permalink
memory: don't try to adjust endianness for zero length eventfd
Browse files Browse the repository at this point in the history
There's no need to adjust endianness for zero length eventfd since the
data wrote was actually ignored by kernel. So skip the adjust in this
case to fix a possible crash when trying to use wildcard mmio eventfd
in ppc.

Cc: Greg Kurz <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Acked-by: Greg Kurz <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
jasowang authored and mstsirkin committed Nov 12, 2015
1 parent a6df8ad commit b8aecea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,9 @@ void memory_region_add_eventfd(MemoryRegion *mr,
};
unsigned i;

adjust_endianness(mr, &mrfd.data, size);
if (size) {
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])) {
Expand Down Expand Up @@ -1721,7 +1723,9 @@ void memory_region_del_eventfd(MemoryRegion *mr,
};
unsigned i;

adjust_endianness(mr, &mrfd.data, size);
if (size) {
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])) {
Expand Down

0 comments on commit b8aecea

Please sign in to comment.