summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Marchesin <marcheu@chromium.org>2011-03-15 10:13:31 -0700
committerStéphane Marchesin <marcheu@chromium.org>2011-03-15 10:13:31 -0700
commitbc7a84d9a1bef3fb8c1e2709033f6c9777599fe9 (patch)
treed4a5462d9cadc512b470939c30e357604547dc17
parentb17e8d353c50d46f0e5f29578f6294003692ea1d (diff)
downloadvboot-bc7a84d9a1bef3fb8c1e2709033f6c9777599fe9.tar.gz
Revert "Add --kloadaddr option to utilities"
This reverts commit 1a0975f5f477abe7425e2b7ade655d73138e5c64. This fixes chromeos-install on x86-mario with a kernel-next profile. BUG=None TEST=Build an x86-mario image with kernel-next, check that /usr/sbin/chromeos-install works. Review URL: http://codereview.chromium.org/6677033 Change-Id: I67fc5c0f70a05a4d662952105542edf454da8022
-rw-r--r--utility/dump_kernel_config.c60
-rw-r--r--utility/vbutil_kernel.c59
2 files changed, 25 insertions, 94 deletions
diff --git a/utility/dump_kernel_config.c b/utility/dump_kernel_config.c
index b44a12e0..4decc7de 100644
--- a/utility/dump_kernel_config.c
+++ b/utility/dump_kernel_config.c
@@ -5,7 +5,6 @@
* Exports the kernel commandline from a given partition/image.
*/
-#include <getopt.h>
#include <inttypes.h> /* For uint64_t */
#include <stdio.h>
#include <stdlib.h>
@@ -17,28 +16,17 @@
#include "vboot_common.h"
#include "vboot_struct.h"
-enum {
- OPT_KLOADADDR = 1000,
-};
-
-static struct option long_opts[] = {
- { "kloadaddr", 1, 0, OPT_KLOADADDR },
- { NULL, 0, 0, 0 }
-};
-
/* Print help and return error */
static int PrintHelp(void) {
puts("dump_kernel_config - Prints the kernel command line\n"
"\n"
- "Usage: dump_kernel_config [--kloadaddr <ADDRESS>] "
- "<image/blockdevice>\n"
+ "Usage: dump_kernel_config <image/blockdevice>\n"
"\n"
"");
return 1;
}
-static uint8_t* find_kernel_config(uint8_t* blob, uint64_t blob_size,
- uint64_t kernel_body_load_address) {
+static uint8_t* find_kernel_config(uint8_t* blob, uint64_t blob_size) {
VbKeyBlockHeader* key_block;
VbKernelPreambleHeader* preamble;
struct linux_kernel_params *params;
@@ -64,7 +52,7 @@ static uint8_t* find_kernel_config(uint8_t* blob, uint64_t blob_size,
/* The parameters are packed before the bootloader and there is no specific
* pointer to it so we just walk back by its allocated size. */
offset = preamble->bootloader_address -
- (kernel_body_load_address + CROS_PARAMS_SIZE) + now;
+ (CROS_32BIT_ENTRY_ADDR + CROS_PARAMS_SIZE) + now;
if (offset > blob_size) {
error("params are outside of the memory blob: %x\n", offset);
return NULL;
@@ -72,7 +60,7 @@ static uint8_t* find_kernel_config(uint8_t* blob, uint64_t blob_size,
params = (struct linux_kernel_params *)(blob + offset);
/* Grab the offset to the kernel command line using the supplied pointer. */
- offset = params->cmd_line_ptr - kernel_body_load_address + now;
+ offset = params->cmd_line_ptr - CROS_32BIT_ENTRY_ADDR + now;
if (offset > blob_size) {
error("cmdline is outside of the memory blob: %x\n", offset);
return NULL;
@@ -116,43 +104,10 @@ static void* MapFile(const char *filename, size_t *size) {
int main(int argc, char* argv[]) {
uint8_t* blob;
size_t blob_size;
- char* infile = NULL;
+ char* infile = argv[1];
uint8_t *config = NULL;
- uint64_t kernel_body_load_address = CROS_32BIT_ENTRY_ADDR;
- int parse_error = 0;
- char *e;
- int i;
-
- while (((i = getopt_long(argc, argv, ":", long_opts, NULL)) != -1) &&
- !parse_error) {
- switch (i) {
- default:
- case '?':
- /* Unhandled option */
- parse_error = 1;
- break;
-
- case 0:
- /* silently handled option */
- break;
-
- case OPT_KLOADADDR:
- kernel_body_load_address = strtoul(optarg, &e, 0);
- if (!*optarg || (e && *e)) {
- fprintf(stderr, "Invalid --kloadaddr\n");
- parse_error = 1;
- }
- break;
- }
- }
-
- if (optind >= argc) {
- fprintf(stderr, "Expected argument after options\n");
- parse_error = 1;
- } else
- infile = argv[optind];
- if (parse_error)
+ if (argc < 2)
return PrintHelp();
if (!infile || !*infile) {
@@ -167,8 +122,7 @@ int main(int argc, char* argv[]) {
return 1;
}
- config = find_kernel_config(blob, (uint64_t)blob_size,
- kernel_body_load_address);
+ config = find_kernel_config(blob, (uint64_t)blob_size);
if (!config) {
error("Error parsing input file\n");
munmap(blob, blob_size);
diff --git a/utility/vbutil_kernel.c b/utility/vbutil_kernel.c
index 85f8a514..a8986db5 100644
--- a/utility/vbutil_kernel.c
+++ b/utility/vbutil_kernel.c
@@ -35,7 +35,6 @@ enum {
OPT_MODE_VERIFY,
OPT_ARCH,
OPT_OLDBLOB,
- OPT_KLOADADDR,
OPT_KEYBLOCK,
OPT_SIGNPUBKEY,
OPT_SIGNPRIVATE,
@@ -59,7 +58,6 @@ static struct option long_opts[] = {
{"verify", 1, 0, OPT_MODE_VERIFY },
{"arch", 1, 0, OPT_ARCH },
{"oldblob", 1, 0, OPT_OLDBLOB },
- {"kloadaddr", 1, 0, OPT_KLOADADDR },
{"keyblock", 1, 0, OPT_KEYBLOCK },
{"signpubkey", 1, 0, OPT_SIGNPUBKEY },
{"signprivate", 1, 0, OPT_SIGNPRIVATE },
@@ -94,7 +92,6 @@ static int PrintHelp(char *progname) {
" --arch <arch> Cpu architecture (default x86)\n"
"\n"
" Optional:\n"
- " --kloadaddr <address> Assign kernel body load address\n"
" --pad <number> Verification padding size in bytes\n"
" --vblockonly Emit just the verification blob\n",
progname);
@@ -112,7 +109,6 @@ static int PrintHelp(char *progname) {
" --version <number> Kernel version\n"
"\n"
" Optional:\n"
- " --kloadaddr <address> Assign kernel body load address\n"
" --pad <number> Verification padding size in bytes\n"
" --vblockonly Emit just the verification blob\n",
progname);
@@ -125,8 +121,7 @@ static int PrintHelp(char *progname) {
" Public key to verify kernel keyblock, in .vbpubk format\n"
" --verbose Print a more detailed report\n"
" --keyblock <file>"
- " Outputs the verified key block, in .keyblock format\n"
- " --kloadaddr <address> Assign kernel body load address\n"
+ " Outputs the verified key block, in .keyblock format\n"
"\n",
progname);
return 1;
@@ -204,9 +199,9 @@ typedef struct blob_s {
} blob_t;
/* Given a blob return the location of the kernel command line buffer. */
-static char* BpCmdLineLocation(blob_t *bp, uint64_t kernel_body_load_address)
+static char* BpCmdLineLocation(blob_t *bp)
{
- return (char*)(bp->blob + bp->bootloader_address - kernel_body_load_address -
+ return (char*)(bp->blob + bp->bootloader_address - CROS_32BIT_ENTRY_ADDR -
CROS_CONFIG_SIZE - CROS_PARAMS_SIZE);
}
@@ -254,8 +249,7 @@ static blob_t *NewBlob(uint64_t version,
const char* vmlinuz,
const char* bootloader_file,
const char* config_file,
- int arch,
- uint64_t kernel_body_load_address) {
+ int arch) {
blob_t* bp;
struct linux_kernel_header* lh = 0;
struct linux_kernel_params* params = 0;
@@ -346,7 +340,7 @@ static blob_t *NewBlob(uint64_t version,
Debug("config goes at blob+0x%" PRIx64 "\n", now);
/* Find the load address of the commandline. We'll need it later. */
- cmdline_addr = kernel_body_load_address + now +
+ cmdline_addr = CROS_32BIT_ENTRY_ADDR + now +
find_cmdline_start((char *)config_buf, config_size);
Debug(" cmdline_addr=0x%" PRIx64 "\n", cmdline_addr);
@@ -383,7 +377,7 @@ static blob_t *NewBlob(uint64_t version,
/* Finally, append the bootloader. Remember where it will load in
* memory, too. */
Debug("bootloader goes at blob+=0x%" PRIx64 "\n", now);
- bp->bootloader_address = kernel_body_load_address + now;
+ bp->bootloader_address = CROS_32BIT_ENTRY_ADDR + now;
bp->bootloader_size = roundup(bootloader_size, CROS_ALIGN);
Debug(" bootloader_address=0x%" PRIx64 "\n", bp->bootloader_address);
Debug(" bootloader_size=0x%" PRIx64 "\n", bp->bootloader_size);
@@ -531,8 +525,7 @@ unwind_oldblob:
/* Pack a .kernel */
static int Pack(const char* outfile, const char* keyblock_file,
const char* signprivate, blob_t *bp, uint64_t pad,
- int vblockonly,
- uint64_t kernel_body_load_address) {
+ int vblockonly) {
VbPrivateKey* signing_key;
VbSignature* body_sig;
VbKernelPreambleHeader* preamble;
@@ -586,7 +579,7 @@ static int Pack(const char* outfile, const char* keyblock_file,
/* Create preamble */
preamble = CreateKernelPreamble(bp->kernel_version,
- kernel_body_load_address,
+ CROS_32BIT_ENTRY_ADDR,
bp->bootloader_address,
bp->bootloader_size,
body_sig,
@@ -635,8 +628,7 @@ static int Pack(const char* outfile, const char* keyblock_file,
/*
* Replace kernel command line in a blob representing a kernel.
*/
-static int ReplaceConfig(blob_t* bp, const char* config_file,
- uint64_t kernel_body_load_address)
+static int ReplaceConfig(blob_t* bp, const char* config_file)
{
uint8_t* new_conf;
uint64_t config_size;
@@ -651,16 +643,14 @@ static int ReplaceConfig(blob_t* bp, const char* config_file,
}
/* fill the config buffer with zeros */
- Memset(BpCmdLineLocation(bp, kernel_body_load_address), 0, CROS_CONFIG_SIZE);
- Memcpy(BpCmdLineLocation(bp, kernel_body_load_address),
- new_conf, config_size);
+ Memset(BpCmdLineLocation(bp), 0, CROS_CONFIG_SIZE);
+ Memcpy(BpCmdLineLocation(bp), new_conf, config_size);
Free(new_conf);
return 0;
}
static int Verify(const char* infile, const char* signpubkey, int verbose,
- const char* key_block_file,
- uint64_t kernel_body_load_address) {
+ const char* key_block_file) {
VbKeyBlockHeader* key_block;
VbKernelPreambleHeader* preamble;
@@ -779,7 +769,7 @@ static int Verify(const char* infile, const char* signpubkey, int verbose,
goto verify_exit;
}
- printf("Config:\n%s\n", BpCmdLineLocation(bp, kernel_body_load_address));
+ printf("Config:\n%s\n", BpCmdLineLocation(bp));
verify_exit:
FreeBlob(bp);
@@ -800,7 +790,6 @@ int main(int argc, char* argv[]) {
int arch = ARCH_X86;
int vblockonly = 0;
int verbose = 0;
- uint64_t kernel_body_load_address = CROS_32BIT_ENTRY_ADDR;
uint64_t pad = DEFAULT_PADDING;
int mode = 0;
int parse_error = 0;
@@ -855,14 +844,6 @@ int main(int argc, char* argv[]) {
oldfile = optarg;
break;
- case OPT_KLOADADDR:
- kernel_body_load_address = strtoul(optarg, &e, 0);
- if (!*optarg || (e && *e)) {
- fprintf(stderr, "Invalid --kloadaddr\n");
- parse_error = 1;
- }
- break;
-
case OPT_KEYBLOCK:
key_block_file = optarg;
break;
@@ -918,12 +899,10 @@ int main(int argc, char* argv[]) {
switch(mode) {
case OPT_MODE_PACK:
- bp = NewBlob(version, vmlinuz, bootloader, config_file, arch,
- kernel_body_load_address);
+ bp = NewBlob(version, vmlinuz, bootloader, config_file, arch);
if (!bp)
return 1;
- r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly,
- kernel_body_load_address);
+ r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly);
FreeBlob(bp);
return r;
@@ -938,20 +917,18 @@ int main(int argc, char* argv[]) {
bp = OldBlob(oldfile);
if (!bp)
return 1;
- r = ReplaceConfig(bp, config_file, kernel_body_load_address);
+ r = ReplaceConfig(bp, config_file);
if (!r) {
if (version >= 0) {
bp->kernel_version = (uint64_t) version;
}
- r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly,
- kernel_body_load_address);
+ r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly);
}
FreeBlob(bp);
return r;
case OPT_MODE_VERIFY:
- return Verify(filename, signpubkey, verbose, key_block_file,
- kernel_body_load_address);
+ return Verify(filename, signpubkey, verbose, key_block_file);
default:
fprintf(stderr,