Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] port/xen: map memory directly in privcmd PRIVCMD_MMAPBATCH




diff --git a/sys/arch/xen/xen/privcmd.c b/sys/arch/xen/xen/privcmd.c
index f584913..033a37d 100644
--- a/sys/arch/xen/xen/privcmd.c
+++ b/sys/arch/xen/xen/privcmd.c

[...]

+               mfn = kmem_alloc(sizeof(u_long) * pmb->num, KM_SLEEP);

Why have you removed the if (mfn == NULL) /* bailout */ check ?

+               error = copyin(pmb->arr, mfn, sizeof(u_long) * pmb->num);

Good, but kmem_alloc() doesn't zero mem - I would use kmem_zalloc()
since you're copyout()ing later.


+               /* Map the memory region directly */
+               error = privcmd_map(pmap, va0, mfn, prot, pmb->num, pmb->dom);
+               if (error) {
+                       kmem_free(mfn, sizeof(u_long) * pmb->num);
                        return error;
+               }
+               copyout(mfn, pmb->arr, sizeof(u_long) * pmb->num);
+               kmem_free(mfn, sizeof(u_long) * pmb->num);
 
                break;
        }
@@ -452,6 +426,24 @@ privcmd_ioctl(void *v)
        return error;
 }
 
+static int privcmd_map(pmap_t pmap, vaddr_t va0, u_long *mfn,
+               vm_prot_t prot, int num, int domid)
+{
+       int i;
+       vaddr_t va;
+       paddr_t ma;
+
+       for(i = 0; i < num; ++i) {
+               va = va0 + (i * PAGE_SIZE);
+               ma = ((paddr_t)mfn[i]) << PGSHIFT;
+               if (pmap_enter_ma(pmap, va, ma, 0, prot, PMAP_CANFAIL, domid))
+                       mfn[i] |= 0xF0000000;

I know this is verbatim from the old code, but can you explain the
constant 0xF0000000 ? I'd prefer to have a #define or const here.


[...]

Cheers,
-- 
Cherry


Home | Main Index | Thread Index | Old Index