From d2b3e5ff08b342364cc33633ea947a2cbdb171b6 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 30 2018 08:16:15 +0000 Subject: import criu-3.9-5.el7a --- diff --git a/.criu.metadata b/.criu.metadata index 2f610b2..acf36e1 100644 --- a/.criu.metadata +++ b/.criu.metadata @@ -1 +1 @@ -e87902d8c4958dcc9dd046a2402acb3af82e3a17 SOURCES/criu-3.5.tar.bz2 +4391d17f23893b276b9f59bc912663a4e4d8a33d SOURCES/criu-3.9.tar.bz2 diff --git a/.gitignore b/.gitignore index 52d35d2..0ddcc0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/criu-3.5.tar.bz2 +SOURCES/criu-3.9.tar.bz2 diff --git a/SOURCES/0001-criu-Remove-PAGE_IMAGE_SIZE.patch b/SOURCES/0001-criu-Remove-PAGE_IMAGE_SIZE.patch new file mode 100644 index 0000000..8680470 --- /dev/null +++ b/SOURCES/0001-criu-Remove-PAGE_IMAGE_SIZE.patch @@ -0,0 +1,46 @@ +From 2ea16be20271dae61156a157b9fabd542b328387 Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:41 +0100 +Subject: [PATCH 1/8] criu: Remove PAGE_IMAGE_SIZE + +It's unused since commit fd3f33f5d23a ("headers: image.h -- Drop unused +entries"), so let's remove it completely. + +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/crtools.c | 1 - + criu/include/image.h | 5 ----- + 2 files changed, 6 deletions(-) + +diff --git a/criu/crtools.c b/criu/crtools.c +index 5cf53d8a0..4ff7a9f24 100644 +--- a/criu/crtools.c ++++ b/criu/crtools.c +@@ -356,7 +356,6 @@ int main(int argc, char *argv[], char *envp[]) + + #undef BOOL_OPT + +- BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE); + BUILD_BUG_ON(CTL_32 != SYSCTL_TYPE__CTL_32); + BUILD_BUG_ON(__CTL_STR != SYSCTL_TYPE__CTL_STR); + /* We use it for fd overlap handling in clone_service_fd() */ +diff --git a/criu/include/image.h b/criu/include/image.h +index d9c4bdbc8..d576f5a13 100644 +--- a/criu/include/image.h ++++ b/criu/include/image.h +@@ -12,11 +12,6 @@ + #include "log.h" + #include "common/bug.h" + +-#ifdef _ARCH_PPC64 +-#define PAGE_IMAGE_SIZE 65536 +-#else +-#define PAGE_IMAGE_SIZE 4096 +-#endif /* _ARCH_PPC64 */ + #define PAGE_RSS 1 + #define PAGE_ANON 2 + +-- +2.17.0 + diff --git a/SOURCES/0001-fix-building-on-newest-glibc-and-kernel.patch b/SOURCES/0001-fix-building-on-newest-glibc-and-kernel.patch deleted file mode 100644 index 4a4beb4..0000000 --- a/SOURCES/0001-fix-building-on-newest-glibc-and-kernel.patch +++ /dev/null @@ -1,41 +0,0 @@ -From cb21b73e859de77804dde8579c6d1d1f84eec3a6 Mon Sep 17 00:00:00 2001 -From: Adrian Reber -Date: Thu, 28 Sep 2017 09:13:33 +0000 -Subject: [PATCH] fix building on newest glibc and kernel - -On Fedora rawhide with kernel-headers-4.14.0-0.rc2.git0.1.fc28.x86_64 -glibc-devel-2.26.90-15.fc28.x86_64 criu does not build any more: - -In file included from /usr/include/linux/aio_abi.h:31:0, - from criu/cr-check.c:24: -/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant - MS_RDONLY = 1, /* Mount read-only. */ - ^ -make[2]: *** [/builddir/build/BUILD/criu-3.5/scripts/nmk/scripts/build.mk:111: criu/cr-check.o] Error 1 -make[1]: *** [criu/Makefile:73: criu/built-in.o] Error 2 -make: *** [Makefile:233: criu] Error 2 - -This simple re-ordering of includes fixes it for me. - -Signed-off-by: Adrian Reber ---- - criu/cr-check.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/criu/cr-check.c b/criu/cr-check.c -index 5dd448b..8986ec4 100644 ---- a/criu/cr-check.c -+++ b/criu/cr-check.c -@@ -21,8 +21,8 @@ - #include - #include - #include --#include - #include -+#include - - #include "../soccr/soccr.h" - --- -1.8.3.1 - diff --git a/SOURCES/0002-parasite-Rename-misnamed-nr_pages.patch b/SOURCES/0002-parasite-Rename-misnamed-nr_pages.patch new file mode 100644 index 0000000..3f81b16 --- /dev/null +++ b/SOURCES/0002-parasite-Rename-misnamed-nr_pages.patch @@ -0,0 +1,59 @@ +From 454fe3e7c07ba48a7a065135482196b53e376de0 Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:42 +0100 +Subject: [PATCH 2/8] parasite: Rename misnamed nr_pages + +It's actually number of bytes spliced, not pages. +And I bet (unsigned long) suits the purpose more than (int). + +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/pie/parasite.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c +index 7a48f324e..b9dae3f94 100644 +--- a/criu/pie/parasite.c ++++ b/criu/pie/parasite.c +@@ -67,7 +67,8 @@ static int dump_pages(struct parasite_dump_pages_args *args) + { + int p, ret, tsock; + struct iovec *iovs; +- int off, nr_segs, nr_pages; ++ int off, nr_segs; ++ unsigned long spliced_bytes = 0; + + tsock = parasite_get_rpc_sock(); + p = recv_fd(tsock); +@@ -75,7 +76,6 @@ static int dump_pages(struct parasite_dump_pages_args *args) + return -1; + + iovs = pargs_iovs(args); +- nr_pages = 0; + off = 0; + nr_segs = args->nr_segs; + if (nr_segs > UIO_MAXIOV) +@@ -89,16 +89,16 @@ static int dump_pages(struct parasite_dump_pages_args *args) + ret, nr_segs, args->off + off); + return -1; + } +- nr_pages += ret; ++ spliced_bytes += ret; + off += nr_segs; + if (off == args->nr_segs) + break; + if (off + nr_segs > args->nr_segs) + nr_segs = args->nr_segs - off; + } +- if (nr_pages != args->nr_pages * PAGE_SIZE) { ++ if (spliced_bytes != args->nr_pages * PAGE_SIZE) { + sys_close(p); +- pr_err("Can't splice all pages to pipe (%d/%d)\n", nr_pages, args->nr_pages); ++ pr_err("Can't splice all pages to pipe (%lu/%d)\n", spliced_bytes, args->nr_pages); + return -1; + } + +-- +2.17.0 + diff --git a/SOURCES/0003-aio-Allow-expressions-in-NR_IOEVENTS_IN_PAGES-macro.patch b/SOURCES/0003-aio-Allow-expressions-in-NR_IOEVENTS_IN_PAGES-macro.patch new file mode 100644 index 0000000..153107d --- /dev/null +++ b/SOURCES/0003-aio-Allow-expressions-in-NR_IOEVENTS_IN_PAGES-macro.patch @@ -0,0 +1,38 @@ +From 37c5b64e0e6966afe66d62ad9c700d27f3065e4e Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:43 +0100 +Subject: [PATCH 3/8] aio: Allow expressions in NR_IOEVENTS_IN_PAGES macro + +The macro is used only in aio_estimate_nr_reqs(): +unsigned int k_max_reqs = NR_IOEVENTS_IN_NPAGES(size/PAGE_SIZE); + +Which compiler may evaluate as (((PAGE_SIZE*size)/PAGE_SIZE) - ...) +It works as long as PAGE_SIZE is long. +The patches set converts PAGE_SIZE to use sysconf() returning +(unsigned), non-long type and making the aio macro overflowing. + +I do not see any value making PAGE_SIZE (unsigned long) typed. + +Cc: Kirill Tkhai +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/aio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/criu/aio.c b/criu/aio.c +index 27c251df5..45651f2d3 100644 +--- a/criu/aio.c ++++ b/criu/aio.c +@@ -13,7 +13,7 @@ + #include "images/mm.pb-c.h" + #include + +-#define NR_IOEVENTS_IN_NPAGES(npages) ((PAGE_SIZE * npages - sizeof(struct aio_ring)) / sizeof(struct io_event)) ++#define NR_IOEVENTS_IN_NPAGES(npages) ((PAGE_SIZE * (npages) - sizeof(struct aio_ring)) / sizeof(struct io_event)) + + int dump_aio_ring(MmEntry *mme, struct vma_area *vma) + { +-- +2.17.0 + diff --git a/SOURCES/0004-compel-criu-Add-ARCH_HAS_LONG_PAGES-to-PIE-binaries.patch b/SOURCES/0004-compel-criu-Add-ARCH_HAS_LONG_PAGES-to-PIE-binaries.patch new file mode 100644 index 0000000..3d9c8ed --- /dev/null +++ b/SOURCES/0004-compel-criu-Add-ARCH_HAS_LONG_PAGES-to-PIE-binaries.patch @@ -0,0 +1,215 @@ +From 0f98ee4641458301a3bbe49c88df381edaea93dc Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:44 +0100 +Subject: [PATCH 4/8] compel/criu: Add ARCH_HAS_LONG_PAGES to PIE binaries + +For architectures like aarch64/ppc64 it's needed to propagate the size +of page inside PIEs. For the parasite page size will be defined during +seizing, and for restorer during early initialization. +Afterward we can use PAGE_SIZE in PIEs like we did before. + +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + compel/include/rpc-pie-priv.h | 3 +++ + compel/plugins/std/infect.c | 17 +++++++++++++++++ + compel/src/lib/infect.c | 3 +++ + criu/cr-restore.c | 3 +++ + criu/include/restorer.h | 3 +++ + criu/pie/restorer.c | 16 ++++++++++++++++ + include/common/arch/aarch64/asm/page.h | 9 +++++++++ + include/common/arch/ppc64/asm/page.h | 9 +++++++++ + 8 files changed, 63 insertions(+) + +diff --git a/compel/include/rpc-pie-priv.h b/compel/include/rpc-pie-priv.h +index f25ca89eb..15f5b14ca 100644 +--- a/compel/include/rpc-pie-priv.h ++++ b/compel/include/rpc-pie-priv.h +@@ -38,6 +38,9 @@ struct parasite_init_args { + uint64_t sigreturn_addr; + uint64_t sigframe; /* pointer to sigframe */ + futex_t daemon_connected; ++#ifdef ARCH_HAS_LONG_PAGES ++ uint32_t page_size; ++#endif + }; + + struct parasite_unmap_args { +diff --git a/compel/plugins/std/infect.c b/compel/plugins/std/infect.c +index 2d3aa3df8..d5e1b4354 100644 +--- a/compel/plugins/std/infect.c ++++ b/compel/plugins/std/infect.c +@@ -3,6 +3,7 @@ + #include "common/scm.h" + #include "common/compiler.h" + #include "common/lock.h" ++#include "common/page.h" + + #define pr_err(fmt, ...) print_on_level(1, fmt, ##__VA_ARGS__) + #define pr_info(fmt, ...) print_on_level(3, fmt, ##__VA_ARGS__) +@@ -19,6 +20,19 @@ static int tsock = -1; + + static struct rt_sigframe *sigframe; + ++#ifdef ARCH_HAS_LONG_PAGES ++/* ++ * XXX: Make it compel's std plugin global variable. Drop parasite_size(). ++ * Hint: compel on aarch64 shall learn relocs for that. ++ */ ++static unsigned __page_size; ++ ++unsigned __attribute((weak)) page_size(void) ++{ ++ return __page_size; ++} ++#endif ++ + int parasite_get_rpc_sock(void) + { + return tsock; +@@ -142,6 +156,9 @@ static noinline __used int parasite_init_daemon(void *data) + + args->sigreturn_addr = (uint64_t)(uintptr_t)fini_sigreturn; + sigframe = (void*)(uintptr_t)args->sigframe; ++#ifdef ARCH_HAS_LONG_PAGES ++ __page_size = args->page_size; ++#endif + + ret = tsock = sys_socket(PF_UNIX, SOCK_SEQPACKET, 0); + if (tsock < 0) { +diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c +index ecc6599b1..d51b8aa88 100644 +--- a/compel/src/lib/infect.c ++++ b/compel/src/lib/infect.c +@@ -613,6 +613,9 @@ static int parasite_init_daemon(struct parasite_ctl *ctl) + + args->sigframe = (uintptr_t)ctl->rsigframe; + args->log_level = compel_log_get_loglevel(); ++#ifdef ARCH_HAS_LONG_PAGES ++ args->page_size = PAGE_SIZE; ++#endif + + futex_set(&args->daemon_connected, 0); + +diff --git a/criu/cr-restore.c b/criu/cr-restore.c +index 54216b8ea..8a436cc98 100644 +--- a/criu/cr-restore.c ++++ b/criu/cr-restore.c +@@ -3650,6 +3650,9 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns + task_args->premmapped_len = rsti(current)->premmapped_len; + + task_args->task_size = kdat.task_size; ++#ifdef ARCH_HAS_LONG_PAGES ++ task_args->page_size = PAGE_SIZE; ++#endif + + RST_MEM_FIXUP_PPTR(task_args->vmas); + RST_MEM_FIXUP_PPTR(task_args->rings); +diff --git a/criu/include/restorer.h b/criu/include/restorer.h +index 15307d9c0..70223be55 100644 +--- a/criu/include/restorer.h ++++ b/criu/include/restorer.h +@@ -209,6 +209,9 @@ struct task_restore_args { + void **breakpoint; + + enum faults fault_strategy; ++#ifdef ARCH_HAS_LONG_PAGES ++ unsigned page_size; ++#endif + } __aligned(64); + + /* +diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c +index 69f8504e3..da20f3298 100644 +--- a/criu/pie/restorer.c ++++ b/criu/pie/restorer.c +@@ -36,6 +36,7 @@ + #include "uffd.h" + + #include "common/lock.h" ++#include "common/page.h" + #include "restorer.h" + #include "aio.h" + #include "seccomp.h" +@@ -76,6 +77,18 @@ bool fault_injected(enum faults f) + return __fault_injected(f, fi_strategy); + } + ++#ifdef ARCH_HAS_LONG_PAGES ++/* ++ * XXX: Make it compel's std plugin global variable. Drop parasite_size(). ++ * Hint: compel on aarch64 shall learn relocs for that. ++ */ ++static unsigned __page_size; ++unsigned page_size(void) ++{ ++ return __page_size; ++} ++#endif ++ + /* + * These are stubs for std compel plugin. + */ +@@ -1230,6 +1243,9 @@ long __export_restore_task(struct task_restore_args *args) + zombies = args->zombies; + n_zombies = args->zombies_n; + *args->breakpoint = rst_sigreturn; ++#ifdef ARCH_HAS_LONG_PAGES ++ __page_size = args->page_size; ++#endif + + ksigfillset(&act.rt_sa_mask); + act.rt_sa_handler = sigchld_handler; +diff --git a/include/common/arch/aarch64/asm/page.h b/include/common/arch/aarch64/asm/page.h +index de1fe5428..4126c8474 100644 +--- a/include/common/arch/aarch64/asm/page.h ++++ b/include/common/arch/aarch64/asm/page.h +@@ -1,6 +1,9 @@ + #ifndef __CR_ASM_PAGE_H__ + #define __CR_ASM_PAGE_H__ + ++#define ARCH_HAS_LONG_PAGES ++ ++#ifndef CR_NOGLIBC + #include + + #ifndef PAGE_SHIFT +@@ -18,4 +21,10 @@ + #define PAGE_PFN(addr) ((addr) / PAGE_SIZE) + #define page_size() sysconf(_SC_PAGESIZE) + ++#else /* CR_NOGLIBC */ ++ ++extern unsigned page_size(void); ++#define PAGE_SIZE page_size() ++ ++#endif /* CR_NOGLIBC */ + #endif /* __CR_ASM_PAGE_H__ */ +diff --git a/include/common/arch/ppc64/asm/page.h b/include/common/arch/ppc64/asm/page.h +index 9d10455f1..a95af55ef 100644 +--- a/include/common/arch/ppc64/asm/page.h ++++ b/include/common/arch/ppc64/asm/page.h +@@ -1,6 +1,9 @@ + #ifndef __CR_ASM_PAGE_H__ + #define __CR_ASM_PAGE_H__ + ++#define ARCH_HAS_LONG_PAGES ++ ++#ifndef CR_NOGLIBC + #include + + /* +@@ -22,4 +25,10 @@ + #define PAGE_PFN(addr) ((addr) / PAGE_SIZE) + #define page_size() sysconf(_SC_PAGESIZE) + ++#else /* CR_NOGLIBC */ ++ ++extern unsigned page_size(void); ++#define PAGE_SIZE page_size() ++ ++#endif /* CR_NOGLIBC */ + #endif /* __CR_ASM_PAGE_H__ */ +-- +2.17.0 + diff --git a/SOURCES/0005-criu-dump-Fix-size-of-personality-buffer.patch b/SOURCES/0005-criu-dump-Fix-size-of-personality-buffer.patch new file mode 100644 index 0000000..133b57f --- /dev/null +++ b/SOURCES/0005-criu-dump-Fix-size-of-personality-buffer.patch @@ -0,0 +1,41 @@ +From 14c0abb1da33176f47939eee04846e8cf3e6992f Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:45 +0100 +Subject: [PATCH 5/8] criu/dump: Fix size of personality buffer + +Personality value is printed in kernel like this: +static int proc_pid_personality(/* .. */) +{ + int err = lock_trace(task); + if (!err) { + seq_printf(m, "%08x\n", task->personality); + unlock_trace(task); + } + return err; +} + +So, we don't need a whole page to read the value. + +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/cr-dump.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/criu/cr-dump.c b/criu/cr-dump.c +index b48a38b8b..208bd5060 100644 +--- a/criu/cr-dump.c ++++ b/criu/cr-dump.c +@@ -98,7 +98,8 @@ int __attribute__((weak)) arch_set_thread_regs(struct pstree_item *item, + return 0; + } + +-static char loc_buf[PAGE_SIZE]; ++#define PERSONALITY_LENGTH 9 ++static char loc_buf[PERSONALITY_LENGTH]; + + void free_mappings(struct vm_area_list *vma_area_list) + { +-- +2.17.0 + diff --git a/SOURCES/0006-criu-log-Define-log-buffer-length-without-PAGE_SIZE.patch b/SOURCES/0006-criu-log-Define-log-buffer-length-without-PAGE_SIZE.patch new file mode 100644 index 0000000..8702306 --- /dev/null +++ b/SOURCES/0006-criu-log-Define-log-buffer-length-without-PAGE_SIZE.patch @@ -0,0 +1,34 @@ +From f8064a7413a0a66ebe7afc8c19e2678b62177b9d Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:46 +0100 +Subject: [PATCH 6/8] criu/log: Define log buffer length without PAGE_SIZE + +The same value, but as PAGE_SIZE can be different for the same +platform - it's no more static value. + +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/log.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/criu/log.c b/criu/log.c +index 6a13266eb..43dcd106f 100644 +--- a/criu/log.c ++++ b/criu/log.c +@@ -30,10 +30,11 @@ + #define DEFAULT_LOGFD STDERR_FILENO + /* Enable timestamps if verbosity is increased from default */ + #define LOG_TIMESTAMP (DEFAULT_LOGLEVEL + 1) ++#define LOG_BUF_LEN (8*1024) + + static unsigned int current_loglevel = DEFAULT_LOGLEVEL; + +-static char buffer[PAGE_SIZE * 2]; ++static char buffer[LOG_BUF_LEN]; + static char buf_off = 0; + + static struct timeval start; +-- +2.17.0 + diff --git a/SOURCES/0007-criu-proc-Define-BUF_SIZE-without-PAGE_SIZE-dependen.patch b/SOURCES/0007-criu-proc-Define-BUF_SIZE-without-PAGE_SIZE-dependen.patch new file mode 100644 index 0000000..6187639 --- /dev/null +++ b/SOURCES/0007-criu-proc-Define-BUF_SIZE-without-PAGE_SIZE-dependen.patch @@ -0,0 +1,44 @@ +From 9457b3169d9c09b4255322c588c59df402fe3196 Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:47 +0100 +Subject: [PATCH 7/8] criu/proc: Define BUF_SIZE without PAGE_SIZE dependency + +PAGE_SIZE will be a variable value on platforms where it can be +different due to large pages. +And looks like (c) there is no reason for BUF_SIZE == PAGE_SIZE, +so let's keep it as it was, rather than complicating it with dynamic +allocation for the buffer. + +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/proc_parse.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/criu/proc_parse.c b/criu/proc_parse.c +index 27719416a..edc56bb99 100644 +--- a/criu/proc_parse.c ++++ b/criu/proc_parse.c +@@ -61,16 +61,16 @@ + #define SIGEV_THREAD_ID 4 /* deliver to thread */ + #endif + ++#define BUF_SIZE 4096 /* Good enough value - can be changed */ ++ + struct buffer { +- char buf[PAGE_SIZE]; ++ char buf[BUF_SIZE]; + char end; /* '\0' */ + }; + + static struct buffer __buf; + static char *buf = __buf.buf; + +-#define BUF_SIZE sizeof(__buf.buf) +- + /* + * This is how AIO ring buffers look like in proc + */ +-- +2.17.0 + diff --git a/SOURCES/0008-ppc64-aarch64-Dynamically-define-PAGE_SIZE.patch b/SOURCES/0008-ppc64-aarch64-Dynamically-define-PAGE_SIZE.patch new file mode 100644 index 0000000..84420c3 --- /dev/null +++ b/SOURCES/0008-ppc64-aarch64-Dynamically-define-PAGE_SIZE.patch @@ -0,0 +1,184 @@ +From c37583942c14d3574efbb42e39798bd21e65cfc3 Mon Sep 17 00:00:00 2001 +From: Dmitry Safonov +Date: Thu, 10 May 2018 19:14:48 +0100 +Subject: [PATCH 8/8] ppc64/aarch64: Dynamically define PAGE_SIZE + +On ppc64/aarch64 Linux can be set to use Large pages, so the PAGE_SIZE +isn't build-time constant anymore. Define it through _SC_PAGESIZE. + +There are different sizes for a page on ppc64: +: #if defined(CONFIG_PPC_256K_PAGES) +: #define PAGE_SHIFT 18 +: #elif defined(CONFIG_PPC_64K_PAGES) +: #define PAGE_SHIFT 16 +: #elif defined(CONFIG_PPC_16K_PAGES) +: #define PAGE_SHIFT 14 +: #else +: #define PAGE_SHIFT 12 +: #endif + +And on aarch64 there are default sizes and possibly someone can set his +own PAGE_SHIFT: +: config ARM64_PAGE_SHIFT +: int +: default 16 if ARM64_64K_PAGES +: default 14 if ARM64_16K_PAGES +: default 12 + +On the downside - each time we need PAGE_SIZE, we're doing libc +function call on aarch64/ppc64. + +Fixes: #415 + +Tested-by: Adrian Reber +Signed-off-by: Dmitry Safonov +Signed-off-by: Andrei Vagin +--- + criu/arch/aarch64/crtools.c | 3 ++ + criu/arch/ppc64/crtools.c | 3 ++ + include/common/arch/aarch64/asm/page.h | 42 +++++++++++++++++--------- + include/common/arch/ppc64/asm/page.h | 40 +++++++++++++++--------- + 4 files changed, 59 insertions(+), 29 deletions(-) + +diff --git a/criu/arch/aarch64/crtools.c b/criu/arch/aarch64/crtools.c +index f98743a23..b2ef1c312 100644 +--- a/criu/arch/aarch64/crtools.c ++++ b/criu/arch/aarch64/crtools.c +@@ -21,6 +21,9 @@ + #include "restorer.h" + #include + ++unsigned __page_size = 0; ++unsigned __page_shift = 0; ++ + #define assign_reg(dst, src, e) dst->e = (__typeof__(dst->e))(src)->e + + int save_task_regs(void *x, user_regs_struct_t *regs, user_fpregs_struct_t *fpsimd) +diff --git a/criu/arch/ppc64/crtools.c b/criu/arch/ppc64/crtools.c +index 5a5966ad4..077c243b2 100644 +--- a/criu/arch/ppc64/crtools.c ++++ b/criu/arch/ppc64/crtools.c +@@ -23,6 +23,9 @@ + #include "images/core.pb-c.h" + #include "images/creds.pb-c.h" + ++unsigned __page_size = 0; ++unsigned __page_shift = 0; ++ + static UserPpc64FpstateEntry *copy_fp_regs(uint64_t *fpregs) + { + UserPpc64FpstateEntry *fpe; +diff --git a/include/common/arch/aarch64/asm/page.h b/include/common/arch/aarch64/asm/page.h +index 4126c8474..bd8fe8f71 100644 +--- a/include/common/arch/aarch64/asm/page.h ++++ b/include/common/arch/aarch64/asm/page.h +@@ -4,22 +4,36 @@ + #define ARCH_HAS_LONG_PAGES + + #ifndef CR_NOGLIBC +-#include +- +-#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 ++#include /* ffsl() */ ++#include /* _SC_PAGESIZE */ ++ ++extern unsigned __page_size; ++extern unsigned __page_shift; ++ ++static inline unsigned page_size(void) ++{ ++ if (!__page_size) ++ __page_size = sysconf(_SC_PAGESIZE); ++ return __page_size; ++} ++ ++static inline unsigned page_shift(void) ++{ ++ if (!__page_shift) ++ __page_shift = (ffsl(page_size()) - 1); ++ return __page_shift; ++} ++ ++/* ++ * Don't add ifdefs for PAGE_SIZE: if any header defines it as a constant ++ * on aarch64, then we need refrain using PAGE_SIZE in criu and use ++ * page_size() across sources (as it may differ on aarch64). ++ */ ++#define PAGE_SIZE page_size() ++#define PAGE_MASK (~(PAGE_SIZE - 1)) ++#define PAGE_SHIFT page_shift() + + #define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +-#define page_size() sysconf(_SC_PAGESIZE) + + #else /* CR_NOGLIBC */ + +diff --git a/include/common/arch/ppc64/asm/page.h b/include/common/arch/ppc64/asm/page.h +index a95af55ef..5107cb8e0 100644 +--- a/include/common/arch/ppc64/asm/page.h ++++ b/include/common/arch/ppc64/asm/page.h +@@ -4,26 +4,36 @@ + #define ARCH_HAS_LONG_PAGES + + #ifndef CR_NOGLIBC +-#include ++#include /* ffsl() */ ++#include /* _SC_PAGESIZE */ ++ ++extern unsigned __page_size; ++extern unsigned __page_shift; ++ ++static inline unsigned page_size(void) ++{ ++ if (!__page_size) ++ __page_size = sysconf(_SC_PAGESIZE); ++ return __page_size; ++} ++ ++static inline unsigned page_shift(void) ++{ ++ if (!__page_shift) ++ __page_shift = (ffsl(page_size()) - 1); ++ return __page_shift; ++} + + /* +- * Default config for Pseries is to use 64K pages. +- * See kernel file arch/powerpc/configs/pseries_*defconfig ++ * Don't add ifdefs for PAGE_SIZE: if any header defines it as a constant ++ * on ppc64, then we need refrain using PAGE_SIZE in criu and use ++ * page_size() across sources (as it may differ on ppc64). + */ +-#ifndef PAGE_SHIFT +-# define PAGE_SHIFT 16 +-#endif +- +-#ifndef PAGE_SIZE +-# define PAGE_SIZE (1UL << PAGE_SHIFT) +-#endif +- +-#ifndef PAGE_MASK +-# define PAGE_MASK (~(PAGE_SIZE - 1)) +-#endif ++#define PAGE_SIZE page_size() ++#define PAGE_MASK (~(PAGE_SIZE - 1)) ++#define PAGE_SHIFT page_shift() + + #define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +-#define page_size() sysconf(_SC_PAGESIZE) + + #else /* CR_NOGLIBC */ + +-- +2.17.0 + diff --git a/SOURCES/27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1.patch b/SOURCES/27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1.patch new file mode 100644 index 0000000..269236a --- /dev/null +++ b/SOURCES/27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1.patch @@ -0,0 +1,83 @@ +From 27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1 Mon Sep 17 00:00:00 2001 +From: Pavel Tikhomirov +Date: Wed, 11 Jul 2018 13:43:33 +0300 +Subject: [PATCH] mount: fix regression where open_mountpoint failed on + readonly fs + +If we fail to create temporary directory for doing a clean mount we can +make mount clean reusing the code which enters new mountns to umount +overmounts. As when last process exits mntns all mounts are implicitly +cleaned from children, see in kernel source - sys_exit->do_exit +->exit_task_namespaces->switch_task_namespaces->free_nsproxy +->put_mnt_ns->umount_tree->drop_collected_mounts->umount_tree: + + /* Hide the mounts from mnt_mounts */ + list_for_each_entry(p, &tmp_list, mnt_list) { + list_del_init(&p->mnt_child); + } + +Fixes commit b6cfb1ce2948 ("mount: make open_mountpoint handle overmouts +properly") + +https://github.com/checkpoint-restore/criu/issues/520 +Signed-off-by: Pavel Tikhomirov +Acked-by: Adrian Reber +Signed-off-by: Andrei Vagin +--- + criu/mount.c | 28 ++++++++++++++++++++-------- + 1 file changed, 20 insertions(+), 8 deletions(-) + +diff --git a/criu/mount.c b/criu/mount.c +index b56164e953..9cc8f6e940 100644 +--- a/criu/mount.c ++++ b/criu/mount.c +@@ -1325,10 +1325,18 @@ int ns_open_mountpoint(void *arg) + if (umount_overmounts(mi)) + goto err; + +- /* Save fd which we opened for parent due to CLONE_FILES flag */ +- *fd = get_clean_fd(mi); +- if (*fd < 0) ++ /* ++ * Save fd which we opened for parent due to CLONE_FILES flag ++ * ++ * Mount can still have children in it, but we don't need to clean it ++ * explicitly as when last process exits mntns all mounts in it are ++ * cleaned from their children, and we are exactly the last process. ++ */ ++ *fd = open(mi->mountpoint, O_DIRECTORY|O_RDONLY); ++ if (*fd < 0) { ++ pr_perror("Unable to open %s", mi->mountpoint); + goto err; ++ } + + return 0; + err: +@@ -1367,18 +1375,22 @@ int open_mountpoint(struct mount_info *pm) + + if (!mnt_is_overmounted(pm)) { + pr_info("\tmount has children %s\n", pm->mountpoint); +- + fd = get_clean_fd(pm); +- if (fd < 0) +- goto err; +- } else { ++ } ++ ++ /* ++ * Mount is overmounted or probably we can't create a temporary ++ * direcotry for a cleaned mount ++ */ ++ if (fd < 0) { + int pid, status; + struct clone_arg ca = { + .mi = pm, + .fd = &fd + }; + +- pr_info("\tmount is overmounted %s\n", pm->mountpoint); ++ pr_info("\tmount is overmounted or has children %s\n", ++ pm->mountpoint); + + /* + * We are overmounted - not accessible in a regular way. We diff --git a/SOURCES/80a4d3cf8cf227c1d0aa45153a6324b16ae5a647.patch b/SOURCES/80a4d3cf8cf227c1d0aa45153a6324b16ae5a647.patch new file mode 100644 index 0000000..630c4c7 --- /dev/null +++ b/SOURCES/80a4d3cf8cf227c1d0aa45153a6324b16ae5a647.patch @@ -0,0 +1,52 @@ +From 80a4d3cf8cf227c1d0aa45153a6324b16ae5a647 Mon Sep 17 00:00:00 2001 +From: Andrei Vagin +Date: Sun, 17 Jun 2018 06:44:42 +0300 +Subject: [PATCH] bitops: use the UL literal for constants + +We operate by long variables in out bit arithmetics, so our constants +should be marked as long too. + +Cc: Adrian Reber +Reported-by: Adrian Reber +Signed-off-by: Andrei Vagin +Tested-by: Adrian Reber +Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> +Signed-off-by: Andrei Vagin +--- + include/common/asm-generic/bitops.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/common/asm-generic/bitops.h b/include/common/asm-generic/bitops.h +index cb449fbf8d..fbd25c1b6b 100644 +--- a/include/common/asm-generic/bitops.h ++++ b/include/common/asm-generic/bitops.h +@@ -28,25 +28,25 @@ + + static inline void set_bit(int nr, volatile unsigned long *addr) { + addr += nr / BITS_PER_LONG; +- *addr |= (1 << (nr % BITS_PER_LONG)); ++ *addr |= (1UL << (nr % BITS_PER_LONG)); + } + + static inline void change_bit(int nr, volatile unsigned long *addr) + { + addr += nr / BITS_PER_LONG; +- *addr ^= (1 << (nr % BITS_PER_LONG)); ++ *addr ^= (1UL << (nr % BITS_PER_LONG)); + } + + static inline int test_bit(int nr, volatile const unsigned long *addr) + { + addr += nr / BITS_PER_LONG; +- return (*addr & (1 << (nr % BITS_PER_LONG))) ? -1 : 0; ++ return (*addr & (1UL << (nr % BITS_PER_LONG))) ? -1 : 0; + } + + static inline void clear_bit(int nr, volatile unsigned long *addr) + { + addr += nr / BITS_PER_LONG; +- *addr &= ~(1 << (nr % BITS_PER_LONG)); ++ *addr &= ~(1UL << (nr % BITS_PER_LONG)); + } + + /** diff --git a/SOURCES/crit.1 b/SOURCES/crit.1 index f613476..4572477 100644 --- a/SOURCES/crit.1 +++ b/SOURCES/crit.1 @@ -2,12 +2,12 @@ .\" Title: crit .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 09/28/2017 +.\" Date: 06/01/2018 .\" Manual: CRIU Manual -.\" Source: criu 3.5 +.\" Source: criu 3.9 .\" Language: English .\" -.TH "CRIT" "1" "09/28/2017" "criu 3\&.5" "CRIU Manual" +.TH "CRIT" "1" "06/01/2018" "criu 3\&.9" "CRIU Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/SOURCES/criu.8 b/SOURCES/criu.8 index 73ac8e1..5973085 100644 --- a/SOURCES/criu.8 +++ b/SOURCES/criu.8 @@ -2,12 +2,12 @@ .\" Title: criu .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 09/28/2017 +.\" Date: 06/01/2018 .\" Manual: CRIU Manual -.\" Source: criu 3.5 +.\" Source: criu 3.9 .\" Language: English .\" -.TH "CRIU" "8" "09/28/2017" "criu 3\&.5" "CRIU Manual" +.TH "CRIU" "8" "06/01/2018" "criu 3\&.9" "CRIU Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/SPECS/criu.spec b/SPECS/criu.spec index 26734f1..633bf2e 100644 --- a/SPECS/criu.spec +++ b/SPECS/criu.spec @@ -1,12 +1,12 @@ -%if 0%{?fedora} > 27 +%if 0%{?fedora} > 27 || 0%{?rhel} > 7 %global py2_prefix python2 %else %global py2_prefix python %endif Name: criu -Version: 3.5 -Release: 4%{?dist} +Version: 3.9 +Release: 5%{?dist} Provides: crtools = %{version}-%{release} Obsoletes: crtools <= 1.0-2 Summary: Tool for Checkpoint/Restore in User-space @@ -14,9 +14,20 @@ Group: System Environment/Base License: GPLv2 URL: http://criu.org/ Source0: http://download.openvz.org/criu/criu-%{version}.tar.bz2 -Patch0: 0001-fix-building-on-newest-glibc-and-kernel.patch -%if ! 0%{?fedora} +Patch1: 0001-criu-Remove-PAGE_IMAGE_SIZE.patch +Patch2: 0002-parasite-Rename-misnamed-nr_pages.patch +Patch3: 0003-aio-Allow-expressions-in-NR_IOEVENTS_IN_PAGES-macro.patch +Patch4: 0004-compel-criu-Add-ARCH_HAS_LONG_PAGES-to-PIE-binaries.patch +Patch5: 0005-criu-dump-Fix-size-of-personality-buffer.patch +Patch6: 0006-criu-log-Define-log-buffer-length-without-PAGE_SIZE.patch +Patch7: 0007-criu-proc-Define-BUF_SIZE-without-PAGE_SIZE-dependen.patch +Patch8: 0008-ppc64-aarch64-Dynamically-define-PAGE_SIZE.patch +Patch9: https://github.com/checkpoint-restore/criu/commit/80a4d3cf8cf227c1d0aa45153a6324b16ae5a647.patch +Patch10: https://github.com/checkpoint-restore/criu/commit/27034e7c64b00a1f2467afb5ebb1d5b9b1a06ce1.patch + + +%if 0%{?rhel} && 0%{?rhel} <= 7 BuildRequires: perl # RHEL has no asciidoc; take man-page from Fedora 26 # zcat /usr/share/man/man8/criu.8.gz > criu.8 @@ -32,7 +43,7 @@ Source3: criu-tmpfiles.conf BuildRequires: systemd BuildRequires: libnet-devel BuildRequires: protobuf-devel protobuf-c-devel python2-devel libnl3-devel libcap-devel -%if 0%{?fedora} +%if 0%{?fedora} || 0%{?rhel} > 7 BuildRequires: asciidoc xmlto BuildRequires: perl-interpreter %endif @@ -47,7 +58,7 @@ criu is the user-space part of Checkpoint/Restore in User-space (CRIU), a project to implement checkpoint/restore functionality for Linux in user-space. -%if 0%{?fedora} +%if 0%{?fedora} || 0%{?rhel} > 7 %package devel Summary: Header files and libraries for %{name} Group: Development/Libraries @@ -61,7 +72,12 @@ This package contains header files and libraries for %{name}. %{?python_provide:%python_provide %{py2_prefix}-%{name}} Summary: Python bindings for %{name} Group: Development/Languages -Requires: %{name} = %{version}-%{release} python-ipaddr protobuf-python +Requires: %{name} = %{version}-%{release} %{py2_prefix}-ipaddr +%if 0%{?fedora} || 0%{?rhel} > 7 +Requires: python2-protobuf +%else +Requires: protobuf-python +%endif %description -n %{py2_prefix}-%{name} python-%{name} contains Python bindings for %{name}. @@ -77,13 +93,23 @@ their content in human-readable form. %prep %setup -q -%patch0 -p1 + +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 %build # %{?_smp_mflags} does not work # -fstack-protector breaks build CFLAGS+=`echo %{optflags} | sed -e 's,-fstack-protector\S*,,g'` make V=1 WERROR=0 PREFIX=%{_prefix} RUNDIR=/run/criu -%if 0%{?fedora} +%if 0%{?fedora} || 0%{?rhel} > 7 make docs V=1 %endif @@ -91,7 +117,7 @@ make docs V=1 %install make install-criu DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir} make install-lib DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir} -%if 0%{?fedora} +%if 0%{?fedora} || 0%{?rhel} > 7 # only install documentation on Fedora as it requires asciidoc, # which is not available on RHEL7 make install-man DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} LIBDIR=%{_libdir} @@ -104,7 +130,7 @@ mkdir -p %{buildroot}%{_tmpfilesdir} install -m 0644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/%{name}.conf install -d -m 0755 %{buildroot}/run/%{name}/ -%if ! 0%{?fedora} +%if 0%{?rhel} && 0%{?rhel} <= 7 # remove devel package rm -rf $RPM_BUILD_ROOT%{_includedir}/criu rm $RPM_BUILD_ROOT%{_libdir}/*.so* @@ -118,7 +144,7 @@ rm -rf $RPM_BUILD_ROOT%{_libexecdir}/%{name} %files %{_sbindir}/%{name} %doc %{_mandir}/man8/criu.8* -%if 0%{?fedora} +%if 0%{?fedora} || 0%{?rhel} > 7 %{_libdir}/*.so.* %{_libexecdir}/%{name} %endif @@ -126,7 +152,7 @@ rm -rf $RPM_BUILD_ROOT%{_libexecdir}/%{name} %{_tmpfilesdir}/%{name}.conf %doc README.md COPYING -%if 0%{?fedora} +%if 0%{?fedora} || 0%{?rhel} > 7 %files devel %{_includedir}/criu %{_libdir}/*.so @@ -143,6 +169,55 @@ rm -rf $RPM_BUILD_ROOT%{_libexecdir}/%{name} %changelog +* Sun Jul 15 2018 Adrian Reber - 3.9-5 +- Add patch to fix runc read-only regression (#1598028) + +* Tue Jun 19 2018 Adrian Reber - 3.9-4 +- Add patch to fix cow01 test case on aarch64 + +* Wed Jun 06 2018 Adrian Reber - 3.9-3 +- Simplify ExclusiveArch now that there is no more F26 + +* Mon Jun 04 2018 Adrian Reber - 3.9-2 +- Add patches for aarch64 page size errors + +* Fri Jun 01 2018 Adrian Reber - 3.9-1 +- Update to 3.9 + +* Tue Apr 03 2018 Adrian Reber - 3.8.1-1 +- Update to 3.8.1 + +* Thu Mar 22 2018 Adrian Reber - 3.8-2 +- Bump release for COPR + +* Wed Mar 14 2018 Adrian Reber - 3.8-1 +- Update to 3.8 + +* Wed Feb 07 2018 Fedora Release Engineering - 3.7-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Sat Feb 03 2018 Igor Gnatenko - 3.7-4 +- Switch to %%ldconfig_scriptlets + +* Fri Jan 12 2018 Adrian Reber - 3.7-3 +- Fix python/python2 dependencies accross all branches + +* Wed Jan 03 2018 Merlin Mathesius - 3.7-2 +- Cleanup spec file conditionals + +* Sat Dec 30 2017 Adrian Reber - 3.7-1 +- Update to 3.7 + +* Fri Dec 15 2017 Iryna Shcherbina - 3.6-2 +- Update Python 2 dependency declarations to new packaging standards + (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) + +* Thu Oct 26 2017 Adrian Reber - 3.6-1 +- Update to 3.6 + +* Wed Oct 18 2017 Adrian Reber - 3.5-5 +- Added patch to fix build on Fedora rawhide aarch64 + * Tue Oct 10 2017 Adrian Reber - 3.5-4 - Upgrade imported manpages to 3.5