Skip to contentSkip to conversation

kexec jump: fix code size checking

PATCH In review Huang Ying 5 participants 10 messages Aug 13, 2008

Subsystems (2)
lore
Share & tools
lore

Huang Ying

author
#0 lore raw

PATCH 1/1 kexec jump: fix code size checking

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

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)
include/asm-x86/kexec.h +3 -0
@@ -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__

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 12 lines · Huang Ying

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

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

include/asm-x86/kexec.h line 51

Quoted 9 lines
include/asm-x86/kexec.h +3 -0
@@ -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?

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#2 lore raw
Quoted 21 lines · Simon Horman
Quoted 20 lines · Huang Ying

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

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)
include/asm-x86/kexec.h +3 -0
@@ -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
 
Quoted 3 lines

include/asm-x86/kexec.h line 51

Quoted 1 line
include/asm-x86/kexec.h +0 -0
 #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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
Quoted 41 lines · Huang Ying
Quoted 21 lines · Simon Horman
Quoted 20 lines · Huang Ying

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

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)
include/asm-x86/kexec.h +3 -0
@@ -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
 
Quoted 3 lines

include/asm-x86/kexec.h line 51

Quoted 1 line
include/asm-x86/kexec.h +0 -0
 #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")

Quoted 7 lines

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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#4 lore raw

On Tue, 2008-08-12 at 20:40 -0700, Eric W. Biederman wrote:
[...]

Quoted 4 lines

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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Acked-by
#5 lore raw
Quoted 8 lines · Huang Ying

On Tue, 2008-08-12 at 20:40 -0700, Eric W. Biederman wrote:
[...]

Quoted 4 lines

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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw
In reply to Huang Ying
Quoted 40 lines · Huang Ying
Quoted 21 lines · Simon Horman
Quoted 20 lines · Huang Ying

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

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)
include/asm-x86/kexec.h +3 -0
@@ -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
 
Quoted 3 lines

include/asm-x86/kexec.h line 51

Quoted 1 line
include/asm-x86/kexec.h +0 -0
 #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")

Quoted 7 lines

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).

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw
In reply to Huang Ying
Quoted 40 lines · Huang Ying
Quoted 21 lines · Simon Horman
Quoted 20 lines · Huang Ying

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

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)
include/asm-x86/kexec.h +3 -0
@@ -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
 
Quoted 3 lines

include/asm-x86/kexec.h line 51

Quoted 1 line
include/asm-x86/kexec.h +0 -0
 #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")

Quoted 8 lines

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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw
In reply to Huang Ying
Quoted 12 lines · Huang Ying

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

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

include/asm-x86/kexec.h line 51

Quoted 9 lines
include/asm-x86/kexec.h +3 -0
@@ -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

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw
Quoted 21 lines · On Wed, 13 Aug 2008 09:19:27 -0400 Vivek Goyal <[email protected]> wrote:
Quoted 20 lines · Huang Ying

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

---
 include/asm-x86/kexec.h |    3 +++
 1 file changed, 3 insertions(+)
include/asm-x86/kexec.h +3 -0
@@ -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
 
Quoted 5 lines

include/asm-x86/kexec.h line 51

Quoted 1 line
include/asm-x86/kexec.h +0 -0
 #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.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec