summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amd64/amd64/pmap.c11
-rw-r--r--sys/include/vm/pmap.h6
2 files changed, 17 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c
index 5fe1e3b..e898e74 100644
--- a/sys/arch/amd64/amd64/pmap.c
+++ b/sys/arch/amd64/amd64/pmap.c
@@ -215,6 +215,17 @@ pmap_create_vas(struct vm_ctx *ctx)
return new_vas;
}
+void
+pmap_switch_vas(struct vm_ctx *ctx, struct vas vas)
+{
+ uintptr_t cr3_val = vas.cr3_flags | vas.top_level;
+
+ __ASMV("mov %0, %%cr3"
+ :
+ : "r" (cr3_val)
+ : "memory");
+}
+
struct vas
pmap_read_vas(void)
{
diff --git a/sys/include/vm/pmap.h b/sys/include/vm/pmap.h
index c591605..516c2ea 100644
--- a/sys/include/vm/pmap.h
+++ b/sys/include/vm/pmap.h
@@ -72,6 +72,12 @@ struct vm_ctx {
struct vas pmap_create_vas(struct vm_ctx *);
/*
+ * Switch the current virtual address space
+ * to another.
+ */
+void pmap_switch_vas(struct vm_ctx *, struct vas);
+
+/*
* Read virtual address space descriptor
* and return it.
*/