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 <rbradford@meta.com>
Assisted-by: Claude:claude-opus-4-7
This commit is contained in:
Rob Bradford
2026-04-26 22:15:22 +01:00
parent efcc090811
commit 63a523b3f3

View File

@@ -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();
}