[Barrelfish-users] modify_flags in x86_32's pmap_target

Simon Gerber simugerber at student.ethz.ch
Thu May 10 14:31:10 CEST 2012


Hi,

This should work fine for now. We're working on a memory management
system overhaul which should land in the public tree some time
relatively soon(tm).

-- Simon


2012/5/10 Shi Jinghao <jhshi at cs.hku.hk>:
> 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;
>  }
>
>
>
>
> _______________________________________________
> Barrelfish-users mailing list
> Barrelfish-users at lists.inf.ethz.ch
> https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users
>



More information about the Barrelfish-users mailing list