diff options
author | Huang Ying <ying.huang@intel.com> | 2008-08-15 03:40:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-15 11:35:42 -0400 |
commit | fb45daa69d287b394eca1619b3fadff7c0215c71 (patch) | |
tree | aeb5a247b105d3b7e7ef2cdb0db5743574d9c480 | |
parent | 163f6876f5c3ff8215e900b93779e960a56b3694 (diff) |
kexec jump: check code size in control page
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.
[akpm@linux-foundation.org: build fix]
Signed-off-by: Huang Ying <ying.huang@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/kernel/machine_kexec_32.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/relocate_kernel_32.S | 10 | ||||
-rw-r--r-- | arch/x86/kernel/vmlinux_32.lds.S | 8 | ||||
-rw-r--r-- | include/asm-x86/kexec.h | 4 |
4 files changed, 20 insertions, 4 deletions
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c index 466450167dea..5c8e7735c896 100644 --- 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) | |||
138 | } | 138 | } |
139 | 139 | ||
140 | control_page = page_address(image->control_code_page); | 140 | control_page = page_address(image->control_code_page); |
141 | memcpy(control_page, relocate_kernel, PAGE_SIZE/2); | 141 | memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE); |
142 | 142 | ||
143 | relocate_kernel_ptr = control_page; | 143 | relocate_kernel_ptr = control_page; |
144 | page_list[PA_CONTROL_PAGE] = __pa(control_page); | 144 | page_list[PA_CONTROL_PAGE] = __pa(control_page); |
diff --git a/arch/x86/kernel/relocate_kernel_32.S b/arch/x86/kernel/relocate_kernel_32.S index 703310a99023..6f50664b2ba5 100644 --- a/arch/x86/kernel/relocate_kernel_32.S +++ b/arch/x86/kernel/relocate_kernel_32.S | |||
@@ -20,10 +20,11 @@ | |||
20 | #define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) | 20 | #define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) |
21 | #define PAE_PGD_ATTR (_PAGE_PRESENT) | 21 | #define PAE_PGD_ATTR (_PAGE_PRESENT) |
22 | 22 | ||
23 | /* control_page + PAGE_SIZE/2 ~ control_page + PAGE_SIZE * 3/4 are | 23 | /* control_page + KEXEC_CONTROL_CODE_MAX_SIZE |
24 | * used to save some data for jumping back | 24 | * ~ control_page + PAGE_SIZE are used as data storage and stack for |
25 | * jumping back | ||
25 | */ | 26 | */ |
26 | #define DATA(offset) (PAGE_SIZE/2+(offset)) | 27 | #define DATA(offset) (KEXEC_CONTROL_CODE_MAX_SIZE+(offset)) |
27 | 28 | ||
28 | /* Minimal CPU state */ | 29 | /* Minimal CPU state */ |
29 | #define ESP DATA(0x0) | 30 | #define ESP DATA(0x0) |
@@ -376,3 +377,6 @@ swap_pages: | |||
376 | popl %ebx | 377 | popl %ebx |
377 | popl %ebp | 378 | popl %ebp |
378 | ret | 379 | ret |
380 | |||
381 | .globl kexec_control_code_size | ||
382 | .set kexec_control_code_size, . - relocate_kernel | ||
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S index cdb2363697d2..af5bdad84604 100644 --- a/arch/x86/kernel/vmlinux_32.lds.S +++ b/arch/x86/kernel/vmlinux_32.lds.S | |||
@@ -209,3 +209,11 @@ SECTIONS | |||
209 | 209 | ||
210 | DWARF_DEBUG | 210 | DWARF_DEBUG |
211 | } | 211 | } |
212 | |||
213 | #ifdef CONFIG_KEXEC | ||
214 | /* Link time checks */ | ||
215 | #include <asm/kexec.h> | ||
216 | |||
217 | ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, | ||
218 | "kexec control code size is too big") | ||
219 | #endif | ||
diff --git a/include/asm-x86/kexec.h b/include/asm-x86/kexec.h index f6fb3d21883c..4246ab7dc988 100644 --- a/include/asm-x86/kexec.h +++ b/include/asm-x86/kexec.h | |||
@@ -41,6 +41,10 @@ | |||
41 | # define PAGES_NR 17 | 41 | # define PAGES_NR 17 |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #ifdef CONFIG_X86_32 | ||
45 | # define KEXEC_CONTROL_CODE_MAX_SIZE 2048 | ||
46 | #endif | ||
47 | |||
44 | #ifndef __ASSEMBLY__ | 48 | #ifndef __ASSEMBLY__ |
45 | 49 | ||
46 | #include <linux/string.h> | 50 | #include <linux/string.h> |