Author: rwatson Date: Sat Apr 30 19:29:03 2016 New Revision: 298859 URL: https://svnweb.freebsd.org/changeset/base/298859
Log: When attempting to satisfy mmap() requests for superpage alignment on 64-bit MIPS, use superpage rather than physical-segment constants, or we may improperly fail to apply suitable alignment -- yet still allow mmap() to appear to succeed. Reviewed by: sson MFC after: 1 week Sponsored by: DARPA, AFRL Modified: head/sys/mips/include/param.h head/sys/mips/mips/pmap.c Modified: head/sys/mips/include/param.h ============================================================================== --- head/sys/mips/include/param.h Sat Apr 30 19:04:59 2016 (r298858) +++ head/sys/mips/include/param.h Sat Apr 30 19:29:03 2016 (r298859) @@ -146,12 +146,14 @@ #define SEGSHIFT (PAGE_SHIFT + NPTEPGSHIFT + NPDEPGSHIFT) #define NBSEG (1ul << SEGSHIFT) #define PDRSHIFT (PAGE_SHIFT + NPTEPGSHIFT) +#define PDRSIZE (1ul << PDRSHIFT) #define PDRMASK ((1 << PDRSHIFT) - 1) #else #define NPDEPGSHIFT 10 /* LOG2(NPTEPG) */ #define SEGSHIFT (PAGE_SHIFT + NPTEPGSHIFT) #define NBSEG (1 << SEGSHIFT) /* bytes/segment */ #define PDRSHIFT SEGSHIFT /* alias for SEG in 32 bit */ +#define PDRSIZE (1ul << PDRSHIFT) #define PDRMASK ((1 << PDRSHIFT) - 1) #endif #define NBPDR (1 << PDRSHIFT) /* bytes/pagedir */ Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Sat Apr 30 19:04:59 2016 (r298858) +++ head/sys/mips/mips/pmap.c Sat Apr 30 19:29:03 2016 (r298859) @@ -3299,18 +3299,18 @@ pmap_align_superpage(vm_object_t object, { vm_offset_t superpage_offset; - if (size < NBSEG) + if (size < PDRSIZE) return; if (object != NULL && (object->flags & OBJ_COLORED) != 0) offset += ptoa(object->pg_color); - superpage_offset = offset & SEGMASK; - if (size - ((NBSEG - superpage_offset) & SEGMASK) < NBSEG || - (*addr & SEGMASK) == superpage_offset) + superpage_offset = offset & PDRMASK; + if (size - ((PDRSIZE - superpage_offset) & PDRMASK) < PDRSIZE || + (*addr & PDRMASK) == superpage_offset) return; - if ((*addr & SEGMASK) < superpage_offset) - *addr = (*addr & ~SEGMASK) + superpage_offset; + if ((*addr & PDRMASK) < superpage_offset) + *addr = (*addr & ~PDRMASK) + superpage_offset; else - *addr = ((*addr + SEGMASK) & ~SEGMASK) + superpage_offset; + *addr = ((*addr + PDRMASK) & ~PDRMASK) + superpage_offset; } #ifdef DDB _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"