Commit graph

456 commits

Author SHA1 Message Date
John Baldwin 993d074be6 Use __SCCSID for SCCS IDs in libkvm sources.
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
2018-05-22 15:52:22 +00:00
Dag-Erling Smørgrav 6bff85ff9a Reduce <sys/queue.h> pollution.
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
2018-05-11 00:01:43 +00:00
Pedro F. Giffuni 5e53a4f90f lib: further adoption of SPDX licensing ID tags.
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.
2017-11-26 02:00:33 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
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.
2017-11-20 19:49:47 +00:00
Will Andrews ec8659b385 libkvm: fix lib32 build. 2017-11-12 03:28:47 +00:00
Will Andrews 8baaf913be libkvm: fix build failures 2017-11-12 01:36:48 +00:00
Will Andrews 2aa6a4f3c8 libkvm: fix 'index' shadowing. 2017-11-12 00:00:38 +00:00
Will Andrews c9057838be libkvm: add kvm_walk_pages API.
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
2017-11-11 23:30:58 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery 3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Enji Cooper 8c09935728 Add HAS_TESTS to all Makefiles that use the SUBDIR.${MK_TESTS}+= tests idiom 2017-08-02 08:14:06 +00:00
Enji Cooper 9f825b1b1d Fix #if conditional added in r319008
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
2017-05-27 23:23:22 +00:00
Enji Cooper fbf8ca6df8 kvm_geterr_test: Compile out the portions that require kvm_open2(3) on
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
2017-05-27 23:19:32 +00:00
Konstantin Belousov 6992112349 Commit the 64-bit inode project.
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
2017-05-23 09:29:05 +00:00
Enji Cooper 10f81a9b3b 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.

Reviewed by:	markj
MFC after:	2 months
Sponsored by:	Dell EMC Isilon
Differential Revision:	D10024
2017-03-28 17:37:49 +00:00
Enji Cooper 25e76a1d57 libkvm: bump WARNS to 6 after recent commits done to resolve warnings issues
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
2017-03-22 02:44:39 +00:00
Enji Cooper 881b0edb8f libkvm: fix warning issues post-r291406
- 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
2017-03-22 02:42:00 +00:00
Enji Cooper 0f5425a4fc 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].

Differential Revision:	D10082
MFC after:	1 week
Reviewed by:	cem (earlier diff), vangyzen
Submitted by:	cem [1]
Sponsored by:	Dell EMC Isilon
2017-03-21 20:48:36 +00:00
Enji Cooper 7d0a282a12 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`.

Differential Revision:	D10022
MFC after:	1 week
Reviewed by:	vangyzen
Sponsored by:	Dell EMC Isilon
2017-03-21 19:02:17 +00:00
Enji Cooper 54fc00f7f9 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 after:	1 week
Reviewed by:	vangyzen
Sponsored by:	Dell EMC Isilon
Differential Revision:	D10065
2017-03-20 18:28:22 +00:00
Enji Cooper 4937896a10 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).

MFC after:	1 week
Noticed by:	vangyzen (D10022)
Relnotes:	yes
Sponsored by:	Dell EMC Isilon
2017-03-20 02:47:28 +00:00
Enji Cooper 3eb11185a6 kvm_open2(3): remove '*' when describing addr argument for resolver
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
2017-03-20 01:19:04 +00:00
Enji Cooper f72823da48 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

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-19 23:04:58 +00:00
Enji Cooper 1f50ad62db 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 after:	1 week
X-MFC with:	r315363
Sponsored by:	Dell EMC Isilon
2017-03-16 03:24:15 +00:00
Enji Cooper 494deaf862 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.

MFC after:	1 week
Reported by:	make manlint
Sponsored by:	Dell EMC Isilon
2017-03-16 03:20:59 +00:00
Enji Cooper d5f024f279 Capitalize .Dt macro argument
By convention, per mdoc(7), the document title should be all caps.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-16 03:18:06 +00:00
Enji Cooper 28047d83f0 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 after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-16 02:31:42 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
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
2017-02-28 23:42:47 +00:00
Pedro F. Giffuni eca80cd0ae 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 after:	2 weeks
2017-01-02 15:12:11 +00:00
Andriy Gapon 7502cc401b libkvm: support access to vmm guest memory, allow writes to fwmem and vmm
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
2016-12-27 10:17:56 +00:00
Gleb Smirnoff f6080aabd7 Fix memory leak.
CID:		1367751
Reviewed by:	jhb
2016-12-20 20:11:16 +00:00
Eric van Gyzen 3d32d4a7c9 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.

Reviewed by:	kib
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D8722
2016-12-07 15:04:22 +00:00
Will Andrews ffdeef3234 libkvm: Improve physical address lookup scaling.
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
2016-07-18 01:55:25 +00:00
Will Andrews 8fb15a24ce libkvm: Bounds check (more) PTE indices. 2016-07-18 01:03:39 +00:00
Will Andrews 197eca22ed libkvm: Put private kvm routines in kvm_private.c. 2016-07-18 01:02:52 +00:00
Pedro F. Giffuni 75f46cf6c8 lib: minor spelling fixes in comments.
No functional change.
2016-05-01 19:37:33 +00:00
Enji Cooper 8b4e5ab944 Don't leak PML4 in _amd64_initvtop(..) if kvm_read2(..) fails
MFC after: 1 week
Reported by: Coverity
CID: 1341474
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:32:19 +00:00
Enji Cooper 9bc9176923 Remove a -Wunused-but-set-variable variable -- pa
Reported by: gcc 5.x
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:31:01 +00:00
Enji Cooper 7aad67e9ca Remove kvm_getfiles(3)
This libcall has been broken since (at least) r174989/8.0-RELEASE.

Bump SHLIB_MAJOR for the change

Differential Revision: https://reviews.freebsd.org/D6052
Relnotes: yes
Reviewed by: jhb, markj
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:21:13 +00:00
Enji Cooper 68b68bf55d 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

Differential Revision: https://reviews.freebsd.org/D6051
MFC after: 1 week
Reviewed by: jhb, markj
Reported by: cppcheck
Sponsored by: EMC / Isilon Storage Division
2016-04-30 09:13:26 +00:00
Enji Cooper fb0e1892d9 Fix up pointer issues with lib/libkvm
In particular,
- avoid dereferencing NULL pointers
- test pointers against NULL, not 0
- test for errout == NULL in the top-level functions (kvm_open, kvm_openfiles,
  kvm_open2, etc)
- Replace a realloc and free on failure with reallocf

Found with: devel/cocchinelle

Differential Revision: https://reviews.freebsd.org/D5954
MFC after: 1 week
Reviewed by: jhb
Sponsored by: EMC / Isilon Storage Division
2016-04-22 18:05:34 +00:00
Glen Barber d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
John Baldwin ad3ecc2025 Fix parsing of a 1GB page table entry.
Use 'pdpe' to extract the PA of the 1GB page instead of 'pde' (which was
a copy and paste bug from the 2MB page case further down).

CID:		1341467
Reported by:	pfg
2016-03-28 18:41:48 +00:00
Glen Barber 317cec3c43 MFH
Sponsored by:	The FreeBSD Foundation
2016-02-22 12:28:23 +00:00
Svatopluk Kraus 08674c4573 Rename pte.h to pte-v4.h and start including directly either pte-v4.h
or pte-v6.h in files which needs it.

There are quite internal definitions in pte-v4.h and pte-v6.h headers
specific for corresponding pmap implementation. These headers should be
included only in very few files and an intention is to not hide for
which implementation such files are.

Further, sys/arm/arm/elf_trampoline.c is an example of file which
uses armv4 like pmap implementation for both armv4 and armv6 platforms.
This is another reason why pte.h which includes specific header
according to __ARM_ARCH is not created.
2016-02-19 09:23:32 +00:00
Svatopluk Kraus d97d068fe8 Remove redundant ARM_L2_ADDR_BITS and L2_ADDR_BITS definitions and
replace them by primary ones where needed.
2016-02-18 09:30:04 +00:00
Glen Barber a70cba9582 First pass through library packaging.
Sponsored by:	The FreeBSD Foundation
2016-02-04 21:16:35 +00:00
Svatopluk Kraus effb4b3c8c Add mmu format info into ARM vmcore.
Fix kvatop translation for 64K pages.

Reviewed by:	jhb
Approved by:	kib (mentor)
Differential Revision:    https://reviews.freebsd.org/D4942
2016-01-15 18:53:06 +00:00
John Baldwin 2f9e579166 Fix building with GCC since PAGE_MASK is signed on i386.
Reviewed by:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D4772
2016-01-14 15:51:13 +00:00
John Baldwin 7f911abe54 Add support to libkvm for reading vmcores from other architectures.
- Add a kvaddr_type to represent kernel virtual addresses instead of
  unsigned long.
- Add a struct kvm_nlist which is a stripped down version of struct nlist
  that uses kvaddr_t for n_value.
- Add a kvm_native() routine that returns true if an open kvm descriptor
  is for a native kernel and memory image.
- Add a kvm_open2() function similar to kvm_openfiles().  It drops the
  unused 'swapfile' argument and adds a new function pointer argument for
  a symbol resolving function.  Native kernels still use _fdnlist() from
  libc to resolve symbols if a resolver function is not supplied, but cross
  kernels require a resolver.
- Add a kvm_nlist2() function similar to kvm_nlist() except that it uses
  struct kvm_nlist instead of struct nlist.
- Add a kvm_read2() function similar to kvm_read() except that it uses
  kvaddr_t instead of unsigned long for the kernel virtual address.
- Add a new kvm_arch switch of routines needed by a vmcore backend.
  Each backend is responsible for implementing kvm_read2() for a given
  vmcore format.
- Use libelf to read headers from ELF kernels and cores (except for
  powerpc cores).
- Add internal helper routines for the common page offset hash table used
  by the minidump backends.
- Port all of the existing kvm backends to implement a kvm_arch switch and
  to be cross-friendly by using private constants instead of ones that
  vary by platform (e.g. PAGE_SIZE).  Static assertions are present when
  a given backend is compiled natively to ensure the private constants
  match the real ones.
- Enable all of the existing vmcore backends on all platforms.  This means
  that libkvm on any platform should be able to perform KVA translation
  and read data from a vmcore of any platform.

Tested on:	amd64, i386, sparc64 (marius)
Differential Revision:	https://reviews.freebsd.org/D3341
2015-11-27 18:58:26 +00:00
John Baldwin 9789cd30e5 Remove trailing whitespace. 2015-11-26 19:42:10 +00:00
John Baldwin 8296e78c83 Remove kvm_sparc.c. This is for 32-bit sparc support and was imported
from 4.4BSD.  It has never been used by FreeBSD.
2015-11-26 19:39:15 +00:00
Bryan Drewery 7b3ea376a2 META MODE: Prefer INSTALL=tools/install.sh to lessen the need for xinstall.host.
This both avoids some dependencies on xinstall.host and allows
bootstrapping on older releases to work due to lack of at least 'install -l'
support.

Sponsored by:	EMC / Isilon Storage Division
2015-11-25 19:10:28 +00:00
Andrew Turner db5ac78d34 Add support to libkvm for reading minidumps on arm64. The kernel side is
missing until it can be cleaned up.

Reviewed by:	jhb
Approved by:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3319
2015-08-20 11:07:51 +00:00
Konstantin Belousov b4490c6e93 The si_status field of the siginfo_t, provided by the waitid(2) and
SIGCHLD signal, should keep full 32 bits of the status passed to the
_exit(2).

Split the combined p_xstat of the struct proc into the separate exit
status p_xexit for normal process exit, and signalled termination
information p_xsig.  Kernel-visible macro KW_EXITCODE() reconstructs
old p_xstat from p_xexit and p_xsig.  p_xexit contains complete status
and copied out into si_status.

Requested by:	Joerg Schilling
Reviewed by:	jilles (previous version), pho
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2015-07-18 09:02:50 +00:00
Baptiste Daroussin 18b2ee82db Revert r284417 it is not necessary anymore 2015-06-15 19:28:07 +00:00
Baptiste Daroussin 4232f82668 Enforce overwritting SHLIBDIR
Since METAMODE has been added, sys.mk loads bsd.mkopt.mk which ends load loading
bsd.own.mk which then defines SHLIBDIR before all the Makefile.inc everywhere.

This makes /lib being populated again.

Reported by:	many
2015-06-15 15:34:20 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Andrew Turner cd12a51d8d Add stub functions to build libkvm. There will be added, but we need them
now get the toolchain target building.

Differential Revision:	https://reviews.freebsd.org/D2185
Sponsored by:	The FreeBSD Foundation
2015-04-02 17:30:19 +00:00
Simon J. Gerraty 9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Andrew Turner 58c47a70a3 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.

Differential Revision:	https://reviews.freebsd.org/D939
MFC after:	1 week
2014-10-19 20:23:31 +00:00
Adrian Chadd e77f9fed15 Update the ULE scheduler + thread and kinfo structs to use int for cpuid
rather than u_char.

To try and play nice with the ABI, the u_char CPU ID values are clamped
at 254.  The new fields now contain the full CPU ID, or -1 for no cpu.

Differential Revision:	D955
Reviewed by:	jhb, kib
Sponsored by:	Norse Corp, Inc.
2014-10-18 19:36:11 +00:00
Andrew Turner 89184254a4 Fix the type of pte_pa as when it is passed into _kvm_pa2off it is either
a uint64_t or a pointer to an off_t. With it being a u_long can result in
incorrect values being returned.
2014-10-16 13:49:54 +00:00
Simon J. Gerraty ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Marcel Moolenaar e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty 9d2ab4a62d Merge head 2014-04-27 08:13:43 +00:00
Andrew Turner 73279d4113 Add a new ARM TARGET_ARCH, armv6hf. This is considered experimental.
This targets the existing ARMv6 and ARMv7 SoCs that contain a VFP unit.
This is an optional coprocessors may not be present in all devices, however
it appears to be in all current SoCs we support.

armv6hf targets the VFP variant of the ARM EABI and our copy of gcc is too
old to support this. Because of this there are a number of WITH/WITHOUT
options that are unsupported and must be left as the default value. The
options and their required value are:
 * WITH_ARM_EABI
 * WITHOUT_GCC
 * WITHOUT_GNUCXX

In addition, without an external toolchain, the following need to be left
as their default:
 * WITH_CLANG
 * WITH_CLANG_IS_CC

As there is a different method of passing float and double values to
functions the ABI is incompatible with existing armv6 binaries. To use
this a full rebuild of world is required. Because no floating point values
are passed into the kernel an armv6 kernel with VFP enabled will work with
an armv6hf userland and vice versa.
2014-03-23 12:49:25 +00:00
Gleb Smirnoff 9292aad4c9 Add kvm_getncpus() to obtain mp_ncpus.
Sponsored by:	Nginx, Inc.
2014-02-12 19:22:48 +00:00
Ed Maste 4842a3220d Add bounds check for pteindex / pdeindex 2014-02-12 15:57:38 +00:00
Gleb Smirnoff 19b5cffe0b 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().

Sponsored by:	Nginx, Inc.
2014-02-12 09:41:17 +00:00
John-Mark Gurney d5ad10055b add support for building a cross-gdb for ARM... This isn't hooked up
to xdev yet as I don't know how to make it work properly...  It also
isn't heavily tested...

Reviewed by:	silence on -arm
2014-02-12 02:08:42 +00:00
Marcel Moolenaar 0b6a0ca072 Handle truncation of the size returned by _kvm_kvatop(). Cores can have
segments larger than INT_MAX.
2014-01-16 06:26:03 +00:00
Marcel Moolenaar cfe2be2b5e We don't have to worry about page sizes when working on virtual
cores (i.e. minidumps). Every segment is virtually contiguous.
2014-01-13 19:02:31 +00:00
Marcel Moolenaar f864e2ab73 Re-apply the part of r260022 that was reverted by r260030 with
one significant difference: for LIB32 builds both TARGET_ARCH
and MACHINE_ARCH are defined. TARGET_ARCH confusingly holds the
architecture of the host (e.g. amd64), while MACHINE_ARCH holds
the architecture were trying to build (e.g. i386). With both
set and different, r260022 changed the behaviour to interpret
the condition as building a cross-amd64 libkvm on i386, when
obviously we're trying to build an i386 version on amd64. When
COMPAT_32BIT is defined, we're building LIB32 and ignore the
value of TARGET_ARCH as we did before.
2014-01-13 19:01:14 +00:00
Marcel Moolenaar 71694e554d Revert part of r260022: LIB32 builds were broken by it. 2013-12-29 03:15:15 +00:00
Marcel Moolenaar 5f96573141 Add support for virtual cores (aka minidumps). To that end, refactor this
file as follows:
1.  Common ia64-specific support functions have the ia64_ prefix.
2.  Functions that work on physical cores have the phys_ prefix.
3.  Functions that work on virtual cores have the virt_ prefix.

With that:
1.  _kvm_kvatop() has been renamed to phys_kvatop() as it handles
    physical cores only.
2.  The new _kvm_kvatop() is nothing but a wrapper that calls either
    phys_kvatop() or virt_kvatop() by virtue of the kvatop function
    pointer in the vmstate structure.
3.  virt_kvatop() is nothing but a wrapper around virt_addr2off().
4.  virt_addr2off() iterates over the Phdrs to find the segment in
    which the address falls and return the file offset for it.

Now it's up to the kernel to populate the core file appropriately.
2013-12-29 02:31:40 +00:00
Marcel Moolenaar 4081b25521 Allow building a cross libkvm for ia64. 2013-12-28 23:02:48 +00:00
Marcel Moolenaar 3f6558c489 Allow building a cross libkvm by setting TARGET_ARCH. The library so
produced will be called libkvm-${ARCH} instead of libkvm. This allows
installing it alongside the native version.
For symbol lookups, use ps_pglobal_lookup() instead of __fdnlist()
when building a cross libkvm. It is assumed that the cross tool that
uses the cross libkvm also provides an implementation for this
proc_services function.

Note that this commit does not change any of the architecture-specific
code for cross-compilation.
2013-12-28 23:01:57 +00:00
Marcel Moolenaar 8a69c4ada4 Fix "kptdir is itself virtual" error, caused by having the kptdir in PBVM.
While here improve errors by having them include addresses (either virtual
or physical).
2013-12-26 07:10:54 +00:00
Gleb Smirnoff 3329973740 Revert r256514 for libkvm. It wasn't correct actually and breaks build. 2013-10-15 13:53:35 +00:00
Gleb Smirnoff 511b5fa590 - While we are spreading the counter(9) across network stack, more userland
tools would need to know about the counter_u64_t type. Allow to include
sys/counter.h from userspace.
- Utilize now defined type in kvm_counter_u64_fetch().

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-15 10:05:37 +00:00
Simon J. Gerraty d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Mikolaj Golub 374931bdc1 In r227839, when removing libkvm dependency on procfs(5),
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
2013-07-10 19:44:43 +00:00
Ed Maste 371df6c6ad Switch to 2-clause license and standard text
Approved by:	bms@
2013-06-06 21:09:27 +00:00
Jilles Tjoelker 7b05a79942 libkvm: Make second /dev/null file descriptor close-on-exec as well.
MFC after:	1 week
2013-05-04 11:45:48 +00:00
Jilles Tjoelker 76dce67f0f libkvm: Use O_CLOEXEC instead of separate fcntl(F_SETFD) call.
MFC after:	1 week
2013-05-04 09:47:51 +00:00
Simon J. Gerraty 69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Joel Dahl aaaade7024 Remove EOL whitespace. 2013-04-11 13:05:38 +00:00
Gleb Smirnoff 8d13912c31 Fix typo. 2013-04-11 10:14:28 +00:00
Gleb Smirnoff b448b67bbb Include types.h for C99 uintXX_t types. 2013-04-11 07:30:49 +00:00
Gleb Smirnoff 2a2134043c o Provide function kvm_read_zpcpu() to access UMA_ZONE_PCPU allocations.
o Provide function kvm_counter_u64_fetch() to fetch valut of a counter(9).

Sponsored by:	Nginx, Inc.
2013-04-10 20:26:53 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Andriy Gapon ca895af355 kvm_getprocs: gracefully handle errors from kvm_deadprocs
and don't confuse callers with incorrect return value

MFC after:	9 days
2012-10-06 20:16:04 +00:00
Andriy Gapon 9fb9ea1c03 kvm_proclist: ignore processes in larvae state
Reviewed by:	jhb
MFC after:	8 days
2012-10-06 20:12:24 +00:00