From: Tomas Hruby Date: Thu, 21 Oct 2010 17:07:05 +0000 (+0000) Subject: VM implicitly aligns mappings to a page X-Git-Tag: v3.2.0~770 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=de1bcaa69a3390da1b261e94f0e1204ece0fe2b4;p=minix.git VM implicitly aligns mappings to a page - problem when a PCI BAR is not aligned - together with David v. Moolenboek --- diff --git a/servers/vm/mmap.c b/servers/vm/mmap.c index d0996b2bf..47aec7298 100644 --- a/servers/vm/mmap.c +++ b/servers/vm/mmap.c @@ -133,6 +133,7 @@ PUBLIC int do_map_phys(message *m) struct vir_region *vr; vir_bytes len; phys_bytes startaddr; + size_t offset; target = m->VMMP_EP; len = m->VMMP_LEN; @@ -159,6 +160,10 @@ PUBLIC int do_map_phys(message *m) if(!(vmp->vm_flags & VMF_HASPT)) return ENXIO; + offset = startaddr % VM_PAGE_SIZE; + len += offset; + startaddr -= offset; + if(len % VM_PAGE_SIZE) len += VM_PAGE_SIZE - (len % VM_PAGE_SIZE); @@ -168,7 +173,7 @@ PUBLIC int do_map_phys(message *m) return ENOMEM; } - m->VMMP_VADDR_REPLY = (void *) arch_map2vir(vmp, vr->vaddr); + m->VMMP_VADDR_REPLY = (void *) (arch_map2vir(vmp, vr->vaddr) + offset); return OK; }