aboutsummaryrefslogtreecommitdiff
path: root/lib/libkvm
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Do a sweep and remove most WARNS=6 settings"Dimitry Andric2021-08-292-0/+4
| | | | | | | | | This reverts commit befc47822966, as it caused various CI build errors, and we never merged the prerequisite commit fe815331bb40 ("build: provide a default WARNS for all in-tree builds"). The latter is rather intrusive, so I will avoid it. Direct commit to stable/12 since the CI bots are broken.
* Do a sweep and remove most WARNS=6 settingsKyle Evans2021-08-292-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. (cherry picked from commit 7cc42f6d25ef2e19059d088fa7d4853fe9afefb5)
* libkvm: Plug couple of memory leaks and check possible calloc(3) failureJung-uk Kim2021-03-061-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. Differential Revision: https://reviews.freebsd.org/D29019 (cherry picked from commit 645eaa2ccaed6eea801d07d6a092974fc1713896) (cherry picked from commit 483c6da3a20b2064cd655f7cb19e6b98dee677ff)
* jobc: rework detection of orphaned groups.Konstantin Belousov2021-02-091-1/+1
| | | | | | | | Tested by: pho For MFC, pg_jobc member is left in struct pgrp, but it is unused now. (cherry picked from commit 5844bd058aed6f3d0c8cbbddd6aa95993ece0189)
* MFC r344855 (by jhb):Dimitry Andric2020-11-078-8/+0
| | | | | | | | | | Drop "All rights reserved" from my copyright statements. Reviewed by: rgrimes Differential Revision: https://reviews.freebsd.org/D19485 Notes: svn path=/stable/12/; revision=367457
* MFC r363020: test: add libkvm read testAlfredo Dal'Ava Junior2020-08-062-1/+101
| | | | | | | | | | | | | This test checks if value received from kvm_read is sane, based on value returned by sysctl interface. Reviewed by: jhb Approved by: jhibbits (mentor) Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D23783 Notes: svn path=/stable/12/; revision=363990
* MFC r362623:Dimitry Andric2020-06-301-2/+2
| | | | | | | | | | | Fix copy/paste mistake in kvm_getswapinfo(3) 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. Notes: svn path=/stable/12/; revision=362800
* MFC r358026:Mark Johnston2020-03-031-4/+2
| | | | | | | Remove swblk_t. Notes: svn path=/stable/12/; revision=358581
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Also update affected Makefile.depend files. MFC of r355616 and r355617 Reviewed by: bdrewery Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/stable/12/; revision=355906
* MFC r352597: Add support for ps -H on corefiles in libkvmMike Karels2019-09-291-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. Sponsored by: Forcepoint LLC Notes: svn path=/stable/12/; revision=352867
* MFC r350048:Mark Johnston2019-07-191-1/+1
| | | | | | | Chase r350037. Notes: svn path=/stable/12/; revision=350141
* MFC r344827-344830, r344845:Mark Johnston2019-06-273-0/+379
| | | | | | | Implement minidump support for RISC-V. Notes: svn path=/stable/12/; revision=349463
* MFC r346571,r346572:Enji Cooper2019-04-296-12/+6
| | | | | | | | | | | | Update the spelling of my name 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". Notes: svn path=/stable/12/; revision=346918
* Make cache coherency attributes definitions available in machine/vm.h on MIPS.Konstantin Belousov2018-08-011-0/+2
| | | | | | | | | | | | Move definitions from cpuregs.h into the cca.h, and include cca.h into vm.h. This is required to make MIPS MD memattr definitions usable in userspace. Sponsored by: The FreeBSD Foundation, Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D15583 Notes: svn path=/head/; revision=337048
* Make struct xinpcb and friends word-size independent.Brooks Davis2018-07-051-2/+0
| | | | | | | | | | | | | | | | | | | | | Replace size_t members with ksize_t (uint64_t) and pointer members (never used as pointers in userspace, but instead as unique idenitifiers) with kvaddr_t (uint64_t). This makes the structs identical between 32-bit and 64-bit ABIs. On 64-bit bit systems, the ABI is maintained. On 32-bit systems, this is an ABI breaking change. The ABI of most of these structs was previously broken in r315662. This also imposes a small API change on userspace consumers who must handle kernel pointers becoming virtual addresses. PR: 228301 (exp-run by antoine) Reviewed by: jtl, kib, rwatson (various versions) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15386 Notes: svn path=/head/; revision=335979
* Use __SCCSID for SCCS IDs in libkvm sources.John Baldwin2018-05-227-37/+7
| | | | | | | | | | | | | | Rather than using #ifdef's around a static char array, use the existing helper macro from <sys/cdefs.h> for SCCS IDs. To preserve existing behavior, add -DNO__SCCSID to CFLAGS to not include SCCS IDs in the built library by default. Reviewed by: brooks, dab (older version) Reviewed by: rgrimes Differential Revision: https://reviews.freebsd.org/D15459 Notes: svn path=/head/; revision=334053
* Reduce <sys/queue.h> pollution.Dag-Erling Smørgrav2018-05-111-0/+1
| | | | | | | | | | | | While <sys/sysctl.h> includes <sys/queue.h> unconditionally, it is only actually used in code which is conditional on _KERNEL. Make the #include itself conditional as well, and fix userland code that uses <sys/queue.h> for other purposes but relied on <sys/sysctl.h> to bring it in. MFC after: 1 week Notes: svn path=/head/; revision=333475
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-266-1/+13
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326219
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2013-0/+26
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* libkvm: fix lib32 build.Will Andrews2017-11-121-0/+1
| | | | Notes: svn path=/head/; revision=325735
* libkvm: fix build failuresWill Andrews2017-11-1210-17/+39
| | | | Notes: svn path=/head/; revision=325732
* libkvm: fix 'index' shadowing.Will Andrews2017-11-121-13/+13
| | | | Notes: svn path=/head/; revision=325729
* libkvm: add kvm_walk_pages API.Will Andrews2017-11-1113-122/+740
| | | | | | | | | | | | | | | | | | | | This API allows callers to enumerate all known pages, including any direct map & kernel map virtual addresses, physical addresses, size, offset into the core, & protection configured. For architectures that support direct map addresses, also generate pages for any direct map only addresses that are not associated with kernel map addresses. Fix page size portability issue left behind from previous kvm page table lookup interface. Reviewed by: jhb Sponsored by: Backtrace I/O Differential Revision: https://reviews.freebsd.org/D12279 Notes: svn path=/head/; revision=325728
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* DIRDEPS_BUILD: Connect new directories.Bryan Drewery2017-10-311-0/+20
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325187
* Add HAS_TESTS to all Makefiles that use the SUBDIR.${MK_TESTS}+= tests idiomEnji Cooper2017-08-021-0/+1
| | | | Notes: svn path=/projects/make-check-sandbox/; revision=321911
* Fix #if conditional added in r319008Enji Cooper2017-05-271-2/+2
| | | | | | | | | | | | I committed an earlier version of the file by accident This is a no-op on ^/head and ^/stable/11. MFC after: now Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319010
* kvm_geterr_test: Compile out the portions that require kvm_open2(3) onEnji Cooper2017-05-271-0/+5
| | | | | | | | | | | | | | systems that lack the libcall, based on __FreeBSD_version. kvm_open2(3) wasn't made available until r291406, which is in ^/stable/11, but not ^/stable/10. This makes some of kvm_geterr_test available for testing on ^/stable/10. MFC after: now Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319008
* Commit the 64-bit inode project.Konstantin Belousov2017-05-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify struct dirent layout to add d_off, increase the size of d_fileno to 64-bits, increase the size of d_namlen to 16-bits, and change the required alignment. Increase struct statfs f_mntfromname[] and f_mntonname[] array length MNAMELEN to 1024. ABI breakage is mitigated by providing compatibility using versioned symbols, ingenious use of the existing padding in structures, and by employing other tricks. Unfortunately, not everything can be fixed, especially outside the base system. For instance, third-party APIs which pass struct stat around are broken in backward and forward incompatible ways. Kinfo sysctl MIBs ABI is changed in backward-compatible way, but there is no general mechanism to handle other sysctl MIBS which return structures where the layout has changed. It was considered that the breakage is either in the management interfaces, where we usually allow ABI slip, or is not important. Struct xvnode changed layout, no compat shims are provided. For struct xtty, dev_t tty device member was reduced to uint32_t. It was decided that keeping ABI compat in this case is more useful than reporting 64-bit dev_t, for the sake of pstat. Update note: strictly follow the instructions in UPDATING. Build and install the new kernel with COMPAT_FREEBSD11 option enabled, then reboot, and only then install new world. Credits: The 64-bit inode project, also known as ino64, started life many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick (mckusick) then picked up and updated the patch, and acted as a flag-waver. Feedback, suggestions, and discussions were carried by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles), and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial ports investigation followed by an exp-run by Antoine Brodin (antoine). Essential and all-embracing testing was done by Peter Holm (pho). The heavy lifting of coordinating all these efforts and bringing the project to completion were done by Konstantin Belousov (kib). Sponsored by: The FreeBSD Foundation (emaste, kib) Differential revision: https://reviews.freebsd.org/D10439 Notes: svn path=/head/; revision=318736
* lib/libkvm: start adding basic tests for kvm(3)Enji Cooper2017-03-288-0/+531
| | | | | | | | | | | | | | | | | | | | | | | | | | | - kvm_close: add a testcase to verify support for errno = EINVAL / -1 (see D10065) when kd == NULL is provided to the libcall. - kvm_geterr: -- Add a negative testcase for kd == NULL returning "" (see D10022). -- Add two positive testcases: --- test the error case using kvm_write on a O_RDONLY descriptor. --- test the "no error" case using kvm_read(3) and kvm_nlist(3) as helper routines and by injecting a bogus error message via _kvm_err (an internal API) _kvm_err was used as there isn't a formalized way to clear the error output, and because kvm_nlist always returns ENOENT with the NULL terminator today. - kvm_open, kvm_open2: -- Add some basic negative tests for kvm_open(3) and kvm_open2(3). Testing positive cases with a specific `corefile`/`execfile`/`resolver` requires more work and would require user intervention today in order to reliably test this out. Reviewed by: markj MFC after: 2 months Sponsored by: Dell EMC Isilon Differential Revision: D10024 Notes: svn path=/head/; revision=316099
* libkvm: bump WARNS to 6 after recent commits done to resolve warnings issuesEnji Cooper2017-03-221-1/+1
| | | | | | | | | MFC after: 1 month Tested with: make tinderbox; clang 4.0.0 (amd64), gcc 4.2.1/6.3.0 (amd64) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315698
* libkvm: fix warning issues post-r291406Enji Cooper2017-03-2211-17/+25
| | | | | | | | | | | | | | | | | - Fix -Wunused warnings with *_native detection handlers by marking `kd` __unused, except with arm/mips, where a slightly more complicated scheme is required to handle the native case vs the non-native case. - Fix -Wmissing-variable-declarations warnings by marking struct kvm_arch objects static. Differential Revision: D10071 MFC after: 1 week Reviewed by: vangyzen Tested with: WIP test code (D10024) // kgdb7121 (i386 crash/kernel on amd64) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315697
* kvm_write: fix -Wcast-qual warning in pointer arithmetic argumentEnji Cooper2017-03-211-1/+1
| | | | | | | | | | | | | | Cast buf to `const char *` when doing arithmetic operation to match `cp`'s type [1]. Differential Revision: D10082 MFC after: 1 week Reviewed by: cem (earlier diff), vangyzen Submitted by: cem [1] Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315688
* kvm_geterr: handle `kd` == NULL in a deterministic/graceful mannerEnji Cooper2017-03-212-1/+15
| | | | | | | | | | | | | | | | | | | Return a NUL string instead of just working by accident with kvm_geterr(3) when MALLOC_PRODUCTION is disabled (I didn't confirm the MALLOC_PRODUCTION being enabled path). Document the new explicit return behavior for kvm_geterr(3), as well as the previous implicit behavior, i.e., the buffer attached to returned via kvm_geterr(3) would be empty if a previous error hadn't been stored in `kd`. Differential Revision: D10022 MFC after: 1 week Reviewed by: vangyzen Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315686
* Handle kd == NULL gracefully with kvm_close(3)Enji Cooper2017-03-202-2/+25
| | | | | | | | | | | | | | | Don't segfault in kvm_close(3) if provided a NULL pointer. Instead, return -1 and set errno to EINVAL. Document this new behavior explicitly. MFC after: 1 week Reviewed by: vangyzen Sponsored by: Dell EMC Isilon Differential Revision: D10065 Notes: svn path=/head/; revision=315647
* kvm_close(3): return `error` instead of blindly returning `0`Enji Cooper2017-03-201-1/+1
| | | | | | | | | | | | | | | `error` is the accumulated error from previous close(2) calls. This bug has been present since the libcall's import from 4.4BSD Lite (r1573). MFC after: 1 week Noticed by: vangyzen (D10022) Relnotes: yes Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315603
* kvm_open2(3): remove '*' when describing addr argument for `resolver`Enji Cooper2017-03-201-2/+2
| | | | | | | | | | | As noted by vangyzen, with a similar issue in D10022, the pointer portion of the .Fa macro call is unnecessary, so remove the '*'. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315601
* Remove a commented out line before kvm_getprocs(3)Enji Cooper2017-03-191-1/+0
| | | | | | | | | | | | | The commented out return value for kvm_getprocs(3) was misleading -- the uncommented line is correct. No content change MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315595
* Tweak r315363 slightlyEnji Cooper2017-03-161-1/+1
| | | | | | | | | | | | I noticed after commit that kvm_dpcpu_setcpu was defined in the manpage. Thus, the correct macro for the function reference is .Fn, not .Xr. MFC after: 1 week X-MFC with: r315363 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315365
* Fix manlint errorsEnji Cooper2017-03-161-3/+3
| | | | | | | | | | | | | - Add missing comma after kvm_dpcpu_setcpu .Nm macro use (multiple .Nm entries should be separated by commas) - Add missing section for kvm_dpcpu_setcpu Xr. MFC after: 1 week Reported by: make manlint Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315363
* Capitalize .Dt macro argumentEnji Cooper2017-03-161-2/+2
| | | | | | | | | | By convention, per mdoc(7), the document title should be all caps. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315362
* Return NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files}Enji Cooper2017-03-161-4/+4
| | | | | | | | | | | | | This is being done for the following reasons: - kvm_open(3), etc says they will return NULL. - NULL by definition is (void*)0 per POSIX, but can be redefined, depending on the compiler, etc. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315360
* Renumber copyright clause 4Warner Losh2017-02-2817-17/+17
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* libkvm - extend a bit the swap statistics field.Pedro F. Giffuni2017-01-023-9/+11
| | | | | | | | | | | Change ksw_used and ksw_total to unsigned, which increases the maximum total swap that can be displayed properly from ~8TB to ~16TB. Obtained from: DragonflyBSD (ecc2e461) MFC after: 2 weeks Notes: svn path=/head/; revision=311101
* libkvm: support access to vmm guest memory, allow writes to fwmem and vmmAndriy Gapon2016-12-272-7/+48
| | | | | | | | | | | | | | | | | | | | | | This change consists of two parts: - allow libkvm to recognize /dev/vmm/* character devices as devices that provide access to the physical memory of a system (similarly to /dev/fwmem*) - allow libkvm to recognize that /dev/vmm/* and /dev/fwmem* devices provide access to the physical memory of live remote systems and, thus, the memory is writable As a result, it should be possible to run commands like $ kgdb -w /path/to/kernel /dev/fwmem0.0 $ kgdb /path/to/kernel /dev/vmm/guest Reviewed by: kib, jhb MFC after: 2 weeks Relnotes: yes Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D8679 Notes: svn path=/head/; revision=310630
* Fix memory leak.Gleb Smirnoff2016-12-201-0/+1
| | | | | | | | CID: 1367751 Reviewed by: jhb Notes: svn path=/head/; revision=310337
* Export the whole thread name in kinfo_procEric van Gyzen2016-12-071-2/+0
| | | | | | | | | | | | | | | | | | kinfo_proc::ki_tdname is three characters shorter than thread::td_name. Add a ki_moretdname field for these three extra characters. Add the new field to kinfo_proc32, as well. Update all in-tree consumers to read the new field and assemble the full name, except for lldb's HostThreadFreeBSD.cpp, which I will handle separately. Bump __FreeBSD_version. Reviewed by: kib MFC after: 1 week Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D8722 Notes: svn path=/head/; revision=309676
* libkvm: Improve physical address lookup scaling.Will Andrews2016-07-188-210/+232
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using a hash table to convert physical page addresses to offsets in the sparse page array, cache the number of bits set for each 4MB chunk of physical pages. Upon lookup, find the nearest cached population count, then add/subtract the number of bits from that point to the page's PTE bit. Then multiply by page size and add to the sparse page map's base offset. This replaces O(n) worst-case lookup with O(1) (plus a small number of bits to scan in the bitmap). Also, for a 128GB system, a typical kernel core of about 8GB will now only require ~4.5MB of RAM for this approach instead of ~48MB as with the hash table. More concretely, /usr/sbin/crashinfo against the same core improves from a max RSS of 188MB and wall time of 43.72s (33.25 user 2.94 sys) to 135MB and 9.43s (2.58 user 1.47 sys). Running "thread apply all bt" in kgdb has a similar RSS improvement, and wall time drops from 4.44s to 1.93s. Reviewed by: jhb Sponsored by: Backtrace I/O Notes: svn path=/head/; revision=302976
* libkvm: Bounds check (more) PTE indices.Will Andrews2016-07-183-0/+10
| | | | Notes: svn path=/head/; revision=302975
* libkvm: Put private kvm routines in kvm_private.c.Will Andrews2016-07-183-464/+526
| | | | Notes: svn path=/head/; revision=302974