Page MenuHomeFreeBSD

sys: do not allow entering vm_fault() on boot until VM is initialized
ClosedPublic

Authored by kib on Sun, Jan 18, 9:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 25, 11:21 AM
Unknown Object (File)
Sun, Jan 25, 11:21 AM
Unknown Object (File)
Sun, Jan 25, 11:21 AM
Unknown Object (File)
Sun, Jan 25, 8:23 AM
Unknown Object (File)
Sun, Jan 25, 8:23 AM
Unknown Object (File)
Sun, Jan 25, 8:23 AM
Unknown Object (File)
Sun, Jan 25, 6:42 AM
Unknown Object (File)
Tue, Jan 20, 10:28 AM
Subscribers

Details

Summary
On amd64, a hack sets td_critnest to 1 in hammer_time(), and then clear
it before returning from hammer_time(), which is too early.  Instead,
set TDP_NOFAULTING for thread0, and clear the flag after vm_init() finished.

Noted by:       adrian

Diff Detail

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

Event Timeline

kib requested review of this revision.Sun, Jan 18, 9:18 PM
This revision is now accepted and ready to land.Sun, Jan 18, 9:20 PM
kib edited the summary of this revision. (Show Details)

Make this MI.

This revision now requires review to proceed.Sun, Jan 18, 10:58 PM

To be clear, the point is to have an explicit panic rather than a boot hang because we end up spinning in an uninitialized trap handler?

sys/vm/vm_init.c
162

I'd add a comment pointing to where this flag is set.

kib marked an inline comment as done.Mon, Jan 19, 3:58 PM

To be clear, the point is to have an explicit panic rather than a boot hang because we end up spinning in an uninitialized trap handler?

It is not necessarily a hang. For instance, kernel_map is not yet initialized, so we are locking non-initialized sx because MAP_SYSTEM_MAP is not set (instead of locking uninitialized mutex). This triggers witness panics AFAIR from the report, but in non-debugging kernels might cause e.g. attempt to use uninitialized sleepqueues which would also fail somehow. So it might end up with anything, as should be for UB in its real sense.

This revision is now accepted and ready to land.Mon, Jan 19, 3:59 PM

Add comment in vm_init.c

This revision now requires review to proceed.Mon, Jan 19, 4:01 PM

Save file before diffing.

This revision is now accepted and ready to land.Mon, Jan 19, 4:15 PM