parent
af06d75d3e
commit
9da113e7a8
@ -123,7 +123,12 @@ pub struct AsanGuestModule<F> {
|
|||||||
mappings: Vec<QemuAsanGuestMapping>,
|
mappings: Vec<QemuAsanGuestMapping>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(cpu_target = "aarch64", cpu_target = "x86_64", feature = "clippy"))]
|
#[cfg(any(
|
||||||
|
cpu_target = "aarch64",
|
||||||
|
cpu_target = "x86_64",
|
||||||
|
cpu_target = "riscv64",
|
||||||
|
feature = "clippy"
|
||||||
|
))]
|
||||||
impl<F> AsanGuestModule<F> {
|
impl<F> AsanGuestModule<F> {
|
||||||
const HIGH_SHADOW_START: GuestAddr = 0x02008fff7000;
|
const HIGH_SHADOW_START: GuestAddr = 0x02008fff7000;
|
||||||
const HIGH_SHADOW_END: GuestAddr = 0x10007fff7fff;
|
const HIGH_SHADOW_END: GuestAddr = 0x10007fff7fff;
|
||||||
@ -135,7 +140,8 @@ impl<F> AsanGuestModule<F> {
|
|||||||
cpu_target = "arm",
|
cpu_target = "arm",
|
||||||
cpu_target = "i386",
|
cpu_target = "i386",
|
||||||
cpu_target = "mips",
|
cpu_target = "mips",
|
||||||
cpu_target = "ppc"
|
cpu_target = "ppc",
|
||||||
|
cpu_target = "riscv32",
|
||||||
))]
|
))]
|
||||||
impl<F> AsanGuestModule<F> {
|
impl<F> AsanGuestModule<F> {
|
||||||
const HIGH_SHADOW_START: GuestAddr = 0x28000000;
|
const HIGH_SHADOW_START: GuestAddr = 0x28000000;
|
||||||
|
@ -8,15 +8,16 @@ use thread_local::ThreadLocal;
|
|||||||
|
|
||||||
#[cfg(any(cpu_target = "arm", cpu_target = "i386", cpu_target = "mips"))]
|
#[cfg(any(cpu_target = "arm", cpu_target = "i386", cpu_target = "mips"))]
|
||||||
use crate::SYS_fstatat64;
|
use crate::SYS_fstatat64;
|
||||||
#[cfg(not(cpu_target = "arm"))]
|
#[cfg(not(any(cpu_target = "arm", cpu_target = "riscv32")))]
|
||||||
use crate::SYS_mmap;
|
use crate::SYS_mmap;
|
||||||
#[cfg(any(cpu_target = "arm", cpu_target = "mips"))]
|
#[cfg(any(cpu_target = "arm", cpu_target = "mips", cpu_target = "riscv32"))]
|
||||||
use crate::SYS_mmap2;
|
use crate::SYS_mmap2;
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
cpu_target = "arm",
|
cpu_target = "arm",
|
||||||
cpu_target = "mips",
|
cpu_target = "mips",
|
||||||
cpu_target = "i386",
|
cpu_target = "i386",
|
||||||
cpu_target = "ppc"
|
cpu_target = "ppc",
|
||||||
|
cpu_target = "riscv32",
|
||||||
)))]
|
)))]
|
||||||
use crate::SYS_newfstatat;
|
use crate::SYS_newfstatat;
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -26,9 +27,10 @@ use crate::{
|
|||||||
NOP_ADDRESS_FILTER,
|
NOP_ADDRESS_FILTER,
|
||||||
},
|
},
|
||||||
qemu::{Hook, SyscallHookResult},
|
qemu::{Hook, SyscallHookResult},
|
||||||
Qemu, SYS_brk, SYS_fstat, SYS_fstatfs, SYS_futex, SYS_getrandom, SYS_mprotect, SYS_mremap,
|
Qemu, SYS_brk, SYS_mprotect, SYS_mremap, SYS_munmap, SYS_pread64, SYS_read, SYS_readlinkat,
|
||||||
SYS_munmap, SYS_pread64, SYS_read, SYS_readlinkat, SYS_statfs,
|
|
||||||
};
|
};
|
||||||
|
#[cfg(not(cpu_target = "riscv32"))]
|
||||||
|
use crate::{SYS_fstat, SYS_fstatfs, SYS_futex, SYS_getrandom, SYS_statfs};
|
||||||
|
|
||||||
// TODO use the functions provided by Qemu
|
// TODO use the functions provided by Qemu
|
||||||
pub const SNAPSHOT_PAGE_SIZE: usize = 4096;
|
pub const SNAPSHOT_PAGE_SIZE: usize = 4096;
|
||||||
@ -804,6 +806,7 @@ where
|
|||||||
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
||||||
h.access(a2, a3 as usize);
|
h.access(a2, a3 as usize);
|
||||||
}
|
}
|
||||||
|
#[cfg(not(cpu_target = "riscv32"))]
|
||||||
SYS_futex => {
|
SYS_futex => {
|
||||||
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
||||||
h.access(a0, a3 as usize);
|
h.access(a0, a3 as usize);
|
||||||
@ -812,7 +815,8 @@ where
|
|||||||
cpu_target = "arm",
|
cpu_target = "arm",
|
||||||
cpu_target = "i386",
|
cpu_target = "i386",
|
||||||
cpu_target = "mips",
|
cpu_target = "mips",
|
||||||
cpu_target = "ppc"
|
cpu_target = "ppc",
|
||||||
|
cpu_target = "riscv32"
|
||||||
)))]
|
)))]
|
||||||
SYS_newfstatat => {
|
SYS_newfstatat => {
|
||||||
if a2 != 0 {
|
if a2 != 0 {
|
||||||
@ -827,10 +831,12 @@ where
|
|||||||
h.access(a2, 4096); // stat is not greater than a page
|
h.access(a2, 4096); // stat is not greater than a page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SYS_statfs | SYS_fstatfs | SYS_fstat => {
|
#[cfg(not(cpu_target = "riscv32"))]
|
||||||
|
SYS_statfs | SYS_fstat | SYS_fstatfs => {
|
||||||
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
||||||
h.access(a1, 4096); // stat is not greater than a page
|
h.access(a1, 4096); // stat is not greater than a page
|
||||||
}
|
}
|
||||||
|
#[cfg(not(cpu_target = "riscv32"))]
|
||||||
SYS_getrandom => {
|
SYS_getrandom => {
|
||||||
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
||||||
h.access(a0, a1 as usize);
|
h.access(a0, a1 as usize);
|
||||||
@ -855,7 +861,7 @@ where
|
|||||||
|
|
||||||
// TODO handle huge pages
|
// TODO handle huge pages
|
||||||
|
|
||||||
#[cfg(any(cpu_target = "arm", cpu_target = "mips"))]
|
#[cfg(any(cpu_target = "arm", cpu_target = "mips", cpu_target = "riscv32"))]
|
||||||
if sys_const == SYS_mmap2 {
|
if sys_const == SYS_mmap2 {
|
||||||
if let Ok(prot) = MmapPerms::try_from(a2 as i32) {
|
if let Ok(prot) = MmapPerms::try_from(a2 as i32) {
|
||||||
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
||||||
@ -863,7 +869,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(cpu_target = "arm"))]
|
#[cfg(not(any(cpu_target = "arm", cpu_target = "riscv32")))]
|
||||||
if sys_const == SYS_mmap {
|
if sys_const == SYS_mmap {
|
||||||
if let Ok(prot) = MmapPerms::try_from(a2 as i32) {
|
if let Ok(prot) = MmapPerms::try_from(a2 as i32) {
|
||||||
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
let h = emulator_modules.get_mut::<SnapshotModule>().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user