Skip to content

Commit 7576f9f

Browse files
a sort of initial skeleton for cpuid.
1 parent 01e0cc7 commit 7576f9f

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

mythril/src/emulate/cpuid.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,30 +192,3 @@ fn cpuid_name(vcpu: &VCpu, actual: CpuIdResult) -> CpuIdResult {
192192
}
193193
actual
194194
}
195-
196-
pub fn emulate_cpuid(
197-
vcpu: &mut vcpu::VCpu,
198-
guest_cpu: &mut vmexit::GuestCpuState,
199-
) -> Result<()> {
200-
let eax = guest_cpu.rax as u32;
201-
202-
let ecx = guest_cpu.rcx as u32;
203-
let mut res = get_cpu_id_result(vcpu, eax, ecx);
204-
205-
//todo move this into get_cpu_id_result
206-
if guest_cpu.rax as u32 == 1 {
207-
// Hide hypervisor feature
208-
res.ecx &= !(1 << 31);
209-
210-
// Hide TSC deadline timer
211-
res.ecx &= !(1 << 24);
212-
} else if guest_cpu.rax as u32 == 0x0b {
213-
res.edx = crate::percore::read_core_id().raw as u32;
214-
}
215-
216-
guest_cpu.rax = res.eax as u64 | (guest_cpu.rax & 0xffffffff00000000);
217-
guest_cpu.rbx = res.ebx as u64 | (guest_cpu.rbx & 0xffffffff00000000);
218-
guest_cpu.rcx = res.ecx as u64 | (guest_cpu.rcx & 0xffffffff00000000);
219-
guest_cpu.rdx = res.edx as u64 | (guest_cpu.rdx & 0xffffffff00000000);
220-
Ok(())
221-
}

mythril/src/vm.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ pub struct HostPhysicalDevices {
349349

350350
/// A configuration for a `VirtualMachine`
351351
pub struct VirtualMachineConfig {
352+
<<<<<<< HEAD
352353
/// The cores assigned as part of this configuration
353354
pub cpus: ArrayVec<[percore::CoreId; MAX_PER_VM_CORE_COUNT]>,
354355

@@ -365,6 +366,13 @@ pub struct VirtualMachineConfig {
365366

366367
/// The size of this machines physical address space in MiB
367368
pub memory: u64,
369+
=======
370+
cpus: ArrayVec<[percore::CoreId; MAX_PER_VM_CORE_COUNT]>,
371+
images: Vec<(String, GuestPhysAddr)>,
372+
virtual_devices: DeviceMap,
373+
physical_devices: PhysicalDeviceConfig,
374+
memory: u64, // in MB
375+
>>>>>>> a sort of initial skeleton for cpuid.
368376
override_cpu_name: bool
369377
}
370378

@@ -404,6 +412,39 @@ impl VirtualMachineConfig {
404412
self.images.push((image, addr));
405413
Ok(())
406414
}
415+
<<<<<<< HEAD
416+
=======
417+
418+
/// Access the configurations virtual `DeviceMap`
419+
pub fn virtual_devices(&self) -> &DeviceMap {
420+
&self.virtual_devices
421+
}
422+
423+
/// Access the configurations virtual `DeviceMap` mutably
424+
pub fn virtual_devices_mut(&mut self) -> &mut DeviceMap {
425+
&mut self.virtual_devices
426+
}
427+
428+
/// Access the configurations physical hardware
429+
pub fn physical_devices(&self) -> &PhysicalDeviceConfig {
430+
&self.physical_devices
431+
}
432+
433+
/// Get the list of CoreIds assicated with this VM
434+
pub fn cpus(&self) -> &ArrayVec<[percore::CoreId; MAX_PER_VM_CORE_COUNT]> {
435+
&self.cpus
436+
}
437+
438+
/// Get the CoreId of the BSP for this VM
439+
pub fn bsp_id(&self) -> percore::CoreId {
440+
self.cpus[0]
441+
}
442+
443+
444+
pub fn override_cpu_name(&self) -> bool {
445+
self.override_cpu_name
446+
}
447+
>>>>>>> a sort of initial skeleton for cpuid.
407448
}
408449

409450
/// A virtual machine

0 commit comments

Comments
 (0)