Page MenuHomeFreeBSD

vm_phys_add_seg(): Check for bad segments, allow empty ones
ClosedPublic

Authored by olce on Jan 23 2025, 5:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 19, 8:16 PM
Unknown Object (File)
Wed, Feb 12, 5:45 PM
Unknown Object (File)
Mon, Feb 10, 12:58 AM
Unknown Object (File)
Feb 2 2025, 4:26 AM
Unknown Object (File)
Feb 1 2025, 4:24 AM
Unknown Object (File)
Jan 29 2025, 6:53 AM
Unknown Object (File)
Jan 28 2025, 7:51 AM
Unknown Object (File)
Jan 28 2025, 12:11 AM
Subscribers

Details

Summary

A bad specification is if 'start' is strictly greater than 'end', or
bounds are not page aligned.

The latter was already tested under INVARIANTS, but now will be also on
production kernels. The reason is that vm_phys_early_startup() pours
early segments into the final phys_segs[] array via vm_phys_add_seg(),
but vm_phys_early_add_seg() did not check their validity. Checking
segments once and for all in vm_phys_add_seg() avoids duplicating
validity tests and is possible since early segments are not used before
being poured into phys_segs[]. Finally, vm_phys_add_seg() is not
performance critical.

Allow empty segments and discard them (silently, unless 'bootverbose' is
true), as vm_page_startup() was testing for this case before calling
vm_phys_add_seg(), and we felt the same test in vm_phys_early_startup()
was due before calling vm_phys_add_seg(). As a consequence, remove the
empty segment test from vm_page_startup().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable