mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
The VIRTIO_PCI_CAP_PCI_CFG indirect access mechanism was ignoring the cap.length field written by the guest driver. PCI config register reads always produce a 4 byte buffer, so when a driver set cap.length to 1 for a byte wide access to device_status at common config offset 0x14, the VMM passed all 4 bytes to read_bar, dispatching to the dword handler which does not cover that offset. Use cap.length to determine the actual BAR access width per virtio spec 4.1.4.9.1. Also replace the unsafe transmute with the safe Le32::to_native() conversion. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>