summaryrefslogtreecommitdiffstats
path: root/lib/libkvm
Commit message (Collapse)AuthorAgeFilesLines
* MFC r316099:ngie2017-05-278-0/+540
| | | | | | | | | | | | | | | | | | | | | | | | | lib/libkvm: start adding basic tests for kvm(3) - 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. MFC note: lib/libkvm/kvm_open2_test is not compiled/tested because ^/stable/10 lacks the kvm_open2(3) libcall.
* MFC r315686,r315688:ngie2017-03-282-2/+16
| | | | | | | | | | | | | | | | | | | | | | r315686: kvm_geterr: handle `kd` == NULL in a deterministic/graceful manner 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`. r315688: kvm_write: fix -Wcast-qual warning in pointer arithmetic argument Cast buf to `const char *` when doing arithmetic operation to match `cp`'s type [1].
* MFC r315647:ngie2017-03-282-2/+25
| | | | | | | | | Handle kd == NULL gracefully with kvm_close(3) 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 r315595,r315603:ngie2017-03-272-2/+1
| | | | | | | | | | | | | | | | | | | | | | | r315595: Remove a commented out line before kvm_getprocs(3) The commented out return value for kvm_getprocs(3) was misleading -- the uncommented line is correct. No content change r315603: kvm_close(3): return `error` instead of blindly returning `0` `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). Noticed by: vangyzen (D10022) Relnotes: yes
* MFC r315360:ngie2017-03-231-3/+3
| | | | | | | | | Return NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files} 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 r315363,r315365:ngie2017-03-231-3/+3
| | | | | | | | | | | | | | | | | r315363: Fix manlint errors - 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. r315365: Tweak r315363 slightly 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 r310630: libkvm: support access to vmm guest memory, allow writes toavg2017-01-182-7/+48
| | | | | | fwmem and vmm Sponsored by: Panzura
* MFC r311101:pfg2017-01-163-9/+11
| | | | | | | | | libkvm - extend a bit the swap statistics field. 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 r309676vangyzen2016-12-151-2/+0
| | | | | | | | | | | | | Export the whole thread name in kinfo_proc 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. Sponsored by: Dell EMC
* MFC r298839:ngie2016-05-131-3/+12
| | | | | | | | | Fix memory allocation edgecases in kvm_argv(..) - Don't leak nbufp on realloc failure in kvm_argv - Catch malloc errors with bufp - Set buflen last in the "buflen == 0" case to ensure that bufp/nbufp is properly reallocated on the next go around
* MFC r298842:ngie2016-05-131-0/+1
| | | | | | Don't leak PML4 in _amd64_initvtop(..) if kvm_read2(..) fails CID: 1341474
* MFC r273284:andrew2014-10-291-10/+26
| | | | | | | | | | Allow libkvm to get the kernel va to pa delta without the need for physaddr. This should allow for a kernel where PHYSADDR and KERNPHYSADDR are both undefined. For now libkvm will use the old method of reading physaddr and kernaddr to allow it to work with old kernels. This could be removed in the future when enough time has passed.
* MFC 259910, 260023, 260028, 260600 & 260701:marcel2014-08-021-75/+158
| | | | | | | | o Fix "kptdir is itself virtual" error, caused by having the kptdir in PBVM. o Allow building a cross libkvm for ia64. o Add support for virtual cores (aka minidumps). o We don't have to worry about page sizes when working on virtual cores. o Handle truncation of the size returned by _kvm_kvatop().
* MFC r261799: Add bounds check for pteindex / pdeindex to amd64 kvm_minidumpemaste2014-07-231-0/+4
|
* Merge r261796 from head:glebius2014-03-043-5/+22
| | | | | | | | While it isn't too late and kvm_read_zpcpu() function isn't yet used outside libkvm(3), change its order of arguments, so that it is the same as in kvm_read(). Merge r261805 from head: Add kvm_getncpus() to obtain mp_ncpus.
* In r227839, when removing libkvm dependency on procfs(5),trociny2013-07-102-2/+1
| | | | | | | | | | | kvm_uread() function, used for reading from /proc/pid/mem, was removed too. But the function declaration remained in kvm.h public header and the soname was not bumped. Remove kvm_uread() from kvm.h and bump the soname. Reported by: rmh Discussed on: arch
* Switch to 2-clause license and standard textemaste2013-06-061-15/+11
| | | | Approved by: bms@
* libkvm: Make second /dev/null file descriptor close-on-exec as well.jilles2013-05-041-1/+1
| | | | MFC after: 1 week
* libkvm: Use O_CLOEXEC instead of separate fcntl(F_SETFD) call.jilles2013-05-041-15/+4
| | | | MFC after: 1 week
* Remove EOL whitespace.joel2013-04-111-1/+1
|
* Fix typo.glebius2013-04-111-1/+1
|
* Include types.h for C99 uintXX_t types.glebius2013-04-111-1/+1
|
* o Provide function kvm_read_zpcpu() to access UMA_ZONE_PCPU allocations.glebius2013-04-104-7/+89
| | | | | | o Provide function kvm_counter_u64_fetch() to fetch valut of a counter(9). Sponsored by: Nginx, Inc.
* kvm_getprocs: gracefully handle errors from kvm_deadprocsavg2012-10-061-2/+8
| | | | | | and don't confuse callers with incorrect return value MFC after: 9 days
* kvm_proclist: ignore processes in larvae stateavg2012-10-061-0/+2
| | | | | Reviewed by: jhb MFC after: 8 days
* If the IdlePDPT is not present, PAE is not activekevlo2012-09-101-1/+0
|
* General mdoc(7) and typo fixes.gjb2012-05-111-2/+2
| | | | | | PR: 167734 Submitted by: Nobuyuki Koganemaru (kogane!jp.freebsd.org) MFC after: 3 days
* Try to avoid ambiguity when sysctl returns ENOMEM additionallytrociny2012-02-011-2/+3
| | | | | | | | | | | | checking the returned oldlen: when ENOMEM is due to the supplied buffer being too short the return oldlen is equal to buffer size. Without this additional check kvm_getprocs() gets stuck in loop if the returned ENOMEM was due the exceeded memorylocked limit. This is easily can be observed running `limits -l 1k top'. Submitted by: Andrey Zonov <andrey zonov org> MFC after: 1 week
* In kvm_argv(), the case when the supplied buffer was too short to hold thetrociny2012-01-151-23/+31
| | | | | | | | | | requested value was handled incorrectly, and the function retuned NULL instead of the truncated result. Fix this and also remove unnecessary check for buf != NULL, which alway retuns true. MFC after: 3 days
* Now kvm_getenvv() and kvm_getargv() don't need procfs(5).trociny2011-11-222-341/+27
| | | | MFC after: 2 weeks
* Add support for PBVM addresses. In a nutshell this means:marcel2011-08-061-7/+81
| | | | | | | | | | | | | | | o get the physical address and size of the PBVM page table. This can be found in the bootinfo structure, of which the physical address is recorded as the ELF entry point. o translate region 4 virtual addresses to physical addresses using the PBVM page table. In _kvm_kvatop() make the distinction between physical address and core file offset a little clearer to avoid confusion. To further enhance readability, always store the translated address into pa so that it's obvious how the translation from va to pa happened. Approved by: re (blanket)
* Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.bz2011-07-181-2/+2
| | | | | | | | | Provide backward compatibility defines under BURN_BRIDGES. Suggested by: jhb Reviewed by: emaste Sponsored by: Sandvine Incorporated Approved by: re (kib)
* With retirement of cpumask_t and usage of cpuset_t for representing aattilio2011-07-041-29/+2
| | | | | | | | | | | | | | | mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient. Remove them and replace their usage with custom pc_cpuid magic (as, atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))). This change is not targeted for MFC because of struct pcpu members removal and dependency by cpumask_t retirement. MD review by: marcel, marius, alc Tested by: pluknet MD testing by: marcel, marius, gonzo, andreast
* Revert r222363, as bde@ pointed out the initial solution was far moreattilio2011-05-311-1/+1
| | | | correct.
* Style fix: cast to size_t rather than u_long when comparing to sizeof()attilio2011-05-271-1/+1
| | | | | | rets. Requested by: kib
* In the near future cpuset_t objects in struct pcpu will be axed out, butattilio2011-05-271-2/+29
| | | | | | | | as long as this does not happen, we need to fix interfaces to userland in order to not break run-time accesses to the structure. Reviwed by: kib Tested by: pluknet
* MFCattilio2011-05-142-8/+0
|
* libkvm: fix logic inversion introduced with last commituqs2011-02-021-2/+2
| | | | | Reported by: Brandon Gooch <jamesbrandongooch@gmail.com> Pointy hat to: uqs
* libkvm: Unbreak build for powerpc64/powerpcuqs2011-01-241-0/+1
| | | | | This slipped through my testing due to the recent roto-tiling of the ARCH/TARGET parts that I need to catch up with. Mea culpa.
* libkvm: fix process runtime calculation on crashdumpsuqs2011-01-232-13/+29
| | | | | | | | | | | | | Fix a long standing bug, where the procs ticks where assumed to be in us. Instead, read cpu_tick_frequency from the kernel and use the same logic to convert runtime. This is still too optimistic in that it assumes cpu_tick_frequency is available and fixed. Since this function is only called on crashdumps, I think we can live with that. Testing has shown the values to be correct for different kern.hz inside Virtualbox. Bump WARNS. Alignment issues on some archs mean this is still at 3. Reviewed by: bde
* libkvm code janitoringuqs2011-01-2320-309/+215
| | | | | | | | | | | | - make WARNS=6 clean for archs w/o strict alignment requirments - add const, ANSIfy, remove unused vars, cast types for comparison - thanks to differing definitions of VM_MIN_ADDRESS across our archs, we need to trick the compiler to not complain about signedness. We could either fix VM_MIN_ADDRESS to always be a simple integer or make the check conditional on $ARCH. Closes PRs: kern/42386, kern/83364 Reviewed by: bde
* Revert most of r210764, now that mdocml does the rightuqs2010-12-281-1/+1
| | | | | | thing with empty quotation macros. Requested by: Alex Kozlov
* Similar to sys/net/vnet.h, define the linker set name for sys/sys/pcpu.hdim2010-11-142-5/+6
| | | | as a macro, and use it instead of literal strings.
* amd64: introduce minidump version 2avg2010-11-111-14/+94
| | | | | | | | | | | | | | | | | | After KVA space was increased to 512GB on amd64 it became impractical to use PTEs as entries in the minidump map of dumped pages, because size of that map alone would already be 1GB. Instead, we now use PDEs as page map entries and employ two stage lookup in libkvm: virtual address -> PDE -> PTE -> physical address. PTEs are now dumped as regular pages. Fixed page map size now is 2MB. libkvm keeps support for accessing amd64 minidumps of version 1. Support for 1GB pages is added. Many thanks to Alan Cox for his guidance, numerous reviews, suggestions, enhancments and corrections. Reviewed by: alc [kernel part] MFC after: 15 days
* Add minidump support for MIPSgonzo2010-11-074-11/+318
|
* Repair some build breakage introduced in r211725 and garbage collect somenwhitehorn2010-08-281-2/+8
| | | | code made obsolete in the same commit.
* MFtbemd:imp2010-08-231-3/+4
| | | | | Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want to test of all the CPUs of a given family conform.
* mdoc: make sure to pass at least one argument to quotation macrosuqs2010-08-021-1/+1
|
* 64-bit PowerPC KVM support.nwhitehorn2010-07-101-0/+218
|
* Much closer approximation of the kernel's calculation of this value.sbruno2010-06-181-1/+6
| | | | | Reviewed by: alc Obtained from: Yahoo Inc.
OpenPOWER on IntegriCloud