mirror of
https://github.com/obhq/obliteration.git
synced 2024-12-02 08:06:34 +00:00
Uses 16K page on AArch64 (#939)
This commit is contained in:
parent
37c2e56d04
commit
cd1fe69189
@ -246,6 +246,22 @@ pub unsafe extern "C" fn vmm_run(
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Support any page size on the host. With page size the same as kernel or lower we don't
|
||||
// need to keep track allocations in the RAM because any requested address from the kernel will
|
||||
// always page-aligned on the host.
|
||||
let host_page_size = match get_page_size() {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
*err = RustError::with_source("couldn't get host page size", e);
|
||||
return null_mut();
|
||||
}
|
||||
};
|
||||
|
||||
if host_page_size > vm_page_size {
|
||||
*err = RustError::new("your system using an unsupported page size");
|
||||
return null_mut();
|
||||
}
|
||||
|
||||
// Get kernel memory size.
|
||||
let mut len = 0;
|
||||
|
||||
@ -268,15 +284,6 @@ pub unsafe extern "C" fn vmm_run(
|
||||
};
|
||||
}
|
||||
|
||||
// Get host page size.
|
||||
let host_page_size = match get_page_size() {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
*err = RustError::with_source("couldn't get host page size", e);
|
||||
return null_mut();
|
||||
}
|
||||
};
|
||||
|
||||
// Round kernel memory size.
|
||||
let len = match len {
|
||||
0 => {
|
||||
@ -327,13 +334,21 @@ pub unsafe extern "C" fn vmm_run(
|
||||
// Read segment data.
|
||||
let mut seg = &mut kern[hdr.p_vaddr..(hdr.p_vaddr + hdr.p_memsz)];
|
||||
|
||||
if let Err(e) = std::io::copy(&mut data, &mut seg) {
|
||||
*err = RustError::with_source(
|
||||
format_args!("couldn't read kernet at offset {}", hdr.p_offset),
|
||||
e,
|
||||
);
|
||||
match std::io::copy(&mut data, &mut seg) {
|
||||
Ok(v) => {
|
||||
if v != hdr.p_filesz {
|
||||
*err = RustError::new(format!("{path} is incomplete"));
|
||||
return null_mut();
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
*err = RustError::with_source(
|
||||
format_args!("couldn't read kernet at offset {}", hdr.p_offset),
|
||||
e,
|
||||
);
|
||||
|
||||
return null_mut();
|
||||
return null_mut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,6 +681,7 @@ enum VmmError {
|
||||
#[error("couldn't get maximum number of CPU for a VM")]
|
||||
GetMaxCpuFailed(#[source] std::io::Error),
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[error("your OS does not support 8 vCPU on a VM")]
|
||||
MaxCpuTooLow,
|
||||
|
||||
|
@ -4,7 +4,7 @@ fn main() {
|
||||
match target.as_str() {
|
||||
"aarch64-unknown-none-softfloat" => {
|
||||
println!("cargo::rustc-link-arg-bins=--pie");
|
||||
println!("cargo::rustc-link-arg-bins=-zmax-page-size=0x1000");
|
||||
println!("cargo::rustc-link-arg-bins=-zmax-page-size=0x4000");
|
||||
}
|
||||
"x86_64-unknown-none" => {
|
||||
println!("cargo::rustc-link-arg-bins=-zmax-page-size=0x1000");
|
||||
|
@ -1 +1 @@
|
||||
pub const PAGE_SIZE: usize = 0x1000;
|
||||
pub const PAGE_SIZE: usize = 0x4000;
|
||||
|
Loading…
Reference in New Issue
Block a user