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: VaThe 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: boolIndicates 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: boolIndicates 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
impl PageFaultReason
Sourcepub fn is_cow_fault(&self) -> bool
pub fn is_cow_fault(&self) -> bool
Returns true if the fault is a copy-on-write violation.
§Returns
trueif this fault requires COW handling.falseotherwise.
Source§impl PageFaultReason
impl PageFaultReason
Sourcepub fn new(ec: PFErrorCode, cr2: Va) -> Self
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).
Sourcepub fn is_demand_paging_fault(&self) -> bool
pub fn is_demand_paging_fault(&self) -> bool
Returns true if the fault is due to demand paging.
§Returns
trueif this fault was caused by an demand paging.falseotherwise.