Commit 69d008d5 authored by Christopher Covington's avatar Christopher Covington Committed by Pavel Emelyanov

Use run-time page_size() for mremap

The old and new address parameters passed to the mremap system
call must be page size aligned. On AArch64, the page size can
only be correctly determined at run time. This fixes the following
errors for CRIU on AArch64 kernels with CONFIG_ARM64_64K_PAGES=y.

      call mremap(0x3ffb7d50000, 8192, 8192, MAYMOVE | FIXED, 0x2a000)
  Error (rst-malloc.c:201): Can't mremap rst mem: Invalid argument

      call mremap(0x3ffb7d90000, 8192, 8192, MAYMOVE | FIXED, 0x32000)
  Error (rst-malloc.c:201): Can't mremap rst mem: Invalid argument
Signed-off-by: 's avatarChristopher Covington <cov@codeaurora.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b61224bf
#ifndef __CR_ASM_PAGE_H__
#define __CR_ASM_PAGE_H__
#include <unistd.h>
#ifndef PAGE_SHIFT
# define PAGE_SHIFT 12
#endif
......
......@@ -2687,7 +2687,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
BUILD_BUG_ON(sizeof(struct task_restore_args) & 1);
BUILD_BUG_ON(sizeof(struct thread_restore_args) & 1);
args_len = round_up(sizeof(*task_args) + sizeof(*thread_args) * current->nr_threads, PAGE_SIZE);
args_len = round_up(sizeof(*task_args) + sizeof(*thread_args) * current->nr_threads, page_size());
pr_info("%d threads require %ldK of memory\n",
current->nr_threads, KBYTES(args_len));
......
......@@ -18,15 +18,15 @@ struct rst_mem_type_s {
unsigned long size;
};
#define RST_MEM_BATCH (2 * PAGE_SIZE)
static inline unsigned long rst_mem_grow(unsigned long need_size)
{
need_size = round_up(need_size, PAGE_SIZE);
if (likely(need_size < RST_MEM_BATCH))
need_size = RST_MEM_BATCH;
int rst_mem_batch = 2 * page_size();
need_size = round_up(need_size, page_size());
if (likely(need_size < rst_mem_batch))
need_size = rst_mem_batch;
else
pr_debug("Growing rst memory %lu pages\n", need_size / PAGE_SIZE);
pr_debug("Growing rst memory %lu pages\n", need_size / page_size());
return need_size;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment