Skip to content

Commit ec06c04

Browse files
committed
clippy
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent b5bbe6d commit ec06c04

File tree

10 files changed

+32
-20
lines changed

10 files changed

+32
-20
lines changed

src/hyperlight_host/src/hypervisor/gdb/arch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ limitations under the License.
1717
//! This file contains architecture specific code for the x86_64
1818
1919
use super::VcpuStopReason;
20+
use crate::hypervisor::regs::CommonRegisters;
21+
use crate::hypervisor::vm::Vm;
2022
use crate::Result;
21-
use crate::{regs::CommonRegisters, vm::Vm};
2223

2324
// Described in Table 6-1. Exceptions and Interrupts at Page 6-13 Vol. 1
2425
// of Intel 64 and IA-32 Architectures Software Developer's Manual

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use gdbstub::target::TargetError;
3131
use thiserror::Error;
3232
use x86_64_target::HyperlightSandboxTarget;
3333

34-
use crate::regs::CommonRegisters;
34+
use crate::hypervisor::regs::CommonRegisters;
3535

3636
#[derive(Debug, Error)]
3737
pub(crate) enum GdbTargetError {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ 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::regs::CommonRegisters;
32+
use crate::hypervisor::regs::CommonRegisters;
3333

3434
use super::{DebugCommChannel, DebugMsg, DebugResponse, GdbTargetError};
3535

src/hyperlight_host/src/hypervisor/hyperlight_vm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod debug {
6767
req: DebugMsg,
6868
dbg_mem_access_fn: Arc<Mutex<dyn DbgMemAccessHandlerCaller>>,
6969
) -> Result<DebugResponse> {
70-
if let Some(_) = self.gdb_conn {
70+
if self.gdb_conn.is_some() {
7171
match req {
7272
DebugMsg::AddHwBreakpoint(addr) => Ok(DebugResponse::AddHwBreakpoint(
7373
self.vm
@@ -142,7 +142,7 @@ mod debug {
142142

143143
e
144144
})
145-
.map(|regs| DebugResponse::ReadRegisters(regs)),
145+
.map(DebugResponse::ReadRegisters),
146146
DebugMsg::RemoveHwBreakpoint(addr) => Ok(DebugResponse::RemoveHwBreakpoint(
147147
self.vm
148148
.remove_hw_breakpoint(addr)
@@ -364,7 +364,7 @@ impl HyperlightSandbox {
364364
vm,
365365
entrypoint,
366366
orig_rsp: rsp_gp,
367-
mem_regions: mem_regions,
367+
mem_regions,
368368

369369
#[cfg(gdb)]
370370
gdb_conn,

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Vm for MshvVm {
133133
}
134134

135135
fn set_regs(&self, regs: &CommonRegisters) -> Result<()> {
136-
let mshv_regs = regs.clone().into();
136+
let mshv_regs = (*regs).into();
137137
Ok(self.vcpu_fd.set_regs(&mshv_regs)?)
138138
}
139139

@@ -143,7 +143,7 @@ impl Vm for MshvVm {
143143
}
144144

145145
fn set_sregs(&self, sregs: &CommonSpecialRegisters) -> Result<()> {
146-
let mshv_sregs = sregs.clone().into();
146+
let mshv_sregs = (*sregs).into();
147147
self.vcpu_fd.set_sregs(&mshv_sregs)?;
148148
Ok(())
149149
}
@@ -153,7 +153,7 @@ impl Vm for MshvVm {
153153
}
154154

155155
fn set_fpu(&self, fpu: &CommonFpu) -> Result<()> {
156-
self.vcpu_fd.set_fpu(&fpu.clone().into())?;
156+
self.vcpu_fd.set_fpu(&(*fpu).into())?;
157157
Ok(())
158158
}
159159

@@ -235,7 +235,7 @@ impl Vm for MshvVm {
235235
let exception_message = m.to_exception_info()?;
236236
let DebugRegisters { dr6, .. } = self.vcpu_fd.get_debug_regs()?;
237237
HyperlightExit::Debug {
238-
dr6: dr6,
238+
dr6,
239239
exception: exception_message.exception_vector as u32,
240240
}
241241
}

src/hyperlight_host/src/hypervisor/inprocess.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ 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;
1720
use std::fmt::Debug;
1821
use std::os::raw::c_void;
1922
use std::sync::{Arc, Mutex};
2023

21-
use log::LevelFilter;
22-
2324
#[cfg(gdb)]
2425
use super::handlers::DbgMemAccessHandlerWrapper;
2526
use super::handlers::{MemAccessHandlerCaller, OutBHandlerCaller};
@@ -127,7 +128,7 @@ impl<'a> HyperlightVm for InprocessDriver<'a> {
127128
_hv_handler: Option<HypervisorHandler>,
128129
_outb_handle_fn: Arc<Mutex<dyn OutBHandlerCaller>>,
129130
_mem_access_fn: Arc<Mutex<dyn MemAccessHandlerCaller>>,
130-
#[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper,
131+
#[cfg(gdb)] _dbg_mem_access_fn: DbgMemAccessHandlerWrapper,
131132
) -> Result<()> {
132133
unimplemented!("run should not be needed since we are in in-process mode")
133134
}
@@ -141,4 +142,14 @@ impl<'a> HyperlightVm for InprocessDriver<'a> {
141142
fn get_memory_regions(&self) -> &[MemoryRegion] {
142143
unimplemented!("get_memory_regions is not supported since we are in in-process mode")
143144
}
145+
146+
#[cfg(gdb)]
147+
/// handles the cases when the vCPU stops due to a Debug event
148+
fn handle_debug(
149+
&mut self,
150+
_dbg_mem_access_fn: Arc<Mutex<dyn DbgMemAccessHandlerCaller>>,
151+
_stop_reason: VcpuStopReason,
152+
) -> Result<()> {
153+
unimplemented!("handle_debug should not be needed since we are in in-process mode")
154+
}
144155
}

src/hyperlight_host/src/hypervisor/kvm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl Vm for KvmVm {
9898
}
9999

100100
fn set_regs(&self, regs: &CommonRegisters) -> Result<()> {
101-
let kvm_regs = regs.clone().into();
101+
let kvm_regs = (*regs).into();
102102
Ok(self.vcpu_fd.set_regs(&kvm_regs)?)
103103
}
104104

@@ -107,15 +107,15 @@ impl Vm for KvmVm {
107107
}
108108

109109
fn set_sregs(&self, sregs: &CommonSpecialRegisters) -> Result<()> {
110-
Ok(self.vcpu_fd.set_sregs(&sregs.clone().into())?)
110+
Ok(self.vcpu_fd.set_sregs(&(*sregs).into())?)
111111
}
112112

113113
fn get_fpu(&self) -> Result<CommonFpu> {
114114
Ok(self.vcpu_fd.get_fpu()?.into())
115115
}
116116

117117
fn set_fpu(&self, fpu: &CommonFpu) -> Result<()> {
118-
Ok(self.vcpu_fd.set_fpu(&fpu.clone().into())?)
118+
Ok(self.vcpu_fd.set_fpu(&(*fpu).into())?)
119119
}
120120

121121
unsafe fn map_memory(&self, regions: &[MemoryRegion]) -> Result<()> {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod fpu;
2-
mod regs;
3-
mod sregs;
2+
mod special_regs;
3+
mod standard_regs;
44

55
pub(crate) use fpu::*;
6-
pub(crate) use regs::*;
7-
pub(crate) use sregs::*;
6+
pub(crate) use special_regs::*;
7+
pub(crate) use standard_regs::*;

0 commit comments

Comments
 (0)