qemu: Fix cpu page size function for full-system (#1452)
* Revert "qemu: add cpu page_size call (#1433)" This reverts commit d338b30c080ecfe1a6639185b6505b7a7b8edbeb. * Reintroduce page_size
This commit is contained in:
parent
4a96354276
commit
04c8d5208b
@ -115,12 +115,12 @@ pub fn generate(
|
||||
.allowlist_function("tlb_plugin_lookup")
|
||||
.allowlist_function("qemu_plugin_hwaddr_phys_addr")
|
||||
.allowlist_function("qemu_plugin_get_hwaddr")
|
||||
.allowlist_function("qemu_target_page_size")
|
||||
.allowlist_function("syx_snapshot_init")
|
||||
.allowlist_function("syx_snapshot_create")
|
||||
.allowlist_function("syx_snapshot_root_restore")
|
||||
.allowlist_function("syx_snapshot_dirty_list_add")
|
||||
.allowlist_function("device_list_all")
|
||||
.allowlist_function("qemu_target_page_size")
|
||||
.blocklist_function("main_loop_wait") // bindgen issue #1313
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks));
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
/* automatically generated by rust-bindgen 0.66.1 */
|
||||
|
||||
extern "C" {
|
||||
#[doc = " qemu_target_page_size - return the target's page size"]
|
||||
pub fn qemu_target_page_size() -> usize;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct __BindgenBitfieldUnit<Storage> {
|
||||
@ -11100,12 +11105,6 @@ impl ::std::ops::BitAndAssign for qemu_plugin_mem_rw {
|
||||
self.0 &= rhs.0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#[doc = " qemu_target_page_size - return the target's page size"]
|
||||
pub fn qemu_target_page_size() -> usize;
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct qemu_plugin_mem_rw(pub ::std::os::raw::c_uint);
|
||||
|
@ -14,10 +14,6 @@ use std::{
|
||||
ptr::null_mut,
|
||||
};
|
||||
|
||||
thread_local! {
|
||||
static SNAPSHOT_PAGE_SIZE: OnceCell<usize> = OnceCell::new();
|
||||
}
|
||||
|
||||
#[cfg(emulation_mode = "usermode")]
|
||||
use libc::c_int;
|
||||
use num_enum::{IntoPrimitive, TryFromPrimitive};
|
||||
@ -751,7 +747,11 @@ impl CPU {
|
||||
pub fn page_size(&self) -> usize {
|
||||
#[cfg(emulation_mode = "usermode")]
|
||||
{
|
||||
SNAPSHOT_PAGE_SIZE.with(|s| {
|
||||
thread_local! {
|
||||
static PAGE_SIZE: OnceCell<usize> = OnceCell::new();
|
||||
}
|
||||
|
||||
PAGE_SIZE.with(|s| {
|
||||
*s.get_or_init(|| {
|
||||
unsafe { libc::sysconf(libc::_SC_PAGE_SIZE) }
|
||||
.try_into()
|
||||
@ -761,8 +761,7 @@ impl CPU {
|
||||
}
|
||||
#[cfg(emulation_mode = "systemmode")]
|
||||
{
|
||||
SNAPSHOT_PAGE_SIZE
|
||||
.with(|s| *s.get_or_init(|| unsafe { libafl_qemu_sys::qemu_target_page_size() }))
|
||||
unsafe { libafl_qemu_sys::qemu_target_page_size() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user