qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

virtio: add virtio_*_phys_cached

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Paolo Bonzini and committed by
Michael S. Tsirkin
e6a830d6 1d8280c1

+52
+52
include/hw/virtio/virtio-access.h
··· 156 156 #endif 157 157 } 158 158 159 + static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev, 160 + MemoryRegionCache *cache, 161 + hwaddr pa) 162 + { 163 + if (virtio_access_is_big_endian(vdev)) { 164 + return lduw_be_phys_cached(cache, pa); 165 + } 166 + return lduw_le_phys_cached(cache, pa); 167 + } 168 + 169 + static inline uint32_t virtio_ldl_phys_cached(VirtIODevice *vdev, 170 + MemoryRegionCache *cache, 171 + hwaddr pa) 172 + { 173 + if (virtio_access_is_big_endian(vdev)) { 174 + return ldl_be_phys_cached(cache, pa); 175 + } 176 + return ldl_le_phys_cached(cache, pa); 177 + } 178 + 179 + static inline uint64_t virtio_ldq_phys_cached(VirtIODevice *vdev, 180 + MemoryRegionCache *cache, 181 + hwaddr pa) 182 + { 183 + if (virtio_access_is_big_endian(vdev)) { 184 + return ldq_be_phys_cached(cache, pa); 185 + } 186 + return ldq_le_phys_cached(cache, pa); 187 + } 188 + 189 + static inline void virtio_stw_phys_cached(VirtIODevice *vdev, 190 + MemoryRegionCache *cache, 191 + hwaddr pa, uint16_t value) 192 + { 193 + if (virtio_access_is_big_endian(vdev)) { 194 + stw_be_phys_cached(cache, pa, value); 195 + } else { 196 + stw_le_phys_cached(cache, pa, value); 197 + } 198 + } 199 + 200 + static inline void virtio_stl_phys_cached(VirtIODevice *vdev, 201 + MemoryRegionCache *cache, 202 + hwaddr pa, uint32_t value) 203 + { 204 + if (virtio_access_is_big_endian(vdev)) { 205 + stl_be_phys_cached(cache, pa, value); 206 + } else { 207 + stl_le_phys_cached(cache, pa, value); 208 + } 209 + } 210 + 159 211 static inline void virtio_tswap16s(VirtIODevice *vdev, uint16_t *s) 160 212 { 161 213 *s = virtio_tswap16(vdev, *s);