diff mbox series

[RFC,24/25] hw/virtio: Add methods for aligned pointer access

Message ID 20210518183655.1711377-25-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series exec: Add load/store API for aligned pointers | expand

Commit Message

Philippe Mathieu-Daudé May 18, 2021, 6:36 p.m. UTC
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/hw/virtio/virtio-access.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index ae66bbd74f9..5b20f004e12 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -66,6 +66,16 @@  static inline rtype virtio_ld ## size ## _phys_cached(VirtIODevice *vdev,\
         return ld ## size ## _be_phys_cached(cache, pa);\
     }\
     return ld ## size ## _le_phys_cached(cache, pa);\
+}\
+static inline rtype virtio_ld ## size ## _phys_cached_aligned(\
+                                                      VirtIODevice *vdev,\
+                                                      MemoryRegionCache *cache,\
+                                                      hwaddr pa)\
+{\
+    if (virtio_access_is_big_endian(vdev)) {\
+        return ld ## size ## _be_phys_cached_aligned(cache, pa);\
+    }\
+    return ld ## size ## _le_phys_cached_aligned(cache, pa);\
 }
 
 #define VIRTIO_ST_CONVERT(size, vtype)\
@@ -98,6 +108,17 @@  static inline void virtio_st ## size ## _phys_cached(VirtIODevice *vdev,\
     } else {\
         st ## size ## _le_phys_cached(cache, pa, value);\
     }\
+}\
+static inline void virtio_st ## size ## _phys_cached_aligned(\
+                                                     VirtIODevice *vdev,\
+                                                     MemoryRegionCache *cache,\
+                                                     hwaddr pa, vtype value)\
+{\
+    if (virtio_access_is_big_endian(vdev)) {\
+        st ## size ## _be_phys_cached_aligned(cache, pa, value);\
+    } else {\
+        st ## size ## _le_phys_cached_aligned(cache, pa, value);\
+    }\
 }
 
 #define VIRTIO_LDST_CONVERT(size, rtype, vtype)\