Skip to content

Commit 3fb6e5f

Browse files
committed
Add errors::PageFault
This covers the error code during a #PF. Signed-off-by: Nathaniel McCallum <[email protected]>
1 parent 1fa5598 commit 3fb6e5f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/errors.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! This module contains errors and exception types.
22
33
use bit_field::BitField;
4+
use bitflags::bitflags;
45

56
/// Exception Error Codes
67
///
@@ -81,6 +82,42 @@ pub enum Exception {
8182
Security = 0x1E,
8283
}
8384

85+
bitflags! {
86+
/// The errors that can cause a page fault.
87+
///
88+
/// This structure is defined by the following manual sections:
89+
/// * AMD Volume 2: 8.4.2
90+
/// * Intel Volume 3A: 4.7
91+
pub struct PageFault: u32 {
92+
/// The fault was caused permissions. Otherwise, missing entry.
93+
const PERMISSIONS = 1 << 0;
94+
95+
/// The fault was caused by a write. Otherwise, a read.
96+
const WRITE = 1 << 1;
97+
98+
/// The fault was user-mode. Otherwise, supervisor-mode.
99+
const USER = 1 << 2;
100+
101+
/// The fault was caused by a reserved bit set.
102+
const RESERVED = 1 << 3;
103+
104+
/// The fault was caused by an instruction fetch.
105+
const INSTRUCTION = 1 << 4;
106+
107+
/// The fault was caused by protection key.
108+
const PROTECTION_KEY = 1 << 5;
109+
110+
/// The fault was caused by shadow stack access (AMD-only).
111+
const SHADOW_STACK = 1 << 6;
112+
113+
/// The fault was caused by SGX access-control requirements (Intel-only).
114+
const SGX = 1 << 15;
115+
116+
/// The fault was caused by RMP violation (AMD-only).
117+
const RMP = 1 << 31;
118+
}
119+
}
120+
84121
/// The index in a selector error
85122
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
86123
pub enum SelectorIndex {

0 commit comments

Comments
 (0)