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>
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>
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>
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>
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>
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>
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>
We have a lot of examples that use jiffies, but they stopped working
long ago on x86-64 (since Linux kernel commit d8ad6d39c35d ("x86_64: Fix
jiffies ODR violation") (in v5.8 and backported to stable releases)) and
never worked on other architectures. This is because jiffies is defined
in the Linux kernel's linker script. #277 proposed updating the examples
to use jiffies_64, but I would guess that most kernel developers are
familiar with jiffies and many have never seen jiffies_64. jiffies is
also a nicer name to type in live demos. Let's add a case to the Linux
kernel object finder to get the jiffies variable.
Reported-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
tests.linux_kernel.helpers.test_mm.TestMm.test_read_physical() fails on
Arm when the user page is mapped from high memory. Replace it with a
test case that uses the test physical address from the test kernel
module and asserts the expected PRNG data. (We will probably run into
more tests that fail with high memory once #244 is merged.)
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This replaces the multiples of a prime sequence used for the per-CPU
helper tests with a slightly more self-documenting PRNG interface in
both the test kernel module and Python test scaffolding. It will be used
more in upcoming tests.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
My previous change to call git unconditionally caused Packit failures,
presumably because git isn't installed for the build:
Traceback (most recent call last):
File "/builddir/build/BUILD/drgn-0.0.22+71.g2f97cc0/setup.py", line 411, in <module>
version=get_version(),
^^^^^^^^^^^^^
File "/builddir/build/BUILD/drgn-0.0.22+71.g2f97cc0/setup.py", line 343, in get_version
subprocess.call(
File "/usr/lib64/python3.11/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.11/subprocess.py", line 1901, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'
We shouldn't bother calling git if .git doesn't exist.
Fixes: 2e9e66cedc ("setup.py: use stricter check for git repository")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
There are a lot of details about how the page table iterator functions
should be used/implemented that commit 174b797ae3 ("libdrgn: platform:
add documentation (especially for drgn_architecture_info)") didn't
cover. Add an example and expand/clarify the documentation for the
callbacks.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
GCC appears to use data8 at -1 when reporting zero length arrays when
comping c++ code, this patch adds support and a test for that behavior.
dwarf_info.c: Remove check for sdata on quirk for array length == 0
Signed-off-by: Jay Kamat <jaygkamat@gmail.com>
When testing #245, I encountered this error:
======================================================================
ERROR: test_identify_unrecognized (tests.linux_kernel.helpers.test_common.TestIdentifyAddress)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/host/home/osandov/repos/drgn/tests/linux_kernel/helpers/test_common.py", line 57, in test_identify_unrecognized
self.assertIsNone(identify_address(self.prog, start_addr - 1))
File "/host/home/osandov/repos/drgn/drgn/helpers/common/memory.py", line 99, in identify_address
symbol = prog.symbol(addr)
OverflowError: can't convert negative int to unsigned
This is because the lowest kernel address in s390x is 0, so we're
passing -1 to identify_address(). Work around that in the test.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
To test builds on other architectures, I'm setting up a Debian chroot
with debootstrap and then building with something like:
mount --bind . "$chroot/mnt"
chroot "$chroot" sh -c 'cd /mnt && python3 setup.py build_ext -i'
However, if I do this from a Git worktree, this fails with an error from
the git call to determine the local version:
fatal: not a git repository: /home/osandov/repos/drgn/.git/worktrees/drgn2
Instead of only checking whether .git exists, use `git --git-dir=.git
rev-parse` to verify that .git is valid. (This will of course rely on
drgn/internal/version.py already having been generated.)
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Now we'll always get the same compiler that was used for the actual
kernel build. Also split this into its own runnable module, vmtest.kmod,
for testing and custom scripting.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
In order to hopefully not have jobs time out, split it into jobs by
architecture and flavor, but limit the parallelism to leave room for
actual test runs. Some of the very old kernel versions don't work on the
other architectures, but we can look into that later.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Old kernel versions (and new kernel versions built with old binutils)
need this for ppc64 module builds.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Before Linux kernel commit 05f6bbf2d714 ("kbuild: remove ld-version
macro") (in v5.12), ppc64 module builds require it.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
I don't know yet whether this is safe to upstream, but for now it should
be good enough for testing.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This was patched in recent stable and longterm branches, but we need it
for older branches. We need a few different backports of it.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Move vmlinux to the module build directory and copy in resolve_btfids.
This is mainly to silence the annoying warning:
Skipping BTF generation for /home/osandov/repos/drgn/build/vmtest/x86_64/tmpge3udm_a/drgn_test.ko due to unavailability of vmlinux
But it might also be useful for testing in the future.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Add the per-architecture QEMU options to the Architecture class and
allow specifying an architecture in -k.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This will automatically download and use a standard cross compiler
instead of requiring the user to do so.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
It defaults to the host architecture (if available). x86_64 is currently
the only option. CROSS_COMPILE must be set in the environment manually.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
To prepare for building architectures other than x86-64, add a
description of architectures, and split the architecture-specific kernel
options into it. For now, we still hard-code x86-64 everywhere.
Signed-off-by: Omar Sandoval <osandov@osandov.com>