Skip to content

Commit

Permalink
Implements run and states for x86 MacOS (#909)
Browse files Browse the repository at this point in the history
Co-authored-by: tompro <tomas.prochazka@apertia.cz>
  • Loading branch information
SuchAFuriousDeath and SuchAFuriousDeath authored Aug 4, 2024
1 parent 833e253 commit 4edcb3f
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
crate-type = ["staticlib"]

[dependencies]
bitflags = "2.6.0"
humansize = "2.1.3"
libc = "0.2.155"
obfw = { git = "https://github.com/obhq/firmware-dumper.git", features = ["read", "std"] }
Expand Down
6 changes: 6 additions & 0 deletions src/core/src/vmm/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ pub trait CpuStates {

#[cfg(target_arch = "x86_64")]
fn set_ss(&mut self, p: bool);

#[cfg(target_arch = "aarch64")]
fn set_sp(&mut self, v: usize);

#[cfg(target_arch = "aarch64")]
fn set_pc(&mut self, v: usize);
}

/// Contains information when VM exited.
Expand Down
10 changes: 10 additions & 0 deletions src/core/src/vmm/linux/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ impl<'a> CpuStates for KvmStates<'a> {
self.sregs.ss.present = p.into();
self.sdirty = true;
}

#[cfg(target_arch = "aarch64")]
fn set_sp(&mut self, v: usize) {
todo!()
}

#[cfg(target_arch = "aarch64")]
fn set_pc(&mut self, v: usize) {
todo!()
}
}

impl<'a> Drop for KvmStates<'a> {
Expand Down
32 changes: 32 additions & 0 deletions src/core/src/vmm/linux/regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ pub struct KvmRegs {
pub rflags: u64,
}

#[cfg(target_arch = "aarch64")]
#[repr(C)]
struct KvmRegs {
pub regs: UserPtRegs,
pub sp_el1: usize,
pub elr_el1: usize,
pub sprs: [usize; 5],
pub fp_regs: UserFpRegs,
}

#[cfg(target_arch = "aarch64")]
#[repr(C)]
struct UserPtRegs {
pub regs: [usize; 31],
pub sp: usize,
pub pc: usize,
pub pstate: usize,
}

#[cfg(target_arch = "aarch64")]
#[repr(C)]
struct UserFpSimdState {
pub vregs: [u128; 32],
pub fpsr: u32,
pub fpcr: u32,
pub reserved: [u32; 2],
}

#[cfg(target_arch = "x86_64")]
#[repr(C)]
pub struct KvmSpecialRegs {
Expand Down Expand Up @@ -52,6 +80,10 @@ pub struct KvmSpecialRegs {
pub interrupt_bitmap: [u64; 4],
}

#[cfg(target_arch = "aarch64")]
#[repr(C)]
struct KvmSpecialRegs {}

#[cfg(target_arch = "x86_64")]
#[repr(C)]
pub struct KvmSegment {
Expand Down
Loading

0 comments on commit 4edcb3f

Please sign in to comment.