All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Huang Ying <ying.huang@intel.com>
Cc: nigel@nigel.suspend2.net,
	Kexec Mailing List <kexec@lists.infradead.org>,
	linux-kernel@vger.kernel.org, "Rafael J. Wysocki" <rjw@sisk.pl>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Pavel Machek <pavel@ucw.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	mingo@elte.hu
Subject: Re: [PATCH -v2 3/8] kexec jump: check code size in control page
Date: Fri, 8 Aug 2008 10:09:38 -0400	[thread overview]
Message-ID: <20080808140938.GE3840@redhat.com> (raw)
In-Reply-To: <1218178356.22039.76.camel@caritas-dev.intel.com>

On Fri, Aug 08, 2008 at 02:52:36PM +0800, Huang Ying wrote:
> Kexec/Kexec-jump require code size in control page is less than
> PAGE_SIZE/2. This patch add link-time checking for this.
> 
> ASSERT() of ld link script is used as the link-time checking
> mechanism.
> 
> Signed-off-by: Huang Ying <ying.huang@intel.com>
> 
> ---
>  arch/x86/kernel/machine_kexec_32.c     |    2 +-
>  arch/x86/kernel/relocate_kernel_32.S   |   10 +++++++---
>  arch/x86/kernel/vmlinux_32.lds.S       |    2 ++
>  arch/x86/kernel/vmlinux_check_32.lds.S |    7 +++++++
>  include/asm-x86/kexec.h                |    4 ++++
>  5 files changed, 21 insertions(+), 4 deletions(-)
> 
> --- a/arch/x86/kernel/machine_kexec_32.c
> +++ b/arch/x86/kernel/machine_kexec_32.c
> @@ -138,7 +138,7 @@ void machine_kexec(struct kimage *image)
>  	}
>  
>  	control_page = page_address(image->control_code_page);
> -	memcpy(control_page, relocate_kernel, PAGE_SIZE/2);
> +	memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
>  
>  	relocate_kernel_ptr = control_page;
>  	page_list[PA_CONTROL_PAGE] = __pa(control_page);
> --- a/arch/x86/kernel/relocate_kernel_32.S
> +++ b/arch/x86/kernel/relocate_kernel_32.S
> @@ -20,10 +20,11 @@
>  #define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
>  #define PAE_PGD_ATTR (_PAGE_PRESENT)
>  
> -/* control_page + PAGE_SIZE/2 ~ control_page + PAGE_SIZE * 3/4 are
> - * used to save some data for jumping back
> +/* control_page + KEXEC_CONTROL_CODE_MAX_SIZE
> + * ~ control_page + PAGE_SIZE * 3/4 are used to save some data for
> + * jumping back
>   */

Hi Huang,

Above comment is not very clear. Can you please elaborate it. I thought
that PAGE_SIZE/2 is used for control code and rest half is shared between
kjump data and stack. What is PAGE_SIZE *3/4?


> -#define DATA(offset)		(PAGE_SIZE/2+(offset))
> +#define DATA(offset)		(KEXEC_CONTROL_CODE_MAX_SIZE+(offset))
>  
>  /* Minimal CPU state */
>  #define ESP			DATA(0x0)
> @@ -376,3 +377,6 @@ swap_pages:
>  	popl	%ebx
>  	popl	%ebp
>  	ret
> +
> +	.globl kexec_control_code_size
> +.set kexec_control_code_size, . - relocate_kernel
> --- a/include/asm-x86/kexec.h
> +++ b/include/asm-x86/kexec.h
> @@ -41,6 +41,10 @@
>  # define PAGES_NR		17
>  #endif
>  
> +#ifdef CONFIG_X86_32
> +# define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> +#endif
> +
>  #ifndef __ASSEMBLY__
>  
>  #include <linux/string.h>
> --- a/arch/x86/kernel/vmlinux_32.lds.S
> +++ b/arch/x86/kernel/vmlinux_32.lds.S
> @@ -209,3 +209,5 @@ SECTIONS
>  
>    DWARF_DEBUG
>  }
> +
> +#include "vmlinux_check_32.lds.S"
> --- /dev/null
> +++ b/arch/x86/kernel/vmlinux_check_32.lds.S
> @@ -0,0 +1,7 @@
> +/*
> + * Link time checks
> + */
> +
> +#include <asm/kexec.h>
> +
> +ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, "kexec control code size is too big")

Will it make sense to move it into vmlinux_32.lds.S itself? Creating a separate
file for a single check seems superfluous.

Thanks
Vivek

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

WARNING: multiple messages have this Message-ID (diff)
From: Vivek Goyal <vgoyal@redhat.com>
To: Huang Ying <ying.huang@intel.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Pavel Machek <pavel@ucw.cz>,
	nigel@nigel.suspend2.net, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Andrew Morton <akpm@linux-foundation.org>,
	mingo@elte.hu, Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Kexec Mailing List <kexec@lists.infradead.org>
Subject: Re: [PATCH -v2 3/8] kexec jump: check code size in control page
Date: Fri, 8 Aug 2008 10:09:38 -0400	[thread overview]
Message-ID: <20080808140938.GE3840@redhat.com> (raw)
In-Reply-To: <1218178356.22039.76.camel@caritas-dev.intel.com>

On Fri, Aug 08, 2008 at 02:52:36PM +0800, Huang Ying wrote:
> Kexec/Kexec-jump require code size in control page is less than
> PAGE_SIZE/2. This patch add link-time checking for this.
> 
> ASSERT() of ld link script is used as the link-time checking
> mechanism.
> 
> Signed-off-by: Huang Ying <ying.huang@intel.com>
> 
> ---
>  arch/x86/kernel/machine_kexec_32.c     |    2 +-
>  arch/x86/kernel/relocate_kernel_32.S   |   10 +++++++---
>  arch/x86/kernel/vmlinux_32.lds.S       |    2 ++
>  arch/x86/kernel/vmlinux_check_32.lds.S |    7 +++++++
>  include/asm-x86/kexec.h                |    4 ++++
>  5 files changed, 21 insertions(+), 4 deletions(-)
> 
> --- a/arch/x86/kernel/machine_kexec_32.c
> +++ b/arch/x86/kernel/machine_kexec_32.c
> @@ -138,7 +138,7 @@ void machine_kexec(struct kimage *image)
>  	}
>  
>  	control_page = page_address(image->control_code_page);
> -	memcpy(control_page, relocate_kernel, PAGE_SIZE/2);
> +	memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
>  
>  	relocate_kernel_ptr = control_page;
>  	page_list[PA_CONTROL_PAGE] = __pa(control_page);
> --- a/arch/x86/kernel/relocate_kernel_32.S
> +++ b/arch/x86/kernel/relocate_kernel_32.S
> @@ -20,10 +20,11 @@
>  #define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
>  #define PAE_PGD_ATTR (_PAGE_PRESENT)
>  
> -/* control_page + PAGE_SIZE/2 ~ control_page + PAGE_SIZE * 3/4 are
> - * used to save some data for jumping back
> +/* control_page + KEXEC_CONTROL_CODE_MAX_SIZE
> + * ~ control_page + PAGE_SIZE * 3/4 are used to save some data for
> + * jumping back
>   */

Hi Huang,

Above comment is not very clear. Can you please elaborate it. I thought
that PAGE_SIZE/2 is used for control code and rest half is shared between
kjump data and stack. What is PAGE_SIZE *3/4?


> -#define DATA(offset)		(PAGE_SIZE/2+(offset))
> +#define DATA(offset)		(KEXEC_CONTROL_CODE_MAX_SIZE+(offset))
>  
>  /* Minimal CPU state */
>  #define ESP			DATA(0x0)
> @@ -376,3 +377,6 @@ swap_pages:
>  	popl	%ebx
>  	popl	%ebp
>  	ret
> +
> +	.globl kexec_control_code_size
> +.set kexec_control_code_size, . - relocate_kernel
> --- a/include/asm-x86/kexec.h
> +++ b/include/asm-x86/kexec.h
> @@ -41,6 +41,10 @@
>  # define PAGES_NR		17
>  #endif
>  
> +#ifdef CONFIG_X86_32
> +# define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> +#endif
> +
>  #ifndef __ASSEMBLY__
>  
>  #include <linux/string.h>
> --- a/arch/x86/kernel/vmlinux_32.lds.S
> +++ b/arch/x86/kernel/vmlinux_32.lds.S
> @@ -209,3 +209,5 @@ SECTIONS
>  
>    DWARF_DEBUG
>  }
> +
> +#include "vmlinux_check_32.lds.S"
> --- /dev/null
> +++ b/arch/x86/kernel/vmlinux_check_32.lds.S
> @@ -0,0 +1,7 @@
> +/*
> + * Link time checks
> + */
> +
> +#include <asm/kexec.h>
> +
> +ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, "kexec control code size is too big")

Will it make sense to move it into vmlinux_32.lds.S itself? Creating a separate
file for a single check seems superfluous.

Thanks
Vivek

  reply	other threads:[~2008-08-08 14:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-08  6:52 [PATCH -v2 3/8] kexec jump: check code size in control page Huang Ying
2008-08-08  6:52 ` Huang Ying
2008-08-08 14:09 ` Vivek Goyal [this message]
2008-08-08 14:09   ` Vivek Goyal
2008-08-11  1:02   ` Huang Ying
2008-08-11  1:02     ` Huang Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080808140938.GE3840@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nigel@nigel.suspend2.net \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    --cc=torvalds@linux-foundation.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.