Skip to content

Commit e0a5254

Browse files
committed
fmt
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 7be03b0 commit e0a5254

File tree

7 files changed

+29
-34
lines changed

7 files changed

+29
-34
lines changed

src/hyperlight_host/src/hypervisor/gdb/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use event_loop::event_loop_thread;
2727
use gdbstub::conn::ConnectionExt;
2828
use gdbstub::stub::GdbStub;
2929
use gdbstub::target::TargetError;
30-
3130
use thiserror::Error;
3231
use x86_64_target::HyperlightSandboxTarget;
3332

src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ use gdbstub::target::ext::section_offsets::{Offsets, SectionOffsets};
2929
use gdbstub::target::{Target, TargetError, TargetResult};
3030
use gdbstub_arch::x86::X86_64_SSE as GdbTargetArch;
3131

32-
use crate::hypervisor::regs::CommonRegisters;
33-
3432
use super::{DebugCommChannel, DebugMsg, DebugResponse, GdbTargetError};
33+
use crate::hypervisor::regs::CommonRegisters;
3534

3635
/// Gdbstub target used by the gdbstub crate to provide GDB protocol implementation
3736
pub(crate) struct HyperlightSandboxTarget {

src/hyperlight_host/src/hypervisor/hyperlight_vm.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
#[cfg(crashdump)]
17-
use crate::hypervisor::crashdump;
18-
use crate::sandbox::hypervisor::HypervisorType;
19-
use crate::HyperlightError::ExecutionCanceledByHost;
2016
use std::convert::TryFrom;
2117
use std::fmt::Debug;
2218
use std::sync::{Arc, Mutex};
@@ -42,12 +38,15 @@ use super::{
4238
HyperlightExit, HyperlightVm, CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP,
4339
CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, EFER_LMA, EFER_LME, EFER_NX, EFER_SCE,
4440
};
41+
#[cfg(crashdump)]
42+
use crate::hypervisor::crashdump;
4543
use crate::hypervisor::hypervisor_handler::HypervisorHandler;
4644
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
4745
use crate::mem::ptr::{GuestPtr, RawPtr};
4846
use crate::metrics::METRIC_GUEST_CANCELLATION;
49-
use crate::HyperlightError;
50-
use crate::{log_then_return, new_error, Result};
47+
use crate::sandbox::hypervisor::HypervisorType;
48+
use crate::HyperlightError::ExecutionCanceledByHost;
49+
use crate::{log_then_return, new_error, HyperlightError, Result};
5150

5251
#[cfg(gdb)]
5352
mod debug {

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ use std::collections::HashMap;
3030
use std::fmt::Debug;
3131
use std::sync::LazyLock;
3232

33-
#[cfg(gdb)]
34-
use super::handlers::DbgMemAccessHandlerCaller;
35-
use super::regs::{CommonFpu, CommonRegisters, CommonSpecialRegisters};
36-
use super::vm::Vm;
37-
use super::HyperlightExit;
38-
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
39-
use crate::{log_then_return, new_error, Result};
4033
#[cfg(mshv2)]
4134
use mshv_bindings::hv_message;
4235
#[cfg(gdb)]
@@ -45,17 +38,25 @@ use mshv_bindings::hv_message_type_HVMSG_X64_EXCEPTION_INTERCEPT;
4538
use mshv_bindings::DebugRegisters;
4639
use mshv_bindings::{
4740
hv_message_type, hv_message_type_HVMSG_GPA_INTERCEPT, hv_message_type_HVMSG_UNMAPPED_GPA,
48-
hv_message_type_HVMSG_X64_HALT, hv_message_type_HVMSG_X64_IO_PORT_INTERCEPT,
41+
hv_message_type_HVMSG_X64_HALT, hv_message_type_HVMSG_X64_IO_PORT_INTERCEPT, hv_register_assoc,
42+
hv_register_name_HV_X64_REGISTER_RIP, hv_register_value,
4943
};
5044
#[cfg(mshv3)]
5145
use mshv_bindings::{
5246
hv_partition_property_code_HV_PARTITION_PROPERTY_SYNTHETIC_PROC_FEATURES,
5347
hv_partition_synthetic_processor_features,
5448
};
55-
use mshv_bindings::{hv_register_assoc, hv_register_name_HV_X64_REGISTER_RIP, hv_register_value};
5649
use mshv_ioctls::{Mshv, VcpuFd, VmFd};
5750
use tracing::{instrument, Span};
5851

52+
#[cfg(gdb)]
53+
use super::handlers::DbgMemAccessHandlerCaller;
54+
use super::regs::{CommonFpu, CommonRegisters, CommonSpecialRegisters};
55+
use super::vm::Vm;
56+
use super::HyperlightExit;
57+
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
58+
use crate::{log_then_return, new_error, Result};
59+
5960
/// Determine whether the HyperV for Linux hypervisor API is present
6061
/// and functional.
6162
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
@@ -263,9 +264,10 @@ impl Vm for MshvVm {
263264

264265
#[cfg(gdb)]
265266
fn translate_gva(&self, gva: u64) -> Result<u64> {
266-
use crate::HyperlightError;
267267
use mshv_bindings::{HV_TRANSLATE_GVA_VALIDATE_READ, HV_TRANSLATE_GVA_VALIDATE_WRITE};
268268

269+
use crate::HyperlightError;
270+
269271
let flags = (HV_TRANSLATE_GVA_VALIDATE_READ | HV_TRANSLATE_GVA_VALIDATE_WRITE) as u64;
270272
let (addr, _) = self
271273
.vcpu_fd
@@ -386,9 +388,8 @@ impl Vm for MshvVm {
386388
addr: u64,
387389
dbg_mem_access_fn: std::sync::Arc<std::sync::Mutex<dyn DbgMemAccessHandlerCaller>>,
388390
) -> Result<()> {
389-
use crate::hypervisor::gdb::arch::SW_BP;
390-
391391
use super::gdb::arch::SW_BP_SIZE;
392+
use crate::hypervisor::gdb::arch::SW_BP;
392393

393394
let mut save_data = [0; SW_BP_SIZE];
394395
let mut mem = dbg_mem_access_fn.lock().unwrap();

src/hyperlight_host/src/hypervisor/inprocess.rs

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

17-
use crate::hypervisor::DbgMemAccessHandlerCaller;
18-
use crate::hypervisor::VcpuStopReason;
19-
use log::LevelFilter;
2017
use std::fmt::Debug;
2118
use std::os::raw::c_void;
2219
use std::sync::{Arc, Mutex};
2320

21+
use log::LevelFilter;
22+
2423
#[cfg(gdb)]
2524
use super::handlers::DbgMemAccessHandlerWrapper;
2625
use super::handlers::{MemAccessHandlerCaller, OutBHandlerCaller};
2726
use super::hypervisor_handler::HypervisorHandler;
2827
use super::HyperlightVm;
28+
use crate::hypervisor::{DbgMemAccessHandlerCaller, VcpuStopReason};
2929
#[cfg(crashdump)]
3030
use crate::mem::memory_region::MemoryRegion;
3131
use crate::sandbox::leaked_outb::LeakedOutBWrapper;

src/hyperlight_host/src/hypervisor/kvm.rs

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

17+
#[cfg(gdb)]
18+
use std::collections::HashMap;
19+
use std::sync::LazyLock;
20+
21+
#[cfg(gdb)]
22+
use kvm_bindings::kvm_guest_debug;
1723
use kvm_bindings::{kvm_userspace_memory_region, KVM_MEM_READONLY};
1824
use kvm_ioctls::Cap::UserMemory;
1925
use kvm_ioctls::{Kvm, VcpuExit, VcpuFd, VmFd};
2026
use tracing::{instrument, Span};
2127

22-
#[cfg(gdb)]
23-
use kvm_bindings::kvm_guest_debug;
24-
#[cfg(gdb)]
25-
use std::collections::HashMap;
26-
use std::sync::LazyLock;
27-
2828
use super::regs::{CommonFpu, CommonRegisters, CommonSpecialRegisters};
2929
use super::vm::Vm;
3030
use super::HyperlightExit;

src/hyperlight_host/src/hypervisor/vm.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ use std::sync::Arc;
44
#[cfg(gdb)]
55
use std::sync::Mutex;
66

7+
use super::regs::{CommonFpu, CommonRegisters, CommonSpecialRegisters};
78
#[cfg(gdb)]
89
use crate::hypervisor::handlers::DbgMemAccessHandlerCaller;
910
use crate::hypervisor::HyperlightExit;
1011
use crate::mem::memory_region::MemoryRegion;
1112
use crate::Result;
1213

13-
use super::regs::CommonFpu;
14-
use super::regs::CommonRegisters;
15-
use super::regs::CommonSpecialRegisters;
16-
1714
pub(crate) trait Vm: Send + Sync + Debug {
1815
/// Get the standard registers of the vCPU
1916
#[allow(dead_code)]

0 commit comments

Comments
 (0)