Skip to content

Commit 4efc52a

Browse files
removed some dynamic allocations added since this MR was opened.
1 parent 990de9d commit 4efc52a

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

mythril/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub enum Error {
8484
InvalidDevice,
8585
NotImplemented,
8686
DeviceError,
87+
MissingDevice
8788
}
8889

8990
impl<T: TryFromPrimitive> From<TryFromPrimitiveError<T>> for Error {

mythril/src/vm.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const MAX_IMAGE_MAPPING_PER_VM: usize = 16;
5353
///
5454
/// This method must be called before calling 'virtual_machines'
5555
pub unsafe fn init_virtual_machines(
56-
machines: impl Iterator<Item = VirtualMachine>,
56+
machines: impl Iterator<Item=VirtualMachine>,
5757
) -> Result<()> {
5858
for machine in machines {
5959
VIRTUAL_MACHINE_SET.insert(machine)?;
@@ -114,8 +114,7 @@ impl VirtualMachineSet {
114114
/// Create a new VirtualMachineSet
115115
const fn new() -> Self {
116116
Self {
117-
contexts: ArrayVec::<[VirtualMachineContext; MAX_VCPU_COUNT]>::new(
118-
),
117+
contexts: ArrayVec::<[VirtualMachineContext; MAX_VCPU_COUNT]>::new(),
119118
vms: ArrayVec::<[VirtualMachine; MAX_VM_COUNT]>::new(),
120119
}
121120
}
@@ -279,7 +278,7 @@ impl VirtualMachineSet {
279278
}
280279

281280
/// Receive all pending messages for the current core
282-
pub fn recv_all_msgs(&self) -> impl Iterator<Item = VirtualMachineMsg> {
281+
pub fn recv_all_msgs(&self) -> impl Iterator<Item=VirtualMachineMsg> {
283282
let context = self
284283
.context_by_core_id(percore::read_core_id())
285284
.expect("No VirtualMachineContext for apic id");
@@ -319,7 +318,7 @@ impl StaticVirtualDevices {
319318

320319
fn devices(
321320
&self,
322-
) -> impl Iterator<Item = &RwLock<dyn virtdev::EmulatedDevice>> {
321+
) -> impl Iterator<Item=&RwLock<dyn virtdev::EmulatedDevice>> {
323322
core::array::IntoIter::new([
324323
&self.acpi_runtime as &RwLock<dyn virtdev::EmulatedDevice>,
325324
&self.vga_controller as &RwLock<dyn virtdev::EmulatedDevice>,
@@ -437,7 +436,7 @@ pub struct VirtualMachine {
437436

438437
/// Portions of the per-core Local APIC state needed for logical addressing
439438
pub logical_apic_state:
440-
BTreeMap<percore::CoreId, virtdev::lapic::LogicalApicState>,
439+
BTreeMap<percore::CoreId, virtdev::lapic::LogicalApicState>,
441440

442441
/// The number of vcpus that are up and waiting to start
443442
cpus_ready: AtomicU32,
@@ -548,9 +547,10 @@ impl VirtualMachine {
548547
// Just ignore writes to unknown ports
549548
Ok(())
550549
}
551-
_ => Err(Error::MissingDevice(
552-
"Unable to dispatch event".into(),
553-
)),
550+
_ => {
551+
error!("Unable to dispatch event");
552+
Err(Error::MissingDevice)
553+
}
554554
};
555555
}
556556
};
@@ -574,7 +574,7 @@ impl VirtualMachine {
574574
pub fn logical_apic_destination(
575575
&self,
576576
mask: u32,
577-
) -> Result<impl Iterator<Item = &percore::CoreId>> {
577+
) -> Result<impl Iterator<Item=&percore::CoreId>> {
578578
// FIXME: currently we only support the 'Flat Model' logical mode
579579
// (so we just ignore the destination format register). See 10.6.2.2
580580
// of Volume 3A of the Intel software developer's manual
@@ -736,7 +736,7 @@ mod test {
736736
32,
737737
host_devices,
738738
)
739-
.unwrap();
739+
.unwrap();
740740

741741
VirtualMachine::new(0, config, &info).unwrap();
742742
}

0 commit comments

Comments
 (0)