mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 11:05:46 +00:00
vmm: Factorize ACPI tables creation inside boot() function
Instead of having the ACPI tables being created both in x86_64 and aarch64 implementations of configure_system(), we can remove the duplicated code by moving the ACPI tables creation in vm.rs inside the boot() function. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
84a741a3fa
commit
b99a3a7dc9
@ -1013,7 +1013,7 @@ impl Vm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn configure_system(&mut self) -> Result<()> {
|
fn configure_system(&mut self, #[cfg(feature = "acpi")] rsdp_addr: GuestAddress) -> Result<()> {
|
||||||
info!("Configuring system");
|
info!("Configuring system");
|
||||||
let mem = self.memory_manager.lock().unwrap().boot_guest_memory();
|
let mem = self.memory_manager.lock().unwrap().boot_guest_memory();
|
||||||
|
|
||||||
@ -1024,23 +1024,10 @@ impl Vm {
|
|||||||
|
|
||||||
let boot_vcpus = self.cpu_manager.lock().unwrap().boot_vcpus();
|
let boot_vcpus = self.cpu_manager.lock().unwrap().boot_vcpus();
|
||||||
|
|
||||||
#[allow(unused_mut, unused_assignments)]
|
|
||||||
let mut rsdp_addr: Option<GuestAddress> = None;
|
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
{
|
let rsdp_addr = Some(rsdp_addr);
|
||||||
rsdp_addr = Some(crate::acpi::create_acpi_tables(
|
#[cfg(not(feature = "acpi"))]
|
||||||
&mem,
|
let rsdp_addr = None;
|
||||||
&self.device_manager,
|
|
||||||
&self.cpu_manager,
|
|
||||||
&self.memory_manager,
|
|
||||||
&self.numa_nodes,
|
|
||||||
));
|
|
||||||
info!(
|
|
||||||
"Created ACPI tables: rsdp_addr = 0x{:x}",
|
|
||||||
rsdp_addr.unwrap().0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let sgx_epc_region = self
|
let sgx_epc_region = self
|
||||||
.memory_manager
|
.memory_manager
|
||||||
@ -1063,7 +1050,10 @@ impl Vm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
fn configure_system(&mut self) -> Result<()> {
|
fn configure_system(
|
||||||
|
&mut self,
|
||||||
|
#[cfg(feature = "acpi")] _rsdp_addr: GuestAddress,
|
||||||
|
) -> Result<()> {
|
||||||
let cmdline = self.get_cmdline()?;
|
let cmdline = self.get_cmdline()?;
|
||||||
let vcpu_mpidrs = self.cpu_manager.lock().unwrap().get_mpidrs();
|
let vcpu_mpidrs = self.cpu_manager.lock().unwrap().get_mpidrs();
|
||||||
let vcpu_topology = self.cpu_manager.lock().unwrap().get_vcpu_topology();
|
let vcpu_topology = self.cpu_manager.lock().unwrap().get_vcpu_topology();
|
||||||
@ -1109,17 +1099,6 @@ impl Vm {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(v, _)| *v);
|
.map(|(v, _)| *v);
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
|
||||||
{
|
|
||||||
let _ = crate::acpi::create_acpi_tables(
|
|
||||||
&mem,
|
|
||||||
&self.device_manager,
|
|
||||||
&self.cpu_manager,
|
|
||||||
&self.memory_manager,
|
|
||||||
&self.numa_nodes,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let gic_device = create_gic(
|
let gic_device = create_gic(
|
||||||
&self.memory_manager.lock().as_ref().unwrap().vm,
|
&self.memory_manager.lock().as_ref().unwrap().vm,
|
||||||
self.cpu_manager.lock().unwrap().boot_vcpus() as u64,
|
self.cpu_manager.lock().unwrap().boot_vcpus() as u64,
|
||||||
@ -1923,6 +1902,22 @@ impl Vm {
|
|||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
let sections = self.extract_tdvf_sections()?;
|
let sections = self.extract_tdvf_sections()?;
|
||||||
|
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
let rsdp_addr = {
|
||||||
|
let mem = self.memory_manager.lock().unwrap().guest_memory().memory();
|
||||||
|
|
||||||
|
let rsdp_addr = crate::acpi::create_acpi_tables(
|
||||||
|
&mem,
|
||||||
|
&self.device_manager,
|
||||||
|
&self.cpu_manager,
|
||||||
|
&self.memory_manager,
|
||||||
|
&self.numa_nodes,
|
||||||
|
);
|
||||||
|
info!("Created ACPI tables: rsdp_addr = 0x{:x}", rsdp_addr.0);
|
||||||
|
|
||||||
|
rsdp_addr
|
||||||
|
};
|
||||||
|
|
||||||
// Configuring the TDX regions requires that the vCPUs are created
|
// Configuring the TDX regions requires that the vCPUs are created
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
let hob_address = if self.config.lock().unwrap().tdx.is_some() {
|
let hob_address = if self.config.lock().unwrap().tdx.is_some() {
|
||||||
@ -1932,7 +1927,14 @@ impl Vm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Configure shared state based on loaded kernel
|
// Configure shared state based on loaded kernel
|
||||||
entry_point.map(|_| self.configure_system()).transpose()?;
|
entry_point
|
||||||
|
.map(|_| {
|
||||||
|
self.configure_system(
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
rsdp_addr,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.transpose()?;
|
||||||
|
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
if let Some(hob_address) = hob_address {
|
if let Some(hob_address) = hob_address {
|
||||||
|
Loading…
Reference in New Issue
Block a user