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 <jianyong.wu@arm.com>
(cherry picked from commit 2434e76ee0eaaa99ae20b1f2f6cd7082cd7b1e63)
This commit is contained in:
Jianyong Wu 2023-10-30 08:04:54 +00:00 committed by Bo Chen
parent a40a0268bb
commit 0886e79630

View File

@ -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.