From af9424cec08f8a504238c9e0fb2ec81f2ce1b1eb Mon Sep 17 00:00:00 2001 From: Christos Katsakioris Date: Tue, 22 Oct 2024 16:34:07 +0300 Subject: [PATCH 1/2] fix(fdt): Improve reporting of errors related to FDT setup Change the doc comment (which also affects the implementation of `std::fmt::Display`) for `ConfigurationError::SetupFDT` to include the underlying `fdt::FtdError`. This improves both the reporting of failures during FDT setup on the logs, as well as the message in API server's corresponding HTTP response. Signed-off-by: Christos Katsakioris Signed-off-by: Filippos Tofalos --- src/vmm/src/arch/aarch64/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vmm/src/arch/aarch64/mod.rs b/src/vmm/src/arch/aarch64/mod.rs index 17ff63f5b87..08ca1b65edb 100644 --- a/src/vmm/src/arch/aarch64/mod.rs +++ b/src/vmm/src/arch/aarch64/mod.rs @@ -28,7 +28,7 @@ use crate::vstate::memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemo /// Errors thrown while configuring aarch64 system. #[derive(Debug, thiserror::Error, displaydoc::Display)] pub enum ConfigurationError { - /// Failed to create a Flattened Device Tree for this aarch64 microVM. + /// Failed to create a Flattened Device Tree for this aarch64 microVM: {0} SetupFDT(#[from] fdt::FdtError), /// Failed to compute the initrd address. InitrdAddress, From 9b48dee6d848eeec014de59467a6af26f8538bdb Mon Sep 17 00:00:00 2001 From: Christos Katsakioris Date: Tue, 22 Oct 2024 22:09:21 +0300 Subject: [PATCH 2/2] fix(fdt): Support FDT setup for CPU caches with high number of sets Change the type of `CacheEntry`'s `number_of_sets` field from `u16` to `u32`, to allow correctly parsing CPU cache information from sysfs and successfully setting up the FDT on hosts with CPU caches with a number of sets that is higher than `u16::MAX`. This also makes a couple of `u16`->`u32` conversions redundant, which we therefore remove. Signed-off-by: Christos Katsakioris Signed-off-by: Filippos Tofalos --- src/vmm/src/arch/aarch64/cache_info.rs | 4 ++-- src/vmm/src/arch/aarch64/fdt.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vmm/src/arch/aarch64/cache_info.rs b/src/vmm/src/arch/aarch64/cache_info.rs index 90a97c8d204..cd61cabeb02 100644 --- a/src/vmm/src/arch/aarch64/cache_info.rs +++ b/src/vmm/src/arch/aarch64/cache_info.rs @@ -38,7 +38,7 @@ pub(crate) struct CacheEntry { // Type of cache: Unified, Data, Instruction. pub type_: CacheType, pub size_: Option, - pub number_of_sets: Option, + pub number_of_sets: Option, pub line_size: Option, // How many CPUS share this cache. pub cpus_per_unit: u16, @@ -114,7 +114,7 @@ impl CacheEntry { } if let Ok(number_of_sets) = store.get_by_key(index, "number_of_sets") { - cache.number_of_sets = Some(number_of_sets.parse::().map_err(|err| { + cache.number_of_sets = Some(number_of_sets.parse::().map_err(|err| { CacheInfoError::InvalidCacheAttr("number_of_sets".to_string(), err.to_string()) })?); } else { diff --git a/src/vmm/src/arch/aarch64/fdt.rs b/src/vmm/src/arch/aarch64/fdt.rs index cd13e434aa9..ff8c561910a 100644 --- a/src/vmm/src/arch/aarch64/fdt.rs +++ b/src/vmm/src/arch/aarch64/fdt.rs @@ -147,7 +147,7 @@ fn create_cpu_nodes(fdt: &mut FdtWriter, vcpu_mpidr: &[u64]) -> Result<(), FdtEr fdt.property_u32(cache.type_.of_cache_line_size(), u32::from(line_size))?; } if let Some(number_of_sets) = cache.number_of_sets { - fdt.property_u32(cache.type_.of_cache_sets(), u32::from(number_of_sets))?; + fdt.property_u32(cache.type_.of_cache_sets(), number_of_sets)?; } } @@ -197,7 +197,7 @@ fn create_cpu_nodes(fdt: &mut FdtWriter, vcpu_mpidr: &[u64]) -> Result<(), FdtEr fdt.property_u32(cache.type_.of_cache_line_size(), u32::from(line_size))?; } if let Some(number_of_sets) = cache.number_of_sets { - fdt.property_u32(cache.type_.of_cache_sets(), u32::from(number_of_sets))?; + fdt.property_u32(cache.type_.of_cache_sets(), number_of_sets)?; } if let Some(cache_type) = cache.type_.of_cache_type() { fdt.property_null(cache_type)?;