[PATCH kvmtool 1/4] virtio/mmio: avoid unaligned accesses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The virtio-mmio code is using unaligned accesses, to its struct
virtio_mmio, as revealed by -fsanitize=undefined.
A closer inspection reveals that this is due to a misplaced u8 member
in struct virtio_mmio, and it inheriting the "packed" attribute from
struct virtio_mmio_hdr.
The simplest fix for the issue is to just move the "u8 irq" member to
the end, so that even with the "packed" attribute in effect, the other
members stay all naturally aligned.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 include/kvm/virtio-mmio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/kvm/virtio-mmio.h b/include/kvm/virtio-mmio.h
index 6bc50bd1..13dcccb6 100644
--- a/include/kvm/virtio-mmio.h
+++ b/include/kvm/virtio-mmio.h
@@ -45,10 +45,10 @@ struct virtio_mmio {
 	u32			addr;
 	void			*dev;
 	struct kvm		*kvm;
-	u8			irq;
 	struct virtio_mmio_hdr	hdr;
 	struct device_header	dev_hdr;
 	struct virtio_mmio_ioevent_param ioeventfds[VIRTIO_MMIO_MAX_VQ];
+	u8			irq;
 };
 
 int virtio_mmio_signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq);
-- 
2.25.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux