@@ -57,7 +57,7 @@ use svsm::svsm_paging::{
5757use svsm:: task:: { KernelThreadStartInfo , schedule_init, start_kernel_task} ;
5858use svsm:: types:: PAGE_SIZE ;
5959use svsm:: utils:: { MemoryRegion , ScopedRef , round_to_pages} ;
60- #[ cfg( feature = "virtio-drivers" ) ]
60+ #[ cfg( all ( feature = "virtio-drivers" , feature = "block" ) ) ]
6161use svsm:: virtio:: probe_mmio_slots;
6262#[ cfg( all( feature = "vtpm" , not( test) ) ) ]
6363use svsm:: vtpm:: vtpm_init;
@@ -162,12 +162,12 @@ fn mapping_info_init(launch_info: &KernelLaunchInfo) {
162162/// Returns Ok if initialization is successful or no virtio devices are found
163163/// Returns an error when a virtio device is found but its driver initialization fails.
164164#[ cfg( feature = "virtio-drivers" ) ]
165- fn initialize_virtio_mmio ( ) -> Result < ( ) , SvsmError > {
166- let mut slots = probe_mmio_slots ( ) ;
167-
165+ fn initialize_virtio_mmio ( _config : & SvsmConfig < ' _ > ) -> Result < ( ) , SvsmError > {
168166 #[ cfg( feature = "block" ) ]
169167 {
170168 use svsm:: block:: virtio_blk:: initialize_block;
169+
170+ let mut slots = probe_mmio_slots ( _config) ;
171171 initialize_block ( & mut slots) ?;
172172 }
173173
@@ -435,11 +435,7 @@ fn svsm_init(launch_info: &KernelLaunchInfo) {
435435 virt_log_usage ( ) ;
436436
437437 #[ cfg( feature = "virtio-drivers" ) ]
438- if config. has_fw_cfg_port ( ) {
439- // Virtio cannot exist if there is no fw_cfg, so do not bother to
440- // attempt initialization if it is not present.
441- initialize_virtio_mmio ( ) . expect ( "Failed to initialize virtio-mmio drivers" ) ;
442- }
438+ initialize_virtio_mmio ( & config) . expect ( "Failed to initialize virtio-mmio drivers" ) ;
443439
444440 if let Err ( e) = SVSM_PLATFORM . launch_fw ( & config) {
445441 panic ! ( "Failed to launch FW: {e:?}" ) ;
0 commit comments