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)
Apr 1 2024, 1:13 PM
Unknown Object (File)
Dec 23 2023, 12:06 AM
Unknown Object (File)
Aug 27 2023, 2:36 PM
Unknown Object (File)
Aug 13 2023, 6:32 AM
Unknown Object (File)
Aug 8 2023, 6:44 PM
Unknown Object (File)
May 14 2023, 8:26 PM
Unknown Object (File)
May 14 2023, 8:19 PM
Unknown Object (File)
May 14 2023, 8:05 PM
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.