mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
vmm: cpu: Only include hotplug/unplug related AML code if dynamic
This will significantly reduce the size of the DSDT and the effort required to parse them if there is no requirement to support hotplug/unplug. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
188078467d
commit
7324b0e514
@ -1463,6 +1463,7 @@ impl CpuManager {
|
||||
struct Cpu {
|
||||
cpu_id: u8,
|
||||
proximity_domain: u32,
|
||||
dynamic: bool,
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "acpi"))]
|
||||
@ -1493,7 +1494,8 @@ impl Aml for Cpu {
|
||||
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
let mat_data: Vec<u8> = self.generate_mat();
|
||||
|
||||
#[allow(clippy::if_same_then_else)]
|
||||
if self.dynamic {
|
||||
aml::Device::new(
|
||||
format!("C{:03}", self.cpu_id).as_str().into(),
|
||||
vec![
|
||||
@ -1542,7 +1544,36 @@ impl Aml for Cpu {
|
||||
),
|
||||
],
|
||||
)
|
||||
.append_aml_bytes(bytes)
|
||||
.append_aml_bytes(bytes);
|
||||
} else {
|
||||
aml::Device::new(
|
||||
format!("C{:03}", self.cpu_id).as_str().into(),
|
||||
vec![
|
||||
&aml::Name::new("_HID".into(), &"ACPI0007"),
|
||||
&aml::Name::new("_UID".into(), &self.cpu_id),
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
&aml::Method::new(
|
||||
"_STA".into(),
|
||||
0,
|
||||
false,
|
||||
// Mark CPU present see CSTA implementation
|
||||
vec![&aml::Return::new(&0xfu8)],
|
||||
),
|
||||
&aml::Method::new(
|
||||
"_PXM".into(),
|
||||
0,
|
||||
false,
|
||||
vec![&aml::Return::new(&self.proximity_domain)],
|
||||
),
|
||||
// The Linux kernel expects every CPU device to have a _MAT entry
|
||||
// containing the LAPIC for this processor with the enabled bit set
|
||||
// even it if is disabled in the MADT (non-boot CPU)
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
&aml::Name::new("_MAT".into(), &aml::Buffer::new(mat_data)),
|
||||
],
|
||||
)
|
||||
.append_aml_bytes(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1566,11 +1597,13 @@ impl Aml for CpuNotify {
|
||||
#[cfg(feature = "acpi")]
|
||||
struct CpuMethods {
|
||||
max_vcpus: u8,
|
||||
dynamic: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
impl Aml for CpuMethods {
|
||||
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
|
||||
if self.dynamic {
|
||||
// CPU status method
|
||||
aml::Method::new(
|
||||
"CSTA".into(),
|
||||
@ -1645,7 +1678,10 @@ impl Aml for CpuMethods {
|
||||
vec![&aml::Local(0), &aml::ONE],
|
||||
),
|
||||
// Reset CINS bit
|
||||
&aml::Store::new(&aml::Path::new("\\_SB_.PRES.CINS"), &aml::ONE),
|
||||
&aml::Store::new(
|
||||
&aml::Path::new("\\_SB_.PRES.CINS"),
|
||||
&aml::ONE,
|
||||
),
|
||||
],
|
||||
),
|
||||
// Check if CRMV bit is set
|
||||
@ -1653,9 +1689,15 @@ impl Aml for CpuMethods {
|
||||
&aml::Equal::new(&aml::Path::new("\\_SB_.PRES.CRMV"), &aml::ONE),
|
||||
// Notify device if it is (with the eject constant 0x3)
|
||||
vec![
|
||||
&aml::MethodCall::new("CTFY".into(), vec![&aml::Local(0), &3u8]),
|
||||
&aml::MethodCall::new(
|
||||
"CTFY".into(),
|
||||
vec![&aml::Local(0), &3u8],
|
||||
),
|
||||
// Reset CRMV bit
|
||||
&aml::Store::new(&aml::Path::new("\\_SB_.PRES.CRMV"), &aml::ONE),
|
||||
&aml::Store::new(
|
||||
&aml::Path::new("\\_SB_.PRES.CRMV"),
|
||||
&aml::ONE,
|
||||
),
|
||||
],
|
||||
),
|
||||
&aml::Add::new(&aml::Local(0), &aml::Local(0), &aml::ONE),
|
||||
@ -1666,12 +1708,16 @@ impl Aml for CpuMethods {
|
||||
],
|
||||
)
|
||||
.append_aml_bytes(bytes)
|
||||
} else {
|
||||
aml::Method::new("CSCN".into(), 0, true, vec![]).append_aml_bytes(bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
impl Aml for CpuManager {
|
||||
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
|
||||
if self.dynamic {
|
||||
// CPU hotplug controller
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
aml::Device::new(
|
||||
@ -1724,6 +1770,7 @@ impl Aml for CpuManager {
|
||||
],
|
||||
)
|
||||
.append_aml_bytes(bytes);
|
||||
}
|
||||
|
||||
// CPU devices
|
||||
let hid = aml::Name::new("_HID".into(), &"ACPI0010");
|
||||
@ -1731,6 +1778,7 @@ impl Aml for CpuManager {
|
||||
// Bundle methods together under a common object
|
||||
let methods = CpuMethods {
|
||||
max_vcpus: self.config.max_vcpus,
|
||||
dynamic: self.dynamic,
|
||||
};
|
||||
let mut cpu_data_inner: Vec<&dyn aml::Aml> = vec![&hid, &uid, &methods];
|
||||
|
||||
@ -1740,6 +1788,7 @@ impl Aml for CpuManager {
|
||||
let cpu_device = Cpu {
|
||||
cpu_id,
|
||||
proximity_domain,
|
||||
dynamic: self.dynamic,
|
||||
};
|
||||
|
||||
cpu_devices.push(cpu_device);
|
||||
|
Loading…
Reference in New Issue
Block a user