Reimplemented BMC
This commit is contained in:
parent
2fb695b3a9
commit
2aad3a1002
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
super::MemoryAccessReason,
|
super::MemoryAccessReason,
|
||||||
crate::{
|
crate::{
|
||||||
mem::{perm_check, HandlePageFault, Memory},
|
mem::{HandlePageFault, Memory},
|
||||||
VmRunError,
|
VmRunError,
|
||||||
},
|
},
|
||||||
core::{mem::MaybeUninit, task::Poll},
|
core::{mem::MaybeUninit, task::Poll},
|
||||||
|
@ -68,7 +68,7 @@ impl BlockCopier {
|
||||||
Some(n) => self.src = n,
|
Some(n) => self.src = n,
|
||||||
None => return Poll::Ready(Err(BlkCopyError::OutOfBounds)),
|
None => return Poll::Ready(Err(BlkCopyError::OutOfBounds)),
|
||||||
};
|
};
|
||||||
|
|
||||||
match self.dst.checked_add(BUF_SIZE as u64) {
|
match self.dst.checked_add(BUF_SIZE as u64) {
|
||||||
Some(n) => self.dst = n,
|
Some(n) => self.dst = n,
|
||||||
None => return Poll::Ready(Err(BlkCopyError::OutOfBounds)),
|
None => return Poll::Ready(Err(BlkCopyError::OutOfBounds)),
|
||||||
|
@ -113,32 +113,16 @@ unsafe fn act(
|
||||||
) -> Result<(), BlkCopyError> {
|
) -> Result<(), BlkCopyError> {
|
||||||
// Load to buffer
|
// Load to buffer
|
||||||
memory
|
memory
|
||||||
.memory_access(
|
.load(src, buf, count, traph)
|
||||||
MemoryAccessReason::Load,
|
.map_err(|super::LoadError(addr)| BlkCopyError::Access {
|
||||||
src,
|
|
||||||
buf,
|
|
||||||
count,
|
|
||||||
perm_check::readable,
|
|
||||||
|src, dst, count| core::ptr::copy(src, dst, count),
|
|
||||||
traph,
|
|
||||||
)
|
|
||||||
.map_err(|addr| BlkCopyError::Access {
|
|
||||||
access_reason: MemoryAccessReason::Load,
|
access_reason: MemoryAccessReason::Load,
|
||||||
addr,
|
addr,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Store from buffer
|
// Store from buffer
|
||||||
memory
|
memory
|
||||||
.memory_access(
|
.store(dst, buf, count, traph)
|
||||||
MemoryAccessReason::Store,
|
.map_err(|super::StoreError(addr)| BlkCopyError::Access {
|
||||||
dst,
|
|
||||||
buf,
|
|
||||||
count,
|
|
||||||
perm_check::writable,
|
|
||||||
|dst, src, count| core::ptr::copy(src, dst, count),
|
|
||||||
traph,
|
|
||||||
)
|
|
||||||
.map_err(|addr| BlkCopyError::Access {
|
|
||||||
access_reason: MemoryAccessReason::Store,
|
access_reason: MemoryAccessReason::Store,
|
||||||
addr,
|
addr,
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -426,12 +426,12 @@ impl PageSize {
|
||||||
/// Unhandled load access trap
|
/// Unhandled load access trap
|
||||||
#[derive(Clone, Copy, Display, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Display, Debug, PartialEq, Eq)]
|
||||||
#[display(fmt = "Load access error at address {_0:#x}")]
|
#[display(fmt = "Load access error at address {_0:#x}")]
|
||||||
pub struct LoadError(u64);
|
pub struct LoadError(pub u64);
|
||||||
|
|
||||||
/// Unhandled store access trap
|
/// Unhandled store access trap
|
||||||
#[derive(Clone, Copy, Display, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Display, Debug, PartialEq, Eq)]
|
||||||
#[display(fmt = "Store access error at address {_0:#x}")]
|
#[display(fmt = "Store access error at address {_0:#x}")]
|
||||||
pub struct StoreError(u64);
|
pub struct StoreError(pub u64);
|
||||||
|
|
||||||
/// There was no entry in page table to unmap
|
/// There was no entry in page table to unmap
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue