[−][src]Struct sunrise_kernel::paging::process_memory::ProcessMemory
The struct representing a process' memory, stored in the ProcessStruct behind a lock.
We always store the table_hierarchy as an inactive hierarchy, and use a shortcut function accessing ActiveHierarchy instead if we detect it's the same cr3 as the currently active one.
A process is the only owner of a ProcessMemory
Fields
userspace_bookkeping: UserspaceBookkeeping
The list of mappings in this address space.
table_hierarchy: InactiveHierarchy
The architecture-dependent paging hierarchy.
heap_base_address: VirtualAddress
The start of the heap of this process. The heap is managed as a brk by the set_heap_size syscall.
The location of each process's heap should be random, to implement ASLR.
Implementations
impl ProcessMemory
[src]
fn get_hierarchy(&mut self) -> DynamicHierarchy
[src]
If these tables are the one currently in use, we return them as an ActiveHierarchy instead.
pub fn map_phys_region_to(
&mut self,
phys: PhysicalMemRegion,
address: VirtualAddress,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<(), KernelError>
[src]
&mut self,
phys: PhysicalMemRegion,
address: VirtualAddress,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<(), KernelError>
Maps a single physical regions to a given virtual address. Used to map mmio regions in UserSpace.
Errors
InvalidAddress
:- there was already a mapping in the range.
- range does not fall in UserLand.
address
is not page aligned.
pub fn create_regular_mapping(
&mut self,
address: VirtualAddress,
length: usize,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<(), KernelError>
[src]
&mut self,
address: VirtualAddress,
length: usize,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<(), KernelError>
Allocates the physical regions, and maps them to specified address.
Errors
InvalidAddress
:- there was already a mapping in the range.
- range does not fall in UserLand.
address
is not page aligned.
InvalidSize
:length
is not page aligned.length
is 0.
PhysicalMemoryExhaustion
: Frames could not be allocated.
pub fn map_partial_shared_mapping(
&mut self,
shared_mapping: Arc<SpinRwLock<Vec<PhysicalMemRegion>>>,
address: VirtualAddress,
phys_offset: usize,
length: usize,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<(), KernelError>
[src]
&mut self,
shared_mapping: Arc<SpinRwLock<Vec<PhysicalMemRegion>>>,
address: VirtualAddress,
phys_offset: usize,
length: usize,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<(), KernelError>
Maps a previously created shared mapping to specified address.
Errors
InvalidAddress
:- there was already a mapping in the range.
- range does not fall in UserLand.
address
is not page aligned.
InvalidSize
:length
is not page aligned.length
is 0.
pub fn guard(
&mut self,
address: VirtualAddress,
length: usize,
ty: MemoryType
) -> Result<(), KernelError>
[src]
&mut self,
address: VirtualAddress,
length: usize,
ty: MemoryType
) -> Result<(), KernelError>
Guards a range of addresses
Errors
InvalidAddress
:- there was already a mapping in the range.
- range does not fall in UserLand.
address
is not page aligned.
InvalidSize
:length
is not page aligned.length
is 0.
pub fn unmap(
&mut self,
address: VirtualAddress,
length: usize
) -> Result<Mapping, KernelError>
[src]
&mut self,
address: VirtualAddress,
length: usize
) -> Result<Mapping, KernelError>
Deletes a mapping in the page tables.
This function will never split an existing mapping, thus address and length must match exactly.
If the range maps physical memory, it will be de-allocated.
Errors
InvalidAddress
:- there was no mapping starting at
address
. - range does not fall in UserLand.
- there was no mapping starting at
InvalidSize
:length
is not the size of the mapping ataddress
.
pub fn query_memory(&self, address: VirtualAddress) -> QueryMemory
[src]
Reads the state of the mapping at a given address.
pub fn expand_mapping(
&mut self,
address: VirtualAddress,
new_size: usize
) -> Result<(), KernelError>
[src]
&mut self,
address: VirtualAddress,
new_size: usize
) -> Result<(), KernelError>
Expand the Heap at address
to new_size
.
New frames are allocated to match new_size
.
If new_size
is equal to old size, nothing is done.
Errors
InvalidAddress
:- There was already a mapping in the range
address..(address + new_size)
. address
does not match any existent mapping.address
falls in a shared or system reserved mapping, which cannot be resized.
- There was already a mapping in the range
InvalidSize
:address..(address + new_size)
does not fall in UserLand.new_size
< previous mapping length.new_size
is not page aligned.
InvalidMemState
:address
does not point to a Heap memory mapping.
pub fn find_available_space(
&self,
length: usize
) -> Result<VirtualAddress, KernelError>
[src]
&self,
length: usize
) -> Result<VirtualAddress, KernelError>
Finds a hole in virtual space at least length
long.
Error
Returns a KernelError if no sufficiently big hole was found.
Returns a KernelError if length
is 0.
pub fn mirror_mapping(
&self,
address: VirtualAddress,
length: usize
) -> Result<CrossProcessMapping, KernelError>
[src]
&self,
address: VirtualAddress,
length: usize
) -> Result<CrossProcessMapping, KernelError>
Retrieves the mapping that address
falls into, and mirror it in KernelLand.
The mapping will be kept alive until the CrossProcessMapping
is dropped.
Error
Returns an Error if the mapping is not RefCounted.
pub fn resize_heap(
&mut self,
new_size: usize
) -> Result<VirtualAddress, KernelError>
[src]
&mut self,
new_size: usize
) -> Result<VirtualAddress, KernelError>
Resize the heap of this process, just like a brk. It can both expand or shrink the heap.
If new_size
== 0, it is completely de-allocated.
Return
The address of the start of the heap.
Error
- InvalidSize if
new_size
is not PAGE_SIZE aligned. - InvalidSize if [
address
..new_size
] does not fall in UserLand, or overlaps an existing mapping.
pub fn switch_to(&mut self)
[src]
Switches to this process memory
pub fn check_range(
&self,
addr: VirtualAddress,
size: usize,
state_mask: MemoryState,
state_expected: MemoryState,
perms_mask: MemoryPermissions,
perms_expected: MemoryPermissions,
_attrs_mask: MemoryAttributes,
_attrs_expected: MemoryAttributes,
_attrs_ignore_mask: MemoryAttributes
) -> Result<(MemoryState, MemoryPermissions, MemoryAttributes), KernelError>
[src]
&self,
addr: VirtualAddress,
size: usize,
state_mask: MemoryState,
state_expected: MemoryState,
perms_mask: MemoryPermissions,
perms_expected: MemoryPermissions,
_attrs_mask: MemoryAttributes,
_attrs_expected: MemoryAttributes,
_attrs_ignore_mask: MemoryAttributes
) -> Result<(MemoryState, MemoryPermissions, MemoryAttributes), KernelError>
Checks that the given memory range is homogenous (that is, all blocks within the range have the same permissions and state), and that it has an expected set of state, permissions and attributes.
Errors
InvalidMemState
- The state of a subsection of the memory region is not in the expected state.
- The perms of a subsection of the memory region is not in the expected state.
- The attrs of a subsection of the memory region is not in the expected state.
- The range does not have homogenous state or perms. All mappings in a region should have the same perms and state.
Trait Implementations
impl Debug for ProcessMemory
[src]
impl Default for ProcessMemory
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ProcessMemory
impl Send for ProcessMemory
impl Sync for ProcessMemory
impl Unpin for ProcessMemory
impl !UnwindSafe for ProcessMemory
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,