From 63a523b3f3efca2f007fd100d156ed40aa80db71 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sun, 26 Apr 2026 22:15:22 +0100 Subject: [PATCH] virtio-devices: iommu: Clamp bypass config field to 0 or 1 The virtio spec says the device must never present a value other than 0 or 1 for bypass. Mask off the upper bits on write so a later read does not return whatever the driver wrote. Signed-off-by: Rob Bradford Assisted-by: Claude:claude-opus-4-7 --- virtio-devices/src/iommu.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index b348bb1ff..165dfdaf7 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -1241,7 +1241,9 @@ impl VirtioDevice for Iommu { return; } - self.config.bypass = data[0]; + // virtio spec says ignore bits 1-7 and that the device must + // never present a value other than 0 or 1. + self.config.bypass = data[0] & 1; self.update_bypass(); }