Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: utility/vbutil_kernel.c

Issue 6651022: Add --kloadaddr option to utilities (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Remove tabs Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« utility/dump_kernel_config.c ('K') | « utility/dump_kernel_config.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Verified boot kernel utility 5 * Verified boot kernel utility
6 */ 6 */
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <getopt.h> 9 #include <getopt.h>
10 #include <inttypes.h> /* For PRIu64 */ 10 #include <inttypes.h> /* For PRIu64 */
(...skipping 17 matching lines...) Expand all
28 28
29 static const int DEFAULT_PADDING = 65536; 29 static const int DEFAULT_PADDING = 65536;
30 30
31 /* Command line options */ 31 /* Command line options */
32 enum { 32 enum {
33 OPT_MODE_PACK = 1000, 33 OPT_MODE_PACK = 1000,
34 OPT_MODE_REPACK, 34 OPT_MODE_REPACK,
35 OPT_MODE_VERIFY, 35 OPT_MODE_VERIFY,
36 OPT_ARCH, 36 OPT_ARCH,
37 OPT_OLDBLOB, 37 OPT_OLDBLOB,
38 OPT_KERNELBODYLOADADDRESS,
38 OPT_KEYBLOCK, 39 OPT_KEYBLOCK,
39 OPT_SIGNPUBKEY, 40 OPT_SIGNPUBKEY,
40 OPT_SIGNPRIVATE, 41 OPT_SIGNPRIVATE,
41 OPT_VERSION, 42 OPT_VERSION,
42 OPT_VMLINUZ, 43 OPT_VMLINUZ,
43 OPT_BOOTLOADER, 44 OPT_BOOTLOADER,
44 OPT_CONFIG, 45 OPT_CONFIG,
45 OPT_VBLOCKONLY, 46 OPT_VBLOCKONLY,
46 OPT_PAD, 47 OPT_PAD,
47 OPT_VERBOSE, 48 OPT_VERBOSE,
48 }; 49 };
49 50
50 enum { 51 enum {
51 ARCH_ARM, 52 ARCH_ARM,
52 ARCH_X86 /* default */ 53 ARCH_X86 /* default */
53 }; 54 };
54 55
55 static struct option long_opts[] = { 56 static struct option long_opts[] = {
56 {"pack", 1, 0, OPT_MODE_PACK }, 57 {"pack", 1, 0, OPT_MODE_PACK },
57 {"repack", 1, 0, OPT_MODE_REPACK }, 58 {"repack", 1, 0, OPT_MODE_REPACK },
58 {"verify", 1, 0, OPT_MODE_VERIFY }, 59 {"verify", 1, 0, OPT_MODE_VERIFY },
59 {"arch", 1, 0, OPT_ARCH }, 60 {"arch", 1, 0, OPT_ARCH },
60 {"oldblob", 1, 0, OPT_OLDBLOB }, 61 {"oldblob", 1, 0, OPT_OLDBLOB },
62 {"kernelbodyloadaddress", 1, 0, OPT_KERNELBODYLOADADDRESS },
Randall Spangler 2011/03/09 17:25:38 kloadaddr
Che-Liang Chiou 2011/03/10 07:41:28 Done.
61 {"keyblock", 1, 0, OPT_KEYBLOCK }, 63 {"keyblock", 1, 0, OPT_KEYBLOCK },
62 {"signpubkey", 1, 0, OPT_SIGNPUBKEY }, 64 {"signpubkey", 1, 0, OPT_SIGNPUBKEY },
63 {"signprivate", 1, 0, OPT_SIGNPRIVATE }, 65 {"signprivate", 1, 0, OPT_SIGNPRIVATE },
64 {"version", 1, 0, OPT_VERSION }, 66 {"version", 1, 0, OPT_VERSION },
65 {"vmlinuz", 1, 0, OPT_VMLINUZ }, 67 {"vmlinuz", 1, 0, OPT_VMLINUZ },
66 {"bootloader", 1, 0, OPT_BOOTLOADER }, 68 {"bootloader", 1, 0, OPT_BOOTLOADER },
67 {"config", 1, 0, OPT_CONFIG }, 69 {"config", 1, 0, OPT_CONFIG },
68 {"vblockonly", 0, 0, OPT_VBLOCKONLY }, 70 {"vblockonly", 0, 0, OPT_VBLOCKONLY },
69 {"pad", 1, 0, OPT_PAD }, 71 {"pad", 1, 0, OPT_PAD },
70 {"verbose", 0, 0, OPT_VERBOSE }, 72 {"verbose", 0, 0, OPT_VERBOSE },
(...skipping 14 matching lines...) Expand all
85 " --keyblock <file> Key block in .keyblock format\n" 87 " --keyblock <file> Key block in .keyblock format\n"
86 " --signprivate <file>" 88 " --signprivate <file>"
87 " Private key to sign kernel data, in .vbprivk format\n" 89 " Private key to sign kernel data, in .vbprivk format\n"
88 " --version <number> Kernel version\n" 90 " --version <number> Kernel version\n"
89 " --vmlinuz <file> Linux kernel bzImage file\n" 91 " --vmlinuz <file> Linux kernel bzImage file\n"
90 " --bootloader <file> Bootloader stub\n" 92 " --bootloader <file> Bootloader stub\n"
91 " --config <file> Command line file\n" 93 " --config <file> Command line file\n"
92 " --arch <arch> Cpu architecture (default x86)\n" 94 " --arch <arch> Cpu architecture (default x86)\n"
93 "\n" 95 "\n"
94 " Optional:\n" 96 " Optional:\n"
97 " --kernelbodyloadaddress <address>\n"
98 " Assign kernel body load address\n"
95 " --pad <number> Verification padding size in bytes\n" 99 " --pad <number> Verification padding size in bytes\n"
96 " --vblockonly Emit just the verification blob\n", 100 " --vblockonly Emit just the verification blob\n",
97 progname); 101 progname);
98 fprintf(stderr, 102 fprintf(stderr,
99 "\nOR\n\n" 103 "\nOR\n\n"
100 "Usage: %s --repack <file> [PARAMETERS]\n" 104 "Usage: %s --repack <file> [PARAMETERS]\n"
101 "\n" 105 "\n"
102 " Required parameters (of --keyblock, --config, and --version \n" 106 " Required parameters (of --keyblock, --config, and --version \n"
103 " at least one is required):\n" 107 " at least one is required):\n"
104 " --keyblock <file> Key block in .keyblock format\n" 108 " --keyblock <file> Key block in .keyblock format\n"
105 " --signprivate <file>" 109 " --signprivate <file>"
106 " Private key to sign kernel data, in .vbprivk format\n" 110 " Private key to sign kernel data, in .vbprivk format\n"
107 " --oldblob <file> Previously packed kernel blob\n" 111 " --oldblob <file> Previously packed kernel blob\n"
108 " --config <file> New command line file\n" 112 " --config <file> New command line file\n"
109 " --version <number> Kernel version\n" 113 " --version <number> Kernel version\n"
110 "\n" 114 "\n"
111 " Optional:\n" 115 " Optional:\n"
116 " --kernelbodyloadaddress <address>\n"
117 " Assign kernel body load address\n"
112 " --pad <number> Verification padding size in bytes\n" 118 " --pad <number> Verification padding size in bytes\n"
113 " --vblockonly Emit just the verification blob\n", 119 " --vblockonly Emit just the verification blob\n",
114 progname); 120 progname);
115 fprintf(stderr, 121 fprintf(stderr,
116 "\nOR\n\n" 122 "\nOR\n\n"
117 "Usage: %s --verify <file> [PARAMETERS]\n" 123 "Usage: %s --verify <file> [PARAMETERS]\n"
118 "\n" 124 "\n"
119 " Optional:\n" 125 " Optional:\n"
120 " --signpubkey <file>" 126 " --signpubkey <file>"
121 " Public key to verify kernel keyblock, in .vbpubk format\n" 127 " Public key to verify kernel keyblock, in .vbpubk format\n"
122 " --verbose Print a more detailed report\n" 128 " --verbose Print a more detailed report\n"
123 " --keyblock <file>" 129 " --keyblock <file>"
124 " Outputs the verified key block, in .keyblock format\n" 130 " Outputs the verified key block, in .keyblock format\n"
131 " --kernelbodyloadaddress <address>\n"
132 " Assign kernel body load address\n"
125 "\n", 133 "\n",
126 progname); 134 progname);
127 return 1; 135 return 1;
128 } 136 }
129 137
130 static void Debug(const char *format, ...) { 138 static void Debug(const char *format, ...) {
131 if (!opt_debug) 139 if (!opt_debug)
132 return; 140 return;
133 141
134 va_list ap; 142 va_list ap;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 uint8_t *blob; 200 uint8_t *blob;
193 201
194 /* these fields are not always initialized */ 202 /* these fields are not always initialized */
195 VbKernelPreambleHeader* preamble; 203 VbKernelPreambleHeader* preamble;
196 VbKeyBlockHeader* key_block; 204 VbKeyBlockHeader* key_block;
197 uint8_t *buf; 205 uint8_t *buf;
198 206
199 } blob_t; 207 } blob_t;
200 208
201 /* Given a blob return the location of the kernel command line buffer. */ 209 /* Given a blob return the location of the kernel command line buffer. */
202 static char* BpCmdLineLocation(blob_t *bp) 210 static char* BpCmdLineLocation(blob_t *bp, uint64_t kernelbodyloadaddress)
Randall Spangler 2011/03/09 17:25:38 kernel_body_load_address (elsewhere, too)
Che-Liang Chiou 2011/03/10 07:41:28 Done.
203 { 211 {
204 return (char*)(bp->blob + bp->bootloader_address - CROS_32BIT_ENTRY_ADDR - 212 return (char*)(bp->blob + bp->bootloader_address - kernelbodyloadaddress -
205 CROS_CONFIG_SIZE - CROS_PARAMS_SIZE); 213 CROS_CONFIG_SIZE - CROS_PARAMS_SIZE);
206 } 214 }
207 215
208 static void FreeBlob(blob_t *bp) { 216 static void FreeBlob(blob_t *bp) {
209 if (bp) { 217 if (bp) {
210 if (bp->blob) 218 if (bp->blob)
211 Free(bp->blob); 219 Free(bp->blob);
212 if (bp->buf) 220 if (bp->buf)
213 Free(bp->buf); 221 Free(bp->buf);
214 Free(bp); 222 Free(bp);
(...skipping 27 matching lines...) Expand all
242 } 250 }
243 } 251 }
244 return config_buf; 252 return config_buf;
245 } 253 }
246 254
247 /* Create a blob from its components */ 255 /* Create a blob from its components */
248 static blob_t *NewBlob(uint64_t version, 256 static blob_t *NewBlob(uint64_t version,
249 const char* vmlinuz, 257 const char* vmlinuz,
250 const char* bootloader_file, 258 const char* bootloader_file,
251 const char* config_file, 259 const char* config_file,
252 int arch) { 260 int arch,
261 uint64_t kernelbodyloadaddress) {
253 blob_t* bp; 262 blob_t* bp;
254 struct linux_kernel_header* lh = 0; 263 struct linux_kernel_header* lh = 0;
255 struct linux_kernel_params* params = 0; 264 struct linux_kernel_params* params = 0;
256 uint8_t* config_buf; 265 uint8_t* config_buf;
257 uint64_t config_size; 266 uint64_t config_size;
258 uint8_t* bootloader_buf; 267 uint8_t* bootloader_buf;
259 uint64_t bootloader_size; 268 uint64_t bootloader_size;
260 uint8_t* kernel_buf; 269 uint8_t* kernel_buf;
261 uint64_t kernel_size; 270 uint64_t kernel_size;
262 uint64_t kernel32_start = 0; 271 uint64_t kernel32_start = 0;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bp->blob = blob; 342 bp->blob = blob;
334 343
335 /* Copy the 32-bit kernel. */ 344 /* Copy the 32-bit kernel. */
336 Debug("kernel goes at blob+=0x%" PRIx64 "\n", now); 345 Debug("kernel goes at blob+=0x%" PRIx64 "\n", now);
337 if (kernel32_size) 346 if (kernel32_size)
338 Memcpy(blob + now, kernel_buf + kernel32_start, kernel32_size); 347 Memcpy(blob + now, kernel_buf + kernel32_start, kernel32_size);
339 now += roundup(now + kernel32_size, CROS_ALIGN); 348 now += roundup(now + kernel32_size, CROS_ALIGN);
340 349
341 Debug("config goes at blob+0x%" PRIx64 "\n", now); 350 Debug("config goes at blob+0x%" PRIx64 "\n", now);
342 /* Find the load address of the commandline. We'll need it later. */ 351 /* Find the load address of the commandline. We'll need it later. */
343 cmdline_addr = CROS_32BIT_ENTRY_ADDR + now + 352 cmdline_addr = kernelbodyloadaddress + now +
344 find_cmdline_start((char *)config_buf, config_size); 353 find_cmdline_start((char *)config_buf, config_size);
345 Debug(" cmdline_addr=0x%" PRIx64 "\n", cmdline_addr); 354 Debug(" cmdline_addr=0x%" PRIx64 "\n", cmdline_addr);
346 355
347 /* Copy the config. */ 356 /* Copy the config. */
348 if (config_size) 357 if (config_size)
349 Memcpy(blob + now, config_buf, config_size); 358 Memcpy(blob + now, config_buf, config_size);
350 now += CROS_CONFIG_SIZE; 359 now += CROS_CONFIG_SIZE;
351 360
352 /* The zeropage data is next. Overlay the linux_kernel_header onto it, and 361 /* The zeropage data is next. Overlay the linux_kernel_header onto it, and
353 * tweak a few fields. */ 362 * tweak a few fields. */
(...skipping 16 matching lines...) Expand all
370 params->e820_entries[0].segment_size = 0x00001000; 379 params->e820_entries[0].segment_size = 0x00001000;
371 params->e820_entries[0].segment_type = E820_TYPE_RAM; 380 params->e820_entries[0].segment_type = E820_TYPE_RAM;
372 params->e820_entries[1].start_addr = 0xfffff000; 381 params->e820_entries[1].start_addr = 0xfffff000;
373 params->e820_entries[1].segment_size = 0x00001000; 382 params->e820_entries[1].segment_size = 0x00001000;
374 params->e820_entries[1].segment_type = E820_TYPE_RESERVED; 383 params->e820_entries[1].segment_type = E820_TYPE_RESERVED;
375 now += CROS_PARAMS_SIZE; 384 now += CROS_PARAMS_SIZE;
376 385
377 /* Finally, append the bootloader. Remember where it will load in 386 /* Finally, append the bootloader. Remember where it will load in
378 * memory, too. */ 387 * memory, too. */
379 Debug("bootloader goes at blob+=0x%" PRIx64 "\n", now); 388 Debug("bootloader goes at blob+=0x%" PRIx64 "\n", now);
380 bp->bootloader_address = CROS_32BIT_ENTRY_ADDR + now; 389 bp->bootloader_address = kernelbodyloadaddress + now;
381 bp->bootloader_size = roundup(bootloader_size, CROS_ALIGN); 390 bp->bootloader_size = roundup(bootloader_size, CROS_ALIGN);
382 Debug(" bootloader_address=0x%" PRIx64 "\n", bp->bootloader_address); 391 Debug(" bootloader_address=0x%" PRIx64 "\n", bp->bootloader_address);
383 Debug(" bootloader_size=0x%" PRIx64 "\n", bp->bootloader_size); 392 Debug(" bootloader_size=0x%" PRIx64 "\n", bp->bootloader_size);
384 if (bootloader_size) 393 if (bootloader_size)
385 Memcpy(blob + now, bootloader_buf, bootloader_size); 394 Memcpy(blob + now, bootloader_buf, bootloader_size);
386 now += bp->bootloader_size; 395 now += bp->bootloader_size;
387 Debug("end of blob is 0x%" PRIx64 "\n", now); 396 Debug("end of blob is 0x%" PRIx64 "\n", now);
388 397
389 /* Free input buffers */ 398 /* Free input buffers */
390 Free(kernel_buf); 399 Free(kernel_buf);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 Free(buf); 527 Free(buf);
519 } 528 }
520 } 529 }
521 return bp; 530 return bp;
522 } 531 }
523 532
524 533
525 /* Pack a .kernel */ 534 /* Pack a .kernel */
526 static int Pack(const char* outfile, const char* keyblock_file, 535 static int Pack(const char* outfile, const char* keyblock_file,
527 const char* signprivate, blob_t *bp, uint64_t pad, 536 const char* signprivate, blob_t *bp, uint64_t pad,
528 int vblockonly) { 537 int vblockonly,
538 uint64_t kernelbodyloadaddress) {
529 VbPrivateKey* signing_key; 539 VbPrivateKey* signing_key;
530 VbSignature* body_sig; 540 VbSignature* body_sig;
531 VbKernelPreambleHeader* preamble; 541 VbKernelPreambleHeader* preamble;
532 VbKeyBlockHeader* key_block; 542 VbKeyBlockHeader* key_block;
533 uint64_t key_block_size; 543 uint64_t key_block_size;
534 FILE* f; 544 FILE* f;
535 uint64_t i; 545 uint64_t i;
536 546
537 if (!outfile) { 547 if (!outfile) {
538 error("Must specify output filename\n"); 548 error("Must specify output filename\n");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 582
573 /* Sign the kernel data */ 583 /* Sign the kernel data */
574 body_sig = CalculateSignature(bp->blob, bp->blob_size, signing_key); 584 body_sig = CalculateSignature(bp->blob, bp->blob_size, signing_key);
575 if (!body_sig) { 585 if (!body_sig) {
576 error("Error calculating body signature\n"); 586 error("Error calculating body signature\n");
577 return 1; 587 return 1;
578 } 588 }
579 589
580 /* Create preamble */ 590 /* Create preamble */
581 preamble = CreateKernelPreamble(bp->kernel_version, 591 preamble = CreateKernelPreamble(bp->kernel_version,
582 CROS_32BIT_ENTRY_ADDR, 592 kernelbodyloadaddress,
583 bp->bootloader_address, 593 bp->bootloader_address,
584 bp->bootloader_size, 594 bp->bootloader_size,
585 body_sig, 595 body_sig,
586 pad - key_block_size, 596 pad - key_block_size,
587 signing_key); 597 signing_key);
588 if (!preamble) { 598 if (!preamble) {
589 error("Error creating preamble.\n"); 599 error("Error creating preamble.\n");
590 return 1; 600 return 1;
591 } 601 }
592 602
(...skipping 28 matching lines...) Expand all
621 631
622 fclose(f); 632 fclose(f);
623 633
624 /* Success */ 634 /* Success */
625 return 0; 635 return 0;
626 } 636 }
627 637
628 /* 638 /*
629 * Replace kernel command line in a blob representing a kernel. 639 * Replace kernel command line in a blob representing a kernel.
630 */ 640 */
631 static int ReplaceConfig(blob_t* bp, const char* config_file) 641 static int ReplaceConfig(blob_t* bp, const char* config_file,
642 uint64_t kernelbodyloadaddress)
632 { 643 {
633 uint8_t* new_conf; 644 uint8_t* new_conf;
634 uint64_t config_size; 645 uint64_t config_size;
635 646
636 if (!config_file) { 647 if (!config_file) {
637 return 0; 648 return 0;
638 } 649 }
639 650
640 new_conf = ReadConfigFile(config_file, &config_size); 651 new_conf = ReadConfigFile(config_file, &config_size);
641 if (!new_conf) { 652 if (!new_conf) {
642 return 1; 653 return 1;
643 } 654 }
644 655
645 /* fill the config buffer with zeros */ 656 /* fill the config buffer with zeros */
646 Memset(BpCmdLineLocation(bp), 0, CROS_CONFIG_SIZE); 657 Memset(BpCmdLineLocation(bp, kernelbodyloadaddress), 0, CROS_CONFIG_SIZE);
647 Memcpy(BpCmdLineLocation(bp), new_conf, config_size); 658 Memcpy(BpCmdLineLocation(bp, kernelbodyloadaddress), new_conf, config_size);
648 Free(new_conf); 659 Free(new_conf);
649 return 0; 660 return 0;
650 } 661 }
651 662
652 static int Verify(const char* infile, const char* signpubkey, int verbose, 663 static int Verify(const char* infile, const char* signpubkey, int verbose,
653 const char* key_block_file) { 664 const char* key_block_file, uint64_t kernelbodyloadaddress) {
654 665
655 VbKeyBlockHeader* key_block; 666 VbKeyBlockHeader* key_block;
656 VbKernelPreambleHeader* preamble; 667 VbKernelPreambleHeader* preamble;
657 VbPublicKey* data_key; 668 VbPublicKey* data_key;
658 VbPublicKey* sign_key = NULL; 669 VbPublicKey* sign_key = NULL;
659 RSAPublicKey* rsa; 670 RSAPublicKey* rsa;
660 blob_t* bp; 671 blob_t* bp;
661 uint64_t now; 672 uint64_t now;
662 int rv = 1; 673 int rv = 1;
663 674
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 goto verify_exit; 773 goto verify_exit;
763 } 774 }
764 printf("Body verification succeeded.\n"); 775 printf("Body verification succeeded.\n");
765 776
766 rv = 0; 777 rv = 0;
767 778
768 if (!verbose) { 779 if (!verbose) {
769 goto verify_exit; 780 goto verify_exit;
770 } 781 }
771 782
772 printf("Config:\n%s\n", BpCmdLineLocation(bp)); 783 printf("Config:\n%s\n", BpCmdLineLocation(bp, kernelbodyloadaddress));
773 784
774 verify_exit: 785 verify_exit:
775 FreeBlob(bp); 786 FreeBlob(bp);
776 return rv; 787 return rv;
777 } 788 }
778 789
779 790
780 int main(int argc, char* argv[]) { 791 int main(int argc, char* argv[]) {
781 char* filename = NULL; 792 char* filename = NULL;
782 char* oldfile = NULL; 793 char* oldfile = NULL;
783 char* key_block_file = NULL; 794 char* key_block_file = NULL;
784 char* signpubkey = NULL; 795 char* signpubkey = NULL;
785 char* signprivate = NULL; 796 char* signprivate = NULL;
786 int version = -1; 797 int version = -1;
787 char* vmlinuz = NULL; 798 char* vmlinuz = NULL;
788 char* bootloader = NULL; 799 char* bootloader = NULL;
789 char* config_file = NULL; 800 char* config_file = NULL;
790 int arch = ARCH_X86; 801 int arch = ARCH_X86;
791 int vblockonly = 0; 802 int vblockonly = 0;
792 int verbose = 0; 803 int verbose = 0;
804 uint64_t kernelbodyloadaddress = CROS_32BIT_ENTRY_ADDR;
793 uint64_t pad = DEFAULT_PADDING; 805 uint64_t pad = DEFAULT_PADDING;
794 int mode = 0; 806 int mode = 0;
795 int parse_error = 0; 807 int parse_error = 0;
796 char* e; 808 char* e;
797 int i,r; 809 int i,r;
798 blob_t *bp; 810 blob_t *bp;
799 811
800 812
801 char *progname = strrchr(argv[0], '/'); 813 char *progname = strrchr(argv[0], '/');
802 if (progname) 814 if (progname)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 else { 849 else {
838 fprintf(stderr, "Unknown architecture string: %s\n", optarg); 850 fprintf(stderr, "Unknown architecture string: %s\n", optarg);
839 parse_error = 1; 851 parse_error = 1;
840 } 852 }
841 break; 853 break;
842 854
843 case OPT_OLDBLOB: 855 case OPT_OLDBLOB:
844 oldfile = optarg; 856 oldfile = optarg;
845 break; 857 break;
846 858
859 case OPT_KERNELBODYLOADADDRESS:
860 kernelbodyloadaddress = strtoul(optarg, &e, 0);
861 if (!*optarg || (e && *e)) {
862 fprintf(stderr, "Invalid --kernelbodyloadaddress\n");
863 parse_error = 1;
864 }
865 break;
866
847 case OPT_KEYBLOCK: 867 case OPT_KEYBLOCK:
848 key_block_file = optarg; 868 key_block_file = optarg;
849 break; 869 break;
850 870
851 case OPT_SIGNPUBKEY: 871 case OPT_SIGNPUBKEY:
852 signpubkey = optarg; 872 signpubkey = optarg;
853 break; 873 break;
854 874
855 case OPT_SIGNPRIVATE: 875 case OPT_SIGNPRIVATE:
856 signprivate = optarg; 876 signprivate = optarg;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 verbose = 1; 912 verbose = 1;
893 break; 913 break;
894 } 914 }
895 } 915 }
896 916
897 if (parse_error) 917 if (parse_error)
898 return PrintHelp(progname); 918 return PrintHelp(progname);
899 919
900 switch(mode) { 920 switch(mode) {
901 case OPT_MODE_PACK: 921 case OPT_MODE_PACK:
902 bp = NewBlob(version, vmlinuz, bootloader, config_file, arch); 922 bp = NewBlob(version, vmlinuz, bootloader, config_file, arch,
923 kernelbodyloadaddress);
903 if (!bp) 924 if (!bp)
904 return 1; 925 return 1;
905 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly); 926 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly,
927 kernelbodyloadaddress);
906 FreeBlob(bp); 928 FreeBlob(bp);
907 return r; 929 return r;
908 930
909 case OPT_MODE_REPACK: 931 case OPT_MODE_REPACK:
910 if (!config_file && !key_block_file && (version<0)) { 932 if (!config_file && !key_block_file && (version<0)) {
911 fprintf(stderr, 933 fprintf(stderr,
912 "You must supply at least one of " 934 "You must supply at least one of "
913 "--config, --keyblock or --version\n"); 935 "--config, --keyblock or --version\n");
914 return 1; 936 return 1;
915 } 937 }
916 938
917 bp = OldBlob(oldfile); 939 bp = OldBlob(oldfile);
918 if (!bp) 940 if (!bp)
919 return 1; 941 return 1;
920 r = ReplaceConfig(bp, config_file); 942 r = ReplaceConfig(bp, config_file, kernelbodyloadaddress);
921 if (!r) { 943 if (!r) {
922 if (version >= 0) { 944 if (version >= 0) {
923 bp->kernel_version = (uint64_t) version; 945 bp->kernel_version = (uint64_t) version;
924 } 946 }
925 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly); 947 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly,
948 kernelbodyloadaddress);
926 } 949 }
927 FreeBlob(bp); 950 FreeBlob(bp);
928 return r; 951 return r;
929 952
930 case OPT_MODE_VERIFY: 953 case OPT_MODE_VERIFY:
931 return Verify(filename, signpubkey, verbose, key_block_file); 954 return Verify(filename, signpubkey, verbose, key_block_file,
955 kernelbodyloadaddress);
932 956
933 default: 957 default:
934 fprintf(stderr, 958 fprintf(stderr,
935 "You must specify a mode: --pack, --repack or --verify\n"); 959 "You must specify a mode: --pack, --repack or --verify\n");
936 return PrintHelp(progname); 960 return PrintHelp(progname);
937 } 961 }
938 } 962 }
OLDNEW
« utility/dump_kernel_config.c ('K') | « utility/dump_kernel_config.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698