virtio-devices: iommu: Drop unrecognised requests without writing reply

The virtio spec requires the device to leave the reply buffer
untouched and report a used length of zero for an unrecognised
request type, so the driver can tell the request was not handled.

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:11:40 +01:00
parent 59f9c7c08a
commit 8fb4aa61c7

View File

@@ -388,6 +388,7 @@ impl Request {
let mut reply: Vec<u8> = Vec::new();
let mut status = VIRTIO_IOMMU_S_OK;
let mut hdr_len = 0;
let mut unrecognised_type = false;
let result = (|| {
match req_head.type_ {
@@ -679,13 +680,19 @@ impl Request {
hdr_len = PROBE_PROP_SIZE;
}
_ => {
status = VIRTIO_IOMMU_S_INVAL;
unrecognised_type = true;
return Err(Error::InvalidRequest);
}
}
Ok(())
})();
// virtio spec: unrecognised request types must not have the reply
// buffer written and must report a used length of zero.
if unrecognised_type {
return Ok(0);
}
let status_desc = desc_chain.next().ok_or(Error::DescriptorChainTooShort)?;
// The status MUST always be writable