From 13e29506329e537efa8aad39ee9419c1b128cac0 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 5 May 2022 16:29:22 -0700 Subject: [PATCH] vcpu: restore behavior of reading unpopulated Bus regions When handling a MMIO or IO read vcpu exit, we don't want to report an error if there is nothing on the Bus at that location. Instead, we should just return all zeroes. This matches the previous behavior before https://crrev.com/c/3606975 and removes an error message during integration_tests:boot. BUG=b:213150327 TEST=tools/dev_container tools/presubmit --all Fixes: 06c00d580d9c ("hypervisor: Trait changes for windows hypervisors support") Change-Id: I6c955ece9184f253b1173e46465cd9a6dafe25bf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631029 Reviewed-by: Vaibhav Nagarnaik Reviewed-by: Noah Gold Tested-by: kokoro Commit-Queue: Daniel Verkamp --- src/linux/vcpu.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/linux/vcpu.rs b/src/linux/vcpu.rs index 5901d56ac4..33c1000a46 100644 --- a/src/linux/vcpu.rs +++ b/src/linux/vcpu.rs @@ -69,7 +69,10 @@ fn bus_io_handler(bus: &Bus) -> impl FnMut(IoParams) -> Option<[u8; 8]> + '_ { error!("unsupported Read size of {} bytes", size); size = data.len(); } - bus.read(address, &mut data[..size]).then(|| data) + // Ignore the return value of `read()`. If no device exists on the bus at the given + // location, return the initial value of data, which is all zeroes. + let _ = bus.read(address, &mut data[..size]); + Some(data) } IoOperation::Write { data } => { if size > data.len() {