From 0886e7963013f337dc91ee215c19f1630b5a7406 Mon Sep 17 00:00:00 2001 From: Jianyong Wu Date: Mon, 30 Oct 2023 08:04:54 +0000 Subject: [PATCH] aarch64: fdt: Use more appropriate default value for topology Now, default values for vcpu topology are 0s, that is not correct and may lead to bug. Fix it by setting default value to 1s. Also add check in case one or more of these values are zero. Fixes: #5892 Signed-off-by: Jianyong Wu (cherry picked from commit 2434e76ee0eaaa99ae20b1f2f6cd7082cd7b1e63) --- arch/src/aarch64/fdt.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/src/aarch64/fdt.rs b/arch/src/aarch64/fdt.rs index a8bed8938..af2695d01 100644 --- a/arch/src/aarch64/fdt.rs +++ b/arch/src/aarch64/fdt.rs @@ -290,10 +290,7 @@ fn create_cpu_nodes( fdt.property_u32("#size-cells", 0x0)?; let num_cpus = vcpu_mpidr.len(); - let threads_per_core = vcpu_topology.unwrap_or_default().0; - let cores_per_package = vcpu_topology.unwrap_or_default().1; - let packages = vcpu_topology.unwrap_or_default().2; - + let (threads_per_core, cores_per_package, packages) = vcpu_topology.unwrap_or((1, 1, 1)); let max_cpus: u32 = (threads_per_core * cores_per_package * packages).into(); // Add cache info.