From 3d5718bd87259a41150db1eea3c31cab5ac5460e Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Tue, 13 Feb 2024 10:42:23 -0800 Subject: [PATCH] virtio-devices: handle IO event for SevSnp properly For SevSnp guest IO events are handled by GHCB protocol. While we get the notification we have to notify via eventfd. Signed-off-by: Muminul Islam --- virtio-devices/src/transport/pci_device.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index 2f711c80a..5afc81bf5 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -1179,7 +1179,14 @@ impl PciDevice for VirtioPciDevice { o if (NOTIFICATION_BAR_OFFSET..NOTIFICATION_BAR_OFFSET + NOTIFICATION_SIZE) .contains(&o) => { + #[cfg(feature = "sev_snp")] + for (_event, _addr) in self.ioeventfds(_base) { + if _addr == _base + offset { + _event.write(1).unwrap(); + } + } // Handled with ioeventfds. + #[cfg(not(feature = "sev_snp"))] error!("Unexpected write to notification BAR: offset = 0x{:x}", o); } o if (MSIX_TABLE_BAR_OFFSET..MSIX_TABLE_BAR_OFFSET + MSIX_TABLE_SIZE).contains(&o) => {