Struct kcore::vm::VmSpace [−][src]
pub struct VmSpace<P: PageTable> { /* fields omitted */ }
Expand description
Virtual memory address space.
Implementations
impl<P: PageTable> VmSpace<P>
[src]
impl<P: PageTable> VmSpace<P>
[src]pub fn check_overlap(&self, va: Range<usize>) -> Result<()>
[src]
pub async fn mmap(
&mut self,
addr: usize,
len: usize,
chan: &Arc<Chan>,
offset: usize,
anonymous: bool
) -> Result<()>
[src]
pub async fn mmap(
&mut self,
addr: usize,
len: usize,
chan: &Arc<Chan>,
offset: usize,
anonymous: bool
) -> Result<()>
[src]Create a memory segment mapping.
Accessing virtual address [addr, addr + len) is equivalent to accessing ontents starting
at offset
of given chan. offset, addr and len must be a multiple of page size.
An anonymous mapping won’t carry any modification to the underlying chan. It’s unspecified when the underlying chan is then modified by others after creating the anonymous mapping, since we may or may not view the modified value in the mapping.
pub async fn munmap(&mut self, addr: usize, len: usize) -> Result<bool>
[src]
pub async fn munmap(&mut self, addr: usize, len: usize) -> Result<bool>
[src]Unmap a continugous chunk of memory.
All pages containing a part of the indicated range [addr, addr + len) are unmapped.
Note that when the chunk of memory to unmap is included by exactly one segment, we need to split it and add a new segment. In other cases, we can just reuse the old segments by modifying their keys and anon.
This is atomic. Return error if unmap failed. Otherwise, all mappings are guaranteed to
be unmapped and the return value indicates whether there are any error when flushing
to the backing objects. See also [VmSegment::unmap
].
pub async fn fork(&mut self) -> Result<VmSpace<P>>
[src]
pub async fn fork(&mut self) -> Result<VmSpace<P>>
[src]Fork an address space.
For example, it may be called when forking a process.
pub async fn fault(&mut self, va: usize) -> Result<()>
[src]
pub async fn fault(&mut self, va: usize) -> Result<()>
[src]Page fault handler at virtual address va
.
Faults can be divided into following cases:
- Fault at a shared page in chan. It may happen when the page is newly mapped shared but not yet referred.
- Fault at a copy-on-write private page. When the private page is forked, corresponding page table entries will be marked as read-only. Thus, for example, this kind of fault will happend when the child process is trying to modify this page.
- Fault at a unfetched private page. It may happen when the page is newly mapped private but not yet referred.
If it returns ok, the address space will have read/write permission to the page containing
virtual address va
. That means the kernel can safely read or write to the page (after
switching to it) without page fault.
pub async fn free(self)
[src]
pub async fn free(self)
[src]Unmap all segments and drop this address space.
Note that this dosen’t gurantee all dirty pages are successfully flushed to their backing object.
Auto Trait Implementations
impl<P> !RefUnwindSafe for VmSpace<P>
impl<P> Send for VmSpace<P> where
P: Send,
P: Send,
impl<P> Sync for VmSpace<P> where
P: Sync,
P: Sync,
impl<P> Unpin for VmSpace<P> where
P: Unpin,
P: Unpin,