aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-08-02 13:48:06 +0200
committerHimbeer <himbeer@disroot.org>2024-08-02 13:48:18 +0200
commit36c191a5c1fcc62283a3950fdee15363b842efdd (patch)
tree9c8843870c64c0b3638aa777426bbb65c1eaf0db
parent0ce5e855c058da456c81f541c14cf1c075c6bc95 (diff)
paging: Allow passing EntryFlags not marked 'valid' to map()
This allows mappings to be invalidated.
-rw-r--r--src/paging.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/paging.zig b/src/paging.zig
index 1a174aa..d1d309c 100644
--- a/src/paging.zig
+++ b/src/paging.zig
@@ -292,13 +292,13 @@ pub const Table = struct {
// discarding offsets. The mapping is written to the specified level,
// creating page tables as needed.
//
- // The mapping must be a leaf, meaning that passing flags
+ // The mapping must be invalid or a leaf, meaning that passing flags
// that indicate no access permissions at all will return an error.
//
// This function internally uses zeroedAlloc to allocate memory for the required page tables,
// but assumes that the physical address to map to has already been allocated by the caller.
pub fn map(root: *Table, vaddr: usize, paddr: usize, flags: EntryFlags, level: usize) !void {
- if (!flags.isLeaf()) return Error.NotALeaf;
+ if (@bitCast(flags.valid) and !flags.isLeaf()) return Error.NotALeaf;
const vpn = virtualPageNumbers(vaddr);