Skip to contentSkip to conversation

Memory-API: Make eventfd adhere to device endianness

PATCH Applied Alexander Graf 2 participants 2 messages Oct 15, 2012 – Oct 17, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Memory-API: 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.

---
 memory.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
memory.c +2 -0
index 4f3ade0..d2f2fd6 100644
@@ -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])) {
Signature · 1 line
1.6.0.2
Applied
#1 lore raw
Quoted 4 lines · Alexander Graf

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.

Quoted 8 lines

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.

Thanks, applied.

Signature · 1 line
error compiling committee.c: too many arguments to function