Page MenuHomeFreeBSD

riscv: Handle supervisor instruction page faults
ClosedPublic

Authored by jrtc27 on Oct 5 2020, 6:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 10, 10:21 AM
Unknown Object (File)
Mon, Dec 9, 2:09 PM
Unknown Object (File)
Nov 22 2024, 7:46 PM
Unknown Object (File)
Nov 16 2024, 5:10 PM
Unknown Object (File)
Nov 14 2024, 8:15 AM
Unknown Object (File)
Nov 10 2024, 9:03 PM
Unknown Object (File)
Oct 5 2024, 12:18 PM
Unknown Object (File)
Oct 4 2024, 3:35 AM
Subscribers

Details

Summary

We should never take instruction page faults when in the kernel, but by
using the standard page fault code we should get a more-informative
message about faulting on a NOFAULT page rather than branching to the
default case here and printing an "Unknown kernel exception ..."
message.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jrtc27 requested review of this revision.Oct 5 2020, 6:27 PM
jrtc27 created this revision.
jhb added a subscriber: jhb.

Minor typo in commit log: s/shold/should/

This revision is now accepted and ready to land.Oct 5 2020, 7:54 PM

Somewhat related, Wes from Cambridge had noted a while back that if we get a fault due to a SUM violation, we will just keep retrying the fault endlessly instead of panicking. That check probably belongs somewhere in the page_fault_handler function.

markj added a subscriber: markj.
In D26685#594577, @jhb wrote:

Somewhat related, Wes from Cambridge had noted a while back that if we get a fault due to a SUM violation, we will just keep retrying the fault endlessly instead of panicking. That check probably belongs somewhere in the page_fault_handler function.

Isn't that handled by the pcb->pcb_onfault == 0 check in the !usermode case?

In D26685#594577, @jhb wrote:

Somewhat related, Wes from Cambridge had noted a while back that if we get a fault due to a SUM violation, we will just keep retrying the fault endlessly instead of panicking. That check probably belongs somewhere in the page_fault_handler function.

Isn't that handled by the pcb->pcb_onfault == 0 check in the !usermode case?

I _think_ the concern was if you have a non-zero pcb_onfault (e.g. you forget to clear it) but SUM is clear and try to access a valid userspace address then pmap_fault_fixup or vm_fault_trap will succeed and you will keep retrying the instruction.

This revision was automatically updated to reflect the committed changes.
In D26685#594577, @jhb wrote:

Somewhat related, Wes from Cambridge had noted a while back that if we get a fault due to a SUM violation, we will just keep retrying the fault endlessly instead of panicking. That check probably belongs somewhere in the page_fault_handler function.

Isn't that handled by the pcb->pcb_onfault == 0 check in the !usermode case?

I _think_ the concern was if you have a non-zero pcb_onfault (e.g. you forget to clear it) but SUM is clear and try to access a valid userspace address then pmap_fault_fixup or vm_fault_trap will succeed and you will keep retrying the instruction.

I do think we should validate the SUM bit in page_fault_handler(). I just assumed that someone had actually managed to trigger this bug and was a bit surprised since SSTATUS_SUM and pcb_onfault are always(?) manipulated together.