riscv64: Correcting pmap_enter() - adding initialization of pdir1
@@ -124,17 +124,21 @@ int pmap_enter(pmap_t *pmap, addr_t pa, void *va, int attr, page_t *alloc)
return -EFAULT;
}
- pmap->pdir2[pdi2] = (((alloc->addr >> 12) << 10) | (attr & 0x10) | 0xc1);
+ pmap->pdir2[pdi2] = (((alloc->addr >> 12) << 10) | /*(attr & 0x10) |*/ 0xc1);
+
+ /* Initialize pdir (MOD) - because of reentrancy */
+ pmap_common.pdir0[((u64)pmap_common.ptable >> 12) & 0x1ff] = (((alloc->addr >> 12) << 10) | /*0x10 | */ 0xcf);
+ hal_cpuFlushTLB(pmap_common.ptable);
+ hal_memset(pmap_common.ptable, 0, 4096);
+
alloc = NULL;
}
-
+ else {
/* Map next level pdir */
addr = ((pmap->pdir2[pdi2] >> 10) << 12);
-
pmap_common.pdir0[((u64)pmap_common.ptable >> 12) & 0x1ff] = (((addr >> 12) << 10) | /*0x10 | */ 0xcf);
-
- /* PGHD_WRITE | PGHD_PRESENT | PGHD_USER); */
hal_cpuFlushTLB(pmap_common.ptable);
+ }
if (!pmap_common.ptable[pdi1]) {
if (alloc == NULL) {
@@ -148,7 +152,7 @@ int pmap_enter(pmap_t *pmap, addr_t pa, void *va, int attr, page_t *alloc)
/* Map next level pdir */
addr = ((pmap_common.ptable[pdi1] >> 10) << 12);
- attr |= 2;
+ attr |= 0x2;
pmap_common.pdir0[((u64)pmap_common.ptable >> 12) & 0x1ff] = (((addr >> 12) << 10) | 0xcf);
/* PGHD_WRITE | PGHD_PRESENT | PGHD_USER); */
