History log of /freebsd-current/lib/libkvm/kvm_amd64.c
Revision Date Author Comments
# dc36d6f9 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

lib: Remove ancient SCCS tags.

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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 993d074b 22-May-2018 John Baldwin <jhb@FreeBSD.org>

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


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# 8baaf913 11-Nov-2017 Will Andrews <will@FreeBSD.org>

libkvm: fix build failures


# 881b0edb 21-Mar-2017 Enji Cooper <ngie@FreeBSD.org>

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


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

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


# 8b4e5ab9 30-Apr-2016 Enji Cooper <ngie@FreeBSD.org>

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


# fb0e1892 22-Apr-2016 Enji Cooper <ngie@FreeBSD.org>

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


# ad3ecc20 28-Mar-2016 John Baldwin <jhb@FreeBSD.org>

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


# 7f911abe 27-Nov-2015 John Baldwin <jhb@FreeBSD.org>

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


# e7d939bd 06-Jul-2014 Marcel Moolenaar <marcel@FreeBSD.org>

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


# c10970dd 23-Jan-2011 Ulrich Spörlein <uqs@FreeBSD.org>

libkvm code janitoring

- 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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 953e4134 13-Jun-2009 Ed Schouten <ed@FreeBSD.org>

Fix missing includes of <string.h>, to silence some compiler warnings.

Submitted by: Pawel Worach


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# d7dc9f76 15-Jun-2007 Hidetoshi Shimokawa <simokawa@FreeBSD.org>

Re-enable raw dump format support on i386 and amd64 for /dev/fwmem.


# 67e40531 08-Jan-2007 Warner Losh <imp@FreeBSD.org>

Remove the advertising clause. UCB did this some time ago, but these
files were never updated to reflect that.

MFC After: 2 days


# e9ca6fe4 20-Apr-2006 Peter Wemm <peter@FreeBSD.org>

Teach libkvm how to read minidumps. It turns out that minidumps are
far more convenient for libkvm to work with because of the page table
block at the beginning. As a result, the MD code is smaller.

libkvm will automatically detect old vs mini dumps on i386 and amd64.

libkvm will handle i386 PAE and non-PAE modes. There is a PAE flag in
the i386 minidump header to signal the width of the entries in the
page table block.

Other convenient values are also present, such as kernbase and the direct
map addresses on amd64.


# add112ff 19-Oct-2005 Peter Wemm <peter@FreeBSD.org>

Fix a well duplicated fencepost error that stopped crashdumps being
readable on certain random memory configurations. If the libkvm consumer
tried to read something that was in the very last pdpe, pde or pte slot,
it would bogusly fail.

This is broken in RELENG_6 too.


# e55a0cd8 29-Jun-2005 Peter Wemm <peter@FreeBSD.org>

Support crash dumps > 4GB in size on 32 bit platforms. _kvm_kvatop()
returned an lseek offset in a "u_long *" value, which can't express >4GB
offsets on 32 bit machines (eg: PAE). Change to "off_t *" for all.

Support ELF crashdumps on i386 and amd64.

Support PAE crashdumps on i386. This is done by auto-detecting the
presence of the IdlePDPT which means that PAE is active.

I used Marcel's _kvm_pa2off strategy and ELF header reader for ELF support
on amd64. Paul Saab ported the amd64 changes to i386 and we implemented
the PAE support from there.

Note that gdb6 in the src tree uses whatever libkvm supports. If you want
to debug an old crash dump, you might want to keep an old libkvm.so handy
and use LD_PRELOAD or the like. This does not detect the old raw dump
format.

Approved by: re


# f2b29125 19-May-2004 Peter Wemm <peter@FreeBSD.org>

Implement crashdump decoding for AMD64 as well, now that I have finally
got a sample to test against.


# a1de871d 30-Apr-2003 Peter Wemm <peter@FreeBSD.org>

AMD64 support; repocopied from i386


# 6eabd845 10-Oct-2001 Bruce Evans <bde@FreeBSD.org>

Compensate for "Compensate for header dethreading" by backing it out.


# e67f5b9f 16-Sep-2001 Matthew Dillon <dillon@FreeBSD.org>

Implement __FBSDID()


# f85f3040 24-Aug-2001 Peter Wemm <peter@FreeBSD.org>

Dynamically adjust to the value of KERNBASE in a crashdump, with
a fallback for old kernels without the "kernbase" symbol.


# 82633431 01-May-2001 Mark Murray <markm@FreeBSD.org>

Compensate for header dethreading.


# c4a7cdb3 27-Dec-1999 Peter Wemm <peter@FreeBSD.org>

Use kldsym(2) to lookup symbol values. This avoids the kvm_mkdb juggling
and is module aware. Yes, this means that kvm_nlist(3) will find symbols
in loaded modules. The emulation of the nlist struct is pretty crude but
seems to work well enough for all the users in the tree that I found.


# 4afb0d5a 17-Aug-1997 Tor Egge <tegge@FreeBSD.org>

Copy code from gnu/usr.bin/gdb/gdb/kvm-fbsd.c to deal with 4 MB pages.


# 2f85bf6e 07-Oct-1996 Peter Wemm <peter@FreeBSD.org>

Implement virtual-to-physical address mapping for the kvm library on
dead kernel debugging. The previous code was a "do nothing".

The most obvious side effect of this is that you can now do things like
this and reasonably expect them to work:
dmesg -M /var/crash/vmcore.3 -N /var/crash/kernel.3
ps -axl -M /var/crash/vmcore.3 -N /var/crash/kernel.3

A good deal of this was lifted from the gdb code to do this, as well as
from NetBSD's libkvm (which has completely different VM macros)


# 51295a4d 12-Jul-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


# 2572133e 02-May-1996 Poul-Henning Kamp <phk@FreeBSD.org>

NBPG -> PAGE_SIZE


# 6c06b4e2 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 3f318480 07-Nov-1994 Poul-Henning Kamp <phk@FreeBSD.org>

A semicolon was lost.


# e4bd6287 07-Nov-1994 Jordan K. Hubbard <jkh@FreeBSD.org>

From: "gj%pcs.dec.com@inet-gw-1.pa.dec.com" <garyj@rks32.pcs.dec.com>
Given the right circumstances, a call to kvm_open can result in a core
dump.

The diff belows fixes this (note that this change is already in the
NetBSD code). Could somebody apply this?

Gary J.
Submitted by: gj


# 338c7541 11-Aug-1994 David Greenman <dg@FreeBSD.org>

Made kvm routines use procfs to get out process data such as argument
strings.


# 21d54b07 27-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

Fix kvm_i386.c just enough to make it compile and return lots of errors
when called. Noop out swapread in kvm_proc.c as our vm system is
different.


# f95a0250 27-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

This is a COPY of kvm_hp300.c, soon to be patched to sorta work with
the i386 port.