Skip to contentSkip to conversation

s390:compel/arch/s390: Add architecture support to compel tool and libraries

PATCH Superseded Michael Holzheu 2 participants 2 messages Jun 29, 2017 – Jun 30, 2017 s390

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/17 s390:compel/arch/s390: Add architecture support to compel tool and libraries

This patch only adds the support but does not enable it for building.

---
 compel/arch/s390/plugins/include/asm/prologue.h    |   1 +
 .../arch/s390/plugins/include/asm/syscall-types.h  |  34 ++
 compel/arch/s390/plugins/std/parasite-head.S       |  26 +
 .../s390/plugins/std/syscalls/Makefile.syscalls    |  58 +++
 .../plugins/std/syscalls/syscall-common-s390.S     |  37 ++
 .../s390/plugins/std/syscalls/syscall-s390.tbl     | 108 ++++
 .../arch/s390/plugins/std/syscalls/syscalls-s390.c |  26 +
 compel/arch/s390/scripts/compel-pack.lds.S         |  40 ++
 compel/arch/s390/src/lib/cpu.c                     |  42 ++
 compel/arch/s390/src/lib/handle-elf-host.c         |   1 +
 compel/arch/s390/src/lib/handle-elf.c              |  22 +
 compel/arch/s390/src/lib/include/handle-elf.h      |  13 +
 compel/arch/s390/src/lib/include/syscall.h         |   8 +
 .../s390/src/lib/include/uapi/asm/breakpoints.h    |  15 +
 compel/arch/s390/src/lib/include/uapi/asm/cpu.h    |  10 +
 compel/arch/s390/src/lib/include/uapi/asm/fpu.h    |  14 +
 .../s390/src/lib/include/uapi/asm/infect-types.h   |  75 +++
 .../arch/s390/src/lib/include/uapi/asm/sigframe.h  |  75 +++
 compel/arch/s390/src/lib/infect.c                  | 559 +++++++++++++++++++++
 include/common/arch/s390/asm/atomic.h              |  67 +++
 include/common/arch/s390/asm/atomic_ops.h          |  74 +++
 include/common/arch/s390/asm/bitops.h              | 164 ++++++
 include/common/arch/s390/asm/bitsperlong.h         |   6 +
 include/common/arch/s390/asm/linkage.h             |  22 +
 include/common/arch/s390/asm/page.h                |  19 +
 25 files changed, 1516 insertions(+)
 create mode 120000 compel/arch/s390/plugins/include/asm/prologue.h
 create mode 100644 compel/arch/s390/plugins/include/asm/syscall-types.h
 create mode 100644 compel/arch/s390/plugins/std/parasite-head.S
 create mode 100644 compel/arch/s390/plugins/std/syscalls/Makefile.syscalls
 create mode 100644 compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S
 create mode 100644 compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
 create mode 100644 compel/arch/s390/plugins/std/syscalls/syscalls-s390.c
 create mode 100644 compel/arch/s390/scripts/compel-pack.lds.S
 create mode 100644 compel/arch/s390/src/lib/cpu.c
 create mode 120000 compel/arch/s390/src/lib/handle-elf-host.c
 create mode 100644 compel/arch/s390/src/lib/handle-elf.c
 create mode 100644 compel/arch/s390/src/lib/include/handle-elf.h
 create mode 100644 compel/arch/s390/src/lib/include/syscall.h
 create mode 100644 compel/arch/s390/src/lib/include/uapi/asm/breakpoints.h
 create mode 100644 compel/arch/s390/src/lib/include/uapi/asm/cpu.h
 create mode 100644 compel/arch/s390/src/lib/include/uapi/asm/fpu.h
 create mode 100644 compel/arch/s390/src/lib/include/uapi/asm/infect-types.h
 create mode 100644 compel/arch/s390/src/lib/include/uapi/asm/sigframe.h
 create mode 100644 compel/arch/s390/src/lib/infect.c
 create mode 100644 include/common/arch/s390/asm/atomic.h
 create mode 100644 include/common/arch/s390/asm/atomic_ops.h
 create mode 100644 include/common/arch/s390/asm/bitops.h
 create mode 100644 include/common/arch/s390/asm/bitsperlong.h
 create mode 100644 include/common/arch/s390/asm/linkage.h
 create mode 100644 include/common/arch/s390/asm/page.h
compel/arch/s390/plugins/include/asm/prologue.h new file +1 -0
new file mode 120000
index 0000000..e0275e3
@@ -0,0 +1 @@
+../../../../../arch/x86/plugins/include/asm/prologue.h
\ No newline at end of file
compel/arch/s390/plugins/include/asm/syscall-types.h new file +34 -0
new file mode 100644
index 0000000..55d7ddb
@@ -0,0 +1,34 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+#define SA_RESTORER     0x04000000U
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	64
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long	sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+/*
+ * Used for rt_sigaction() system call - see kernel "struct sigaction" in
+ * include/linux/signal.h.
+ */
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+struct mmap_arg_struct;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
compel/arch/s390/plugins/std/parasite-head.S new file +26 -0
new file mode 100644
index 0000000..f4cb372
@@ -0,0 +1,26 @@
+#include "common/asm/linkage.h"
+
+	.section .head.text, "ax"
+
+/*
+ * Entry point for parasite_service()
+ *
+ * Addresses of symbols are exported in auto-generated criu/pie/parasite-blob.h
+ *
+ * Function is called via parasite_run(). The command for parasite_service()
+ * is stored in global variable __export_parasite_cmd.
+ *
+ * Load parameters for parasite_service(unsigned int cmd, void *args):
+ *
+ *  - Parameter 1 (cmd) : %r2 = *(uint32 *)(__export_parasite_cmd + pc)
+ *  - Parameter 2 (args): %r3 = __export_parasite_args + pc
+ */
+ENTRY(__export_parasite_head_start)
+	larl	%r14,__export_parasite_cmd
+	llgf	%r2,0(%r14)
+	larl	%r3,__export_parasite_args
+	brasl	%r14,parasite_service
+	.long 0x00010001	/* S390_BREAKPOINT_U16: Generates SIGTRAP */
+__export_parasite_cmd:
+	.long 0
+END(__export_parasite_head_start)
compel/arch/s390/plugins/std/syscalls/Makefile.syscalls new file +58 -0

58 lines not on this page · raw message

compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +37 -0
new file mode 100644
index 0000000..79e3b8e
@@ -0,0 +1,37 @@
+#include "common/asm/linkage.h"
+
+/*
+ * Define a system call
+ *
+ * C-ABI on s390:
+ * - Parameters 1-5 are passed in %r2-%r6
+ * - Parameter 6 is passed on the stack 160(%r15)
+ * - Return value is in %r2
+ * - Return address is in %r14
+ * - Registers %r0-%r6,%r14 are call-clobbered
+ * - Registers %r7-%r13,%r15 are call-saved
+ *
+ * SVC ABI on s390:
+ * - For SVC 0 the system call number is passed in %r1
+ * - Parameters 1-6 are passed in %r2-%r7
+ * - Return value is passed in %r2
+ * - Besides of %r2 all registers are call-saved
+ */
+#define SYSCALL(name, opcode)						\
+ENTRY(name);								\
+	lgr	%r0,%r7;		/* Save %r7 */			\
+	lg	%r7,160(%r15);		/* Load 6th parameter */	\
+	lghi	%r1,opcode;		/* Load SVC number */		\
+	svc	0;			/* Issue SVC 0 */		\
+	lgr	%r7,%r0;		/* Restore %r7 */		\
+	br	%r14;			/* Return to caller */		\
+END(name)								\
+
+/*
+ * Issue rt_sigreturn system call for sa_restorer
+ */
+ENTRY(__cr_restore_rt)
+	lghi	%r1,__NR_rt_sigreturn
+	svc	0
+END(__cr_restore_rt)
+
compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl new file +108 -0

108 lines not on this page · raw message

compel/arch/s390/plugins/std/syscalls/syscalls-s390.c new file +26 -0
new file mode 100644
index 0000000..2b35cca
@@ -0,0 +1,26 @@
+#include "asm/infect-types.h"
+
+/*
+ * Define prototype because of compile error if we include uapi/std/syscall.h
+ */
+long sys_old_mmap (struct mmap_arg_struct *);
+
+/*
+ * On s390 we have defined __ARCH_WANT_SYS_OLD_MMAP - Therefore implement
+ * system call with one parameter "mmap_arg_struct".
+ */
+unsigned long sys_mmap(void *addr, unsigned long len, unsigned long prot,
+		       unsigned long flags, unsigned long fd,
+		       unsigned long offset)
+{
+	struct mmap_arg_struct arg_struct;
+
+	arg_struct.addr = (unsigned long)addr;
+	arg_struct.len = len;
+	arg_struct.prot = prot;
+	arg_struct.flags = flags;
+	arg_struct.fd = fd;
+	arg_struct.offset = offset;
+
+	return sys_old_mmap(&arg_struct);
+}
compel/arch/s390/scripts/compel-pack.lds.S new file +40 -0
new file mode 100644
index 0000000..91ffbda
@@ -0,0 +1,40 @@
+OUTPUT_ARCH(s390:64-bit)
+EXTERN(__export_parasite_head_start)
+
+SECTIONS
+{
+	.text : {
+		*(.head.text)
+		ASSERT(DEFINED(__export_parasite_head_start),
+			"Symbol __export_parasite_head_start is missing");
+		*(.text*)
+		*(.compel.exit)
+		*(.compel.init)
+	}
+
+	.data : {
+		*(.data*)
+		*(.bss*)
+	}
+
+	.rodata : {
+		*(.rodata*)
+		*(.got*)
+	}
+
+	.toc : ALIGN(8) {
+		*(.toc*)
+	}
+
+	/DISCARD/ : {
+		*(.debug*)
+		*(.comment*)
+		*(.note*)
+		*(.group*)
+		*(.eh_frame*)
+	}
+
+/* Parasite args should have 4 bytes align, as we have futex inside. */
+. = ALIGN(4);
+__export_parasite_args = .;
+}
compel/arch/s390/src/lib/cpu.c new file +42 -0

42 lines not on this page · raw message

compel/arch/s390/src/lib/handle-elf-host.c new file +1 -0
new file mode 120000
index 0000000..fe46118
@@ -0,0 +1 @@
+handle-elf.c
\ No newline at end of file
compel/arch/s390/src/lib/handle-elf.c new file +22 -0
new file mode 100644
index 0000000..01a8bf4
@@ -0,0 +1,22 @@
+#include <string.h>
+
+#include "uapi/compel.h"
+
+#include "handle-elf.h"
+#include "piegen.h"
+#include "log.h"
+
+static const unsigned char __maybe_unused
+elf_ident_64[EI_NIDENT] = {
+	0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+int handle_binary(void *mem, size_t size)
+{
+	if (memcmp(mem, elf_ident_64, sizeof(elf_ident_64)) == 0)
+		return handle_elf_s390(mem, size);
+
+	pr_err("Unsupported Elf format detected\n");
+	return -EINVAL;
+}
compel/arch/s390/src/lib/include/handle-elf.h new file +13 -0
new file mode 100644
index 0000000..cd13574
@@ -0,0 +1,13 @@
+#ifndef COMPEL_HANDLE_ELF_H__
+#define COMPEL_HANDLE_ELF_H__
+
+#include "elf64-types.h"
+
+#define ELF_S390
+
+#define __handle_elf				handle_elf_s390
+#define arch_is_machine_supported(e_machine)	(e_machine == EM_S390)
+
+int handle_elf_s390(void *mem, size_t size);
+
+#endif /* COMPEL_HANDLE_ELF_H__ */
compel/arch/s390/src/lib/include/syscall.h new file +8 -0
new file mode 100644
index 0000000..57d4912
@@ -0,0 +1,8 @@
+#ifndef __COMPEL_SYSCALL_H__
+#define __COMPEL_SYSCALL_H__
+
+unsigned long sys_mmap(void *addr, unsigned long len, unsigned long prot,
+		       unsigned long flags, unsigned long fd,
+		       unsigned long offset);
+
+#endif
compel/arch/s390/src/lib/include/uapi/asm/breakpoints.h new file +15 -0
new file mode 100644
index 0000000..5f09049
@@ -0,0 +1,15 @@
+#ifndef __COMPEL_BREAKPOINTS_H__
+#define __COMPEL_BREAKPOINTS_H__
+#define ARCH_SI_TRAP TRAP_BRKPT
+
+static inline int ptrace_set_breakpoint(pid_t pid, void *addr)
+{
+	return 0;
+}
+
+static inline int ptrace_flush_breakpoints(pid_t pid)
+{
+	return 0;
+}
+
+#endif
compel/arch/s390/src/lib/include/uapi/asm/cpu.h new file +10 -0
new file mode 100644
index 0000000..b01db51
@@ -0,0 +1,10 @@
+#ifndef UAPI_COMPEL_ASM_CPU_H__
+#define UAPI_COMPEL_ASM_CPU_H__
+
+#include <stdint.h>
+
+typedef struct {
+	uint64_t		hwcap[2];
+} compel_cpuinfo_t;
+
+#endif /* __CR_ASM_CPU_H__ */
compel/arch/s390/src/lib/include/uapi/asm/fpu.h new file +14 -0
new file mode 100644
index 0000000..49c9078
@@ -0,0 +1,14 @@
+#ifndef __CR_ASM_FPU_H__
+#define __CR_ASM_FPU_H__
+
+#include <sys/types.h>
+#include <stdbool.h>
+
+/*
+ * This one is used in restorer
+ */
+typedef struct {
+	bool has_fpu;
+} fpu_state_t;
+
+#endif /* __CR_ASM_FPU_H__ */
compel/arch/s390/src/lib/include/uapi/asm/infect-types.h new file +75 -0

75 lines not on this page · raw message

compel/arch/s390/src/lib/include/uapi/asm/sigframe.h new file +75 -0

75 lines not on this page · raw message

compel/arch/s390/src/lib/infect.c new file +559 -0

559 lines not on this page · raw message

include/common/arch/s390/asm/atomic.h new file +67 -0

67 lines not on this page · raw message

include/common/arch/s390/asm/atomic_ops.h new file +74 -0

74 lines not on this page · raw message

include/common/arch/s390/asm/bitops.h new file +164 -0

164 lines not on this page · raw message

include/common/arch/s390/asm/bitsperlong.h new file +6 -0
new file mode 100644
index 0000000..d95727d
@@ -0,0 +1,6 @@
+#ifndef __CR_BITSPERLONG_H__
+#define __CR_BITSPERLONG_H__
+
+#define BITS_PER_LONG 64
+
+#endif /* __CR_BITSPERLONG_H__ */
include/common/arch/s390/asm/linkage.h new file +22 -0
new file mode 100644
index 0000000..99895ce
@@ -0,0 +1,22 @@
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+#ifdef __ASSEMBLY__
+
+#define __ALIGN .align 4, 0x07
+
+#define GLOBAL(name)		\
+	.globl name;		\
+	name:
+
+#define ENTRY(name)		\
+	.globl name;		\
+	.type name, @function;	\
+	__ALIGN;		\
+	name:
+
+#define END(name)		\
+	.size name, . - name
+
+#endif /* __ASSEMBLY__ */
+#endif
include/common/arch/s390/asm/page.h new file +19 -0
new file mode 100644
index 0000000..8e8c649
@@ -0,0 +1,19 @@
+#ifndef __CR_ASM_PAGE_H__
+#define __CR_ASM_PAGE_H__
+
+#ifndef PAGE_SHIFT
+#define PAGE_SHIFT	12
+#endif
+
+#ifndef PAGE_SIZE
+#define PAGE_SIZE	(1UL << PAGE_SHIFT)
+#endif
+
+#ifndef PAGE_MASK
+#define PAGE_MASK	(~(PAGE_SIZE - 1))
+#endif
+
+#define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
+#define page_size()	PAGE_SIZE
+
+#endif /* __CR_ASM_PAGE_H__ */
Signature · 1 line
2.7.4
Reviewed-by on v2 1/17
#1 lore raw

Re: [CRIU] [PATCH v2 01/17] s390:compel/arch/s390: Add architecture support to compel tool and libra

2017-06-29 22:24 GMT+03:00 Michael Holzheu <[email protected]>:

Quoted 4 lines

This patch only adds the support but does not enable it for building.

LGTM, and looking at diffstat - shouldn't break anything we already have,

Quoted 1 line

---

...

Quoted 15 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +9 -0
new file mode 100644
index 0000000..79e3b8e
@@ -0,0 +1,37 @@
+#include "common/asm/linkage.h"
+
+/*
+ * Define a system call
+ *
+ * C-ABI on s390:
+ * - Parameters 1-5 are passed in %r2-%r6
+ * - Parameter 6 is passed on the stack 160(%r15)
+ * - Return value is in %r2

compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S line 19

Quoted 10 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +10 -0
+ * - Return address is in %r14
+ * - Registers %r0-%r6,%r14 are call-clobbered
+ * - Registers %r7-%r13,%r15 are call-saved
+ *
+ * SVC ABI on s390:
+ * - For SVC 0 the system call number is passed in %r1
+ * - Parameters 1-6 are passed in %r2-%r7
+ * - Return value is passed in %r2
+ * - Besides of %r2 all registers are call-saved
+ */

I like the comment :)

Quoted 18 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +18 -0
+#define SYSCALL(name, opcode)                                          \
+ENTRY(name);                                                           \
+       lgr     %r0,%r7;                /* Save %r7 */                  \
+       lg      %r7,160(%r15);          /* Load 6th parameter */        \
+       lghi    %r1,opcode;             /* Load SVC number */           \
+       svc     0;                      /* Issue SVC 0 */               \
+       lgr     %r7,%r0;                /* Restore %r7 */               \
+       br      %r14;                   /* Return to caller */          \
+END(name)                                                              \
+
+/*
+ * Issue rt_sigreturn system call for sa_restorer
+ */
+ENTRY(__cr_restore_rt)
+       lghi    %r1,__NR_rt_sigreturn
+       svc     0
+END(__cr_restore_rt)
+

...

Quoted 29 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +29 -0
+/*
+ * Issue s390 mmap call
+ */
+void *remote_mmap(struct parasite_ctl *ctl,
+                 void *addr, size_t length, int prot,
+                 int flags, int fd, off_t offset)
+{
+       void *where = (void *)ctl->ictx.syscall_ip + BUILTIN_SYSCALL_SIZE;
+       struct mmap_arg_struct arg_struct;
+       pid_t pid = ctl->rpid;
+       long map = 0;
+       int err;
+
+       /* Setup s390 mmap data */
+       arg_struct.addr = (unsigned long)addr;
+       arg_struct.len = length;
+       arg_struct.prot = prot;
+       arg_struct.flags = flags;
+       arg_struct.fd = fd;
+       arg_struct.offset = offset;
+
+       /* Move args to process */
+       if (ptrace_swap_area(pid, where, &arg_struct, sizeof(arg_struct))) {
+               pr_err("Can't inject memfd args (pid: %d)\n", pid);
+               return NULL;
+       }
+
+       /* Do syscall */
+       err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long) where,

compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S

Quoted 10 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +10 -0
+                            0, 0, 0, 0, 0);
+       if (err < 0 || (long)map < 0)
+               map = 0;
+
+       /* Restore data */
+       if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
+               pr_err("Can't restore mmap args (pid: %d)\n", pid);
+               if (map != 0) {
+                       err = compel_syscall(ctl, __NR_munmap, NULL, map,
+                                            length, 0, 0, 0, 0);

Well, we could avoid setting err here, as we can't handle it anyway - we're so fucked up here %)
But that's not significant.

...

Quoted 51 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +51 -0
+/*
+ * Kernel task size level
+ *
+ * We have (dynamic) 4 level page tables for 64 bit since linux 2.6.25:
+ *
+ *  5a216a2083 ("[S390] Add four level page tables for CONFIG_64BIT=y.")
+ *  6252d702c5 ("[S390] dynamic page tables.")
+ *
+ * The code below is already prepared for future (dynamic) 5 level page tables.
+ *
+ * Besides that there is one problematic kernel bug that has been fixed for
+ * linux 4.11 by the following commit:
+ *
+ *  ee71d16d22 ("s390/mm: make TASK_SIZE independent from the number
+ *              of page table levels")
+ *
+ * A 64 bit process on s390x always starts with 3 levels and upgrades to 4
+ * levels for mmap(> 4 TB) and to 5 levels for mmap(> 16 EB).
+ *
+ * Unfortunately before fix ee71d16d22 for a 3 level process munmap()
+ * and mremap() fail for addresses > 4 TB. CRIU uses the task size,
+ * to unmap() all memory from a starting point to task size to get rid of
+ * unwanted mappings. CRIU uses mremap() to establish the final mappings
+ * which also fails if we want to restore mappings > 4 TB and the initial
+ * restore process still runs with 3 levels.
+ *
+ * To support the current CRIU design on s390 we return task size = 4 TB when
+ * a kernel without fix ee71d16d22 is detected. In this case we can dump at
+ * least processes with < 4 TB which is the most likely case anyway.
+ *
+ * For kernels with fix ee71d16d22 we are fully functional.
+ */
+enum kernel_ts_level {
+       /* Kernel with 4 level page tables without fix ee71d16d22 */
+       KERNEL_TS_LEVEL_4_FIX_NO,
+       /* Kernel with 4 level page tables with fix ee71d16d22 */
+       KERNEL_TS_LEVEL_4_FIX_YES,
+       /* Kernel with 4 level page tables with or without fix ee71d16d22 */
+       KERNEL_TS_LEVEL_4_FIX_UNKN,
+       /* Kernel with 5 level page tables */
+       KERNEL_TS_LEVEL_5,
+};
+
+/* See arch/s390/include/asm/processor.h */
+#define TASK_SIZE_LEVEL_3      0x40000000000UL         /* 4 TB */
+#define TASK_SIZE_LEVEL_4      0x20000000000000UL      /* 8 PB */
+#define TASK_SIZE_LEVEL_5      0xffffffffffffefffUL    /* 16 EB - 0x1000 */
+
+/*
+ * Return detected kernel version regarding task size level
+ *

compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S

Quoted 10 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +10 -0
+ * We use unmap() to probe the maximum possible page table level of kernel
+ */
+static enum kernel_ts_level get_kernel_ts_level(void)
+{
+       unsigned long criu_end_addr = max_mapped_addr();
+
+       /* Check for 5 levels */
+       if (criu_end_addr > TASK_SIZE_LEVEL_4)
+               return KERNEL_TS_LEVEL_5;
+       else if (munmap((void *) TASK_SIZE_LEVEL_4, 0x1000) == 0)

Can't we occasionally unmap something that's already mapped? Is it restricted by kernel to mmap() on such high address?

Quoted 14 lines
compel/arch/s390/plugins/std/syscalls/syscall-common-s390.S new file +14 -0
+               return KERNEL_TS_LEVEL_5;
+
+       if (criu_end_addr < TASK_SIZE_LEVEL_3) {
+               /* Check for 4 level kernel with fix */
+               if (munmap((void *) TASK_SIZE_LEVEL_3, 0x1000) == 0)
+                       return KERNEL_TS_LEVEL_4_FIX_YES;
+               else
+                       return KERNEL_TS_LEVEL_4_FIX_NO;
+       }
+       /* We can't find out if kernel has the fix */
+       return KERNEL_TS_LEVEL_4_FIX_UNKN;
+}
+
+/*
Signature · 1 line
             Dmitry