Page MenuHomeFreeBSD

sys: add safe_read(9)
Needs ReviewPublic

Authored by kib on Mar 29 2025, 5:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 23, 1:23 PM
Unknown Object (File)
Sat, May 2, 5:09 PM
Unknown Object (File)
Sat, May 2, 12:42 PM
Unknown Object (File)
Fri, May 1, 4:09 PM
Unknown Object (File)
Thu, Apr 30, 3:47 AM
Unknown Object (File)
Thu, Apr 30, 3:47 AM
Unknown Object (File)
Wed, Apr 29, 1:25 AM
Unknown Object (File)
Mon, Apr 27, 3:16 PM

Details

Reviewers
emaste
markj
jhb
Summary
amd64: extract uiomove_mem() from memrw()


The MD function with MI interface to provide a way to read arbitrary
(canonical) KVA.  amd64 only for now.

Tested by:      aokblast

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Mar 29 2025, 5:18 PM

Slightly different version, avoid the thread-private flag.

kib retitled this revision from safe_read to sys: add safe_read(9).
kib edited the summary of this revision. (Show Details)
kib added reviewers: emaste, markj, jhb.
sys/amd64/amd64/trap.c
797 ↗(On Diff #178476)

Maybe it should be formulated as if (__predict_false(!usermode && ...?

sys/sys/systm.h
557
559
kib marked 2 inline comments as done.Sat, May 23, 5:58 PM
kib added inline comments.
sys/amd64/amd64/trap.c
797 ↗(On Diff #178476)

I believe that the first check for tf_rip makes the shortest path through the condition: userspace must work hard to fault with this specific %rip, and kernel most likely would not fault on safe_read_read with other conditions false.

kib edited the summary of this revision. (Show Details)

Complete overhaul. Stop modifying page fault handler at all. Reuse code from mem.c.