-#include <hal/cpu.h>
#include <klibc/string.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/spike.h>
#include <lunaix/syslog.h>
+#include <sys/cpu.h>
LOG_MODULE("VMM")
// See if attr make sense
assert(attr <= 128);
- if (!l1pt->entry[l1_inx]) {
+ x86_pte_t* l1pte = &l1pt->entry[l1_inx];
+ if (!*l1pte) {
x86_page_table* new_l1pt_pa =
(x86_page_table*)pmm_alloc_page(KERNEL_PID, PP_FGPERSIST);
}
// This must be writable
- l1pt->entry[l1_inx] =
- NEW_L1_ENTRY(attr | PG_WRITE | PG_PRESENT, new_l1pt_pa);
+ *l1pte = NEW_L1_ENTRY(attr | PG_WRITE | PG_PRESENT, new_l1pt_pa);
// make sure our new l2 table is visible to CPU
cpu_flush_page((ptr_t)l2pt);
memset((void*)l2pt, 0, PG_SIZE);
} else {
+ if ((attr & PG_ALLOW_USER) && !(*l1pte & PG_ALLOW_USER)) {
+ *l1pte |= PG_ALLOW_USER;
+ }
+
x86_pte_t pte = l2pt->entry[l2_inx];
if (pte && (options & VMAP_IGNORE)) {
return 1;