aboutsummaryrefslogtreecommitdiff
path: root/lib/libkvm
Commit message (Collapse)AuthorAgeFilesLines
* libkvm/kvm_open.3: document broken full dumpsAhmad Khalifa2025-06-221-1/+14
| | | | | | | | | | | Starting 13.1 the amd64 kernel was made relocatable, but the kernel didn't provide enough information for libkvm to figure out where it was loaded. Reviewed by: markj Approved by: imp (mentor) Pull Request: https://github.com/freebsd/freebsd-src/pull/1706 Closes: https://github.com/freebsd/freebsd-src/pull/1706
* libkvm/kvm_amd64: account for relocatable kernelsAhmad Khalifa2025-06-221-9/+37
| | | | | | | | | | | amd64 kernels don't have to be loaded at 2M physical anymore, they can be anywhere in the lower 4G of the physical address space. The kernel now provides its physical address in an ELF section in the dump, so account for it. Reviewed by: markj Approved by: imp (mentor) Pull Request: https://github.com/freebsd/freebsd-src/pull/1706
* cred: Hide internal flag CRED_FLAG_CAPMODEOlivier Certner2024-12-161-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | This flag is used in field 'cr_flags', which is never directly visible outside the kernel. That field is however exported through 'struct kinfo_proc' objects (field 'ki_cr_flags'), either from the kernel via sysctls or from libkvm, and is supposed to contain exported flags prefixed with KI_CRF_ (currently, KI_CRF_CAPABILITY_MODE and KI_CRF_GRP_OVERFLOW, this second one being a purely userland one signaling overflow of 'ki_groups'). Make sure that KI_CRF_CAPABILITY_MODE is the flag actually exported and tested by userland programs, and hide the internal CRED_FLAG_CAPMODE. As both flags are currently defined to the same value, this doesn't change the KBI, but of course does change the KPI. A code search via GitHub and Google fortunately doesn't reveal any outside uses for CRED_FLAG_CAPMODE. While here, move assignment of 'ki_uid' to a more logical place in kvm_proclist(), and definition of XU_NGROUPS as well in 'sys/ucred.h' (no functional/interface changes intended). Reviewed by: mhorne Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46909
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* lib: Automated cleanup of cdefs and other formattingWarner Losh2023-11-2716-16/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* lib: Remove ancient SCCS tags.Warner Losh2023-11-2715-29/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-167-7/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-165-10/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-164-4/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1626-47/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-167-14/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* arm: Rename pte-v6.h to pte.hAndrew Turner2023-07-241-8/+1
| | | | | | | There is no need for this to be versioned after the removal of armv4/v5 Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D41139
* libkvm: Remove set but unused variable from ppc64mmu_hpt_init.John Baldwin2023-06-201-3/+0
| | | | Reported by: GCC
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-126-6/+6
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* kvm_close(3): Check kd->sparse_map != NULL before munmapAshish SHUKLA2022-10-161-1/+1
| | | | | PR: 266113 Reviewed by: markj
* kern_tc.c/cputick2usec() (which is used to calculate cputime fromfirk2022-03-211-7/+2
| | | | | | | | | | | | | | | | | cpu ticks) has some imprecision and, worse, huge timestep (about 20 minutes on 4GHz CPU) near 53.4 days of elapsed time. kern_time.c/cputick2timespec() (it is used for clock_gettime() for querying process or thread consumed cpu time) Uses cputick2usec() and then needlessly converting usec to nsec, obviously losing precision even with fixed cputick2usec(). kern_time.c/kern_clock_getres() uses some weird (anyway wrong) formula for getting cputick resolution. PR: 262215 Reviewed by: gnn Differential Revision: https://reviews.freebsd.org/D34558
* Make page size dynamic in libkvm for arm64Andrew Turner2022-03-152-32/+62
| | | | | | | | | | To allow for a future 16k or 64k page size we need to tell libkvm which is being used. Add a flag field in unused space in minidumphdr and use it to signal between the different options. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34548
* libkvm: Remove mips supportWarner Losh2021-12-313-490/+0
| | | | | | | libkvm references files in sys/mips, so remove it ahead of removing sys/mips. Sponsored by: Netflix
* Document 7f911abe's new functions came in 11.0David E. O'Brien2021-12-164-0/+24
| | | | | Document that the 7f911abe "Add support to libkvm for reading vmcores from other architectures." added functions appeared first in FreeBSD 11.0.
* libkvm: fix kvm_walk_pagesBora Özarslan2021-12-101-2/+2
| | | | | | | | | Correct bitmap operations in _kvm_bitmap_next. Reviewed by: jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19183
* libkvm: Fix kvm_getloadavg() on modern kernel vmcoresMichał Górny2021-12-071-5/+4
| | | | | | | | | | | | | Fix kvm_getloadavg() to work correctly on vmcores for modern kernel versions. The kernels no longer include the `_fscale` symbol causing the kvm_nlist() invocation to fail. The code seemed to already assume that `_fscale` could be missing but the early kvm_nlist() result check has caused the function to fail if any symbol were missing. Modify it to only treat `_averunnable` as obligatory, and handle missing `_fscale` gracefully. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32884
* libkvm: Fix build after removeal of p_tracevpKonstantin Belousov2021-05-221-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week
* libkvm: Refine the previous commit (645eaa2ccaed)Jung-uk Kim2021-03-031-2/+2
| | | | | | Resort free()'ing memory in kvm_close() to make it easier to MFC. MFC after: 3 days
* libkvm: Plug couple of memory leaks and check possible calloc(3) failureJung-uk Kim2021-03-031-0/+7
| | | | | | | | | | | First, r204494 introduced dpcpu_off in struct __kvm and it was allocated from _kvm_dpcpu_init() but it was not free(3)'ed from kvm_close(3). Second, r291406 introduced kvm_nlist2(3) and converted kvm_nlist(3) to use the new function but it did not free the temporary buffer. Also, check possible calloc(3) failure while I am in the neighborhood. MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29019
* Use atomic loads/stores when updating td->td_stateAlex Richardson2021-02-181-1/+1
| | | | | | | | | | | | | | | KCSAN complains about racy accesses in the locking code. Those races are fine since they are inside a TD_SET_RUNNING() loop that expects the value to be changed by another CPU. Use relaxed atomic stores/loads to indicate that this variable can be written/read by multiple CPUs at the same time. This will also prevent the compiler from doing unexpected re-ordering. Reported by: GENERIC-KCSAN Test Plan: KCSAN no longer complains, kernel still runs fine. Reviewed By: markj, mjg (earlier version) Differential Revision: https://reviews.freebsd.org/D28569
* jobc: rework detection of orphaned groups.Konstantin Belousov2021-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Instead of trying to maintain pg_jobc counter on each process group update (and sometimes before), just calculate the counter when needed. Still, for the benefit of the signal delivery code, explicitly mark orphaned groups as such with the new process group flag. This way we prevent bugs in the corner cases where updates to the counter were missed due to complicated configuration of p_pptr/p_opptr/real_parent (debugger). Since we need to iterate over all children of the process on exit, this change mostly affects the process group entry and leave, where we need to iterate all process group members to detect orpaned status. (For MFC, keep pg_jobc around but unused). Reported by: jhb Reviewed by: jilles Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27871
* Always use 64-bit physical addresses for dump_avail[] in minidumpsMark Johnston2020-12-039-34/+12
| | | | | | | | | | | | | | | | | | | | | | As of r365978, minidumps include a copy of dump_avail[]. This is an array of vm_paddr_t ranges. libkvm walks the array assuming that sizeof(vm_paddr_t) is equal to the platform "word size", but that's not correct on some platforms. For instance, i386 uses a 64-bit vm_paddr_t. Fix the problem by always dumping 64-bit addresses. On platforms where vm_paddr_t is 32 bits wide, namely arm and mips (sometimes), translate dump_avail[] to an array of uint64_t ranges. With this change, libkvm no longer needs to maintain a notion of the target word size, so get rid of it. This is a no-op on platforms where sizeof(vm_paddr_t) == 8. Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27082 Notes: svn path=/head/; revision=368307
* Split out cwd/root/jail, cmask state from filedesc tableConrad Meyer2020-11-171-0/+1
| | | | | | | | | | | | | | | | No functional change intended. Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux(4). __FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof. Reviewed by: kib Discussed with: markj, mjg Differential Revision: https://reviews.freebsd.org/D27037 Notes: svn path=/head/; revision=367777
* libkvm: catch up with pre-subtracated per-cpu addressesMateusz Guzik2020-10-061-0/+29
| | | | | | | | | Only concerns amd64. Reported by: imp Notes: svn path=/head/; revision=366468
* Do a sweep and remove most WARNS=6 settingsKyle Evans2020-10-012-4/+0
| | | | | | | | | | | | | | | Repeating the default WARNS here makes it slightly more difficult to experiment with default WARNS changes, e.g. if we did something absolutely bananas and introduced a WARNS=7 and wanted to try lifting the default to that. Drop most of them; there is one in the blake2 kernel module, but I suspect it should be dropped -- the default WARNS in the rest of the build doesn't currently apply to kernel modules, and I haven't put too much thought into whether it makes sense to make it so. Notes: svn path=/head/; revision=366304
* [PowerPC64LE] libkvm powerpc64le support.Brandon Bergren2020-09-232-19/+61
| | | | | | | | | | * Add missing _kvm16toh() function. * Teach libkvm about powerpc64le. Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=366055
* Sparsify the vm_page_dump bitmapD Scott Phillips2020-09-219-50/+176
| | | | | | | | | | | | | | | | | | | On Ampere Altra systems, the sparse population of RAM within the physical address space causes the vm_page_dump bitmap to be much larger than necessary, increasing the size from ~8 Mib to > 2 Gib (and overflowing `int` for the size). Changing the page dump bitmap also changes the minidump file format, so changes are also necessary in libkvm. Reviewed by: jhb Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26131 Notes: svn path=/head/; revision=365978
* test: add libkvm read testAlfredo Dal'Ava Junior2020-07-082-1/+101
| | | | | | | | | | | | | | | | This test checks if value received from kvm_read is sane, based on value returned by sysctl interface. This should catch regression on bug fixed by r359160 Reviewed by: jhb Approved by: jhibbits (mentor) MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D23783 Notes: svn path=/head/; revision=363020
* Fix copy/paste mistake in kvm_getswapinfo(3)Dimitry Andric2020-06-251-2/+2
| | | | | | | | | | | It seems this manpage was copied from kvm_getloadavg(3), but the DIAGNOSTICS section was not updated completely. Update the section with correct information about a return value of -1. MFC after: 3 days Notes: svn path=/head/; revision=362623
* Remove swblk_t.Mark Johnston2020-02-171-4/+2
| | | | | | | | | | | | | | | | | | | It was used only to store the bounds of each swap device. However, since swblk_t is a signed 32-bit int and daddr_t is a signed 64-bit int, swp_pager_isondev() may return an invalid result if swap devices are repeatedly added and removed and sw_end for a device ends up becoming a negative number. Note that the removed comment about maximum swap size still applies. Reviewed by: jeff, kib Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23666 Notes: svn path=/head/; revision=358026
* Partially revert VNET change and expand VNET structure.Bjoern A. Zeeb2020-02-173-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Revert parts of r353274 replacing vnet_state with a shutdown flag. Not having the state flag for the current SI_SUB_* makes it harder to debug kernel or module panics related to VNET bringup or teardown. Not having the state also does not allow us to check for other dependency levels between components, e.g. for moving interfaces. Expand the VNET structure with the new boolean flag indicating that we are doing a shutdown of a given vnet and update the vnet magic cookie for the change. Update libkvm to compile with a bool in the kernel struct. Bump __FreeBSD_version for (external) module builds to more easily detect the change. Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23097 Notes: svn path=/head/; revision=358020
* Remove sparc64 filesWarner Losh2020-02-122-356/+0
| | | | | | | | | These were disconnected from the build when the kernel was removed. Since they depend on removed parts of the kernel, remove them completely. Notes: svn path=/head/; revision=357795
* Implement kvm_kerndispLeandro Lupori2020-02-067-4/+102
| | | | | | | | | | | | | | | This change adds a new libkvm function, kvm_kerndisp(), that can be used to retrieve the kernel displacement, that is the difference between the kernel's base virtual address at run time and the kernel base virtual address specified in the kernel image file. This will be used by kgdb, to properly relocate kernel symbols, when needed. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D23285 Notes: svn path=/head/; revision=357615
* Remove sparc64 kernel supportWarner Losh2020-02-031-2/+1
| | | | | | | | | Remove all sparc64 specific files Remove all sparc64 ifdefs Removee indireeect sparc64 ifdefs Notes: svn path=/head/; revision=357455
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-1/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* [PPC64] Initial libkvm minidump implementationLeandro Lupori2019-12-094-0/+950
| | | | | | | | | | | | | This change adds PowerPC64 support for minidumps on libkvm. Address translation, page walk, and data retrieval were tested and seem to be working correctly. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D21555 Notes: svn path=/head/; revision=355557
* kvm: fix types for cross-debuggingEd Maste2019-11-082-16/+16
| | | | | | | | | | | | | | | | | As with other libkvm interfaces use maximum-sized types to support cross-debugging (e.g. a 64-bit vmcore on a 32-bit host). See https://lists.freebsd.org/pipermail/svn-src-all/2019-February/176051.html for further discussion. This is an API-breaking change, but there are few consumers of this interface today. Reviewed by: will Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21945 Notes: svn path=/head/; revision=354543
* Add support for ps -H on corefiles in libkvmMike Karels2019-09-221-102/+147
| | | | | | | | | | | | | | | | | | Add support for kernel threads in kvm_getprocs() and the underlying kvm_proclist() in libkvm when fetching from a kernel core file. This has been missing/needed for several releases, when kernel threads became normal threads. The loop over the processes now contains a sub-loop for threads, which iterates beyond the first thread only when threads are requested. Also set some fields such as tid that were previously uninitialized. Reviewed by: vangyzen jhb(earlier revision) MFC after: 4 days Sponsored by: Forcepoint LLC Differential Revision: https://reviews.freebsd.org/D21461 Notes: svn path=/head/; revision=352597
* Add powerpc support to libkvm probe functionLeandro Lupori2019-09-101-1/+2
| | | | | | | | | | PowerPC kernels are of DYN type, instead of EXEC. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D21583 Notes: svn path=/head/; revision=352175
* pkgbase: Put a lot of binaries and lib in FreeBSD-runtimeEmmanuel Vadot2019-09-051-1/+1
| | | | | | | | | | | | All of them are needed to be able to boot to single user and be able to repair a existing FreeBSD installation so put them directly into FreeBSD-runtime. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21503 Notes: svn path=/head/; revision=351855
* Chase r350037.Mark Johnston2019-07-161-1/+1
| | | | | | | | | Reported by: jenkins MFC with: r350037 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=350048
* Update the spelling of my name (continuation of r346571)Enji Cooper2019-04-226-12/+6
| | | | | | | | | | | | Previous spellings of my name (NGie, Ngie) weren't my legal spelling. Use Enji instead for clarity. While here, remove "All Rights Reserved" from copyrights I "own". MFC after: 1 week Notes: svn path=/head/; revision=346572
* Drop "All rights reserved" from my copyright statements.John Baldwin2019-03-068-8/+0
| | | | | | | | | Reviewed by: rgrimes MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D19485 Notes: svn path=/head/; revision=344855
* Reorder copyright lines to preserve the source of "All rights reserved."Mark Johnston2019-03-061-1/+1
| | | | | | | | Reported by: rgrimes MFC with: r344829, r344830 Notes: svn path=/head/; revision=344845