Changeset 26512 in vbox for trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
- Timestamp:
- Feb 14, 2010 9:47:37 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57683
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
r22632 r26512 182 182 */ 183 183 if (RT_LIKELY(ioctl(pThis->hDevice, uFunction, pvReq) >= 0)) 184 184 return VINF_SUCCESS; 185 185 186 186 /* This is the reverse operation of the one found in SUPDrv-linux.c */ … … 217 217 char *pvPages = (char *)mmap(NULL, cbMmap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 218 218 if (pvPages == MAP_FAILED) 219 219 return VERR_NO_MEMORY; 220 220 221 221 if (pThis->fSysMadviseWorks) 222 222 { 223 224 225 226 227 228 229 230 231 223 /* 224 * It is not fatal if we fail here but a forked child (e.g. the ALSA sound server) 225 * could crash. Linux < 2.6.16 does not implement madvise(MADV_DONTFORK) but the 226 * kernel seems to split bigger VMAs and that is all that we want -- later we set the 227 * VM_DONTCOPY attribute in supdrvOSLockMemOne(). 228 */ 229 if (madvise (pvPages, cbMmap, MADV_DONTFORK)) 230 LogRel(("SUPLib: madvise %p-%p failed\n", pvPages, cbMmap)); 231 *ppvPages = pvPages; 232 232 } 233 233 else 234 234 { 235 236 237 238 239 240 241 242 235 /* 236 * madvise(MADV_DONTFORK) is not available (most probably Linux 2.4). Enclose any 237 * mmapped region by two unmapped pages to guarantee that there is exactly one VM 238 * area struct of the very same size as the mmap area. 239 */ 240 mprotect(pvPages, PAGE_SIZE, PROT_NONE); 241 mprotect(pvPages + cbMmap - PAGE_SIZE, PAGE_SIZE, PROT_NONE); 242 *ppvPages = pvPages + PAGE_SIZE; 243 243 } 244 244 memset(*ppvPages, 0, cPages << PAGE_SHIFT);
Note:
See TracChangeset
for help on using the changeset viewer.