[Barrelfish-users] modify_flags in x86_32's pmap_target

Shi Jinghao jhshi at cs.hku.hk
Thu May 10 13:52:01 CEST 2012


Hi,

I found that x86_32's modify_flags in pmap_target is not yet implemented
(NYI). But my project happen to need this utility. As I saw no special
difficulty in it, especially when x86_64 already has an implementation, so
I don't know why it's still NYI. Are there any special concerns?

Anyway, I ported the modify_flags in x86_64 to x86_32 arch, with two
small modifications:

- change all X86_64 to X86_32 (of course)
- chage find_ptable fuction call to get_ptable

No problems occur so far and my program run happily with this modify_flags.
But can anyone confirm that this is good?

Thanks,
Jinghao

Here is my patch, FYI.

--- a/lib/barrelfish/target/x86_32/pmap_target.c Wed May 09 19:32:01 2012
+0800
+++ b/lib/barrelfish/target/x86_32/pmap_target.c Wed May 09 19:32:34 2012
+0800
@@ -417,7 +417,47 @@
 static errval_t modify_flags(struct pmap *pmap, genvaddr_t vaddr, size_t
size,
                              vregion_flags_t flags, size_t *retsize)
 {
-    USER_PANIC("NYI");
+    errval_t err, ret;
+    struct pmap_x86 *x86 = (struct pmap_x86 *)pmap;
+    size = ROUND_UP(size, X86_32_BASE_PAGE_SIZE);
+
+    for (size_t i = 0; i < size; i += X86_32_BASE_PAGE_SIZE) {
+        // Find the page table
+        struct vnode *ptable ;
+        err = get_ptable(x86, vaddr + i, &ptable);
+        if (err_is_fail(err) || ptable == NULL) { // not mapped
+            ret = LIB_ERR_PMAP_FIND_VNODE;
+            continue;
+        }
+
+        // Find the page
+        struct vnode *vn = find_vnode(ptable, X86_32_PTABLE_BASE(vaddr +
i));
+        if (vn == NULL) { // not mapped
+            ret = LIB_ERR_PMAP_FIND_VNODE;
+            continue;
+        }
+
+        // Unmap it in the kernel
+        err = vnode_unmap(ptable->u.vnode.cap, vn->entry);
+        if (err_is_fail(err)) {
+            return err_push(err, LIB_ERR_VNODE_UNMAP);
+        }
+
+        // Remap with changed flags
+        paging_x86_32_flags_t pmap_flags = vregion_to_pmap_flag(flags);
+        err = vnode_map(ptable->u.vnode.cap, vn->u.frame.cap, vn->entry,
+                        pmap_flags, vn->u.frame.offset);
+        if (err_is_fail(err)) {
+            return err_push(err, LIB_ERR_VNODE_MAP);
+        }
+
+        vn->u.frame.flags = flags;
+    }
+
+    if (retsize) {
+        *retsize = size;
+    }
+
     return SYS_ERR_OK;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.inf.ethz.ch/pipermail/barrelfish-users/attachments/20120510/2ae58f74/attachment.html 


More information about the Barrelfish-users mailing list