mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
arch: x86_64: handle npot CPU topology
This PR addresses a bug in which the cpu topology of a guest
with non power-of-two number of cores is incorrect. For example,
in some contexts, a virtual machine with 2-sockets and 12-cores
will incorrectly believe that 16 cores are on socket 1 and 8
cores are on socket 2. In other cases, common topology enumeration
software such as hwloc will crash.
The root of the problem was the way that cloud-hypervisor generates
apic_id. On x86_64, the (x2) apic_id embeds information about cpu
topology. The cpuid instruction is primarily used to discover the
number of sockets, dies, cores, threads, etc. Using this information,
the (x2) apic_id is masked to determine which {core, die, socket} the
cpu is on. When the cpu topology is not a power of two
(e.g. a 12-core machine), this requires non-contiguous (x2) apic_id.
Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
This commit is contained in:
committed by
Rob Bradford
parent
a2ceb00fbc
commit
5c0b66529a
@@ -1175,6 +1175,8 @@ impl Vm {
|
||||
.as_deref()
|
||||
.map(|strings| strings.iter().map(|s| s.as_ref()).collect::<Vec<&str>>());
|
||||
|
||||
let topology = self.cpu_manager.lock().unwrap().get_vcpu_topology();
|
||||
|
||||
arch::configure_system(
|
||||
&mem,
|
||||
arch::layout::CMDLINE_START,
|
||||
@@ -1185,6 +1187,7 @@ impl Vm {
|
||||
serial_number.as_deref(),
|
||||
uuid.as_deref(),
|
||||
oem_strings.as_deref(),
|
||||
topology,
|
||||
)
|
||||
.map_err(Error::ConfigureSystem)?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user