[CRIU] [RFC] Check page size at run time

Pavel Emelyanov xemul at parallels.com
Mon Oct 5 03:22:54 PDT 2015


On 10/03/2015 03:47 PM, Christopher Covington wrote:
> CRIU can be built to support different PAGE_SIZE values. Move the
> page size check from build time to run time.
> 
> Signed-off-by: Christopher Covington <cov at codeaurora.org>
> ---
>  crtools.c       |  2 --
>  include/image.h |  5 -----
>  kerndat.c       | 13 +++++++++++++
>  3 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/crtools.c b/crtools.c
> index ea8b889..52d148b 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -255,8 +255,6 @@ int main(int argc, char *argv[], char *envp[])
>  		{ },
>  	};
>  
> -	BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
> -
>  	cr_pb_init();
>  	if (restrict_uid(getuid(), getgid()))
>  		return 1;
> diff --git a/include/image.h b/include/image.h
> index 305febf..a1e5544 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -11,11 +11,6 @@
>  #include "bfd.h"
>  #include "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
>  
> diff --git a/kerndat.c b/kerndat.c
> index e57c6fd..4e10e63 100644
> --- a/kerndat.c
> +++ b/kerndat.c
> @@ -296,6 +296,17 @@ static int get_task_size(void)
>  	return 0;
>  }
>  
> +static int check_page_size(void)
> +{
> +	if (PAGE_SIZE != page_size()) {
> +		pr_err("Page size mismatch.\n");
> +		pr_err("Built for: %ld running with: %ld.\n", (unsigned long)PAGE_SIZE,
> +		       page_size());
> +		return -1;
> +	}
> +	return 0;
> +}
> +
>  int kerndat_fdinfo_has_lock()
>  {
>  	int fd, pfd = -1, exit_code = -1, len;
> @@ -348,6 +359,8 @@ int kerndat_init(void)

The kerndat_init() is only called on dump, restore calls kerndat_init_rst(). Do
we want to check page-size on restore as well?

>  		ret = kerndat_fdinfo_has_lock();
>  	if (!ret)
>  		ret = get_task_size();
> +	if (!ret)
> +		ret = check_page_size();
>  
>  	kerndat_lsm();
>  
> 



More information about the CRIU mailing list