Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/kern_ksyms.c
RevisionDateAuthorComments
 1.109  03-Oct-2024  andvar s/preudo/pseudo/ in comment.
 1.108  21-Feb-2023  riastradh ksyms(4): Reject negative offsets earlier in lseek.

Avoid arithmetic overflow.

XXX pullup-10
 1.107  15-Jul-2022  mrg branches: 1.107.4;
convert "ksyms: checking <symbol>" into KSYMS_DEBUG over normal DEBUG.
 1.106  06-Jul-2022  riastradh uvm(9): fo_mmap caller guarantees positive size.

No functional change intended, just sprinkling assertions to make it
clearer.
 1.105  22-Sep-2021  rin ksymsmmap: Add missing uao_reference(9) call for ks->ks_uobj.

Fix failure for savecore(8) and subsequent kernel panic, introduced to
kern_ksyms.c rev 1.03, at least for sh3 and alpha.

For sh3 and alpha, savecore(8) supports coff and ecoff, respectively, via
libkvm via nlist(3). nlist(3) routines for coff and ecoff use mmap(2) and
munmap(2) for /dev/ksyms.

This munmap(2) decrements reference count for ks->ks_uobj. Unless it is
incremented in ksymsmmap(), ks->ks_uobj will be freed unexpectedly.
 1.104  11-Sep-2021  riastradh ksyms: Use pserialize(9) for kernel access to ksyms.

This makes it available in interrupt context, e.g. for printing
messages with kernel symbol names for return addresses as drm wants
to do.
 1.103  11-Sep-2021  riastradh ksyms(4): Take a complete snapshot on each open.

- Snapshots are stored in pageable anonymous uvm objects.
- Snapshots are reference-counted so they can be reused across opens.
- Opening /dev/ksyms blocks module unload until snapshot is taken.
- Merely holding /dev/ksyms open does not block module unload.
- /dev/ksyms is now mmappable.

This slightly changes the behaviour of fstat(2) on /dev/ksyms -- it
is a little more useful now! In particular, st_size is the size of
the symbol table. Some other fields which were not very useful to
begin with -- st_dev, st_ino, st_mode, st_nlink, st_*time,
st_blksize, st_blocks -- are now different, and independent of the
file system on which the device node resides.

Discussed in

https://mail-index.netbsd.org/source-changes-d/2021/08/17/msg013425.html

This is option (3), adapted to make the ksyms snapshots pageable,
after options (1) and (2) posed practical problems.
 1.102  07-Sep-2021  riastradh Revert "ksyms(4): Simply block unload until last /dev/ksyms close."

This appears to break t_execsnoop -- presumably something goes wrong
with how libdtrace uses ksyms. To investigate.
 1.101  07-Sep-2021  riastradh Revert "ksyms: Use pserialize(9) for kernel access to ksyms."
 1.100  07-Sep-2021  riastradh ksyms: Use pserialize(9) for kernel access to ksyms.

This makes it available in interrupt context, e.g. for printing
messages with kernel symbol names for return addresses as drm wants
to do.
 1.99  07-Sep-2021  riastradh ksyms(4): Simply block unload until last /dev/ksyms close.

Otherwise, readers may get a garbled snapshot of ksyms (or a crash on
an assertion failure because of the garbled snapshot) if modules are
unloaded while they read.

https://mail-index.netbsd.org/source-changes-d/2021/08/17/msg013425.html
 1.98  18-Jul-2021  mlelstv skip symbol tables that were unloaded again to avoid EFAULT when reading
ksyms.

also restore TAILQ_FOREACH idiom.
 1.97  03-Jun-2021  riastradh ksyms(4): Allow multiple concurrent opens of /dev/ksyms.

First one takes a snapshot; others all agree with the snapshot.

Previously this code path was just broken (could fail horribly if
modules were unloaded after one of the opens is closed), so I just
blocked it off in an earlier commit, but that broke crash(8). So
let's continue allowing multiple opens seeing the same snapshot, but
without the horrible bugs.
 1.96  03-Jun-2021  riastradh ksyms(4): Don't skip symbol tables that are soon to be freed, take 2.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.

The previous change was busted because of an off-by-one error in a
previous previous change's iteration over the symtabs; that error has
since been corrected.
 1.95  03-Jun-2021  riastradh ksyms(4): Fix race in ksymsread iteration.

TAILQ_NEXT(ksyms_last_snapshot) might change while we are iterating,
but ksyms_last_snapshot itself cannot, so invert the loop structure.

Discussed with rin@.
 1.94  02-Jun-2021  rin Fix regression introduced in rev 1.90:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_ksyms.c#rev1.90

in which the last element of ksyms_symtabs is skipped by mistake.
 1.93  02-Jun-2021  riastradh branches: 1.93.2;
Revert "ksyms(4): Don't skip symbol tables that are soon to be freed."

Apparently the equality kassert this restored doesn't work; to be
analyzed.
 1.92  01-Jun-2021  riastradh ksyms(4): Don't skip symbol tables that are soon to be freed.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.
 1.91  01-Jun-2021  riastradh ksyms(4): Modify ksyms_symtabs only at IPL_HIGH.

This limits the opportunities for ddb to witness an inconsistent
state of the symbol table list.
 1.90  01-Jun-2021  riastradh ksyms(4): Fix ksymsread synchronization.

Fixes crash on concurrent update and read of /dev/ksyms.

XXX Unclear why we have to skip sd_gone entries here -- it seems like
they should be preserved until ksymsclose.
 1.89  23-Sep-2020  simonb branches: 1.89.6;
The current MIPS DDB stacktrace code doesn't work if no symbols are
available, so fall back to old-fashioned unwind code if no symbols.
 1.88  05-Jan-2020  pgoyette When reading from /dev/ksyms we need to skip over entries that have
been marked as sd_gone. Otherwise we might try to uiomove() data from
memory that has been unmapped, resulting in EFAULT.

XXX This (along with other pre-existing checks st->sd_gone) is still
racy, but it's an improvement over current code. Ideally we would
make a complete copy of the symbol table when we open /dev/ksyms so
we could ignore any changes that occur.

ad@ says "good enough for now"

XXX Pullup to -9 and -8
 1.87  04-Nov-2017  christos branches: 1.87.4; 1.87.8;
use Elf_Sym ** instead of casting.
 1.86  03-Nov-2017  maxv Handle absolute relocations coming from the kernel: preserve SHN_ABS in
the kernel and module symbols, and when relocating a symbol that has
SHN_ABS, take its value as-is and don't return an error if it equals zero.

Sent on tech-kern@.
 1.85  14-Jun-2017  chs create an nmap table for module symtabs too.
needed by dtrace.
 1.84  07-Jul-2016  msaitoh branches: 1.84.10;
KNF. Remove extra spaces. No functional change.
 1.83  27-Dec-2015  gson KSYMS_MAX_ID is too small for i386 kernels built with MKDEBUG=yes,
causing a number of ATF tests to fail. Increase it by 50%, from 65536
to 98304.
 1.82  09-Dec-2015  maxv KNF
 1.81  30-Aug-2015  uebayasi Use makeoptions_COPY_SYMTAB via opt_copy_symtab.h in sources. Remove a hack
to set -DCOPY_SYMTAB from sys/conf/Makefile.kern.inc. Remove unnecessary
dependencies too.
 1.80  27-Aug-2015  uebayasi Constify a little.
 1.79  21-Aug-2015  christos we don't need ioconf.h if we don't have the ksyms pseudo-device
 1.78  21-Aug-2015  christos If we don't have a pseudo-device, we don't need the attach function.
 1.77  20-Aug-2015  christos include ioconf.h instead of locally declaring the prototype of the attach
function
 1.76  20-May-2015  matt Change the ksyms ioctls to more compat_netbsd32 friendly. Use _IOWR ioctls
to avoid extra copyouts. With these changes, netstat and vmstat work on
mips64eb with the normal N32 userland and a N64 kernel.
 1.75  15-Dec-2014  christos Don't hard code crap we have perfectly good constants for.
 1.74  09-Dec-2014  christos - use the unused section in the array to put a NetBSD note in it
- cleanup the hard-coded constants in the stringtab
 1.73  17-Aug-2014  joerg branches: 1.73.2;
Reorganize symbol table embedding. The existing option SYMTAB_SPACE is
replaced by the make option COPY_SYMTAB set to any value. The copy of
the symbol table is no longer put into a buffer in kern_ksyms.o, but a
small helper object. This object is build first with a dummy size, then
the kernel is linked to compute the real dimension of the symbol table
buffer. After that, the helper object is rebuild and the kernel linked
again.
 1.72  25-Jul-2014  dholland branches: 1.72.2; 1.72.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.71  16-Mar-2014  dholland branches: 1.71.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.70  07-Apr-2013  chs branches: 1.70.4;
don't overwrite the CTF info with the symbol table.
 1.69  17-Jan-2013  matt Add a separate bool to indicate a symbol table has been loaded.
ksym_initted indicates whether the kmutex has been initted or not.
Add __cacheline_aligned to the kmutex.
 1.68  18-Nov-2012  chs make ksyms structures not depend on KDTRACE_HOOKS.
always include a CTF section, even though it might be empty.
this fixes savecore's generated kernel symbol table files.
 1.67  05-Dec-2011  christos branches: 1.67.6;
close the comment, there is a draft.
 1.66  05-Dec-2011  christos PR/45687: Mike Pumford: savecore: (null): _ksyms_hdr not in namelist
Make it non-static and add a comment so that they don't become static again.
 1.65  28-Jul-2011  uebayasi branches: 1.65.2; 1.65.6;
Define SYMTAB_SPACE in opt_ksyms.h, not opt_ddbparam.h. Ensure
that ddb(4) code is independent of SYMTAB_SPACE value.
 1.64  27-Jul-2011  uebayasi These don't need uvm/uvm_extern.h.
 1.63  24-Apr-2011  rmind - Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.
 1.62  04-Jan-2011  matt branches: 1.62.2;
When determining max/min sym value, ignore ABS symbols which don't
have a type. This stops ksym thinking that the _KERNEL_OPT symbols
could actually be useful.
 1.61  27-Jul-2010  jakllsch Use 'z' printf format modifier to print size_t in debug code.
 1.60  04-May-2010  tsutsui Some KNF.
 1.59  03-May-2010  darran DTrace: Fix several bugs where the mod_ctf_get() function could return
success even though no CTF section was present in the kernel or module.
This fixes the panic that several people saw when trying out the FBT
provider without updating /boot or missing a CTF section in /netbsd.
 1.58  14-Mar-2010  darran branches: 1.58.2;
DTrace: Make the CTF handling conditional on KDTRACE_HOOKS for now since
it breaks the boot of the atari kernel (and possibly others).
 1.57  13-Mar-2010  christos make this compile.
 1.56  12-Mar-2010  darran DTrace: Add support for CTF sections in the netbsd elf image, load these
at boot.
Add a ksyms_mod_foreach() function to iterate a callback function over the
set of elf symbols for a specific module (netbsd included).
Add kern_ctf.c and mod_ctf_get() to allow the retrieval and decompression
of CTF sections for a specific module.
 1.55  01-Mar-2010  darran Revert accidental commit of CTF work-in-progress changes.
 1.54  01-Mar-2010  darran DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
 1.53  31-Jan-2010  hubertf branches: 1.53.2;
Replace more printfs with aprint_normal / aprint_verbose
Makes "boot -z" go mostly silent for me.
 1.52  25-Nov-2009  pooka Remove highly questionable assert which demans that the kernel symbol
table is in memory at a lower address than the string table.
 1.51  15-Mar-2009  cegger ansify function definitions
 1.50  23-Jan-2009  jmmv branches: 1.50.2;
Initialize SYMTAB_SPACE ksyms during ksyms_init. Per PR port-evbarm/40311.
 1.49  01-Jan-2009  pooka _KERNEL_OPT
 1.48  05-Dec-2008  ad Make the fake ELF object work with gdb.

- Output a .bss section and make all the symbols relative to it, instead
of making them absolute.
- Output a single load section, no need for two.

'gdb /dev/ksyms' still doesn't work because ksyms doesn't do mmap yet.
 1.47  30-Nov-2008  martin As discussed on tech-kern: mutex_init is too heavyweight for early bootstrap
phases, so move the initialization of the ksyms mutex back into main via
a function called ksyms_init. Rename the existing (but quite different)
ksyms_init* variations into ksyms_addsyms_elf() and ksyms_addsyms_explicit()
and adapt machdep code accordingly.
 1.46  16-Nov-2008  ad Our qsort() is inappropriate for kernel use because it makes recursive
calls. Replace it with a kheapsort() function in kernel. Pointed out
by tron@.
 1.45  16-Nov-2008  ad Remove unneeded includes.
 1.44  16-Nov-2008  ad Fix ksyms_getname() broken in previous.
 1.43  16-Nov-2008  ad - Local symbols could shadow globals in some instances. Fix it.

- mutex_enter() from ksyms_getval() could panic due to a change made
in revision 1.40. Fix it.

- Replace the p-tree with a binary search of global symbols. Saves about
250kB of wired memory on i386 and allows for faster lookups within
module symbol tables.
 1.42  12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.41  24-Oct-2008  christos branches: 1.41.2; 1.41.4;
don't hold locks in ddb (call ksyms_getval_unlocked()), pointed out by ad.
 1.40  23-Oct-2008  christos don't expose ksyms_lock
 1.39  20-Oct-2008  ad PR kern/38814 ksyms needs locking

- Make ksyms MT safe.
- Fix deadlock from an operation like "modload foo.lkm < /dev/ksyms".
- Fix uninitialized structure members.
- Reduce memory footprint for loaded modules.
- Export ksyms structures for kernel grovellers like savecore.
- Some KNF.
 1.38  10-Oct-2008  skrll RCSID police.
 1.37  06-Oct-2008  ad PR kern/39681 ddb doesn't work with new MODULAR modules

Complete initialization of new symbol table record.
 1.36  22-Jul-2008  christos report local symbols too.
 1.35  20-Feb-2008  matt branches: 1.35.6; 1.35.10; 1.35.12; 1.35.14; 1.35.16;
For each symtab, remember which symbols have the minimum and maximum value.
When returning a "close" symbol, make sure the value being searched for is
within the symtab. This prevents ddb matching addresses beyond the end of
the kernel.
 1.34  04-Jan-2008  ad Ignore symbols marked undefined.
 1.33  02-Apr-2007  christos branches: 1.33.10; 1.33.16; 1.33.22;
Don't panic if we don't find a symbol or string table. Perhaps the kernel
has been stripped?
 1.32  04-Mar-2007  christos branches: 1.32.2; 1.32.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.31  06-Nov-2006  jmmv branches: 1.31.4;
Pass a simple ELF header to ksyms_init_explicit with the minimum contents
required to initialize ksyms_hdr. Otherwise LKMs do not work when using
ksyms_init_explicit instead of ksyms_init, as is the case of booting an
i386 kernel using Multiboot.
 1.30  01-Nov-2006  yamt remove some __unused from function parameters.
 1.29  25-Oct-2006  jmmv Add a function (ksyms_init_explicit) to add a symbol table when we know the
exact address of the symtab and strtab ELF sections contents beforehand.

This will be used in i386's Multiboot code to add the initial kernel ksyms
without having to prepare a minimal ELF image that matches the format
expected by the reguluar ksyms_init function.

This part was reviewed by cube@ and successfully passes a full i386 release
build.
 1.28  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.27  11-Dec-2005  christos branches: 1.27.20; 1.27.22;
merge ktrace-lwp.
 1.26  25-Jun-2005  riz branches: 1.26.2;
Use %zx in a format string to print a size_t, not %lx, so a kernel
with KSYMS_DEBUG will compile.
 1.25  23-Jun-2005  thorpej Use ANSI function decls. Apply some static.
 1.24  29-May-2005  christos - add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.
 1.23  26-Feb-2005  perry branches: 1.23.2;
nuke trailing whitespace
 1.22  15-Feb-2005  cube The way I handled /dev/ksyms requests vs. kernel requests was completely
broken. Inside the kernel, we always have to use the real values of the
st_name fields, and only do the math when the request comes from userland.

No need for ksyms_getval_from{kernel,userland} hack anymore. However, a
different version will be asked for pull-up in -2{,-0}, one that doesn't
break the API, that is.

Fixes PR#29133 from Jens Kessmeier.
 1.21  19-Feb-2004  matt branches: 1.21.6; 1.21.8; 1.21.10;
Move detection of a special symbol into a separate function. Add some more
special symbols.
 1.20  18-Feb-2004  matt Support really large LKMs. Find out how much space is needed for symbols
and then allocate it on demand. Rename some common symbols (__bss_start,
_edata, _end, __start_link_set_*, __stop_link_set_*) so that ".<module>"
is appended to them. This shrinks an amd64 kernel by 20KB of BSS.
 1.19  18-Feb-2004  matt s/sumbols/symbols/
 1.18  08-Jan-2004  cube If ksyms have not been initialized, return ENXIO in ksymsopen instead of
ksymsread, because ksyms client test availability with open() and not
read().
 1.17  17-Nov-2003  cube o Fix a bug in ksyms that changed the real meaning of st_name entries for
symbols, and made it impossible for the kernel to use that value, and
correctly find symbols from LKMs.
o Allow LKM users to use DDB to debug the entry function of a LKM by
loading the symbol table with the temporary name /lkmtemp/ before calling
it, and then renaming it once we know the module name.

Approved by ragge@.
 1.16  06-Nov-2003  ragge Do not try to enter more than MAX_INT16 symbols into the patricia tree;
the not-entered symbols will be found anyway but via a linear-search.
This only happens if something is wrong when linking the kernel.
Fixes problems reported on port-hp700.
 1.15  25-Oct-2003  christos fix uninitialized variables. one of them is a compiler bug.
 1.14  03-Sep-2003  ragge long -> unsigned long.
 1.13  29-Jun-2003  fvdl branches: 1.13.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.12  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.11  01-Jun-2003  jdolecek Add __KERNEL_RCSID()
 1.10  16-May-2003  itojun use strlcpy. [fixed off-by-one in subr_prop.c]
 1.9  11-May-2003  jdolecek make couple ksym functions' arguments const
 1.8  07-May-2003  ragge Remove useless entries from the symbol table at load.
Add patricia-tree-style lookup code for symbols (for fast lookups).
 1.7  02-May-2003  ragge #ifdef KSYMS_DEBUG should be #if NKSYMS.
 1.6  02-May-2003  tron Fix build problems for kernel configurations without the "ksyms"
pseudo-device.
 1.5  01-May-2003  ragge Enable the ioctl's.
 1.4  26-Apr-2003  ragge Make ksymms_init() take void * parameters instead of caddr_t.
 1.3  25-Apr-2003  ragge Mobe the SYMTAB_SPACE stuff to ksyms_init, so that it can be used without
DDB compiled-in.
 1.2  25-Apr-2003  ragge Explicitly cast printf arg to long, from Tom Spindler.
 1.1  24-Apr-2003  ragge Basic implementation of in-kernel symbol table manager + /dev/ksyms.
 1.13.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.5  17-Feb-2005  skrll Sync with HEAD.
 1.13.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.13.2.2  03-Aug-2004  skrll Sync with HEAD
 1.13.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.21.10.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.8.1  29-Apr-2005  kent sync with -current
 1.21.6.1  01-Jul-2005  tron Pull up revision 1.26 (requested by riz in ticket #2037):
Use %zx in a format string to print a size_t, not %lx, so a kernel
with KSYMS_DEBUG will compile.
 1.23.2.1  28-Jun-2005  tron Pull up revision 1.26 (requested by riz in ticket #508):
Use %zx in a format string to print a size_t, not %lx, so a kernel
with KSYMS_DEBUG will compile.
 1.26.2.5  27-Feb-2008  yamt sync with head.
 1.26.2.4  21-Jan-2008  yamt sync with head
 1.26.2.3  03-Sep-2007  yamt sync with head.
 1.26.2.2  30-Dec-2006  yamt sync with head.
 1.26.2.1  21-Jun-2006  yamt sync with head.
 1.27.22.2  10-Dec-2006  yamt sync with head.
 1.27.22.1  22-Oct-2006  yamt sync with head
 1.27.20.1  18-Nov-2006  ad Sync with head.
 1.31.4.2  15-Apr-2007  yamt sync with head.
 1.31.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.32.4.1  11-Jul-2007  mjf Sync with head.
 1.32.2.1  10-Apr-2007  ad Sync with head.
 1.33.22.1  08-Jan-2008  bouyer Sync with HEAD
 1.33.16.1  18-Feb-2008  mjf Sync with HEAD.
 1.33.10.2  23-Mar-2008  matt sync with HEAD
 1.33.10.1  09-Jan-2008  matt sync with HEAD
 1.35.16.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.35.16.1  19-Oct-2008  haad Sync with HEAD.
 1.35.14.1  28-Jul-2008  simonb Sync with head.
 1.35.12.2  10-Oct-2008  skrll Sync with HEAD.
 1.35.12.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.35.10.3  11-Aug-2010  yamt sync with head.
 1.35.10.2  11-Mar-2010  yamt sync with head
 1.35.10.1  04-May-2009  yamt sync with head.
 1.35.6.4  17-Jan-2009  mjf - Fix a CVS merge breakage
- Catch up with some driver changes
 1.35.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.35.6.2  28-Sep-2008  mjf Sync with HEAD.
 1.35.6.1  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.41.4.2  14-Feb-2010  bouyer Pull up following revision(s) (requested by hubertf in ticket #1290):
sys/kern/kern_ksyms.c: revision 1.53
sys/dev/pci/agp_via.c: revision 1.18
sys/netipsec/key.c: revision 1.63
sys/arch/x86/x86/x86_autoconf.c: revision 1.49
sys/kern/init_main.c: revision 1.415
sys/kern/cnmagic.c: revision 1.11
sys/netipsec/ipsec.c: revision 1.47
sys/arch/x86/x86/pmap.c: revision 1.100
sys/netkey/key.c: revision 1.176
Replace more printfs with aprint_normal / aprint_verbose
Makes "boot -z" go mostly silent for me.
 1.41.4.1  31-Mar-2009  snj branches: 1.41.4.1.4;
Apply patch (requested by martin in ticket 602):
ksyms_init calls mutex_init too early, which leads to failure on, e.g.,
sparc64 LOCKDEBUG kernels. Instead, add a new function ksyms_init_finalize
and call it from main. Fixed in a more intrusive and less ugly way on HEAD.
 1.41.4.1.4.1  21-Apr-2010  matt sync to netbsd-5
 1.41.2.3  28-Apr-2009  skrll Sync with HEAD.
 1.41.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.41.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.50.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.53.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.58.2.3  31-May-2011  rmind sync with head
 1.58.2.2  05-Mar-2011  rmind sync with head
 1.58.2.1  30-May-2010  rmind sync with head
 1.62.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.65.6.1  18-Feb-2012  mrg merge to -current.
 1.65.2.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.65.2.3  23-Jan-2013  yamt sync with head
 1.65.2.2  16-Jan-2013  yamt sync with (a bit old) head
 1.65.2.1  17-Apr-2012  yamt sync with head
 1.67.6.5  03-Dec-2017  jdolecek update from HEAD
 1.67.6.4  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.67.6.3  23-Jun-2013  tls resync from head
 1.67.6.2  25-Feb-2013  tls resync with head
 1.67.6.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.70.4.1  18-May-2014  rmind sync with head
 1.71.2.1  10-Aug-2014  tls Rebase.
 1.72.4.1  03-Mar-2016  martin Pull up following revision(s) (requested by pgoyette in ticket #1108):
sys/kern/kern_module.c: revision 1.107-1.110
sys/kern/kern_ksyms.c: revision 1.82
Add some additional status messages for kern.module.verbose=TRUE

Remove extraneous ')' from previous.

KNF

In module_do_load(), consolidate checking for a pre-existing module,
and return a single error value EEXIST. When making a recursive
call (to load required modules), treat a pre-existing module as
success.

Without this change, when a module was loaded by specific request
(as opposed to being loaded as a requirement of some other module),
we would always load the module from the file-system, and then
after making various sanity/compatability checks we would destroy
the new copy if there was a pre-existing copy.

Fixes PR kern/40764

XXX Note that if the module exists, we bypass all of the various
XXX "compatability" checks, including whether or not the existing
XXX module is of any particular class! (In the previous code, we
XXX checked to see if the newly-loaded copy had the correct class,
XXX but not the pre-existing copy, which could have been loaded
XXX from a different path/filename.)
 1.72.2.1  03-Mar-2016  martin Pull up following revision(s) (requested by pgoyette in ticket #1108):
sys/kern/kern_module.c: revision 1.107-1.110
sys/kern/kern_ksyms.c: revision 1.82
Add some additional status messages for kern.module.verbose=TRUE

Remove extraneous ')' from previous.

KNF

In module_do_load(), consolidate checking for a pre-existing module,
and return a single error value EEXIST. When making a recursive
call (to load required modules), treat a pre-existing module as
success.

Without this change, when a module was loaded by specific request
(as opposed to being loaded as a requirement of some other module),
we would always load the module from the file-system, and then
after making various sanity/compatability checks we would destroy
the new copy if there was a pre-existing copy.

Fixes PR kern/40764

XXX Note that if the module exists, we bypass all of the various
XXX "compatability" checks, including whether or not the existing
XXX module is of any particular class! (In the previous code, we
XXX checked to see if the newly-loaded copy had the correct class,
XXX but not the pre-existing copy, which could have been loaded
XXX from a different path/filename.)
 1.73.2.6  28-Aug-2017  skrll Sync with HEAD
 1.73.2.5  19-Mar-2016  skrll Sync with HEAD
 1.73.2.4  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.73.2.3  22-Sep-2015  skrll Sync with HEAD
 1.73.2.2  06-Jun-2015  skrll Sync with HEAD
 1.73.2.1  06-Apr-2015  skrll Sync with HEAD
 1.84.10.1  07-Jan-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #1482):

sys/kern/kern_ksyms.c: revision 1.88 (patch)

When reading from /dev/ksyms we need to skip over entries that have
been marked as sd_gone. Otherwise we might try to uiomove() data from
memory that has been unmapped, resulting in EFAULT.

XXX This (along with other pre-existing checks st->sd_gone) is still
racy, but it's an improvement over current code. Ideally we would
make a complete copy of the symbol table when we open /dev/ksyms so
we could ignore any changes that occur.

ad@ says "good enough for now"

XXX Pullup to -9 and -8
 1.87.8.2  21-Jun-2021  martin Pull up following revision(s) (requested by riastradh in ticket #1299):

sys/kern/kern_ksyms.c: revision 1.90
sys/kern/kern_ksyms.c: revision 1.91
sys/kern/kern_ksyms.c: revision 1.92
sys/kern/kern_ksyms.c: revision 1.93
sys/kern/kern_ksyms.c: revision 1.94
sys/kern/kern_ksyms.c: revision 1.95
sys/kern/kern_ksyms.c: revision 1.96
sys/kern/kern_ksyms.c: revision 1.97

ksyms(4): Fix ksymsread synchronization.

Fixes crash on concurrent update and read of /dev/ksyms.
XXX Unclear why we have to skip sd_gone entries here -- it seems like
they should be preserved until ksymsclose.
ksyms(4): Modify ksyms_symtabs only at IPL_HIGH.

This limits the opportunities for ddb to witness an inconsistent
state of the symbol table list.
ksyms(4): Don't skip symbol tables that are soon to be freed.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.
Revert "ksyms(4): Don't skip symbol tables that are soon to be freed."

Apparently the equality kassert this restored doesn't work; to be
analyzed.

Fix regression introduced in rev 1.90
in which the last element of ksyms_symtabs is skipped by mistake.

ksyms(4): Fix race in ksymsread iteration.
TAILQ_NEXT(ksyms_last_snapshot) might change while we are iterating,
but ksyms_last_snapshot itself cannot, so invert the loop structure.

Discussed with rin@.

ksyms(4): Don't skip symbol tables that are soon to be freed, take 2.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.
The previous change was busted because of an off-by-one error in a
previous previous change's iteration over the symtabs; that error has
since been corrected.

ksyms(4): Allow multiple concurrent opens of /dev/ksyms.

First one takes a snapshot; others all agree with the snapshot.
Previously this code path was just broken (could fail horribly if
modules were unloaded after one of the opens is closed), so I just
blocked it off in an earlier commit, but that broke crash(8). So
let's continue allowing multiple opens seeing the same snapshot, but
without the horrible bugs.
 1.87.8.1  07-Jan-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #609):

sys/kern/kern_ksyms.c: revision 1.88

When reading from /dev/ksyms we need to skip over entries that have
been marked as sd_gone. Otherwise we might try to uiomove() data from
memory that has been unmapped, resulting in EFAULT.

XXX This (along with other pre-existing checks st->sd_gone) is still
racy, but it's an improvement over current code. Ideally we would
make a complete copy of the symbol table when we open /dev/ksyms so
we could ignore any changes that occur.

ad@ says "good enough for now"

XXX Pullup to -9 and -8
 1.87.4.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.89.6.2  01-Aug-2021  thorpej Sync with HEAD.
 1.89.6.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.93.2.1  06-Jun-2021  cjep sync with head
 1.107.4.1  24-Feb-2023  martin Pull up following revision(s) (requested by riastradh in ticket #107):

sys/kern/kern_ksyms.c: revision 1.108

ksyms(4): Reject negative offsets earlier in lseek.

Avoid arithmetic overflow.

RSS XML Feed