* vm_page_zero_invalid() * * The kernel assumes that the invalid portions of a page contain * garbage, but such pages can be mapped into memory by user code. * When this occurs, we must zero out the non-valid portions of the * page so user code sees what it expects. * * Pages are most often semi-valid when the end of a file is mapped * into memory and the file's size is not page aligned.
| 5276 | * into memory and the file's size is not page aligned. |
| 5277 | */ |
| 5278 | void |
| 5279 | vm_page_zero_invalid(vm_page_t m, boolean_t setvalid) |
| 5280 | { |
| 5281 | int b; |
| 5282 | int i; |
| 5283 | |
| 5284 | /* |
| 5285 | * Scan the valid bits looking for invalid sections that |
| 5286 | * must be zeroed. Invalid sub-DEV_BSIZE'd areas ( where the |
| 5287 | * valid bit may be set ) have already been zeroed by |
| 5288 | * vm_page_set_validclean(). |
| 5289 | */ |
| 5290 | for (b = i = 0; i <= PAGE_SIZE / DEV_BSIZE; ++i) { |
| 5291 | if (i == (PAGE_SIZE / DEV_BSIZE) || |
| 5292 | (m->valid & ((vm_page_bits_t)1 << i))) { |
| 5293 | if (i > b) { |
| 5294 | pmap_zero_page_area(m, |
| 5295 | b << DEV_BSHIFT, (i - b) << DEV_BSHIFT); |
| 5296 | } |
| 5297 | b = i + 1; |
| 5298 | } |
| 5299 | } |
| 5300 | |
| 5301 | /* |
| 5302 | * setvalid is TRUE when we can safely set the zero'd areas |
| 5303 | * as being valid. We can do this if there are no cache consistancy |
| 5304 | * issues. e.g. it is ok to do with UFS, but not ok to do with NFS. |
| 5305 | */ |
| 5306 | if (setvalid) |
| 5307 | vm_page_valid(m); |
| 5308 | } |
| 5309 | |
| 5310 | /* |
| 5311 | * vm_page_is_valid: |
no test coverage detected