From f8bb4e99a64aa9df31465ee817fc5623a2822b63 Mon Sep 17 00:00:00 2001
From: Ian Moffett <ian@osmora.org>
Date: Thu, 29 Feb 2024 21:58:43 -0500
Subject: kernel/amd64: pmap: Add user pte flag

Signed-off-by: Ian Moffett <ian@osmora.org>
---
 sys/arch/amd64/amd64/pmap.c | 2 ++
 sys/include/vm/pmap.h       | 1 +
 2 files changed, 3 insertions(+)

diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c
index e898e74..7b8609a 100644
--- a/sys/arch/amd64/amd64/pmap.c
+++ b/sys/arch/amd64/amd64/pmap.c
@@ -64,6 +64,8 @@ pmap_prot_to_pte(vm_prot_t prot)
         pte_flags |= PTE_RW;
     if (__TEST(prot, PROT_EXEC))
         pte_flags &= ~(PTE_NX);
+    if (__TEST(prot, PROT_USER))
+        pte_flags |= PTE_US;
 
     return pte_flags;
 }
diff --git a/sys/include/vm/pmap.h b/sys/include/vm/pmap.h
index 516c2ea..85c6753 100644
--- a/sys/include/vm/pmap.h
+++ b/sys/include/vm/pmap.h
@@ -52,6 +52,7 @@
 /* prot flags for mappings */
 #define PROT_WRITE      __BIT(0)      /* Writable */
 #define PROT_EXEC       __BIT(1)      /* Executable */
+#define PROT_USER       __BIT(2)      /* User accessible */
 
 #define is_vas_valid(vas) (vas.top_level != 0)
 
-- 
cgit v1.2.3