Skip to content

Commit 37123ff

Browse files
committed
fixup! Add InterruptHandle trait, and implement trait for mshv,kvm and windows
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 4abdd49 commit 37123ff

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/hyperlight_host/src/hypervisor/hyperv_windows.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ use super::fpu::{FP_TAG_WORD_DEFAULT, MXCSR_DEFAULT};
3636
use super::handlers::DbgMemAccessHandlerWrapper;
3737
use super::handlers::{MemAccessHandlerWrapper, OutBHandlerWrapper};
3838
use super::surrogate_process::SurrogateProcess;
39+
use super::surrogate_process_manager::*;
3940
use super::windows_hypervisor_platform::{VMPartition, VMProcessor};
4041
use super::wrappers::{HandleWrapper, WHvFPURegisters};
41-
use super::{surrogate_process_manager::*, InterruptHandle};
4242
use super::{
43-
HyperlightExit, Hypervisor, VirtualCPU, CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP,
44-
CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, EFER_LMA, EFER_LME, EFER_NX, EFER_SCE,
43+
HyperlightExit, Hypervisor, InterruptHandle, VirtualCPU, CR0_AM, CR0_ET, CR0_MP, CR0_NE,
44+
CR0_PE, CR0_PG, CR0_WP, CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, EFER_LMA, EFER_LME, EFER_NX,
45+
EFER_SCE,
4546
};
4647
use crate::hypervisor::fpu::FP_CONTROL_WORD_DEFAULT;
4748
use crate::hypervisor::wrappers::WHvGeneralRegisters;
@@ -108,7 +109,7 @@ impl HypervWindowsDriver {
108109
mem_regions,
109110
interrupt_handle: Arc::new(WindowsInterruptHandle {
110111
running: AtomicBool::new(false),
111-
parition_handle: partition_handle,
112+
partition_handle,
112113
dropped: AtomicBool::new(false),
113114
}),
114115
})
@@ -509,14 +510,14 @@ impl Drop for HypervWindowsDriver {
509510
pub struct WindowsInterruptHandle {
510511
// `WHvCancelRunVirtualProcessor()` will return Ok even if the vcpu is not running, which is the reason we need this flag.
511512
running: AtomicBool,
512-
parition_handle: WHV_PARTITION_HANDLE,
513+
partition_handle: WHV_PARTITION_HANDLE,
513514
dropped: AtomicBool,
514515
}
515516

516517
impl InterruptHandle for WindowsInterruptHandle {
517518
fn kill(&self) -> bool {
518519
self.running.load(Ordering::Relaxed)
519-
&& unsafe { WHvCancelRunVirtualProcessor(self.parition_handle, 0, 0).is_ok() }
520+
&& unsafe { WHvCancelRunVirtualProcessor(self.partition_handle, 0, 0).is_ok() }
520521
}
521522

522523
fn dropped(&self) -> bool {

src/hyperlight_host/src/sandbox/uninitialized_evolve.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
use crate::hypervisor::handlers::{MemAccessHandlerCaller, OutBHandlerCaller};
18-
use crate::hypervisor::Hypervisor;
19-
#[cfg(target_os = "linux")]
20-
use crate::signal_handlers::setup_signal_handlers;
21-
use crate::HyperlightError::NoHypervisorFound;
2217
use std::sync::{Arc, Mutex};
2318

2419
use rand::Rng;
@@ -27,6 +22,8 @@ use tracing::{instrument, Span};
2722
use super::hypervisor::{get_available_hypervisor, HypervisorType};
2823
#[cfg(gdb)]
2924
use super::mem_access::dbg_mem_access_handler_wrapper;
25+
use crate::hypervisor::handlers::{MemAccessHandlerCaller, OutBHandlerCaller};
26+
use crate::hypervisor::Hypervisor;
3027
use crate::mem::layout::SandboxMemoryLayout;
3128
use crate::mem::mgr::SandboxMemoryManager;
3229
use crate::mem::ptr::{GuestPtr, RawPtr};
@@ -39,6 +36,9 @@ use crate::sandbox::mem_access::mem_access_handler_wrapper;
3936
use crate::sandbox::outb::outb_handler_wrapper;
4037
use crate::sandbox::{HostSharedMemory, MemMgrWrapper};
4138
use crate::sandbox_state::sandbox::Sandbox;
39+
#[cfg(target_os = "linux")]
40+
use crate::signal_handlers::setup_signal_handlers;
41+
use crate::HyperlightError::NoHypervisorFound;
4242
use crate::{log_then_return, new_error, MultiUseSandbox, Result, UninitializedSandbox};
4343

4444
/// The implementation for evolving `UninitializedSandbox`es to
@@ -227,9 +227,10 @@ fn set_up_hypervisor_partition(
227227

228228
#[cfg(target_os = "windows")]
229229
Some(HypervisorType::Whp) => {
230-
use crate::hypervisor::wrappers::HandleWrapper;
231230
use std::ffi::c_void;
232231

232+
use crate::hypervisor::wrappers::HandleWrapper;
233+
233234
let mmap_file_handle = mgr
234235
.shared_mem
235236
.with_exclusivity(|e| e.get_mmap_file_handle())?;

0 commit comments

Comments
 (0)