|
2 | 2 |
|
3 | 3 | use core::fmt; |
4 | 4 | use memory_addr::PhysAddr; |
| 5 | +use x86_64::structures::paging::page_table::PageTableFlags as PTF; |
5 | 6 |
|
6 | 7 | use crate::{GenericPTE, MappingFlags}; |
7 | 8 |
|
8 | | -bitflags::bitflags! { |
9 | | - /// Possible flags for a page table entry. |
10 | | - /// |
11 | | - /// Reference: https://docs.rs/crate/x86_64/0.15.2/source/src/structures/paging/page_table.rs |
12 | | - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] |
13 | | - pub struct PTF: u64 { |
14 | | - /// Specifies whether the mapped frame or page table is loaded in memory. |
15 | | - const PRESENT = 1; |
16 | | - /// Controls whether writes to the mapped frames are allowed. |
17 | | - /// |
18 | | - /// If this bit is unset in a level 1 page table entry, the mapped frame is read-only. |
19 | | - /// If this bit is unset in a higher level page table entry the complete range of mapped |
20 | | - /// pages is read-only. |
21 | | - const WRITABLE = 1 << 1; |
22 | | - /// Controls whether accesses from userspace (i.e. ring 3) are permitted. |
23 | | - const USER_ACCESSIBLE = 1 << 2; |
24 | | - /// If this bit is set, a “write-through” policy is used for the cache, else a “write-back” |
25 | | - /// policy is used. |
26 | | - const WRITE_THROUGH = 1 << 3; |
27 | | - /// Disables caching for the pointed entry is cacheable. |
28 | | - const NO_CACHE = 1 << 4; |
29 | | - /// Set by the CPU when the mapped frame or page table is accessed. |
30 | | - const ACCESSED = 1 << 5; |
31 | | - /// Set by the CPU on a write to the mapped frame. |
32 | | - const DIRTY = 1 << 6; |
33 | | - /// Specifies that the entry maps a huge frame instead of a page table. Only allowed in |
34 | | - /// P2 or P3 tables. |
35 | | - const HUGE_PAGE = 1 << 7; |
36 | | - /// Indicates that the mapping is present in all address spaces, so it isn't flushed from |
37 | | - /// the TLB on an address space switch. |
38 | | - const GLOBAL = 1 << 8; |
39 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
40 | | - const BIT_9 = 1 << 9; |
41 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
42 | | - const BIT_10 = 1 << 10; |
43 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
44 | | - const BIT_11 = 1 << 11; |
45 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
46 | | - const BIT_52 = 1 << 52; |
47 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
48 | | - const BIT_53 = 1 << 53; |
49 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
50 | | - const BIT_54 = 1 << 54; |
51 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
52 | | - const BIT_55 = 1 << 55; |
53 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
54 | | - const BIT_56 = 1 << 56; |
55 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
56 | | - const BIT_57 = 1 << 57; |
57 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
58 | | - const BIT_58 = 1 << 58; |
59 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
60 | | - const BIT_59 = 1 << 59; |
61 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
62 | | - const BIT_60 = 1 << 60; |
63 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
64 | | - const BIT_61 = 1 << 61; |
65 | | - /// Available to the OS, can be used to store additional data, e.g. custom flags. |
66 | | - const BIT_62 = 1 << 62; |
67 | | - /// Forbid code execution from the mapped frames. |
68 | | - /// |
69 | | - /// Can be only used when the no-execute page protection feature is enabled in the EFER |
70 | | - /// register. |
71 | | - const NO_EXECUTE = 1 << 63; |
72 | | - } |
73 | | -} |
74 | | - |
75 | 9 | impl From<PTF> for MappingFlags { |
76 | 10 | fn from(f: PTF) -> Self { |
77 | 11 | if !f.contains(PTF::PRESENT) { |
|
0 commit comments