From ef4d480cedcf362c8b4dfd5934c15ae3836e65de Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 11 May 2008 20:33:47 +0000 Subject: Correct an error in pmap_align_superpage(). Specifically, correctly handle the case where the mapping is greater than a superpage in size but the alignment of the physical pages spans a superpage boundary. --- sys/amd64/amd64/pmap.c | 5 +++-- sys/i386/i386/pmap.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index dcd6b2a9028b..5af214f5fe43 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -4480,11 +4480,12 @@ pmap_align_superpage(vm_object_t object, vm_ooffset_t offset, { vm_offset_t superpage_offset; + if (size < NBPDR) + return; if (object != NULL && (object->flags & OBJ_COLORED) != 0) offset += ptoa(object->pg_color); superpage_offset = offset & PDRMASK; - if (size < superpage_offset || - size - superpage_offset < NBPDR || + if (size - ((NBPDR - superpage_offset) & PDRMASK) < NBPDR || (*addr & PDRMASK) == superpage_offset) return; if ((*addr & PDRMASK) < superpage_offset) diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 474fea5c0387..a68881026757 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -4608,11 +4608,12 @@ pmap_align_superpage(vm_object_t object, vm_ooffset_t offset, { vm_offset_t superpage_offset; + if (size < NBPDR) + return; if (object != NULL && (object->flags & OBJ_COLORED) != 0) offset += ptoa(object->pg_color); superpage_offset = offset & PDRMASK; - if (size < superpage_offset || - size - superpage_offset < NBPDR || + if (size - ((NBPDR - superpage_offset) & PDRMASK) < NBPDR || (*addr & PDRMASK) == superpage_offset) return; if ((*addr & PDRMASK) < superpage_offset) -- cgit v1.3