@samitouri / QOSamiQemu / commits / 93b32a8737

hw/virtio: Inline virtio_access_is_big_endian()

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260225041948.52929-4-philmd@linaro.org Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Pierrick Bouvier committed Feb 25, 2026 at 05:19 UTC 93b32a87377b69ebb32d6bbd66121d7e4b92e171
2 files changed +14 -19
hw/virtio/virtio.c
+2 -2
@@ -222,7 +222,7 @@ static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
222 MemoryRegionCache *cache,
223 hwaddr pa)
224 {
225 - if (virtio_access_is_big_endian(vdev)) {
225 + if (virtio_vdev_is_big_endian(vdev)) {
226 return lduw_be_phys_cached(cache, pa);
227 }
228 return lduw_le_phys_cached(cache, pa);
@@ -232,7 +232,7 @@ static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
232 MemoryRegionCache *cache,
233 hwaddr pa, uint16_t value)
234 {
235 - if (virtio_access_is_big_endian(vdev)) {
235 + if (virtio_vdev_is_big_endian(vdev)) {
236 stw_be_phys_cached(cache, pa, value);
237 } else {
238 stw_le_phys_cached(cache, pa, value);
include/hw/virtio/virtio-access.h
+12 -17
@@ -21,14 +21,9 @@
21 #include "hw/virtio/virtio.h"
22 #include "hw/virtio/virtio-bus.h"
23
24 -static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
25 -{
26 - return virtio_vdev_is_big_endian(vdev);
27 -}
28 -
24 static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)
25 {
31 - if (virtio_access_is_big_endian(vdev)) {
26 + if (virtio_vdev_is_big_endian(vdev)) {
27 stw_be_p(ptr, v);
28 } else {
29 stw_le_p(ptr, v);
@@ -37,7 +32,7 @@ static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)
32
33 static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v)
34 {
40 - if (virtio_access_is_big_endian(vdev)) {
35 + if (virtio_vdev_is_big_endian(vdev)) {
36 stl_be_p(ptr, v);
37 } else {
38 stl_le_p(ptr, v);
@@ -46,7 +41,7 @@ static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v)
41
42 static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v)
43 {
49 - if (virtio_access_is_big_endian(vdev)) {
44 + if (virtio_vdev_is_big_endian(vdev)) {
45 stq_be_p(ptr, v);
46 } else {
47 stq_le_p(ptr, v);
@@ -55,7 +50,7 @@ static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v)
50
51 static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr)
52 {
58 - if (virtio_access_is_big_endian(vdev)) {
53 + if (virtio_vdev_is_big_endian(vdev)) {
54 return lduw_be_p(ptr);
55 } else {
56 return lduw_le_p(ptr);
@@ -64,7 +59,7 @@ static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr)
59
60 static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr)
61 {
67 - if (virtio_access_is_big_endian(vdev)) {
62 + if (virtio_vdev_is_big_endian(vdev)) {
63 return ldl_be_p(ptr);
64 } else {
65 return ldl_le_p(ptr);
@@ -73,7 +68,7 @@ static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr)
68
69 static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)
70 {
76 - if (virtio_access_is_big_endian(vdev)) {
71 + if (virtio_vdev_is_big_endian(vdev)) {
72 return ldq_be_p(ptr);
73 } else {
74 return ldq_le_p(ptr);
@@ -83,9 +78,9 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)
78 static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s)
79 {
80 #if HOST_BIG_ENDIAN
86 - return virtio_access_is_big_endian(vdev) ? s : bswap16(s);
81 + return virtio_vdev_is_big_endian(vdev) ? s : bswap16(s);
82 #else
88 - return virtio_access_is_big_endian(vdev) ? bswap16(s) : s;
83 + return virtio_vdev_is_big_endian(vdev) ? bswap16(s) : s;
84 #endif
85 }
86
@@ -97,9 +92,9 @@ static inline void virtio_tswap16s(VirtIODevice *vdev, uint16_t *s)
92 static inline uint32_t virtio_tswap32(VirtIODevice *vdev, uint32_t s)
93 {
94 #if HOST_BIG_ENDIAN
100 - return virtio_access_is_big_endian(vdev) ? s : bswap32(s);
95 + return virtio_vdev_is_big_endian(vdev) ? s : bswap32(s);
96 #else
102 - return virtio_access_is_big_endian(vdev) ? bswap32(s) : s;
97 + return virtio_vdev_is_big_endian(vdev) ? bswap32(s) : s;
98 #endif
99 }
100
@@ -111,9 +106,9 @@ static inline void virtio_tswap32s(VirtIODevice *vdev, uint32_t *s)
106 static inline uint64_t virtio_tswap64(VirtIODevice *vdev, uint64_t s)
107 {
108 #if HOST_BIG_ENDIAN
114 - return virtio_access_is_big_endian(vdev) ? s : bswap64(s);
109 + return virtio_vdev_is_big_endian(vdev) ? s : bswap64(s);
110 #else
116 - return virtio_access_is_big_endian(vdev) ? bswap64(s) : s;
111 + return virtio_vdev_is_big_endian(vdev) ? bswap64(s) : s;
112 #endif
113 }
114