Skip to content

Commit a8fe1bb

Browse files
some reformatting and addressing warnings.
1 parent 11fbe78 commit a8fe1bb

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

mythril/src/emulate/cpuid.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ fn get_cpu_id_result(
3232
eax_in: u32,
3333
ecx_in: u32,
3434
) -> CpuIdResult {
35-
36-
let mut actual = raw_cpuid::native_cpuid::cpuid_count(
37-
eax_in,
38-
ecx_in,
39-
);
35+
let mut actual = raw_cpuid::native_cpuid::cpuid_count(eax_in, ecx_in);
4036

4137
match eax_in {
4238
CPUID_NAME => cpuid_name(vcpu, actual),
@@ -57,27 +53,25 @@ fn get_cpu_id_result(
5753
EXTENDED_TOPOLOGY_ENUMERATION => {
5854
todo!("This basically requires APIC stuff to be done.")
5955
}
60-
PROCESSOR_EXTENDED_STATE_ENUMERATION => {
61-
actual
62-
}
56+
PROCESSOR_EXTENDED_STATE_ENUMERATION => actual,
6357
// There are bunch more leaves after PROCESSOR_EXTENDED_STATE_ENUMERATION, however most of them seem unlikely to be used/ not relevant
6458
V2_EXTENDED_TOPOLOGY_ENUMERATION => {
6559
todo!("Requires APIC")
6660
}
67-
0x40000000..=0x4FFFFFFF=> {
61+
0x40000000..=0x4FFFFFFF => {
6862
// these are software reserved.
6963
actual
7064
}
71-
EXTENDED_FUNCTION_CPUID_INFORMATION => {
72-
CpuIdResult{
73-
eax: MAX_CPUID_INPUT,
74-
ebx: 0,
75-
ecx: 0,
76-
edx: 0
77-
}
78-
}
65+
EXTENDED_FUNCTION_CPUID_INFORMATION => CpuIdResult {
66+
eax: MAX_CPUID_INPUT,
67+
ebx: 0,
68+
ecx: 0,
69+
edx: 0,
70+
},
7971
CPUID_BRAND_STRING_1..=CPUID_BRAND_STRING_3 => {
80-
if vcpu.vm.config.override_cpu_name() { todo!("CPU Brand string not implemented yet") }
72+
if vcpu.vm.config.override_cpu_name() {
73+
todo!("CPU Brand string not implemented yet")
74+
}
8175
actual
8276
}
8377
_ => {
@@ -99,7 +93,7 @@ bitfield! {
9993
max_addressable_ids_physical,set_max_addressable_ids_physical:26,31;
10094
}
10195

102-
fn intel_cache_topo(mut actual: CpuIdResult) -> CpuIdResult {
96+
fn intel_cache_topo(actual: CpuIdResult) -> CpuIdResult {
10397
let mut cache_topo_eax = IntelCoreCacheTopologyEaxRes(actual.eax);
10498
cache_topo_eax.set_max_addressable_ids_logical(todo!("waiting on apics"));
10599
cache_topo_eax.set_max_addressable_ids_physical(todo!("waiting on apics"));
@@ -210,15 +204,13 @@ pub fn emulate_cpuid(
210204

211205
//todo move this into get_cpu_id_result
212206
if guest_cpu.rax as u32 == 1 {
213-
214207
// Hide hypervisor feature
215208
res.ecx &= !(1 << 31);
216209

217210
// Hide TSC deadline timer
218211
res.ecx &= !(1 << 24);
219212
}
220213

221-
222214
guest_cpu.rax = res.eax as u64 | (guest_cpu.rax & 0xffffffff00000000);
223215
guest_cpu.rbx = res.ebx as u64 | (guest_cpu.rbx & 0xffffffff00000000);
224216
guest_cpu.rcx = res.ecx as u64 | (guest_cpu.rcx & 0xffffffff00000000);

mythril/src/vcpu.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ pub struct VCpu {
9494
pub local_apic: virtdev::lapic::LocalApic,
9595
pending_interrupts: BTreeMap<u8, InjectedInterruptType>,
9696
stack: Vec<u8>,
97-
vcpu_apic_id: usize,
9897
}
9998

10099
impl VCpu {
@@ -111,12 +110,11 @@ impl VCpu {
111110
let stack = vec![0u8; 1024 * 1024];
112111

113112
let mut vcpu = Box::pin(Self {
114-
vm: vm,
115-
vmcs: vmcs,
113+
vm,
114+
vmcs,
116115
local_apic: virtdev::lapic::LocalApic::new(),
117-
stack: stack,
116+
stack,
118117
pending_interrupts: BTreeMap::new(),
119-
vcpu_apic_id: todo!()
120118
});
121119

122120
// All VCpus in a VM must share the same address space

mythril/src/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl VirtualMachineConfig {
324324
virtual_devices: DeviceMap::default(),
325325
physical_devices,
326326
memory,
327-
override_cpu_name: todo!()
327+
override_cpu_name: todo!(),
328328
})
329329
}
330330

0 commit comments

Comments
 (0)