public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec jump: fix code size checking
@ 2008-08-13  1:04 Huang Ying
  2008-08-13  2:47 ` Simon Horman
  2008-08-13 13:19 ` Vivek Goyal
  0 siblings, 2 replies; 10+ messages in thread
From: Huang Ying @ 2008-08-13  1:04 UTC (permalink / raw)
  To: Eric W. Biederman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, Vivek Goyal, mingo, Linus Torvalds
  Cc: linux-kernel, Kexec Mailing List

Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
reminding.

Signed-off-by: Huang Ying <ying.huang@intel.com>

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)

--- a/include/asm-x86/kexec.h
+++ b/include/asm-x86/kexec.h
@@ -43,6 +43,9 @@
 
 #ifdef CONFIG_X86_32
 # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
+# ifndef CONFIG_KEXEC
+#  define kexec_control_code_size	0
+# endif
 #endif
 
 #ifndef __ASSEMBLY__



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  1:04 [PATCH] kexec jump: fix code size checking Huang Ying
@ 2008-08-13  2:47 ` Simon Horman
  2008-08-13  3:05   ` Huang Ying
  2008-08-13 13:19 ` Vivek Goyal
  1 sibling, 1 reply; 10+ messages in thread
From: Simon Horman @ 2008-08-13  2:47 UTC (permalink / raw)
  To: Huang Ying
  Cc: Eric W. Biederman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, Vivek Goyal, mingo, Linus Torvalds,
	Kexec Mailing List, linux-kernel

On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
> Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
> reminding.
> 
> Signed-off-by: Huang Ying <ying.huang@intel.com>
> 
> ---
>  include/asm-x86/kexec.h |    3 +++
>  1 file changed, 3 insertions(+)
> 
> --- a/include/asm-x86/kexec.h
> +++ b/include/asm-x86/kexec.h
> @@ -43,6 +43,9 @@
>  
>  #ifdef CONFIG_X86_32
>  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> +# ifndef CONFIG_KEXEC
> +#  define kexec_control_code_size	0
> +# endif
>  #endif
>  
>  #ifndef __ASSEMBLY__

Is it impossible to skip the linker check in the !CONFIG_KEXEC case?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  2:47 ` Simon Horman
@ 2008-08-13  3:05   ` Huang Ying
  2008-08-13  3:40     ` Eric W. Biederman
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Huang Ying @ 2008-08-13  3:05 UTC (permalink / raw)
  To: Simon Horman
  Cc: Eric W. Biederman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, Vivek Goyal, mingo, Linus Torvalds,
	Kexec Mailing List, linux-kernel

On Wed, 2008-08-13 at 12:47 +1000, Simon Horman wrote:
> On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
> > Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
> > reminding.
> > 
> > Signed-off-by: Huang Ying <ying.huang@intel.com>
> > 
> > ---
> >  include/asm-x86/kexec.h |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > --- a/include/asm-x86/kexec.h
> > +++ b/include/asm-x86/kexec.h
> > @@ -43,6 +43,9 @@
> >  
> >  #ifdef CONFIG_X86_32
> >  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> > +# ifndef CONFIG_KEXEC
> > +#  define kexec_control_code_size	0
> > +# endif
> >  #endif
> >  
> >  #ifndef __ASSEMBLY__
> 
> Is it impossible to skip the linker check in the !CONFIG_KEXEC case?

It is possible. I think there are several ways to do that.

1) use #ifdef in vmlinux_32.lds.S, such as:

#ifdef CONFIG_KEXEC
ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
       "kexec control code size is too big")
#endif

2) #define a macro for kexec check ld script in asm/kexec.h, such as:

#define LD_CHECK_KEXEC()	ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, \
				       "kexec control code size is too big")

and use that in vmlinux_32.lds.S.

3) #define kexec_control_code_size 0. So that the check can be passed
always. And, code size = 0 is reasonable for no code (CONFIG_KEXEC=n).


I think 3) is better. What do you think about?

Best Regards,
Huang Ying



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  3:05   ` Huang Ying
@ 2008-08-13  3:40     ` Eric W. Biederman
  2008-08-13  5:18       ` Huang Ying
  2008-08-13  3:48     ` Simon Horman
  2008-08-13 13:21     ` Vivek Goyal
  2 siblings, 1 reply; 10+ messages in thread
From: Eric W. Biederman @ 2008-08-13  3:40 UTC (permalink / raw)
  To: Huang Ying
  Cc: Simon Horman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, Vivek Goyal, mingo, Linus Torvalds,
	Kexec Mailing List, linux-kernel

Huang Ying <ying.huang@intel.com> writes:

> On Wed, 2008-08-13 at 12:47 +1000, Simon Horman wrote:
>> On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
>> > Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
>> > reminding.
>> > 
>> > Signed-off-by: Huang Ying <ying.huang@intel.com>
>> > 
>> > ---
>> >  include/asm-x86/kexec.h |    3 +++
>> >  1 file changed, 3 insertions(+)
>> > 
>> > --- a/include/asm-x86/kexec.h
>> > +++ b/include/asm-x86/kexec.h
>> > @@ -43,6 +43,9 @@
>> >  
>> >  #ifdef CONFIG_X86_32
>> >  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
>> > +# ifndef CONFIG_KEXEC
>> > +#  define kexec_control_code_size	0
>> > +# endif
>> >  #endif
>> >  
>> >  #ifndef __ASSEMBLY__
>> 
>> Is it impossible to skip the linker check in the !CONFIG_KEXEC case?
>
> It is possible. I think there are several ways to do that.
>
> 1) use #ifdef in vmlinux_32.lds.S, such as:
>
> #ifdef CONFIG_KEXEC
> ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
>        "kexec control code size is too big")
> #endif
>
> 2) #define a macro for kexec check ld script in asm/kexec.h, such as:
>
> #define LD_CHECK_KEXEC() ASSERT(kexec_control_code_size <=
> KEXEC_CONTROL_CODE_MAX_SIZE, \
> 				       "kexec control code size is too big")
>
> and use that in vmlinux_32.lds.S.
>
> 3) #define kexec_control_code_size 0. So that the check can be passed
> always. And, code size = 0 is reasonable for no code (CONFIG_KEXEC=n).
>
>
> I think 3) is better. What do you think about?

4) Put the code is a special section .text.kexec? and have the linker
   always do the size comparison and the computation of the section size.

The fewer conditionals we have the less likely something is to break.

Eric

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  3:05   ` Huang Ying
  2008-08-13  3:40     ` Eric W. Biederman
@ 2008-08-13  3:48     ` Simon Horman
  2008-08-13 13:21     ` Vivek Goyal
  2 siblings, 0 replies; 10+ messages in thread
From: Simon Horman @ 2008-08-13  3:48 UTC (permalink / raw)
  To: Huang Ying
  Cc: nigel, Kexec Mailing List, linux-kernel, Rafael J. Wysocki,
	Eric W. Biederman, Pavel Machek, Andrew Morton, Linus Torvalds,
	mingo, Vivek Goyal

On Wed, Aug 13, 2008 at 11:05:15AM +0800, Huang Ying wrote:
> On Wed, 2008-08-13 at 12:47 +1000, Simon Horman wrote:
> > On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
> > > Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
> > > reminding.
> > > 
> > > Signed-off-by: Huang Ying <ying.huang@intel.com>
> > > 
> > > ---
> > >  include/asm-x86/kexec.h |    3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > --- a/include/asm-x86/kexec.h
> > > +++ b/include/asm-x86/kexec.h
> > > @@ -43,6 +43,9 @@
> > >  
> > >  #ifdef CONFIG_X86_32
> > >  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> > > +# ifndef CONFIG_KEXEC
> > > +#  define kexec_control_code_size	0
> > > +# endif
> > >  #endif
> > >  
> > >  #ifndef __ASSEMBLY__
> > 
> > Is it impossible to skip the linker check in the !CONFIG_KEXEC case?
> 
> It is possible. I think there are several ways to do that.
> 
> 1) use #ifdef in vmlinux_32.lds.S, such as:
> 
> #ifdef CONFIG_KEXEC
> ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
>        "kexec control code size is too big")
> #endif
> 
> 2) #define a macro for kexec check ld script in asm/kexec.h, such as:
> 
> #define LD_CHECK_KEXEC()	ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, \
> 				       "kexec control code size is too big")
> 
> and use that in vmlinux_32.lds.S.
> 
> 3) #define kexec_control_code_size 0. So that the check can be passed
> always. And, code size = 0 is reasonable for no code (CONFIG_KEXEC=n).
> 
> 
> I think 3) is better. What do you think about?

Hi Huang,

I think that 1) with possibly the slight variation of moving
#include <asm/kexec.h> inside #ifdef CONFIG_KEXEC is better
because it avoids introducing kexec_control_code_size,
which is currently only used in arch/x86/kernel/relocate_kernel_32.S
and arch/x86/kernel/vmlinux_32.lds.S, into kexec.h.

/* Link time checks */

#ifdef CONFIG_KEXEC
#include <asm/kexec.h>

ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
       "kexec control code size is too big")
#endif


My second preference would be 3) as it seems simpler than 2).


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  3:40     ` Eric W. Biederman
@ 2008-08-13  5:18       ` Huang Ying
  2008-08-13  5:51         ` Simon Horman
  0 siblings, 1 reply; 10+ messages in thread
From: Huang Ying @ 2008-08-13  5:18 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Simon Horman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, Vivek Goyal, mingo, Linus Torvalds,
	Kexec Mailing List, linux-kernel

On Tue, 2008-08-12 at 20:40 -0700, Eric W. Biederman wrote:
[...]
> 4) Put the code is a special section .text.kexec? and have the linker
>    always do the size comparison and the computation of the section size.
> 
> The fewer conditionals we have the less likely something is to break.

Yes. This one is good. But I think current one is acceptable too.

Best Regards,
Huang Ying



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  5:18       ` Huang Ying
@ 2008-08-13  5:51         ` Simon Horman
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Horman @ 2008-08-13  5:51 UTC (permalink / raw)
  To: Huang Ying
  Cc: Eric W. Biederman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, Vivek Goyal, mingo, Linus Torvalds,
	Kexec Mailing List, linux-kernel

On Wed, Aug 13, 2008 at 01:18:12PM +0800, Huang Ying wrote:
> On Tue, 2008-08-12 at 20:40 -0700, Eric W. Biederman wrote:
> [...]
> > 4) Put the code is a special section .text.kexec? and have the linker
> >    always do the size comparison and the computation of the section size.
> > 
> > The fewer conditionals we have the less likely something is to break.
> 
> Yes. This one is good. But I think current one is acceptable too.

If you really think that 1) is the best way

Acked-by: Simon Horman <horms@verge.net.au>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  1:04 [PATCH] kexec jump: fix code size checking Huang Ying
  2008-08-13  2:47 ` Simon Horman
@ 2008-08-13 13:19 ` Vivek Goyal
  2008-08-13 17:07   ` Andrew Morton
  1 sibling, 1 reply; 10+ messages in thread
From: Vivek Goyal @ 2008-08-13 13:19 UTC (permalink / raw)
  To: Huang Ying
  Cc: Eric W. Biederman, Pavel Machek, nigel, Rafael J. Wysocki,
	Andrew Morton, mingo, Linus Torvalds, linux-kernel,
	Kexec Mailing List

On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
> Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
> reminding.
> 
> Signed-off-by: Huang Ying <ying.huang@intel.com>
> 
> ---
>  include/asm-x86/kexec.h |    3 +++
>  1 file changed, 3 insertions(+)
> 
> --- a/include/asm-x86/kexec.h
> +++ b/include/asm-x86/kexec.h
> @@ -43,6 +43,9 @@
>  
>  #ifdef CONFIG_X86_32
>  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> +# ifndef CONFIG_KEXEC
> +#  define kexec_control_code_size	0
> +# endif
>  #endif
>  
>  #ifndef __ASSEMBLY__

I think Andrew already fixed it. Right way is to put code in vmlinux.lds.S
under #ifdef CONFIG_KEXEC, than defining the symbol kexec_control_code_size
if CONFIG_KEXEC=n

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13  3:05   ` Huang Ying
  2008-08-13  3:40     ` Eric W. Biederman
  2008-08-13  3:48     ` Simon Horman
@ 2008-08-13 13:21     ` Vivek Goyal
  2 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2008-08-13 13:21 UTC (permalink / raw)
  To: Huang Ying
  Cc: Simon Horman, Eric W. Biederman, Pavel Machek, nigel,
	Rafael J. Wysocki, Andrew Morton, mingo, Linus Torvalds,
	Kexec Mailing List, linux-kernel

On Wed, Aug 13, 2008 at 11:05:15AM +0800, Huang Ying wrote:
> On Wed, 2008-08-13 at 12:47 +1000, Simon Horman wrote:
> > On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
> > > Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
> > > reminding.
> > > 
> > > Signed-off-by: Huang Ying <ying.huang@intel.com>
> > > 
> > > ---
> > >  include/asm-x86/kexec.h |    3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > --- a/include/asm-x86/kexec.h
> > > +++ b/include/asm-x86/kexec.h
> > > @@ -43,6 +43,9 @@
> > >  
> > >  #ifdef CONFIG_X86_32
> > >  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> > > +# ifndef CONFIG_KEXEC
> > > +#  define kexec_control_code_size	0
> > > +# endif
> > >  #endif
> > >  
> > >  #ifndef __ASSEMBLY__
> > 
> > Is it impossible to skip the linker check in the !CONFIG_KEXEC case?
> 
> It is possible. I think there are several ways to do that.
> 
> 1) use #ifdef in vmlinux_32.lds.S, such as:
> 
> #ifdef CONFIG_KEXEC
> ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
>        "kexec control code size is too big")
> #endif
> 
> 2) #define a macro for kexec check ld script in asm/kexec.h, such as:
> 
> #define LD_CHECK_KEXEC()	ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, \
> 				       "kexec control code size is too big")
> 
> and use that in vmlinux_32.lds.S.
> 
> 3) #define kexec_control_code_size 0. So that the check can be passed
> always. And, code size = 0 is reasonable for no code (CONFIG_KEXEC=n).
> 
> 
> I think 3) is better. What do you think about?
> 

I think 1) is good enough.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kexec jump: fix code size checking
  2008-08-13 13:19 ` Vivek Goyal
@ 2008-08-13 17:07   ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2008-08-13 17:07 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: Huang Ying, Eric W. Biederman, Pavel Machek, nigel,
	Rafael J. Wysocki, mingo, Linus Torvalds, linux-kernel,
	Kexec Mailing List

On Wed, 13 Aug 2008 09:19:27 -0400 Vivek Goyal <vgoyal@redhat.com> wrote:

> On Wed, Aug 13, 2008 at 09:04:35AM +0800, Huang Ying wrote:
> > Fix building issue when CONFIG_KEXEC=n. Thanks to Vivek Goyal for his
> > reminding.
> > 
> > Signed-off-by: Huang Ying <ying.huang@intel.com>
> > 
> > ---
> >  include/asm-x86/kexec.h |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > --- a/include/asm-x86/kexec.h
> > +++ b/include/asm-x86/kexec.h
> > @@ -43,6 +43,9 @@
> >  
> >  #ifdef CONFIG_X86_32
> >  # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
> > +# ifndef CONFIG_KEXEC
> > +#  define kexec_control_code_size	0
> > +# endif
> >  #endif
> >  
> >  #ifndef __ASSEMBLY__
> 
> I think Andrew already fixed it. Right way is to put code in vmlinux.lds.S
> under #ifdef CONFIG_KEXEC, than defining the symbol kexec_control_code_size
> if CONFIG_KEXEC=n

I was wondering about that.

I resurrected that patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-08-13 17:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-13  1:04 [PATCH] kexec jump: fix code size checking Huang Ying
2008-08-13  2:47 ` Simon Horman
2008-08-13  3:05   ` Huang Ying
2008-08-13  3:40     ` Eric W. Biederman
2008-08-13  5:18       ` Huang Ying
2008-08-13  5:51         ` Simon Horman
2008-08-13  3:48     ` Simon Horman
2008-08-13 13:21     ` Vivek Goyal
2008-08-13 13:19 ` Vivek Goyal
2008-08-13 17:07   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox