Page MenuHomeFreeBSD

Implement the ksyms mmap interface using d_mmap_single.
ClosedPublic

Authored by markj on Jul 31 2017, 1:22 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 23, 12:20 AM
Unknown Object (File)
Feb 16 2024, 8:31 PM
Unknown Object (File)
Jan 21 2024, 12:19 AM
Unknown Object (File)
Dec 22 2023, 10:16 PM
Unknown Object (File)
Nov 28 2023, 7:07 AM
Unknown Object (File)
Sep 1 2023, 7:13 PM
Unknown Object (File)
Sep 1 2023, 7:13 PM
Unknown Object (File)
Sep 1 2023, 7:10 PM
Subscribers
None

Details

Summary

This attempts to fix mmap(/dev/ksyms). In particular, we now
preallocate a VM object for the pages backing the symbol table and allow
it to be shared among processes that share the device file handle.

While here, fix some unrelated bugs:

  • don't call the dtor if ksyms_open() fails, since devfs_open() will do that for us
  • check for errors from copyout()
  • use an sx lock instead of a mutex to allow M_WAITOK allocations
Test Plan

Only basic functional testing of the mmap and ioctl interfaces so far.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 10803
Build 11197: arc lint + arc unit

Event Timeline

markj added reviewers: kib, alc.
sys/dev/ksyms/ksyms.c
410

Why is this limitation useful ?

480–483

Can the addition overflow ?

496

As was noted in the presentation, close might happen in the context of the process which is different from the process where open occured.

sys/dev/ksyms/ksyms.c
410

I can't see a reason.

480–483

I think so.

496

Hm, right. I think this behaviour of mapping on open is not really supportable - there is no reliable way to remove the mapping on close.

Further cleanups:

  • Remove the ksyms ioctl interface. lockstat was modified to work without it, and the interface isn't present in Solaris/illumos.
  • Don't map the object into the opening process. We have no good way of removing the mapping when the device is closed.
  • Use uiomove_object() to copy the ELF file into the object, and in ksyms_read().
sys/dev/ksyms/ksyms.c
410

I think I'll remove this, but would prefer to do so in a separate revision.

496

I addressed this by simply removing the ioctl interface, which effectively removes the need to manually map the image into the process' address space.

kib added inline comments.
sys/dev/ksyms/ksyms.c
492

You may remove empty ksyms_close(). kern_conf.c automatically substitutes NULL d_close with the same stub.

This revision is now accepted and ready to land.Aug 2 2017, 8:12 AM
This revision was automatically updated to reflect the committed changes.