Skip to content

Commit 0b9cf39

Browse files
ckatsakroypat
authored andcommitted
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 <[email protected]> Signed-off-by: Filippos Tofalos <[email protected]>
1 parent 7b4adcd commit 0b9cf39

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/vmm/src/arch/aarch64/cache_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(crate) struct CacheEntry {
3838
// Type of cache: Unified, Data, Instruction.
3939
pub type_: CacheType,
4040
pub size_: Option<u32>,
41-
pub number_of_sets: Option<u16>,
41+
pub number_of_sets: Option<u32>,
4242
pub line_size: Option<u16>,
4343
// How many CPUS share this cache.
4444
pub cpus_per_unit: u16,
@@ -114,7 +114,7 @@ impl CacheEntry {
114114
}
115115

116116
if let Ok(number_of_sets) = store.get_by_key(index, "number_of_sets") {
117-
cache.number_of_sets = Some(number_of_sets.parse::<u16>().map_err(|err| {
117+
cache.number_of_sets = Some(number_of_sets.parse::<u32>().map_err(|err| {
118118
CacheInfoError::InvalidCacheAttr("number_of_sets".to_string(), err.to_string())
119119
})?);
120120
} else {

src/vmm/src/arch/aarch64/fdt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn create_cpu_nodes(fdt: &mut FdtWriter, vcpu_mpidr: &[u64]) -> Result<(), FdtEr
147147
fdt.property_u32(cache.type_.of_cache_line_size(), u32::from(line_size))?;
148148
}
149149
if let Some(number_of_sets) = cache.number_of_sets {
150-
fdt.property_u32(cache.type_.of_cache_sets(), u32::from(number_of_sets))?;
150+
fdt.property_u32(cache.type_.of_cache_sets(), number_of_sets)?;
151151
}
152152
}
153153

@@ -197,7 +197,7 @@ fn create_cpu_nodes(fdt: &mut FdtWriter, vcpu_mpidr: &[u64]) -> Result<(), FdtEr
197197
fdt.property_u32(cache.type_.of_cache_line_size(), u32::from(line_size))?;
198198
}
199199
if let Some(number_of_sets) = cache.number_of_sets {
200-
fdt.property_u32(cache.type_.of_cache_sets(), u32::from(number_of_sets))?;
200+
fdt.property_u32(cache.type_.of_cache_sets(), number_of_sets)?;
201201
}
202202
if let Some(cache_type) = cache.type_.of_cache_type() {
203203
fdt.property_null(cache_type)?;

0 commit comments

Comments
 (0)