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)
Fri, Nov 21, 12:43 AM
Unknown Object (File)
Fri, Nov 21, 12:37 AM
Unknown Object (File)
Fri, Nov 21, 12:35 AM
Unknown Object (File)
Fri, Nov 21, 12:35 AM
Unknown Object (File)
Mon, Nov 17, 1:26 AM
Unknown Object (File)
Sun, Nov 16, 11:04 PM
Unknown Object (File)
Sun, Nov 16, 9:34 PM
Unknown Object (File)
Mon, Nov 10, 3:05 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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34002
Build 31191: arc lint + arc unit

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.