@@ -79,7 +79,7 @@ impl<'a> AcpiTableWriter<'a> {
7979 fn build_dsdt (
8080 & mut self ,
8181 mmio_device_manager : & MMIODeviceManager ,
82- pci_segment : & PciSegment ,
82+ pci_segment : Option < & PciSegment > ,
8383 acpi_device_manager : & ACPIDeviceManager ,
8484 ) -> Result < u64 , AcpiError > {
8585 let mut dsdt_data = Vec :: new ( ) ;
@@ -93,7 +93,9 @@ impl<'a> AcpiTableWriter<'a> {
9393 // Architecture specific DSDT data
9494 setup_arch_dsdt ( & mut dsdt_data) ;
9595
96- pci_segment. append_aml_bytes ( & mut dsdt_data) ;
96+ if let Some ( pci_segment) = pci_segment {
97+ pci_segment. append_aml_bytes ( & mut dsdt_data) ;
98+ }
9799
98100 let mut dsdt = Dsdt :: new ( OEM_ID , * b"FCVMDSDT" , OEM_REVISION , dsdt_data) ;
99101 self . write_acpi_table ( & mut dsdt)
@@ -130,12 +132,17 @@ impl<'a> AcpiTableWriter<'a> {
130132 /// Build the XSDT table for the guest
131133 ///
132134 /// Currently, we pass to the guest just FADT and MADT tables.
133- fn build_xsdt ( & mut self , fadt_addr : u64 , madt_addr : u64 , mcfg_addr : u64 ) -> Result < u64 , AcpiError > {
135+ fn build_xsdt ( & mut self , fadt_addr : u64 , madt_addr : u64 , mcfg_addr : Option < u64 > ) -> Result < u64 , AcpiError > {
136+ let tables = if let Some ( mcfg_addr) = mcfg_addr {
137+ vec ! [ fadt_addr, madt_addr, mcfg_addr]
138+ } else {
139+ vec ! [ fadt_addr, madt_addr]
140+ } ;
134141 let mut xsdt = Xsdt :: new (
135142 OEM_ID ,
136143 * b"FCMVXSDT" ,
137144 OEM_REVISION ,
138- vec ! [ fadt_addr , madt_addr , mcfg_addr ] ,
145+ tables ,
139146 ) ;
140147 self . write_acpi_table ( & mut xsdt)
141148 }
@@ -181,7 +188,7 @@ pub(crate) fn create_acpi_tables(
181188 resource_allocator : & mut ResourceAllocator ,
182189 mmio_device_manager : & MMIODeviceManager ,
183190 acpi_device_manager : & ACPIDeviceManager ,
184- pci_segment : & PciSegment ,
191+ pci_segment : Option < & PciSegment > ,
185192 pci_mmio_config_addr : u64 ,
186193 vcpus : & [ Vcpu ] ,
187194) -> Result < ( ) , AcpiError > {
@@ -193,7 +200,7 @@ pub(crate) fn create_acpi_tables(
193200 let dsdt_addr = writer. build_dsdt ( mmio_device_manager, pci_segment, acpi_device_manager) ?;
194201 let fadt_addr = writer. build_fadt ( dsdt_addr) ?;
195202 let madt_addr = writer. build_madt ( vcpus. len ( ) . try_into ( ) . unwrap ( ) ) ?;
196- let mcfg_addr = writer. build_mcfg ( pci_mmio_config_addr) ?;
203+ let mcfg_addr = pci_segment . map ( |_| writer. build_mcfg ( pci_mmio_config_addr) ) . transpose ( ) ?;
197204 let xsdt_addr = writer. build_xsdt ( fadt_addr, madt_addr, mcfg_addr) ?;
198205 writer. build_rsdp ( xsdt_addr)
199206}
0 commit comments