Commit Graph

1598 Commits

Author SHA1 Message Date
Omar Sandoval
b47152a6e7 tests: remove unused IDR from test kernel module
The test kernel module has several -Woverflow warnings when compiled for
Arm:

  /home/osandov/repos/drgn/build/vmtest/arm/tmp9g8977mn/drgn_test.c:785:9: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '6221254864074593878' to '1448498774' [-Woverflow]
    785 |         0x5656565656565656,
        |         ^~~~~~~~~~~~~~~~~~
  /home/osandov/repos/drgn/build/vmtest/arm/tmp9g8977mn/drgn_test.c:786:9: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '1311768465173141112' to '305419896' [-Woverflow]
    786 |         0x1234567812345678,
        |         ^~~~~~~~~~~~~~~~~~
  /home/osandov/repos/drgn/build/vmtest/arm/tmp9g8977mn/drgn_test.c:787:9: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '1311768467294899695' to '2427178479' [-Woverflow]
    787 |         0x1234567890abcdef,
        |         ^~~~~~~~~~~~~~~~~~

drgn_test_idr_dense and drgn_test_idr_ptrs aren't actually used by the
tests, so remove them.

Fixes: 4f2c8f0735 ("tests: idr: add test cases for idr.")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-27 17:31:23 -07:00
Omar Sandoval
28e7a79925 setup.py: use setuptools versions of distutils.command.build and distutils.errors
The setuptools guide for porting from distutils [1] recommends this.
However, the setuptools versions aren't available on older versions of
setuptools, so we still need to fall back to distutils.

1: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-27 16:03:43 -07:00
Omar Sandoval
53fdd6cad7 setup.py: replace distutils.log with logging from standard library
The setuptools guide for porting from distutils [1] recommends this.

1: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-27 16:02:04 -07:00
Omar Sandoval
2017cd6fe2 setup.py: use copy_file and mkpath from setuptools.Command instead of distutils
distutils is deprecated and was removed in Python 3.12 [1]. setuptools
provides a vendored copy of distutils, but they discourage against using
it [2]. So, let's stop importing distutils, starting with replacing our
calls of distutils.file_util.copy_file() and distutils.dir_util.mkpath()
with their equivalent methods from setuptools.Command.

1: https://peps.python.org/pep-0632/
2: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-27 15:57:21 -07:00
Omar Sandoval
91644e48d3 Move supported kernel versions from setup.py to vmtest.config
And use the list of flavors from vmtest.config in setup.py instead of
duplicating it.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-27 10:17:40 -07:00
Omar Sandoval
f14624baac Update elfutils in manylinux wheels to 0.189
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-27 09:53:21 -07:00
Omar Sandoval
4c3c886b5a setup.py: add 6.4 to vmtest kernels
6.4 needed an unusual number of changes:

- 3f3a957562 ("libdrgn: linux_kernel: Fix module detection on kernel
  v6.4")
- da7a11f83e ("drgn.helpers.linux.block: update
  for_each_{disk,partition} for Linux 6.4")
- 7e7c300a139b ("libdrgn: orc_info: handle ORC changes in Linux 6.3 and
  6.4")

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
91ede0c6a4 libdrgn: orc_info: handle ORC changes in Linux 6.3 and 6.4
The ORC format changed twice recently:

- Linux kernel commit ffb1b4a41016 ("x86/unwind/orc: Add 'signal' field
  to ORC metadata") (in v6.3).
- Linux kernel commit fb799447ae29 ("x86,objtool: Split
  UNWIND_HINT_EMPTY in two") (in v6.4).

The former went unnoticed because the change was subtle, and the latter
completely broke x86-64 kernel stack traces.

To handle this, let's "upgrade" the format to the latest version when we
load and sort the ORC information. This is more work upfront but avoids
needing to handle the version differences every time we use ORC to
unwind.

Unfortunately, ORC currently doesn't have any sort of versioning, so we
have to break the rule of not checking kernel versions. However, I have
a kernel patch pending merging that should fix this for the future.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
fc47ec1b78 libdrgn: add prog pointer to struct drgn_module
The next commit needs this.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
3085259d82 libdrgn: orc_info: use unsigned int instead of size_t for num_entries
It's unrealistic for there to be more than 4 billion ORC entries. Switch
to an unsigned int. The main benefit is that the indices array that we
use to sort the parallel arrays of entries and pc_offsets becomes half
the size, which also makes parsing ORC about 10% faster (down from ~5 ms
to ~4.5 ms for the Fedora vmlinux on my laptop).

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
dd08658a6e libdrgn: don't cache ORC sections in struct drgn_elf_file
.orc_unwind_ip and .orc_unwind are only referenced while initially
parsing ORC data and then never touched again, so it's wasteful to cache
them in struct drgn_elf_file. Look them up if and when we parse the ORC
data instead.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
0bb503c6a0 libdrgn: orc_info: check ORC section alignment instead of copying
In practice, the .orc_unwind and .orc_unwind_ip sections will always be
suitably aligned. Check it, then assume the alignment later.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
8526b86644 libdrgn: linux_kernel: get slightly smaller code for kernel_module_iterator_next()
By using the same temporary objects in the Linux 6.4 branch as the
pre-6.4 branch, we get slightly better code generation.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
104a14781d tests: test compressed debug sections
Test both .zdebug_* sections and SHF_COMPRESSED .debug_* sections.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-20 13:45:04 -07:00
Omar Sandoval
2ee625fc74 libdrgn: handle DWARF sections exactly* like libdw
We only support .debug_* sections, but libdw also supports .zdebug_*,
.debug_*.dwo, and .gnu.debuglto_.debug_*. Mimic how libdw chooses debug
sections, with one exception: .debug_cu_index and .debug_tu_index (used
for DWP, which we don't support yet but will) should be considered DWO
sections (this needs to be fixed in libdw, too).

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-20 13:45:04 -07:00
Omar Sandoval
9ad47a97eb contrib: add script to dump platform drivers
For a discussion on the linux-debuggers mailing list:
https://lore.kernel.org/linux-debuggers/87v8fiw0fm.fsf@oracle.com/T/#t

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-20 11:11:23 -07:00
Stephen Brennan
e9141fa396 ci: reduce usage and add Python 3.12 beta
With 3.12 beta, there are 7 Python versions to test, which is making the
test matrix too large. To reduce the amount of CI test runs that occur,
by default we will only run 2: the oldest and newest released Python
versions. To further reduce the CI test runs, we will eliminate CI runs
when a branch is pushed (only main will be tested).

The "ci" action becomes a reusable workflow, which gets called by other
possible workflows:

1. pull_request.yml: On pull request, only the 2 default Python versions
   are tested.  The "test-all-python-versions" label can be applied to
   pull requests to override this.
2. push.yml: On push to main, all Python versions are tested.
3. vmtest-build.yml: After the vmtest kernels are built
4. On manual request: the user has the option to specify

Signed-off-by: Stephen Brennan <stephen@brennan.io>
2023-06-15 17:31:57 -07:00
Omar Sandoval
cff9b6185c libdrgn: fix typo in ORC unwinder handling of ORC_REG_SP_INDIRECT
ORC_REG_SP_INDIRECT is supposed to be an indirect access via rsp, but we
have a typo and are using rbp instead. This is a partial fix for #304.

Fixes: 630d39e345 ("libdrgn: add ORC unwinder")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-15 13:03:10 -07:00
Omar Sandoval
95c7d9ab63 tests: add better test for kernel Program.crashed_thread()
Instead of simply checking whether the thread ID is non-zero, write a
specific task name to /proc/self/comm before crashing and check that.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-15 09:57:18 -07:00
Omar Sandoval
e2e2ebc317 libdrgn: fix Linux kernel crashed_thread() on non-x86 architectures
We currently use crashing_cpu to determine the thread that caused a
kernel crash. However, crashing_cpu is x86-specific (it is defined in
arch/x86/kernel/reboot.c). Since Linux 4.5, the generic panic code
defines a very similar variable, panic_cpu. Use that instead so that we
support all architectures, but fall back to crashing_cpu to support
older kernels on x86 (even though we don't claim to support 4.4
anymore).

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-15 07:56:19 -07:00
Johannes Thumshirn
e4b7749463 contrib: add btrfs block group dumper
Add a script to dump all btrfs block groups and decode relevant members to
contrib.

Example output for a given filesystem:
BG at 536870912
        flags: BTRFS_BLOCK_GROUP_DATA (0x1)
        length: 134217728
        used: 0
        pinned: 0
        reserved: 0
        runtime_flags: BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE|BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE (0x120)
        zone_unsuable: 0

BG at 671088640
        flags: BTRFS_BLOCK_GROUP_SYSTEM|BTRFS_BLOCK_GROUP_DUP (0x22)
        length: 134217728
        used: 16384
        pinned: 0
        reserved: 0
        runtime_flags: BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE|BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE (0x120)
        zone_unsuable: 16384

BG at 805306368
        flags: BTRFS_BLOCK_GROUP_METADATA|BTRFS_BLOCK_GROUP_DUP (0x24)
        length: 134217728
        used: 131072
        pinned: 0
        reserved: 0
        runtime_flags: BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE|BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE (0x120)
        zone_unsuable: 147456

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
2023-06-14 16:36:13 -07:00
Boris Burkov
c0694d6ce2 Add btrfs helpers to contrib
btrfs_tree.py is a pile of helpers Omar gave me once that I have
cherished ever since. It mostly deals with walking and parsing btrees.

btrfs_tree_mod_log.py is a script I wrote to do a tree mod log search
and rewind while debugging a btrfs issue.

Signed-off-by: Boris Burkov <boris@bur.io>
2023-06-09 09:38:26 -07:00
Omar Sandoval
772492838f drgn.helpers.linux.mm: add arbitrary address translation helpers
follow_{page,pfn,phys}() translate the virtual address by walking the
page table for a given mm_struct (built on top of the existing page
table iterator interface). vmalloc_to_page() and vmalloc_to_pfn() are
special cases for vmalloc addresses.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-02 23:40:38 -07:00
Omar Sandoval
573bfad9fb vmtest.kbuild: make BTF patches also fix kernel modules
Applying the 5.10-stable patches fixing BTF with older pahole to
5.11-5.13 missed updating the pahole flags for kernel modules (because
kernel modules didn't have BTF in 5.10). Regenerate the patches for 5.11
ourselves.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 23:47:15 -07:00
Omar Sandoval
de1251a72a vmtest.kbuild: add patch to fix --Werror=use-after-free build failures
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 23:47:08 -07:00
Omar Sandoval
5c92485950 setup.py: add 6.3 to vmtest kernels
Commit bf9159cff367 ("drgn.helpers.linux.mm: fix compound_{order,nr} for
Linux 6.3+") is the only change necessary for Linux v6.3.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 14:50:25 -07:00
Omar Sandoval
2d2a69a322 drgn.helpers.linux.mm: fix compound_{order,nr} for Linux 6.3+
Linux 6.3 removed struct page::compound_order. Instead, we need to use
struct folio::_folio_order. Update compound_order() and redefine
compound_nr() in terms of compound_order() so we only need to handle the
divergence in one place.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 14:50:25 -07:00
Omar Sandoval
da7a11f83e drgn.helpers.linux.block: update for_each_{disk,partition} for Linux 6.4
Linux kernel commits 884f8ce42cce ("driver core: class: implement
class_get/put without the private pointer.") and 2df418cf4b72 ("driver
core: class: remove subsystem private pointer from struct class") (in
v6.4) changed the way to go from struct class to struct subsys_private.
_for_each_block_device(), used by for_each_disk() and
for_each_partition(), needs struct subsys_private. The "new" way also
works on old kernels, so add _class_to_subsys() mirroring
class_to_subsys() in Linux 6.4 and make _for_each_block_device() use it.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 14:50:25 -07:00
Stephen Brennan
ce8b2938e6 libdrgn: linux_kernel: Fix compiler warning
With GCC 13.1.1 and the recommended build
setup (CONFIGURE_FLAGS="--enable-compiler-warnings=error"), I get the
following failure:

In function 'linux_kernel_get_vmemmap',
    inlined from 'linux_kernel_object_find' at ../../libdrgn/linux_kernel_object_find.inc.strswitch:34:12:
../../libdrgn/linux_kernel.c:370:23: error: 'address' may be used uninitialized [-Werror=maybe-uninitialized]
  370 |                 err = drgn_object_set_unsigned(&prog->vmemmap, qualified_type,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  371 |                                                address, 0);
      |                                                ~~~~~~~~~~~
../../libdrgn/linux_kernel.c: In function 'linux_kernel_object_find':
../../libdrgn/linux_kernel.c:361:26: note: 'address' was declared here
  361 |                 uint64_t address;
      |                          ^~~~~~~
cc1: all warnings being treated as errors

While linux_kernel_get_vmemmap_address should always update address in a
non-error case, the compiler seems to disagree. It's easy enough to shut
up the compiler by initializing address to 0. What's more, if there is
an actual issue where the linux_kernel_get_vmemmap_address does NOT
update the address variable, a 0 value will be easier to debug than
garbage from an uninitialized variable.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-06-01 14:49:34 -07:00
Stephen Brennan
49d6bfdb24 Fix test failure on Python 3.12 (fixes #298)
Running tests on Python 3.12, we get:

test_int (tests.test_language_c.TestLiteral.test_int) ... python3.12: /usr/include/python3.12/object.h:215: Py_SIZE: Assertion `ob->ob_type != &PyLong_Type' failed.
Aborted (core dumped)

We're relying on an implementation detail to check whether the object is
negative. Instead, catch an overflow error, negate and try again.
Genuine overflows will still overflow on the second time, but negative
numbers will succeed.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-06-01 14:23:51 -07:00
Ido Schimmel
3f3a957562 libdrgn: linux_kernel: Fix module detection on kernel v6.4
Kernel commit ac3b43283923 ("module: replace module_layout with
module_memory") in v6.4 changed the layout of `struct module`, resulting
in the following drgn error [1].

Fix this by first trying to determine the base address and size of each
kernel module via the `struct module_memory mem[MOD_TEXT]` member,
before falling back to previous methods that work on older kernels.

Tested on v6.4-rc2 and v6.3 which does not include the above mentioned
commit.

Note that kernel commit b4aff7513df3 ("scripts/gdb: use mem instead of
core_layout to get the module address") performs a similar fix in Python
GDB scripts.

Closes #296.

[1]
```
# drgn
drgn 0.0.22 (using Python 3.11.3, elfutils 0.189, with libkdumpfile)
For help, type help(drgn).
>>> import drgn
>>> from drgn import NULL, Object, cast, container_of, execscript, offsetof, reinterpret, sizeof
>>> from drgn.helpers.common import *
>>> from drgn.helpers.linux import *
warning: could not get debugging information for:
kernel modules (could not find loaded kernel modules: 'struct module' has no member 'core_size')
```

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2023-05-28 22:08:18 -07:00
Omar Sandoval
fc3ea4184a libdrgn: use new include-what-you-use exported declarations and fix warnings
include-what-you-use/include-what-you-use#1164 fixed
include-what-you-use/include-what-you-use#971 so that we can export
forward declarations instead of hacking around it. I can't reproduce the
issue with BINARY_OP_SIGNED_2C anymore either, so we can remove that
hack, too. Also fix any other warnings.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-05-24 00:25:25 -07:00
Omar Sandoval
067c139355 vmtest.kmod: document that -k may be given multiple times
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-03-27 13:18:44 -07:00
Sven Schnelle
73e451d588 tests: enable MM tests on s390x
s390x now has full mm support, so enable the tests for it.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
2023-03-22 15:24:11 -07:00
Sven Schnelle
3483a69a56 libdrgn: add s390x pagetable walk support
Add support for walking s390x page tables. This supports
up to 5 level page table walking and huge/large pages. In order
to figure out the level of paging used, we read the first entry
of the pgd, which is always mapped for lowcore access and use the
level bits of the next page table. This is because drgn passes mm::pgd
as pgtable argument to the walker function which doesn't contain the
ASCE bits.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
2023-03-22 15:24:11 -07:00
Martin Liska
1133b2fd31 Fix output for of lsmod.py
Unify it with what lsmod(8) does.

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-27 14:22:14 -08:00
Martin Liska
983ec87a77 contrib: add vmmap.py script
Mimics `cat /proc/$pid/maps` and the script output is:

Start        End          Flgs   Offset Dev   Inode            File path
55dee5284000-55dee53f3000 r-xp 00000000 fd:02 10515            /usr/lib/systemd/systemd
55dee53f3000-55dee5441000 r--p 0016f000 fd:02 10515            /usr/lib/systemd/systemd
55dee5441000-55dee5442000 rw-p 001bd000 fd:02 10515            /usr/lib/systemd/systemd
55dee5f4c000-55dee615d000 rw-p 00000000 00:00 0
7f5fc801c000-7f5fc8024000 r-xp 00000000 fd:02 1181379          /usr/lib64/libffi.so.7.1.0
7f5fc8024000-7f5fc8224000 ---p 00008000 fd:02 1181379          /usr/lib64/libffi.so.7.1.0
7f5fc8224000-7f5fc8225000 r--p 00008000 fd:02 1181379          /usr/lib64/libffi.so.7.1.0
...

Signed-off-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Omar Sandoval <osandov@osandov.com>
2023-02-25 02:08:46 -08:00
Martin Liska
35f9de75b3 contrib: add memory statistics to ps.py
New output of the command is:

PID     PPID    CPU  ST    VMS     RSS  MEM%  COMM
1       0       0    S   10.4M    6.5M   0.4 init
2       0       0    S       0       0   0.0 [kthreadd]
...
263     1       4    S    2.4G  163.5M   9.5 python3
264     1       5    S    2.4G  163.5M   9.5 python3
265     1       6    S    2.4G  163.5M   9.5 python3
266     1       10   S    2.4G  163.5M   9.5 python3
267     1       12   S    2.4G  163.5M   9.5 python3
268     1       13   S    2.4G  163.5M   9.5 python3
269     1       14   S    2.4G  163.5M   9.5 python3
270     1       15   S    2.4G  163.5M   9.5 python3
271     1       16   S    2.4G  163.5M   9.5 python3
...

Supports also older kernel releases like 4.4.

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-25 02:07:57 -08:00
Martin Liska
e6228245a0 Fix TCP listing contrib script
Since Linux kernel commit 8dbd76e79a16 ("tcp/dccp: fix possible race
__inet_lookup_established()") (in v5.5), it's actually hlist_nulls_head
what is used for items of inet_hashinfo::listening_hash. This commit was
also backported to stable kernels, so with the change it works for all
releases starting with v4.9. The version 4.4 is not supported right now
(nulls head list is probably not known at the time).

Fixes: #268

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-24 13:15:00 -08:00
Martin Liska
adc8c430bb add kernel_sys.py to contrib
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          #1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-24 12:22:00 -08:00
Omar Sandoval
0d03be7d62 libdrgn: silence -Wmaybe-uninitialized false positive
This false positive appears to only trigger on 32-bit. I reproduced it
with GCC 10 and 12.

Fixes #242.

Reported-by: Timothée Cocault <timothee.cocault@gmail.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-24 01:04:15 -08:00
Omar Sandoval
030fb78eaf vmtest.config: enable LPAE for Arm alternative flavor
LPAE uses a different page table format and enables 2GB huge pages, so
it'll be interesting to test.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 18:03:02 -08:00
Omar Sandoval
0b7238baa3 vmtest.config: fix CONFIG_KEXEC_FILE for s390x
On s390x, CONFIG_KEXEC_FILE depends on CONFIG_CRYPTO_SHA256_S390.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 17:44:05 -08:00
Omar Sandoval
cc77c444ba vmtest.config: enable rtc-cmos driver in x86-64 Kconfig
We go through the trouble of enabling a real-time clock driver for other
architectures, so do the same on x86-64.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 17:19:23 -08:00
Omar Sandoval
ee20b2d759 vmtest.config: enable hugetlbfs in kconfig
This will be used to test huge page address translation.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 17:09:40 -08:00
Omar Sandoval
07b9ee5f36 vmtest.kbuild: generate package in final directory
vmtest.kbuild -b $build_dir -p $package_dir --package-format directory
fails when attempting to rename the temporary package directory if
$build_dir and $package_dir are on different filesystems or Btrfs
subvolumes. Put the temporary package directory in $package_dir so that
the rename can succeed.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 11:16:46 -08:00
Omar Sandoval
ff89a6d267 drgn.helpers.linux.slab: fix check for directly mapped address
High memory is not directly mapped, so _find_containing_slab() needs to
check against max_low_pfn, not max_pfn.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 01:37:29 -08:00
Omar Sandoval
3a4480289c tests: remove @skip_unless_have_full_mm_support from page <-> pfn <-> phys helper tests
The phys <-> pfn helpers only need PAGE_SHIFT, which is always
available, the page <-> pfn helpers only need vmemmap or mem_map, which
is independent of virtual address translation, and the page <-> phys
helpers are built on top of those.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 16:12:33 -08:00
Omar Sandoval
7cf3d7ddf9 drgn.helpers.linux.mm: handle CONFIG_FLATMEM
AArch64, ppc64, s390x, and x86-64 all default to
CONFIG_SPARSEMEM_VMEMMAP, which allows us to translate between struct
page * and PFN with trivial array operations on vmemmap. Arm and i386,
however, use CONFIG_FLATMEM, which has a different array, mem_map, that
we can use similarly. Update the helpers that use vmemmap to use a new
wrapper that gets the proper array.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 16:06:21 -08:00
Omar Sandoval
101639caaf tests: don't compare values of reference objects in assertIdentical()
The value can change between two reads. This caused test failures in the
previous commit 18a8f69ad8 ("libdrgn: linux_kernel: add object finder
for jiffies"). The important thing is that the addresses are the same.

Fixes: 75c3679147 ("Rewrite drgn core in C")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 13:33:47 -08:00