From df418a215306f9733322dcd2165307c9ff8ea4ff Mon Sep 17 00:00:00 2001 From: Jinank Jain Date: Wed, 7 May 2025 12:30:18 +0000 Subject: [PATCH] vmm: Split device creation from interrupt controller creation For MSHV guests, we would need interrupt controller to be initialized before the VM gets initialized. This is because we are registering the base address of GIC distributor with MSHV as part of interrupt controller initialization workflow. And MSHV mandates that this property is set before we initialize the VM. Signed-off-by: Jinank Jain --- vmm/src/device_manager.rs | 9 +++++++-- vmm/src/vm.rs | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 9a59a0e15..c10249713 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -1223,18 +1223,23 @@ impl DeviceManager { self.console_resize_pipe.clone() } + pub fn create_interrupt_controller( + &mut self, + ) -> DeviceManagerResult>> { + self.add_interrupt_controller() + } + pub fn create_devices( &mut self, console_info: Option, console_resize_pipe: Option>, original_termios_opt: Arc>>, + interrupt_controller: Arc>, ) -> DeviceManagerResult<()> { trace_scoped!("create_devices"); let mut virtio_devices: Vec = Vec::new(); - let interrupt_controller = self.add_interrupt_controller()?; - self.cpu_manager .lock() .unwrap() diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index a2df6fdf4..693066a5b 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -651,10 +651,16 @@ impl Vm { ) .map_err(Error::DeviceManager)?; + let ic = device_manager + .lock() + .unwrap() + .create_interrupt_controller() + .map_err(Error::DeviceManager)?; + device_manager .lock() .unwrap() - .create_devices(console_info, console_resize_pipe, original_termios) + .create_devices(console_info, console_resize_pipe, original_termios, ic) .map_err(Error::DeviceManager)?; #[cfg(feature = "tdx")]