Page MenuHomeFreeBSD

amd64: fix sysctl vm.pmap.kernel_maps
ClosedPublic

Authored by kib on Jul 21 2025, 2:33 PM.
Tags
None
Referenced Files
F131895510: D51453.id158894.diff
Sun, Oct 12, 1:20 AM
F131895497: D51453.id158866.diff
Sun, Oct 12, 1:20 AM
F131895486: D51453.id.diff
Sun, Oct 12, 1:19 AM
F131895484: D51453.id158898.diff
Sun, Oct 12, 1:19 AM
F131844427: D51453.diff
Sat, Oct 11, 3:49 PM
Unknown Object (File)
Thu, Oct 9, 3:03 AM
Unknown Object (File)
Sat, Sep 20, 7:22 PM
Unknown Object (File)
Sep 12 2025, 2:11 AM
Subscribers

Details

Summary
amd64 pmap: only link as many DMAP pml4 page tables as was allocated


amd64 K*SAN: add kva_layout members for K*SAN maps

The members are added regardless of the kernel config.


amd64 pmap: add kva_layout.kva_max

And use it instead of manually providing the same value as sentinel in
code for sysctl vm.pmap.kernel_maps.


amd64 sysctl_kmaps_check(): add pml5e arg

For now all callers pass zero.


amd64 vm.pmap.kernel_maps: provide canonical address switch for la57


amd64 sysctl vm.pmap.kernel_maps: rework

Iterate over the KVA instead of the pml4 indexes.  Otherwise, we would
need to iterate of pml5 indexes for LA57 and then either use secondary
loop for pml4 entries, or use flat indexes for pml4.  It is simpler to
have unified loop for both paging modes.

Instead of checking pml4 indexes for start of interesting kernel maps,
use kva_layout.  Again, this makes the printing of heralds independent
of the paging mode.

Restart the loop iteration when changing address due to
canonicalization.  This is needed to not miss printing the map herald
line.

Diff Detail

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

Event Timeline

kib requested review of this revision.Jul 21 2025, 2:33 PM
sys/amd64/amd64/pmap.c
498
510
11982

What does UB mean here?

sys/amd64/include/vmparam.h
203 ↗(On Diff #158866)
204 ↗(On Diff #158866)
kib marked 5 inline comments as done.Jul 22 2025, 1:08 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
11982

Undefined behavior.

Without the intialization, la48 pmap would read uninitialized pml5e to pass its value to sysctl_kmaps_check().

kib marked an inline comment as done.

Convert all K*SAN_MIN/MAX_ADDRESSes to kva_layout members.
Remove spare '\'.

This revision is now accepted and ready to land.Jul 22 2025, 1:38 PM