Page MenuHomeFreeBSD

Several bug fixes and robustness improvements for the AP boot page table allocation.
ClosedPublic

Authored by kib on Aug 26 2018, 1:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 5, 12:52 AM
Unknown Object (File)
Mar 7 2024, 7:53 PM
Unknown Object (File)
Feb 14 2024, 9:40 AM
Unknown Object (File)
Feb 14 2024, 9:40 AM
Unknown Object (File)
Feb 14 2024, 9:40 AM
Unknown Object (File)
Feb 14 2024, 9:40 AM
Unknown Object (File)
Feb 14 2024, 9:27 AM
Unknown Object (File)
Feb 13 2024, 9:26 AM

Details

Summary

At the time that mp_bootaddress() is called, phys_avail[] array does not reflect some memory reservations already done, like kernel placement. Recent changes to DMAP protection which make kernel text read-only in DMAP revealed this, where on some machines AP boot page tables selection appears to intersect with the kernel itself.

Fix this by checking the addresses selected using the same algorithm as bootaddr_rwx(). Also, try to chomp pages for the page table not only at the start of the contiguous range, but also at the end. This should improve robustness when the only suitable range is already consumed by the kernel.

N.B. I think that phys_avail[] manipulation functions from D16719 can be usefully applied there. At least, this code is very good testing place for that revision.

Reported and tested by: Michael Gmelin <freebsd@grem.de>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 19186

Event Timeline

Accepting to confirm that I tested this patch one more time against r338318 on the Acer Chromebook c720 (previous test was against an older version of the kernel). Obviously my feedback isn't sufficient and this still requires review by the original reviewers (aka experts).

This revision is now accepted and ready to land.Aug 27 2018, 11:24 AM
sys/amd64/amd64/mp_machdep.c
149

Hmm, the 'end' here seems overly conservative. It seems like you kind of want something like 'end = start + AP_BOOTPT_SZ' as you do below for the "chomp at the end". You would have to add the same type of overflow check ('end <= physmap[i + 1]'). (That is, suppose you had some region much larger than 3 page and the start was ok, but 'end' wasn't for some reason, you would skip it.)

sys/amd64/amd64/mp_machdep.c
149

I see. Then is_mpboot_good() does not need end >= start + AP_BOOT_SZ check, which brings back the symmetry.

kib marked an inline comment as done.

When chomping at start, only check that start and start + 3 pages do not fall into kernel memory.
Also check for overflows.

This revision now requires review to proceed.Aug 27 2018, 4:43 PM
This revision is now accepted and ready to land.Aug 27 2018, 5:19 PM

Tested again, new version also works as expected, mptramp_pagetables is 0x7bf77000 on c720

This revision was automatically updated to reflect the committed changes.