|
1 | 1 | //! This module contains errors and exception types.
|
2 | 2 |
|
3 | 3 | use bit_field::BitField;
|
| 4 | +use bitflags::bitflags; |
4 | 5 |
|
5 | 6 | /// Exception Error Codes
|
6 | 7 | ///
|
@@ -81,6 +82,42 @@ pub enum Exception {
|
81 | 82 | Security = 0x1E,
|
82 | 83 | }
|
83 | 84 |
|
| 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 | + |
84 | 121 | /// The index in a selector error
|
85 | 122 | #[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
86 | 123 | pub enum SelectorIndex {
|
|
0 commit comments