From 2a1d955eb45074a463e9e79d1275f15c783144dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20Yi=C4=9Fit=20=C5=9Eahin?= Date: Wed, 10 Jun 2026 17:00:58 +0200 Subject: [PATCH 1/4] docs(virtio-pci): explain IsrStatus::acknowledge --- src/drivers/virtio/transport/pci.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/drivers/virtio/transport/pci.rs b/src/drivers/virtio/transport/pci.rs index babe017063..34974a267e 100644 --- a/src/drivers/virtio/transport/pci.rs +++ b/src/drivers/virtio/transport/pci.rs @@ -483,6 +483,8 @@ impl IsrStatus { } pub fn acknowledge(&mut self) -> IsrStatusRaw { + // Driver read of ISR status causes the device to de-assert an interrupt. + // VIRTIO spec. v1.4 sec. 4.1.4.5 self.isr_stat.as_ptr().read() } } From 4817cf89e422b410d5b2b98d425c5bffad44377b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20Yi=C4=9Fit=20=C5=9Eahin?= Date: Wed, 10 Jun 2026 17:09:29 +0200 Subject: [PATCH 2/4] refactor(virtio): deduplicate config_change in handle_interrupt --- src/drivers/console/mod.rs | 12 +++++------- src/drivers/fs/mod.rs | 12 +++++------- src/drivers/net/virtio/mod.rs | 12 +++++------- src/drivers/vsock/mod.rs | 12 +++++------- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/drivers/console/mod.rs b/src/drivers/console/mod.rs index 01b0f731e5..b4b7016256 100644 --- a/src/drivers/console/mod.rs +++ b/src/drivers/console/mod.rs @@ -287,14 +287,12 @@ impl VirtioConsoleDriver { pub fn handle_interrupt(&mut self) { let status = self.isr_stat.acknowledge(); - #[cfg(not(feature = "pci"))] - if status.contains(virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") - } + let config_change = cfg_select! { + feature = "pci" => virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT, + _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, + }; - #[cfg(feature = "pci")] - if status.contains(virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT) { + if status.contains(config_change) { info!("Configuration changes are not possible! Aborting"); todo!("Implement possibility to change config on the fly...") } diff --git a/src/drivers/fs/mod.rs b/src/drivers/fs/mod.rs index cebad3e144..08b5d62ee1 100644 --- a/src/drivers/fs/mod.rs +++ b/src/drivers/fs/mod.rs @@ -161,14 +161,12 @@ impl VirtioFsDriver { pub fn handle_interrupt(&mut self) { let status = self.isr_stat.acknowledge(); - #[cfg(not(feature = "pci"))] - if status.contains(virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") - } + let config_change = cfg_select! { + feature = "pci" => virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT, + _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, + }; - #[cfg(feature = "pci")] - if status.contains(virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT) { + if status.contains(config_change) { info!("Configuration changes are not possible! Aborting"); todo!("Implement possibility to change config on the fly...") } diff --git a/src/drivers/net/virtio/mod.rs b/src/drivers/net/virtio/mod.rs index 03fc66b399..56bf1987aa 100644 --- a/src/drivers/net/virtio/mod.rs +++ b/src/drivers/net/virtio/mod.rs @@ -522,14 +522,12 @@ impl NetworkDriver for VirtioNetDriver { fn handle_interrupt(&mut self) { let status = self.isr_stat.acknowledge(); - #[cfg(not(feature = "pci"))] - if status.contains(virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") - } + let config_change = cfg_select! { + feature = "pci" => virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT, + _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, + }; - #[cfg(feature = "pci")] - if status.contains(virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT) { + if status.contains(config_change) { info!("Configuration changes are not possible! Aborting"); todo!("Implement possibility to change config on the fly...") } diff --git a/src/drivers/vsock/mod.rs b/src/drivers/vsock/mod.rs index 77588be9d1..fabe1feeb9 100644 --- a/src/drivers/vsock/mod.rs +++ b/src/drivers/vsock/mod.rs @@ -308,14 +308,12 @@ impl VirtioVsockDriver { pub fn handle_interrupt(&mut self) { let status = self.isr_stat.acknowledge(); - #[cfg(not(feature = "pci"))] - if status.contains(virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") - } + let config_change = cfg_select! { + feature = "pci" => virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT, + _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, + }; - #[cfg(feature = "pci")] - if status.contains(virtio::pci::IsrStatus::DEVICE_CONFIGURATION_INTERRUPT) { + if status.contains(config_change) { info!("Configuration changes are not possible! Aborting"); todo!("Implement possibility to change config on the fly...") } From def6c2ea2533e86dd27009fdb5bfa674c9f9fc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 10 Jun 2026 17:17:08 +0200 Subject: [PATCH 3/4] fix(virtio): simplify config change panic --- src/drivers/console/mod.rs | 3 +-- src/drivers/fs/mod.rs | 3 +-- src/drivers/net/virtio/mod.rs | 3 +-- src/drivers/vsock/mod.rs | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/drivers/console/mod.rs b/src/drivers/console/mod.rs index b4b7016256..e7bf374e9f 100644 --- a/src/drivers/console/mod.rs +++ b/src/drivers/console/mod.rs @@ -293,8 +293,7 @@ impl VirtioConsoleDriver { }; if status.contains(config_change) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") + todo!("Device configuration change notification cannot be handled yet"); } crate::console::CONSOLE_WAKER.lock().wake(); diff --git a/src/drivers/fs/mod.rs b/src/drivers/fs/mod.rs index 08b5d62ee1..e11fb564b8 100644 --- a/src/drivers/fs/mod.rs +++ b/src/drivers/fs/mod.rs @@ -167,8 +167,7 @@ impl VirtioFsDriver { }; if status.contains(config_change) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") + todo!("Device configuration change notification cannot be handled yet"); } } } diff --git a/src/drivers/net/virtio/mod.rs b/src/drivers/net/virtio/mod.rs index 56bf1987aa..83ce0dc5c6 100644 --- a/src/drivers/net/virtio/mod.rs +++ b/src/drivers/net/virtio/mod.rs @@ -528,8 +528,7 @@ impl NetworkDriver for VirtioNetDriver { }; if status.contains(config_change) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") + todo!("Device configuration change notification cannot be handled yet"); } wake_network_waker(); diff --git a/src/drivers/vsock/mod.rs b/src/drivers/vsock/mod.rs index fabe1feeb9..f5b9f0d0cb 100644 --- a/src/drivers/vsock/mod.rs +++ b/src/drivers/vsock/mod.rs @@ -314,8 +314,7 @@ impl VirtioVsockDriver { }; if status.contains(config_change) { - info!("Configuration changes are not possible! Aborting"); - todo!("Implement possibility to change config on the fly...") + todo!("Device configuration change notification cannot be handled yet"); } } From c2c0912a3612134b7c0240ec684f6fbc73f48ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20Yi=C4=9Fit=20=C5=9Eahin?= Date: Fri, 5 Jun 2026 15:26:04 +0200 Subject: [PATCH 4/4] fix(virtio): do not fail on device configuration change if possible Some of the device configuration change interrupts are only relevant if configuration values are cached by the driver. However, we do not make use of any such configurations. Thus, only panic if the interrupt is sent because the device needs reset, which we currently cannot handle and must not ignore. --- src/drivers/console/mod.rs | 2 +- src/drivers/fs/mod.rs | 2 +- src/drivers/net/virtio/mod.rs | 2 +- src/drivers/virtio/transport/mmio.rs | 8 ++++++++ src/drivers/virtio/transport/pci.rs | 5 +++++ src/drivers/vsock/mod.rs | 2 +- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/drivers/console/mod.rs b/src/drivers/console/mod.rs index e7bf374e9f..e94f592e72 100644 --- a/src/drivers/console/mod.rs +++ b/src/drivers/console/mod.rs @@ -292,7 +292,7 @@ impl VirtioConsoleDriver { _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, }; - if status.contains(config_change) { + if status.contains(config_change) && self.com_cfg.does_device_need_reset() { todo!("Device configuration change notification cannot be handled yet"); } diff --git a/src/drivers/fs/mod.rs b/src/drivers/fs/mod.rs index e11fb564b8..5afeab1870 100644 --- a/src/drivers/fs/mod.rs +++ b/src/drivers/fs/mod.rs @@ -166,7 +166,7 @@ impl VirtioFsDriver { _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, }; - if status.contains(config_change) { + if status.contains(config_change) && self.com_cfg.does_device_need_reset() { todo!("Device configuration change notification cannot be handled yet"); } } diff --git a/src/drivers/net/virtio/mod.rs b/src/drivers/net/virtio/mod.rs index 83ce0dc5c6..2f9146d806 100644 --- a/src/drivers/net/virtio/mod.rs +++ b/src/drivers/net/virtio/mod.rs @@ -527,7 +527,7 @@ impl NetworkDriver for VirtioNetDriver { _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, }; - if status.contains(config_change) { + if status.contains(config_change) && self.com_cfg.does_device_need_reset() { todo!("Device configuration change notification cannot be handled yet"); } diff --git a/src/drivers/virtio/transport/mmio.rs b/src/drivers/virtio/transport/mmio.rs index 27f2147da4..1a0f81dff6 100644 --- a/src/drivers/virtio/transport/mmio.rs +++ b/src/drivers/virtio/transport/mmio.rs @@ -208,6 +208,14 @@ impl ComCfg { .update(|status| status | DeviceStatus::DRIVER_OK); } + pub fn does_device_need_reset(&self) -> bool { + self.com_cfg + .as_ptr() + .status() + .read() + .contains(DeviceStatus::DEVICE_NEEDS_RESET) + } + pub fn print_information(&mut self) { let ptr = self.com_cfg.as_ptr(); diff --git a/src/drivers/virtio/transport/pci.rs b/src/drivers/virtio/transport/pci.rs index 34974a267e..bebfa11d48 100644 --- a/src/drivers/virtio/transport/pci.rs +++ b/src/drivers/virtio/transport/pci.rs @@ -361,6 +361,11 @@ impl ComCfg { .device_status() .update(|s| s | DeviceStatus::DRIVER_OK); } + + pub fn does_device_need_reset(&self) -> bool { + let status = self.com_cfg.as_ptr().device_status().read(); + status.contains(DeviceStatus::DEVICE_NEEDS_RESET) + } } /// Notification Structure to handle virtqueue notification settings. diff --git a/src/drivers/vsock/mod.rs b/src/drivers/vsock/mod.rs index f5b9f0d0cb..c44f75ff81 100644 --- a/src/drivers/vsock/mod.rs +++ b/src/drivers/vsock/mod.rs @@ -313,7 +313,7 @@ impl VirtioVsockDriver { _ => virtio::mmio::InterruptStatus::CONFIGURATION_CHANGE_NOTIFICATION, }; - if status.contains(config_change) { + if status.contains(config_change) && self.com_cfg.does_device_need_reset() { todo!("Device configuration change notification cannot be handled yet"); } }