-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vdso: handle s390x correctly #2590
base: criu-dev
Are you sure you want to change the base?
vdso: handle s390x correctly #2590
Conversation
On s390x there is currently a build failure: criu/pie/util-vdso.c: In function ‘elf_symbol_lookup’: criu/pie/util-vdso.c:313:31: error: initialization of ‘uint32_t *’ {aka ‘unsigned int *’} from incompatible pointer type ‘Hash_t *’ {aka ‘long unsigned int *’} [-Wincompatible-pointer-types] 313 | uint32_t *h = bucket + nbucket + (j - sym_off); | ^~~~~~ Replacing uint32_t with Hash_t which is defined behind a architecture specific ifdef solves this error. Signed-off-by: Adrian Reber <[email protected]>
@@ -310,8 +310,8 @@ static unsigned long elf_symbol_lookup(uintptr_t mem, size_t size, | |||
addr = mem + dyn_symtab->d_un.d_ptr - load->p_vaddr; | |||
|
|||
if (use_gnu_hash) { | |||
uint32_t *h = bucket + nbucket + (j - sym_off); | |||
uint32_t hash_val; | |||
Hash_t *h = bucket + nbucket + (j - sym_off); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symbol_hash is uint32_t, should we change its type here and in other places?
I do. I can run a test using GNU_HASH on s390x if that helps. |
Forcing to GNU_HASH makes CRIU segfault. I changed all occurrences of uint32_t to Hash_t. My first assumption is that this could be a big endian problem. Not sure. I have following changes: # git diff
diff --git a/criu/pie/util-vdso.c b/criu/pie/util-vdso.c
index 9819335d8..0c4f030a5 100644
--- a/criu/pie/util-vdso.c
+++ b/criu/pie/util-vdso.c
@@ -212,7 +212,7 @@ static int parse_elf_dynamic(uintptr_t mem, size_t size, Phdr_t *dynamic,
dyn_syment = d;
pr_debug("DT_SYMENT: %lx\n", (unsigned long)d->d_un.d_val);
} else if (d->d_tag == DT_HASH) {
- dyn_sysv_hash = d;
+ //dyn_sysv_hash = d;
pr_debug("DT_HASH: %lx\n", (unsigned long)d->d_un.d_ptr);
} else if (d->d_tag == DT_GNU_HASH) {
/*
@@ -295,7 +295,7 @@ static bool elf_symbol_match(uintptr_t mem, size_t size,
static unsigned long elf_symbol_lookup(uintptr_t mem, size_t size,
- const char *symbol, uint32_t symbol_hash, unsigned int sym_off,
+ const char *symbol, Hash_t symbol_hash, unsigned int sym_off,
uintptr_t dynsymbol_names, Dyn_t *dyn_symtab, Phdr_t *load,
Hash_t nbucket, Hash_t nchain, Hash_t *bucket, Hash_t *chain,
const size_t vdso_symbol_length, bool use_gnu_hash)
@@ -310,8 +310,8 @@ static unsigned long elf_symbol_lookup(uintptr_t mem, size_t size,
addr = mem + dyn_symtab->d_un.d_ptr - load->p_vaddr;
if (use_gnu_hash) {
- uint32_t *h = bucket + nbucket + (j - sym_off);
- uint32_t hash_val;
+ Hash_t *h = bucket + nbucket + (j - sym_off);
+ Hash_t hash_val;
symbol_hash |= 1;
do {
@@ -356,8 +356,8 @@ static int parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
unsigned long (*elf_hash)(const unsigned char *);
if (use_gnu_hash) {
- uint32_t *gnu_hash = (uint32_t *)hash;
- uint32_t bloom_sz;
+ Hash_t *gnu_hash = hash;
+ Hash_t bloom_sz;
size_t *bloom;
nbucket = gnu_hash[0]; And I get: # criu/criu check -v4
(00.000000) CRIU run id = 28c44a36-5c2d-4527-9ffe-1fa0ab03741e
(00.000013) Version: 4.0 (gitid v4.0-65-gd4585a024)
(00.000047) Running on s390x Linux 6.12.0-50.el10.s390x #1 SMP Thu Feb 6 07:31:28 UTC 2025 s390x
(00.000064) File /run/criu.kdat does not exist
(00.000116) sockets: Probing sock diag modules
(00.000154) sockets: Done probing
(00.002488) PAGEMAP_SCAN is supported
(00.002530) Pagemap is fully functional
(00.002571) Found anon-shmem device at 1
(00.002614) Found hugetlb device at 11
(00.002633) Reset 73905's dirty tracking
(00.002695) ... done
(00.002721) Dirty track supported on kernel
(00.002832) Max user page table levels (task size): KERNEL_TS_LEVEL_5
(00.002836) Found task size of ffffffffffffefff
(00.004008) net: Restoring netdev veth idx 10
(00.004241) net: Dumping netns links
(00.004262) net: LD: Got link 1, type 772
(00.004266) net: LD: Got link 10, type 1
(00.049466) vdso: Parsing at 3ffce2fe000 3ffce300000
(00.049487) vdso: PT_LOAD p_vaddr: 0
(00.049490) vdso: DT_HASH: 120
(00.049493) vdso: DT_GNU_HASH: 198
(00.049495) vdso: DT_STRTAB: 2d0
(00.049497) vdso: DT_SYMTAB: 1e0
(00.049499) vdso: DT_STRSZ: c8
(00.049501) vdso: DT_SYMENT: 18
(00.049502) vdso: nbucket 300000001 sym_off 6 bloom_sz a1080858054000a6 bloom 3ffce2fe1b8 bucket 84046bff82fe6e8
Segmentation fault (core dumped)
# coredumpctl gdb
PID: 73905 (criu)
UID: 0 (root)
GID: 0 (root)
Signal: 11 (SEGV)
Timestamp: Mon 2025-02-10 04:58:27 EST (30s ago)
Command Line: criu/criu check -v4
Executable: /home/criu/criu/criu
Control Group: /user.slice/user-0.slice/session-2.scope
Unit: session-2.scope
Slice: user-0.slice
Session: 2
Owner UID: 0 (root)
Boot ID: 862f733096b84538a3a50d57df5b5294
Machine ID: c0c2c1f58db247d1ba0de215cec8554d
Hostname: s390x
Storage: /var/lib/systemd/coredump/core.criu.0.862f733096b84538a3a50d57df5b5294.73905.1739181507000000.zst (present)
Size on Disk: 239.3K
Message: Process 73905 (criu) of user 0 dumped core.
Module libtinfo.so.6 from rpm ncurses-6.4-14.20240127.el10.s390x
Module libffi.so.8 from rpm libffi-3.4.4-9.el10.s390x
Module libgmp.so.10 from rpm gmp-6.2.1-10.el10.s390x
Module libreadline.so.8 from rpm readline-8.2-11.el10.s390x
Module libjansson.so.4 from rpm jansson-2.14-3.el10.s390x
Module libxtables.so.12 from rpm iptables-1.8.11-7.el10.s390x
Module libnftnl.so.11 from rpm libnftnl-1.2.8-2.el10.s390x
Module libmnl.so.0 from rpm libmnl-1.0.5-7.el10.s390x
Module libtasn1.so.6 from rpm libtasn1-4.19.0-9.el10.s390x
Module libunistring.so.5 from rpm libunistring-1.1-10.el10.s390x
Module libidn2.so.0 from rpm libidn2-2.3.7-3.el10.s390x
Module libp11-kit.so.0 from rpm p11-kit-0.25.5-7.el10.s390x
Module libmd.so.0 from rpm libmd-1.1.0-5.el10_0.s390x
Module libuuid.so.1 from rpm util-linux-2.40.2-5.el10.s390x
Module libnet.so.1 from rpm libnet-1.3-7.el10.s390x
Module libnl-3.so.200 from rpm libnl3-3.11.0-1.el10.s390x
Module libprotobuf-c.so.1 from rpm protobuf-c-1.5.0-6.el10.s390x
Module libnftables.so.1 from rpm nftables-1.1.1-3.el10.s390x
Module libgnutls.so.30 from rpm gnutls-3.8.8-1.el10.s390x
Module libbsd.so.0 from rpm libbsd-0.12.2-4.el10_0.s390x
Stack trace of thread 73905:
#0 0x000000000109d928 n/a (n/a + 0x0)
ELF object binary architecture: IBM S/390
GNU gdb (CentOS Stream) 14.2-4.el10
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "s390x-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/criu/criu/criu...
[New LWP 73905]
This GDB supports auto-downloading debuginfo from the following URLs:
<https://debuginfod.centos.org/>
Enable debuginfod for this session? (y or [n]) n
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `criu/criu check -v4'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 elf_symbol_lookup (vdso_symbol_length=31, mem=<optimized out>, size=<optimized out>, symbol=<optimized out>, symbol_hash=17306926892819324997, sym_off=<optimized out>, dynsymbol_names=<optimized out>, dyn_symtab=<optimized out>,
load=<optimized out>, nbucket=12884901889, nchain=0, bucket=0x84046bff82fe6e8, chain=0x0, use_gnu_hash=true) at criu/pie-util-vdso.c:307
307 if (j == STN_UNDEF)
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.39-37.el10.s390x gmp-6.2.1-10.el10.s390x gnutls-3.8.8-1.el10.s390x iptables-libs-1.8.11-7.el10.s390x jansson-2.14-3.el10.s390x libbsd-0.12.2-4.el10_0.s390x libffi-3.4.4-9.el10.s390x libgcc-14.2.1-7.el10.s390x libidn2-2.3.7-3.el10.s390x libmd-1.1.0-5.el10_0.s390x libmnl-1.0.5-7.el10.s390x libnet-1.3-7.el10.s390x libnftnl-1.2.8-2.el10.s390x libnl3-3.11.0-1.el10.s390x libtasn1-4.19.0-9.el10.s390x libunistring-1.1-10.el10.s390x libuuid-2.40.2-5.el10.s390x ncurses-libs-6.4-14.20240127.el10.s390x nftables-1.1.1-3.el10.s390x p11-kit-0.25.5-7.el10.s390x protobuf-c-1.5.0-6.el10.s390x readline-8.2-11.el10.s390x
(gdb) bt
#0 elf_symbol_lookup (vdso_symbol_length=31, mem=<optimized out>, size=<optimized out>, symbol=<optimized out>, symbol_hash=17306926892819324997, sym_off=<optimized out>, dynsymbol_names=<optimized out>, dyn_symtab=<optimized out>,
load=<optimized out>, nbucket=12884901889, nchain=0, bucket=0x84046bff82fe6e8, chain=0x0, use_gnu_hash=true) at criu/pie-util-vdso.c:307
#1 parse_elf_symbols (mem=4397210787840, size=8192, load=<optimized out>, t=0x11773e8 <vdso_maps+16>, dynsymbol_names=4397210788560, hash=<optimized out>, dyn_symtab=0x3ffce2ff270, use_gnu_hash=true) at criu/pie-util-vdso.c:391
#2 vdso_fill_symtable (mem=4397210787840, size=<optimized out>, t=t@entry=0x11773e8 <vdso_maps+16>) at criu/pie-util-vdso.c:460
#3 0x00000000010d1a3e in vdso_fill_self_symtable (s=0x11773d8 <vdso_maps>) at criu/vdso.c:412
#4 kerndat_vdso_fill_symtable () at criu/vdso.c:626
#5 0x0000000001075476 in kerndat_init () at criu/kerndat.c:1905
#6 0x0000000001029988 in main (argc=<optimized out>, argv=0x3ffce2f9758, envp=<optimized out>) at criu/crtools.c:266 Any recommendations at what to look for to figure this out? |
On s390x there is currently a build failure:
Replacing uint32_t with Hash_t which is defined behind a architecture specific ifdef solves this error.
Fixes: #2582
CC: @0x7f454c46