[CRIU] [RFC 1/3] Use run-time page_size() in pie_size()

Christopher Covington cov at codeaurora.org
Thu Jul 23 04:59:48 PDT 2015


This fixes the following error for CRIU on AArch64 kernels with
CONFIG_ARM64_64K_PAGES=y.

  Error (cr-restore.c:2828): Can't mmap section for restore code

This occurred because the address being requested (0x16000 in
one case) was not page aligned.

Also change the capitalization of the pie_size() macro to make it
clear that the value is not necessarily a build-time constant.

Signed-off-by: Christopher Covington <cov at codeaurora.org>
---
 cr-restore.c       | 2 +-
 parasite-syscall.c | 4 ++--
 pie/pie-relocs.h   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index e7bac3f..54e35ce 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2373,7 +2373,7 @@ static int prepare_restorer_blob(void)
 	 * in turn will lead to set-exe-file prctl to fail with EBUSY.
 	 */
 
-	restorer_len = PIE_SIZE(restorer_blob);
+	restorer_len = pie_size(restorer_blob);
 	restorer = mmap(NULL, restorer_len,
 			PROT_READ | PROT_WRITE | PROT_EXEC,
 			MAP_PRIVATE | MAP_ANON, 0, 0);
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 78af13b..6d2e7fc 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -1204,7 +1204,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 
 	ctl->args_size = round_up(parasite_args_size, PAGE_SIZE);
 	parasite_args_size = PARASITE_ARG_SIZE_MIN; /* reset for next task */
-	map_exchange_size = PIE_SIZE(parasite_blob) + ctl->args_size;
+	map_exchange_size = pie_size(parasite_blob) + ctl->args_size;
 	map_exchange_size += RESTORE_STACK_SIGFRAME + PARASITE_STACK_SIZE;
 	if (item->nr_threads > 1)
 		map_exchange_size += PARASITE_STACK_SIZE;
@@ -1225,7 +1225,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	ctl->addr_cmd		= parasite_sym(ctl->local_map, __export_parasite_cmd);
 	ctl->addr_args		= parasite_sym(ctl->local_map, __export_parasite_args);
 
-	p = PIE_SIZE(parasite_blob) + ctl->args_size;
+	p = pie_size(parasite_blob) + ctl->args_size;
 
 	ctl->rsigframe	= ctl->remote_map + p;
 	ctl->sigframe	= ctl->local_map  + p;
diff --git a/pie/pie-relocs.h b/pie/pie-relocs.h
index 354aa9b..1449ca6 100644
--- a/pie/pie-relocs.h
+++ b/pie/pie-relocs.h
@@ -10,7 +10,7 @@
 
 extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size,
 					    elf_reloc_t *elf_relocs, size_t nr_relocs);
-#define PIE_SIZE(__blob_name)	(round_up(sizeof(__blob_name) + nr_gotpcrel * sizeof(long), PAGE_SIZE))
+#define pie_size(__blob_name)	(round_up(sizeof(__blob_name) + nr_gotpcrel * sizeof(long), page_size()))
 #define ELF_RELOCS_APPLY_PARASITE(__mem, __vbase)			\
 	elf_relocs_apply(__mem, __vbase, sizeof(parasite_blob),		\
 			 parasite_relocs, ARRAY_SIZE(parasite_relocs))
@@ -20,7 +20,7 @@ extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size,
 
 #else
 
-#define PIE_SIZE(__blob_name)	(round_up(sizeof(__blob_name), PAGE_SIZE))
+#define pie_size(__blob_name)	(round_up(sizeof(__blob_name), page_size()))
 #define ELF_RELOCS_APPLY_PARASITE(__mem, __vbase)
 #define ELF_RELOCS_APPLY_RESTORER(__mem, __vbase)
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



More information about the CRIU mailing list