X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/28c176b668c841a3b7fb093faccf0efa39257603..refs/heads/eme/build-tools:/lunaix-os/arch/x86/mm/vmutils.c diff --git a/lunaix-os/arch/x86/mm/vmutils.c b/lunaix-os/arch/x86/mm/vmutils.c index df831c2..8c99710 100644 --- a/lunaix-os/arch/x86/mm/vmutils.c +++ b/lunaix-os/arch/x86/mm/vmutils.c @@ -1,5 +1,6 @@ #include -#include + +#include struct leaflet* dup_leaflet(struct leaflet* leaflet) @@ -9,8 +10,9 @@ dup_leaflet(struct leaflet* leaflet) new_leaflet = alloc_leaflet(leaflet_order(leaflet)); - src_va = leaflet_mount(leaflet); + // TODO need a proper long term fix for the contention of page mount point dest_va = vmap(new_leaflet, KERNEL_DATA); + src_va = leaflet_mount(leaflet); size_t cnt_wordsz = leaflet_size(new_leaflet) / sizeof(ptr_t); @@ -36,4 +38,23 @@ dup_leaflet(struct leaflet* leaflet) vunmap(dest_va, new_leaflet); return new_leaflet; -} \ No newline at end of file +} + +pte_t +translate_vmr_prot(unsigned int vmr_prot, pte_t pte) +{ + pte = pte_mkuser(pte); + + if ((vmr_prot & PROT_WRITE)) { + pte = pte_mkwritable(pte); + } + + if ((vmr_prot & PROT_EXEC)) { + pte = pte_mkexec(pte); + } + else { + pte = pte_mknonexec(pte); + } + + return pte; +}