Skip to content

Commit

Permalink
tests: enable MM tests on s390x
Browse files Browse the repository at this point in the history
s390x now has full mm support, so enable the tests for it.

Signed-off-by: Sven Schnelle <[email protected]>
  • Loading branch information
svens-s390 authored and osandov committed Mar 22, 2023
1 parent 3483a69 commit 73e451d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion drgn/helpers/linux/mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-----------------
The ``drgn.helpers.linux.mm`` module provides helpers for working with the
Linux memory management (MM) subsystem. Only AArch64, s390x and x86-64 are
Linux memory management (MM) subsystem. Only AArch64, s390x, and x86-64 are
currently supported.
"""

Expand Down
32 changes: 19 additions & 13 deletions libdrgn/arch_s390x.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ linux_kernel_pgtable_iterator_init_s390x(struct drgn_program *prog,
struct pgtable_iterator_s390x *it =
container_of(_it, struct pgtable_iterator_s390x, it);
for (int i = 0; i < 5; i++)
it->pagetable[i].addr = UINT64_C(-1);
it->pagetable[i].addr = UINT64_MAX;
it->levels = 3;
}

Expand Down Expand Up @@ -399,12 +399,13 @@ linux_kernel_pgtable_iterator_next_s390x(struct drgn_program *prog,
uint64_t entry;

/*
* Note: we need the ASCE bits to determine the levels of paging in use, but we
* only get the pgd address from drgn. Therefore do the same what the linux kernel
* does: read the first level entry, and deduct the number of levels from the TT bits.
* Note: we need the ASCE bits to determine the levels of paging in use,
* but we only get the pgd address from drgn. Therefore do the same what
* the linux kernel does: read the first level entry, and deduct the
* number of levels from the TT bits.
*/

struct drgn_error *err = drgn_program_read_u64(prog, table, true, &entry);
struct drgn_error *err = drgn_program_read_u64(prog, table, true,
&entry);
if (err)
return err;

Expand All @@ -425,10 +426,11 @@ linux_kernel_pgtable_iterator_next_s390x(struct drgn_program *prog,
it->pagetable[level].length != length ||
it->pagetable[level].offset != offset) {
/*
* It's only marginally more expensive to read 4096 bytes than 8
* bytes, so we always read the full table.
* It's only marginally more expensive to read 4096
* bytes than 8 bytes, so we always read the full table.
*/
err = drgn_program_read_memory(prog, it->pagetable[level].entries,
err = drgn_program_read_memory(prog,
it->pagetable[level].entries,
table, length * 8, true);
if (err)
return err;
Expand Down Expand Up @@ -475,10 +477,14 @@ const struct drgn_architecture_info arch_info_s390x = {
.linux_kernel_get_initial_registers =
linux_kernel_get_initial_registers_s390x,
.apply_elf_reloc = apply_elf_reloc_s390,
.linux_kernel_pgtable_iterator_create = linux_kernel_pgtable_iterator_create_s390x,
.linux_kernel_pgtable_iterator_destroy = linux_kernel_pgtable_iterator_destroy_s390x,
.linux_kernel_pgtable_iterator_init = linux_kernel_pgtable_iterator_init_s390x,
.linux_kernel_pgtable_iterator_next = linux_kernel_pgtable_iterator_next_s390x,
.linux_kernel_pgtable_iterator_create =
linux_kernel_pgtable_iterator_create_s390x,
.linux_kernel_pgtable_iterator_destroy =
linux_kernel_pgtable_iterator_destroy_s390x,
.linux_kernel_pgtable_iterator_init =
linux_kernel_pgtable_iterator_init_s390x,
.linux_kernel_pgtable_iterator_next =
linux_kernel_pgtable_iterator_next_s390x,
};

const struct drgn_architecture_info arch_info_s390 = {
Expand Down
2 changes: 1 addition & 1 deletion tests/linux_kernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def setUpClass(cls):
"DRGN_TEST_KMOD" in os.environ, "test requires drgn_test Linux kernel module"
)

HAVE_FULL_MM_SUPPORT = NORMALIZED_MACHINE_NAME in ("aarch64", "x86_64")
HAVE_FULL_MM_SUPPORT = NORMALIZED_MACHINE_NAME in ("aarch64", "s390x", "x86_64")

skip_unless_have_full_mm_support = unittest.skipUnless(
HAVE_FULL_MM_SUPPORT,
Expand Down

0 comments on commit 73e451d

Please sign in to comment.