aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-23 13:40:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-23 13:40:34 -0400
commit8ca038dc10eec80f280d9d483f1835ac2763a787 (patch)
tree3394e1c028782b1a8d06455096c0516842fb62af
parente7b30a17c1ef5cbc67c5381407d2d03484b8def3 (diff)
parenta9aff3eaaf0966c2a1bb3717d811363d81e52c76 (diff)
Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 EFI updates from Ingo Molnar: "This patchset makes changes to the bzImage EFI header, so that it can be signed with a secure boot signature tool. It should not affect anyone who is not using the EFI self-boot feature in any way." * 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86, efi: Fix NumberOfRvaAndSizes field in PE32 header for EFI_STUB x86, efi: Fix .text section overlapping image header for EFI_STUB x86, efi: Fix issue of overlapping .reloc section for EFI_STUB
-rw-r--r--arch/x86/boot/compressed/eboot.c14
-rw-r--r--arch/x86/boot/header.S26
-rw-r--r--arch/x86/boot/tools/build.c24
3 files changed, 41 insertions, 23 deletions
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 0cdfc0d2315e..2c14e76bb4c7 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -904,11 +904,19 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table)
904 904
905 memset(boot_params, 0x0, 0x4000); 905 memset(boot_params, 0x0, 0x4000);
906 906
907 /* Copy first two sectors to boot_params */
908 memcpy(boot_params, image->image_base, 1024);
909
910 hdr = &boot_params->hdr; 907 hdr = &boot_params->hdr;
911 908
909 /* Copy the second sector to boot_params */
910 memcpy(&hdr->jump, image->image_base + 512, 512);
911
912 /*
913 * Fill out some of the header fields ourselves because the
914 * EFI firmware loader doesn't load the first sector.
915 */
916 hdr->root_flags = 1;
917 hdr->vid_mode = 0xffff;
918 hdr->boot_flag = 0xAA55;
919
912 /* 920 /*
913 * The EFI firmware loader could have placed the kernel image 921 * The EFI firmware loader could have placed the kernel image
914 * anywhere in memory, but the kernel has various restrictions 922 * anywhere in memory, but the kernel has various restrictions
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index f1bbeeb09148..8bbea6aa40d9 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -147,7 +147,7 @@ optional_header:
147 # Filled in by build.c 147 # Filled in by build.c
148 .long 0x0000 # AddressOfEntryPoint 148 .long 0x0000 # AddressOfEntryPoint
149 149
150 .long 0x0000 # BaseOfCode 150 .long 0x0200 # BaseOfCode
151#ifdef CONFIG_X86_32 151#ifdef CONFIG_X86_32
152 .long 0 # data 152 .long 0 # data
153#endif 153#endif
@@ -189,7 +189,7 @@ extra_header_fields:
189 .quad 0 # SizeOfHeapCommit 189 .quad 0 # SizeOfHeapCommit
190#endif 190#endif
191 .long 0 # LoaderFlags 191 .long 0 # LoaderFlags
192 .long 0x1 # NumberOfRvaAndSizes 192 .long 0x6 # NumberOfRvaAndSizes
193 193
194 .quad 0 # ExportTable 194 .quad 0 # ExportTable
195 .quad 0 # ImportTable 195 .quad 0 # ImportTable
@@ -217,18 +217,17 @@ section_table:
217 217
218 # 218 #
219 # The EFI application loader requires a relocation section 219 # The EFI application loader requires a relocation section
220 # because EFI applications are relocatable and not having 220 # because EFI applications must be relocatable. But since
221 # this section seems to confuse it. But since we don't need 221 # we don't need the loader to fixup any relocs for us, we
222 # the loader to fixup any relocs for us just fill it with a 222 # just create an empty (zero-length) .reloc section header.
223 # single dummy reloc.
224 # 223 #
225 .ascii ".reloc" 224 .ascii ".reloc"
226 .byte 0 225 .byte 0
227 .byte 0 226 .byte 0
228 .long reloc_end - reloc_start 227 .long 0
229 .long reloc_start 228 .long 0
230 .long reloc_end - reloc_start # SizeOfRawData 229 .long 0 # SizeOfRawData
231 .long reloc_start # PointerToRawData 230 .long 0 # PointerToRawData
232 .long 0 # PointerToRelocations 231 .long 0 # PointerToRelocations
233 .long 0 # PointerToLineNumbers 232 .long 0 # PointerToLineNumbers
234 .word 0 # NumberOfRelocations 233 .word 0 # NumberOfRelocations
@@ -469,10 +468,3 @@ setup_corrupt:
469 468
470 .data 469 .data
471dummy: .long 0 470dummy: .long 0
472
473 .section .reloc
474reloc_start:
475 .long dummy - reloc_start
476 .long 10
477 .word 0
478reloc_end:
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
index 24443a332083..3f61f6e2b46f 100644
--- a/arch/x86/boot/tools/build.c
+++ b/arch/x86/boot/tools/build.c
@@ -198,12 +198,19 @@ int main(int argc, char ** argv)
198 198
199 pe_header = get_unaligned_le32(&buf[0x3c]); 199 pe_header = get_unaligned_le32(&buf[0x3c]);
200 200
201 /* Size of code */
202 put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]);
203
204 /* Size of image */ 201 /* Size of image */
205 put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); 202 put_unaligned_le32(file_sz, &buf[pe_header + 0x50]);
206 203
204 /*
205 * Subtract the size of the first section (512 bytes) which
206 * includes the header and .reloc section. The remaining size
207 * is that of the .text section.
208 */
209 file_sz -= 512;
210
211 /* Size of code */
212 put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]);
213
207#ifdef CONFIG_X86_32 214#ifdef CONFIG_X86_32
208 /* 215 /*
209 * Address of entry point. 216 * Address of entry point.
@@ -216,8 +223,14 @@ int main(int argc, char ** argv)
216 /* .text size */ 223 /* .text size */
217 put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]); 224 put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]);
218 225
226 /* .text vma */
227 put_unaligned_le32(0x200, &buf[pe_header + 0xb4]);
228
219 /* .text size of initialised data */ 229 /* .text size of initialised data */
220 put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]); 230 put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]);
231
232 /* .text file offset */
233 put_unaligned_le32(0x200, &buf[pe_header + 0xbc]);
221#else 234#else
222 /* 235 /*
223 * Address of entry point. startup_32 is at the beginning and 236 * Address of entry point. startup_32 is at the beginning and
@@ -231,9 +244,14 @@ int main(int argc, char ** argv)
231 /* .text size */ 244 /* .text size */
232 put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]); 245 put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]);
233 246
247 /* .text vma */
248 put_unaligned_le32(0x200, &buf[pe_header + 0xc4]);
249
234 /* .text size of initialised data */ 250 /* .text size of initialised data */
235 put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]); 251 put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]);
236 252
253 /* .text file offset */
254 put_unaligned_le32(0x200, &buf[pe_header + 0xcc]);
237#endif /* CONFIG_X86_32 */ 255#endif /* CONFIG_X86_32 */
238#endif /* CONFIG_EFI_STUB */ 256#endif /* CONFIG_EFI_STUB */
239 257