From ea0729c01674b98d25a21ee11f7020f9f2761628 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 17 Dec 2021 15:54:52 +0100 Subject: [PATCH] vmm: acpi: Create ACPI tables for TDX The way to create ACPI tables for TDX is different as each table must be passed through the HOB. This means the XSDT table is not required since the firmware will take care of creating it. Same for RSDP, this is firmware responsibility to provide it to the guest. That's why this patch creates a TDX dedicated function, returning a list of Sdt objects, which will let the calling code copy the content of each table through the HOB. Signed-off-by: Sebastien Boeuf --- vmm/src/acpi.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/vmm/src/acpi.rs b/vmm/src/acpi.rs index fd0072c72..73826c03e 100644 --- a/vmm/src/acpi.rs +++ b/vmm/src/acpi.rs @@ -776,3 +776,48 @@ pub fn create_acpi_tables( ); rsdp_offset } + +#[cfg(feature = "tdx")] +#[allow(unused)] +pub fn create_acpi_tables_tdx( + device_manager: &Arc>, + cpu_manager: &Arc>, + memory_manager: &Arc>, + numa_nodes: &NumaNodes, +) -> Vec { + // DSDT + let mut tables = vec![create_dsdt_table( + device_manager, + cpu_manager, + memory_manager, + )]; + + // FACP aka FADT + tables.push(create_facp_table(GuestAddress(0))); + + // MADT + tables.push(cpu_manager.lock().unwrap().create_madt()); + + // MCFG + tables.push(create_mcfg_table( + device_manager.lock().unwrap().pci_segments(), + )); + + // SRAT and SLIT + // Only created if the NUMA nodes list is not empty. + if !numa_nodes.is_empty() { + // SRAT + tables.push(create_srat_table(numa_nodes)); + + // SLIT + tables.push(create_slit_table(numa_nodes)); + }; + + // VIOT + if let Some((iommu_bdf, devices_bdf)) = device_manager.lock().unwrap().iommu_attached_devices() + { + tables.push(create_viot_table(iommu_bdf, devices_bdf)); + } + + tables +}