Skip to content

Commit b727e78

Browse files
got rid of check_vm_instruction related allocations.
1 parent 3015be7 commit b727e78

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

mythril/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub enum VmInstructionError {
4444
InvalidOperandToInveptInvvpid = 28,
4545
}
4646

47-
pub fn check_vm_insruction(rflags: u64, error: String) -> Result<()> {
47+
pub fn check_vm_instruction(rflags: u64, error: &str) -> Result<()> {
4848
let rflags = rflags::RFlags::from_bits_truncate(rflags);
4949

5050
if rflags.contains(RFlags::FLAGS_CF) {

mythril/src/vcpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl VCpu {
171171
/// Begin execution in the guest context for this core
172172
pub fn launch(&mut self) -> Result<!> {
173173
let rflags = unsafe { vmlaunch_wrapper() };
174-
error::check_vm_insruction(rflags, "Failed to launch vm".into())?;
174+
error::check_vm_instruction(rflags, "Failed to launch vm")?;
175175

176176
unreachable!()
177177
}

mythril/src/vmcs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ fn vmcs_write(field: VmcsField, value: u64) -> Result<()> {
333333
rflags
334334
};
335335

336-
error::check_vm_insruction(
336+
error::check_vm_instruction(
337337
rflags,
338-
format!("Failed to write 0x{:x} to field {:?}", value, field),
338+
format!("Failed to write 0x{:x} to field {:?}", value, field).as_str(),
339339
)
340340
}
341341

@@ -369,7 +369,7 @@ fn vmcs_activate(vmcs: &mut Vmcs, _vmx: &vmx::Vmx) -> Result<()> {
369369
rflags
370370
};
371371

372-
error::check_vm_insruction(rflags, "Failed to activate VMCS".into())
372+
error::check_vm_instruction(rflags, "Failed to activate VMCS")
373373
}
374374

375375
fn vmcs_clear(vmcs_page: &mut Raw4kPage) -> Result<()> {
@@ -382,7 +382,7 @@ fn vmcs_clear(vmcs_page: &mut Raw4kPage) -> Result<()> {
382382
: "volatile");
383383
rflags
384384
};
385-
error::check_vm_insruction(rflags, "Failed to clear VMCS".into())
385+
error::check_vm_instruction(rflags, "Failed to clear VMCS")
386386
}
387387

388388
pub struct Vmcs {

mythril/src/vmexit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub extern "C" fn vmexit_handler(state: *mut GuestCpuState) {
5454

5555
#[no_mangle]
5656
pub extern "C" fn vmresume_failure_handler(rflags: u64) {
57-
error::check_vm_insruction(rflags, "Failed to vmresume".into())
57+
error::check_vm_instruction(rflags, "Failed to vmresume")
5858
.expect("vmresume failed");
5959
}
6060

mythril/src/vmx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Vmx {
5252
rflags
5353
};
5454

55-
error::check_vm_insruction(rflags, "Failed to enable vmx".into())?;
55+
error::check_vm_instruction(rflags, "Failed to enable vmx")?;
5656
Ok(Vmx {
5757
_vmxon_region: vmxon_region,
5858
})
@@ -70,7 +70,7 @@ impl Vmx {
7070
rflags
7171
};
7272

73-
error::check_vm_insruction(rflags, "Failed to disable vmx".into())
73+
error::check_vm_instruction(rflags, "Failed to disable vmx")
7474
}
7575

7676
pub fn revision() -> u32 {
@@ -90,7 +90,7 @@ impl Vmx {
9090
: "m"(val), "r"(t));
9191
rflags
9292
};
93-
error::check_vm_insruction(rflags, "Failed to execute invept".into())
93+
error::check_vm_instruction(rflags, "Failed to execute invept")
9494
}
9595

9696
pub fn invvpid(&self, mode: InvVpidMode) -> Result<()> {
@@ -112,7 +112,7 @@ impl Vmx {
112112
: "m"(val), "r"(t));
113113
rflags
114114
};
115-
error::check_vm_insruction(rflags, "Failed to execute invvpid".into())
115+
error::check_vm_instruction(rflags, "Failed to execute invvpid")
116116
}
117117
}
118118

0 commit comments

Comments
 (0)