PageFaultReason

Struct PageFaultReason 

Source
pub struct PageFaultReason {
    pub fault_addr: Va,
    pub is_write_access: bool,
    pub is_present: bool,
}
Expand description

Represents the reason for a page fault in a virtual memory system.

This struct is used to capture various details about a page fault, including the faulting address, the type of access that caused the fault (read or write).

Fields§

§fault_addr: Va

The address that caused the page fault.

This is the virtual address that the program attempted to access when the page fault occurred. It can be useful for debugging and identifying the location in memory where the fault happened.

§is_write_access: bool

Indicates whether the fault was due to a write access violation.

A value of true means that the program attempted to write to a page that was marked as read-only or otherwise restricted from write access. A value of false indicates that the access was a read or the page allowed write access.

§is_present: bool

Indicates whether the page that caused the fault is present in memory.

A value of true means that the page is currently loaded into memory, and the fault may have occurred due to other conditions, such as protection violations. A value of false means the page is not present in memory (e.g., the page might have been swapped out or mapped as a non-resident page).

Implementations§

Source§

impl PageFaultReason

Source

pub fn is_cow_fault(&self) -> bool

Returns true if the fault is a copy-on-write violation.

§Returns
  • true if this fault requires COW handling.
  • false otherwise.
Source§

impl PageFaultReason

Source

pub fn new(ec: PFErrorCode, cr2: Va) -> Self

Probe the cause of page fault into a PageFaultReason.

This function decodes a hardware-provided PFErrorCode, generated by the CPU when a page fault occurs, into a structured PageFaultReason that the kernel can interpret.

The decoded information includes:

  • The type of access (is_write_access),
  • Whether the faulting page is currently mapped (is_present),
  • The faulting virtual address (fault_addr).
Source

pub fn is_demand_paging_fault(&self) -> bool

Returns true if the fault is due to demand paging.

§Returns
  • true if this fault was caused by an demand paging.
  • false otherwise.

Trait Implementations§

Source§

impl Debug for PageFaultReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for PageFaultReason

§

impl RefUnwindSafe for PageFaultReason

§

impl Send for PageFaultReason

§

impl Sync for PageFaultReason

§

impl Unpin for PageFaultReason

§

impl UnwindSafe for PageFaultReason

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.