mail.coreboot.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

coreboot-gerrit

Thread Start a new thread
Download
Threads by month
  • ----- 2025 -----
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2015 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2014 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2013 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
coreboot-gerrit@coreboot.org

August 2015

  • 1 participants
  • 814 discussions
Patch set updated for coreboot: drivers/intel/fsp1_1: Do no run microcode updates via FSP
by Alexandru Gagniuc Sept. 1, 2015

Sept. 1, 2015
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11463 -gerrit commit cc7a12a0eae9ffd7f144576da494fb00bc5c3938 Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com> Date: Sat Aug 29 14:34:25 2015 -0700 drivers/intel/fsp1_1: Do no run microcode updates via FSP Our bootblock already upgrades the CPU microcode before any call to FSP. As a result, the FSP microcode update will be a no-op. Since we have to pass the microcode location to FSP via a stack, before CAR, this stack exists in flash, and needs the location hardcoded. If we remove this limitation, then we no longer need to hardcode the location of the microcode, and can use the standard rules for adding microcode. Note that this is only true for the BSP. APs take a different path. TEST=Build cyan and observe BSP come up with updated microcode (rev > 0), and observed APs are also succesfully updated, Then booted Fedora 22 with linux-4.2-rc8 and SeaBIOS payload. Change-Id: I47d11061a1cfb741a633102225b63715d1bfd382 Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com> --- src/drivers/intel/fsp1_1/Kconfig | 13 ------------- src/drivers/intel/fsp1_1/cache_as_ram.inc | 18 +++++++++++++++--- src/soc/intel/braswell/microcode/Makefile.inc | 11 ----------- src/soc/intel/skylake/microcode/Makefile.inc | 11 ----------- 4 files changed, 15 insertions(+), 38 deletions(-) diff --git a/src/drivers/intel/fsp1_1/Kconfig b/src/drivers/intel/fsp1_1/Kconfig index 2ffa323..cdf767d 100644 --- a/src/drivers/intel/fsp1_1/Kconfig +++ b/src/drivers/intel/fsp1_1/Kconfig @@ -45,19 +45,6 @@ config HAVE_FSP_BIN if HAVE_FSP_BIN -config CPU_MICROCODE_CBFS_LEN - hex "Microcode update region length in bytes" - default 0 - help - The length in bytes of the microcode update region. - -config CPU_MICROCODE_CBFS_LOC - hex "Microcode update base address in CBFS" - default 0 - help - The location (base address) in CBFS that contains the microcode update - binary. - config FSP_FILE string "Intel FSP binary path and filename" help diff --git a/src/drivers/intel/fsp1_1/cache_as_ram.inc b/src/drivers/intel/fsp1_1/cache_as_ram.inc index 6af30ce..3ef8cb7 100644 --- a/src/drivers/intel/fsp1_1/cache_as_ram.inc +++ b/src/drivers/intel/fsp1_1/cache_as_ram.inc @@ -33,6 +33,8 @@ #include <cpu/x86/post_code.h> #include <cbmem.h> +#define FSP_SUCCESS 0 +#define FSP_INVALID_PARAMETER 2 #define LHLT_DELAY 0x50000 /* I/O delay between post codes on failure */ /* @@ -109,9 +111,19 @@ CAR_init_done: * mm1: high 32-bits of TSC value */ - cmp $0, %eax + cmp $FSP_SUCCESS, %eax + je fsp_temp_ram_init_ok + + /* + * It's OK if we get FSP_INVALID_PARAMETER. In most cases, that means + * that a microcode update was not found (because we never passed one + * to FSP in the first place). However CAR setup is still done. + */ + cmp $FSP_INVALID_PARAMETER, %al jne halt2 +fsp_temp_ram_init_ok: + /* Setup bootloader stack */ movl %edx, %esp @@ -344,8 +356,8 @@ fake_fsp_stack: .long find_fsp_ret CAR_init_params: - .long CONFIG_CPU_MICROCODE_CBFS_LOC /* Microcode Location */ - .long CONFIG_CPU_MICROCODE_CBFS_LEN /* Microcode Length */ + .long 0 /* Microcode Location */ + .long 0 /* Microcode Length */ .long 0xFFFFFFFF - CONFIG_CBFS_SIZE + 1 /* Firmware Location */ .long CONFIG_CBFS_SIZE /* Total Firmware Length */ diff --git a/src/soc/intel/braswell/microcode/Makefile.inc b/src/soc/intel/braswell/microcode/Makefile.inc index da25b8b..3497328 100644 --- a/src/soc/intel/braswell/microcode/Makefile.inc +++ b/src/soc/intel/braswell/microcode/Makefile.inc @@ -1,13 +1,2 @@ # Add CPU uCode source to list of files to build. cpu_microcode-y += microcode_blob.c - -# This section overrides the default build process for the microcode to place -# it at a known location in the CBFS. This only needs to be enabled if FSP is -# being used. -# Define the correct offset for the file in CBFS -fsp_ucode_cbfs_base = $(CONFIG_CPU_MICROCODE_CBFS_LOC) - -# Override the location that was supplied by the core code. -add-cpu-microcode-to-cbfs = \ - $(CBFSTOOL) $(1) add -n $(cpu_ucode_cbfs_name) -f $(cpu_ucode_cbfs_file) -t microcode -b $(fsp_ucode_cbfs_base) - diff --git a/src/soc/intel/skylake/microcode/Makefile.inc b/src/soc/intel/skylake/microcode/Makefile.inc index a5e8981..ba308f6 100644 --- a/src/soc/intel/skylake/microcode/Makefile.inc +++ b/src/soc/intel/skylake/microcode/Makefile.inc @@ -1,13 +1,2 @@ # Add CPU uCode source to list of files to build. cpu_microcode-$(CONFIG_CPU_MICROCODE_CBFS_GENERATE) += microcode_blob.c - -# This section overrides the default build process for the microcode to place -# it at a known location in the CBFS. This only needs to be enabled if FSP is -# being used. -# Define the correct offset for the file in CBFS -fsp_ucode_cbfs_base = $(CONFIG_CPU_MICROCODE_CBFS_LOC) - -# Override the location that was supplied by the core code. -add-cpu-microcode-to-cbfs = \ - $(CBFSTOOL) $(1) add -n $(cpu_ucode_cbfs_name) -f $(cpu_ucode_cbfs_file) -t microcode -b $(fsp_ucode_cbfs_base) -
1 0
0 0
Patch set updated for coreboot: cbfstool: implement decompression support for cbfstool extract
by Patrick Georgi Sept. 1, 2015

Sept. 1, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11363 -gerrit commit cffd041d28d01744eb3ce63b061a5703ef93f421 Author: Patrick Georgi <patrick(a)georgi-clan.de> Date: Wed Aug 26 13:01:10 2015 +0200 cbfstool: implement decompression support for cbfstool extract Change-Id: I5142b03d3c3e028eeb179f225848f762186f94a8 Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de> --- util/cbfstool/cbfs_image.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 876e4da..f1bda74 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -661,9 +661,20 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, ERROR("File not found: %s\n", entry_name); return -1; } + + unsigned int decompressed_size = 0; + unsigned int compression = cbfs_file_get_compression_info(entry, + &decompressed_size); + + decomp_func_ptr decompress = decompression_function(compression); + if (!decompress) { + ERROR("looking up decompression routine failed\n"); + return -1; + } + LOG("Found file %.30s at 0x%x, type %.12s, size %d\n", entry_name, cbfs_get_entry_addr(image, entry), - get_cbfs_entry_type_name(ntohl(entry->type)), ntohl(entry->len)); + get_cbfs_entry_type_name(ntohl(entry->type)), decompressed_size); if (ntohl(entry->type) == CBFS_COMPONENT_STAGE) { WARN("Stages are extracted in SELF format.\n"); @@ -673,8 +684,13 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, WARN("Payloads are extracted in SELF format.\n"); } - buffer.data = CBFS_SUBHEADER(entry); - buffer.size = ntohl(entry->len); + buffer.data = malloc(decompressed_size); + buffer.size = decompressed_size; + if (decompress(CBFS_SUBHEADER(entry), ntohl(entry->len), + buffer.data, buffer.size)) { + ERROR("decompression failed for %s\n", entry_name); + return -1; + } buffer.name = strdup("(cbfs_export_entry)"); if (buffer_write_file(&buffer, filename) != 0) { ERROR("Failed to write %s into %s.\n", @@ -682,6 +698,7 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, free(buffer.name); return -1; } + free(buffer.data); free(buffer.name); INFO("Successfully dumped the file to: %s\n", filename); return 0;
1 0
0 0
Patch set updated for coreboot: cbfstool: add decompression wrappers
by Patrick Georgi Sept. 1, 2015

Sept. 1, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11362 -gerrit commit 5a623150537b8ad34c0151a6c6678e220463d885 Author: Patrick Georgi <patrick(a)georgi-clan.de> Date: Wed Aug 26 12:53:41 2015 +0200 cbfstool: add decompression wrappers ... and document the interface. Change-Id: I86a071a61fd6c1ef842f8ffe51f12f0cefdaf2fe Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de> --- util/cbfstool/common.h | 16 +++++++++++++++- util/cbfstool/compress.c | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h index 5fb1906..4a97fed 100644 --- a/util/cbfstool/common.h +++ b/util/cbfstool/common.h @@ -146,10 +146,24 @@ void buffer_delete(struct buffer *buffer); const char *arch_to_string(uint32_t a); uint32_t string_to_arch(const char *arch_string); -typedef int (*comp_func_ptr) (char *, int, char *, int *); +/* Compress in_len bytes from in, storing the result at out, returning the + * resulting length in out_len. + * Returns 0 on error, + * != 0 otherwise, depending on the compressing function. + */ +typedef int (*comp_func_ptr) (char *in, int in_len, char *out, int *out_len); + +/* Decompress in_len bytes from in, storing the result at out, up to out_len + * bytes. + * Returns 0 on error, + * != 0 otherwise, depending on the decompressing function. + */ +typedef int (*decomp_func_ptr) (char *in, int in_len, char *out, int out_len); + enum comp_algo { CBFS_COMPRESS_NONE = 0, CBFS_COMPRESS_LZMA = 1 }; comp_func_ptr compression_function(enum comp_algo algo); +decomp_func_ptr decompression_function(enum comp_algo algo); uint64_t intfiletype(const char *name); diff --git a/util/cbfstool/compress.c b/util/cbfstool/compress.c index ab94b35..2bde7df 100644 --- a/util/cbfstool/compress.c +++ b/util/cbfstool/compress.c @@ -31,6 +31,10 @@ static int lzma_compress(char *in, int in_len, char *out, int *out_len) return do_lzma_compress(in, in_len, out, out_len); } +static int lzma_decompress(char *in, int in_len, char *out, unused int out_len) +{ + return do_lzma_uncompress(out, out_len, in, in_len); +} static int none_compress(char *in, int in_len, char *out, int *out_len) { memcpy(out, in, in_len); @@ -38,6 +42,12 @@ static int none_compress(char *in, int in_len, char *out, int *out_len) return 0; } +static int none_decompress(char *in, int in_len, char *out, unused int out_len) +{ + memcpy(out, in, in_len); + return 0; +} + comp_func_ptr compression_function(enum comp_algo algo) { comp_func_ptr compress; @@ -54,3 +64,20 @@ comp_func_ptr compression_function(enum comp_algo algo) } return compress; } + +decomp_func_ptr decompression_function(enum comp_algo algo) +{ + decomp_func_ptr decompress; + switch (algo) { + case CBFS_COMPRESS_NONE: + decompress = none_decompress; + break; + case CBFS_COMPRESS_LZMA: + decompress = lzma_decompress; + break; + default: + ERROR("Unknown compression algorithm %d!\n", algo); + return NULL; + } + return decompress; +}
1 0
0 0
Patch set updated for coreboot: cbfstool: factor out parsing compression file attributes
by Patrick Georgi Sept. 1, 2015

Sept. 1, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11361 -gerrit commit b5a5dd05bb3011ad268229193cf5c6a3d04ad123 Author: Patrick Georgi <patrick(a)georgi-clan.de> Date: Wed Aug 26 12:23:26 2015 +0200 cbfstool: factor out parsing compression file attributes cbfstool extract also needs it. Change-Id: I8302bb18c5f797eb0a43ec4e4269790f3d49a896 Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de> --- util/cbfstool/cbfs_image.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index e64be9e..876e4da 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -178,6 +178,26 @@ static void cbfs_decode_payload_segment(struct cbfs_payload_segment *output, assert(seg.size == 0); } +static int cbfs_file_get_compression_info(struct cbfs_file *entry, + uint32_t *decompressed_size) +{ + unsigned int compression = CBFS_COMPRESS_NONE; + *decompressed_size = ntohl(entry->len); + for (struct cbfs_file_attribute *attr = cbfs_file_first_attr(entry); + attr != NULL; + attr = cbfs_file_next_attr(entry, attr)) { + if (ntohl(attr->tag) == CBFS_FILE_ATTR_TAG_COMPRESSION) { + struct cbfs_file_attr_compression *ac = + (struct cbfs_file_attr_compression *)attr; + compression = ntohl(ac->compression); + if (decompressed_size) + *decompressed_size = + ntohl(ac->decompressed_size); + } + } + return compression; +} + void cbfs_get_header(struct cbfs_header *header, void *src) { struct buffer outheader; @@ -777,18 +797,9 @@ int cbfs_print_entry_info(struct cbfs_image *image, struct cbfs_file *entry, if (!fp) fp = stdout; - unsigned int compression = CBFS_COMPRESS_NONE; unsigned int decompressed_size = 0; - for (struct cbfs_file_attribute *attr = cbfs_file_first_attr(entry); - attr != NULL; - attr = cbfs_file_next_attr(entry, attr)) { - if (ntohl(attr->tag) == CBFS_FILE_ATTR_TAG_COMPRESSION) { - struct cbfs_file_attr_compression *ac = - (struct cbfs_file_attr_compression *)attr; - compression = ntohl(ac->compression); - decompressed_size = ntohl(ac->decompressed_size); - } - } + unsigned int compression = cbfs_file_get_compression_info(entry, + &decompressed_size); if (compression == CBFS_COMPRESS_NONE) { fprintf(fp, "%-30s 0x%-8x %-12s %d\n",
1 0
0 0
Patch set updated for coreboot: cbfstool: allow compression at file header level
by Patrick Georgi Sept. 1, 2015

Sept. 1, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10935 -gerrit commit b6f6f715d8403d6fe69a5889a9ed1d8751fcfbd2 Author: Daisuke Nojiri <dnojiri(a)chromium.org> Date: Thu Jul 9 15:07:45 2015 -0700 cbfstool: allow compression at file header level Currently, compression is only allowed at subheader level (e.g. cbfs_stage, cbfs_payload_segment). This change adds compression field to each file's header so that any cbfs file can be compressed. With the necessary additions in coreboot and libpayload, the following sample code can load a compressed file: const char *name = "foo.bmp"; struct cbfs_file *file = cbfs_get_file(media, name); void *dst = malloc(ntohl(file->uncompressed_size)); dst = cbfs_get_file_content(media, name, type, file, dst); cbfs_stage and cbfs_payload_segment continue to support compression at subheader level because stages and payloads have to be decompressed to the load address, which is stored in the subheader. For these, file level compression should be turned off. Change-Id: I9a00ec99dfc68ffb2771bb4a3cc5ba6ba8a326f4 Signed-off-by: Daisuke Nojiri <dnojiri(a)chromium.org> Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org> --- util/cbfstool/cbfs.h | 9 +++++++++ util/cbfstool/cbfstool.c | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h index 185bdde..44e3dcd 100644 --- a/util/cbfstool/cbfs.h +++ b/util/cbfstool/cbfs.h @@ -104,6 +104,15 @@ struct cbfs_file_attribute { * 0xff. Support both. */ #define CBFS_FILE_ATTR_TAG_UNUSED 0 #define CBFS_FILE_ATTR_TAG_UNUSED2 0xffffffff +#define CBFS_FILE_ATTR_TAG_COMPRESSION 0x42435a4c + +struct cbfs_file_attr_compression { + uint32_t tag; + uint32_t len; + /* whole file compression format. 0 if no compression. */ + uint32_t compression; + uint32_t decompressed_size; +} __PACKED; struct cbfs_stage { uint32_t compression; diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 059acbf..679abf8 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -230,6 +230,38 @@ static int cbfs_add_component(const char *filename, return 0; } +static int cbfstool_convert_raw(struct buffer *buffer, + unused uint32_t *offset, struct cbfs_file *header) +{ + char *compressed; + int compressed_size; + + comp_func_ptr compress = compression_function(param.compression); + if (!compress) + return -1; + compressed = calloc(buffer->size, 1); + + if (compress(buffer->data, buffer->size, + compressed, &compressed_size)) { + WARN("Compression failed - disabled\n"); + } else { + struct cbfs_file_attr_compression *attrs = + (struct cbfs_file_attr_compression *) + cbfs_add_file_attr(header, + CBFS_FILE_ATTR_TAG_COMPRESSION, + sizeof(struct cbfs_file_attr_compression)); + if (attrs == NULL) + return -1; + free(buffer->data); + buffer->data = compressed; + attrs->compression = htonl(param.compression); + attrs->decompressed_size = htonl(buffer->size); + buffer->size = compressed_size; + header->len = htonl(buffer->size); + } + return 0; +} + static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset, struct cbfs_file *header) { @@ -301,7 +333,7 @@ static int cbfs_add(void) param.type, param.baseaddress, param.headeroffset, - NULL); + cbfstool_convert_raw); } static int cbfs_add_stage(void) @@ -747,7 +779,7 @@ static bool cbfs_is_legacy_format(struct buffer *buffer) } static const struct command commands[] = { - {"add", "H:r:f:n:t:b:vh?", cbfs_add, true, true}, + {"add", "H:r:f:n:t:c:b:vh?", cbfs_add, true, true}, {"add-flat-binary", "H:r:f:n:l:e:c:b:vh?", cbfs_add_flat_binary, true, true}, {"add-payload", "H:r:f:n:t:c:b:C:I:vh?", cbfs_add_payload, true, true}, @@ -862,7 +894,7 @@ static void usage(char *name) " -h Display this help message\n\n" "COMMANDs:\n" " add [-r image,regions] -f FILE -n NAME -t TYPE \\\n" - " [-b base-address] " + " [-c compression] [-b base-address] " "Add a component\n" " add-payload [-r image,regions] -f FILE -n NAME \\\n" " [-c compression] [-b base-address] "
1 0
0 0
Patch set updated for coreboot: cbfstool: add extended file attributes for cbfs_file
by Patrick Georgi Sept. 1, 2015

Sept. 1, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10934 -gerrit commit 464478eed1a946734ccf7d2307d8729881d39325 Author: Patrick Georgi <pgeorgi(a)chromium.org> Date: Wed Jul 15 20:49:00 2015 +0200 cbfstool: add extended file attributes for cbfs_file cbfs_file_first_attr(struct cbfs_file *) and cbfs_file_next_attr(struct cbfs_file *, struct cbfs_file_attribute *) help navigate through extended attributes. cbfs_add_file_attr(header, tag, size) adds a new file attribute to header. Change-Id: I325965286c44f31abd95df684d340cebb0e68b75 Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org> --- util/cbfstool/cbfs.h | 11 ++++++ util/cbfstool/cbfs_image.c | 85 +++++++++++++++++++++++++++++++++++++++++++--- util/cbfstool/cbfs_image.h | 14 ++++++++ 3 files changed, 105 insertions(+), 5 deletions(-) diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h index 3f80a04..185bdde 100644 --- a/util/cbfstool/cbfs.h +++ b/util/cbfstool/cbfs.h @@ -21,6 +21,10 @@ #include <stdint.h> +/* cbfstool will fail when trying to build a cbfs_file header that's larger + * than MAX_CBFS_FILE_HEADER_BUFFER. 1K should give plenty of room. */ +#define MAX_CBFS_FILE_HEADER_BUFFER 1024 + /* create a magic number in host-byte order. * b3 is the high order byte. * in the coreboot tools, we go with the 32-bit @@ -77,6 +81,7 @@ struct cbfs_file { /* length of file data */ uint32_t len; uint32_t type; + /* offset to struct cbfs_file_attribute or 0 */ uint32_t attributes_offset; /* length of header incl. variable data */ uint32_t offset; @@ -95,6 +100,11 @@ struct cbfs_file_attribute { uint8_t data[0]; } __PACKED; +/* Depending on how the header was initialized, it may be backed with 0x00 or + * 0xff. Support both. */ +#define CBFS_FILE_ATTR_TAG_UNUSED 0 +#define CBFS_FILE_ATTR_TAG_UNUSED2 0xffffffff + struct cbfs_stage { uint32_t compression; uint64_t entry; @@ -155,6 +165,7 @@ struct cbfs_payload { #define CBFS_COMPONENT_NULL 0xFFFFFFFF #define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) ) + /* cbfs_image.c */ uint32_t get_cbfs_entry_type(const char *name, uint32_t default_value); uint32_t get_cbfs_compression(const char *name, uint32_t unknown); diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index e71d598..49ff2cd 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -997,11 +997,8 @@ int cbfs_is_valid_entry(struct cbfs_image *image, struct cbfs_file *entry) struct cbfs_file *cbfs_create_file_header(int type, size_t len, const char *name) { - // assume that there won't be file names of ~1000 bytes - const int bufsize = 1024; - - struct cbfs_file *entry = malloc(bufsize); - memset(entry, CBFS_CONTENT_DEFAULT_VALUE, bufsize); + struct cbfs_file *entry = malloc(MAX_CBFS_FILE_HEADER_BUFFER); + memset(entry, CBFS_CONTENT_DEFAULT_VALUE, MAX_CBFS_FILE_HEADER_BUFFER); memcpy(entry->magic, CBFS_FILE_MAGIC, sizeof(entry->magic)); entry->type = htonl(type); entry->len = htonl(len); @@ -1022,6 +1019,84 @@ int cbfs_create_empty_entry(struct cbfs_file *entry, int type, return 0; } +struct cbfs_file_attribute *cbfs_file_first_attr(struct cbfs_file *file) +{ + /* attributes_offset should be 0 when there is no attribute, but all + * values that point into the cbfs_file header are invalid, too. */ + if (ntohl(file->attributes_offset) <= sizeof(*file)) + return NULL; + + /* There needs to be enough space for the file header and one + * attribute header for this to make sense. */ + if (ntohl(file->offset) <= + sizeof(*file) + sizeof(struct cbfs_file_attribute)) + return NULL; + + return (struct cbfs_file_attribute *) + (((uint8_t *)file) + ntohl(file->attributes_offset)); +} + +struct cbfs_file_attribute *cbfs_file_next_attr(struct cbfs_file *file, + struct cbfs_file_attribute *attr) +{ + /* ex falso sequitur quodlibet */ + if (attr == NULL) + return NULL; + + /* Is there enough space for another attribute? */ + if ((uint8_t *)attr + ntohl(attr->len) + + sizeof(struct cbfs_file_attribute) >= + (uint8_t *)file + ntohl(file->offset)) + return NULL; + + struct cbfs_file_attribute *next = (struct cbfs_file_attribute *) + (((uint8_t *)attr) + ntohl(attr->len)); + /* If any, "unused" attributes must come last. */ + if (ntohl(next->tag) == CBFS_FILE_ATTR_TAG_UNUSED) + return NULL; + if (ntohl(next->tag) == CBFS_FILE_ATTR_TAG_UNUSED2) + return NULL; + + return next; +} + +struct cbfs_file_attribute *cbfs_add_file_attr(struct cbfs_file *header, + uint32_t tag, + uint32_t size) +{ + struct cbfs_file_attribute *attr, *next; + next = cbfs_file_first_attr(header); + do { + attr = next; + next = cbfs_file_next_attr(header, attr); + } while (next != NULL); + uint32_t header_size = ntohl(header->offset) + size; + if (header_size > MAX_CBFS_FILE_HEADER_BUFFER) { + DEBUG("exceeding allocated space for cbfs_file headers"); + return NULL; + } + /* attr points to the last valid attribute now. + * If NULL, we have to create the first one. */ + if (attr == NULL) { + /* New attributes start where the header ends. + * header->offset is later set to accomodate the + * additional structure. */ + header->attributes_offset = header->offset; + attr = (struct cbfs_file_attribute *) + (((uint8_t *)header) + + ntohl(header->attributes_offset)); + } else { + attr = (struct cbfs_file_attribute *) + (((uint8_t *)attr) + + ntohl(attr->len)); + } + header->offset = htonl(header_size); + memset(attr, CBFS_CONTENT_DEFAULT_VALUE, size); + attr->tag = htonl(tag); + attr->len = htonl(size); + return attr; +} + /* Finds a place to hold whole data in same memory page. */ static int is_in_same_page(uint32_t start, uint32_t size, uint32_t page) { diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h index 7a9b484..aea8260 100644 --- a/util/cbfstool/cbfs_image.h +++ b/util/cbfstool/cbfs_image.h @@ -170,4 +170,18 @@ int cbfs_merge_empty_entry(struct cbfs_image *image, struct cbfs_file *entry, /* Returns the size of a cbfs file header with no extensions */ size_t cbfs_calculate_file_header_size(const char *name); + +/* Given a cbfs_file, return the first file attribute, or NULL. */ +struct cbfs_file_attribute *cbfs_file_first_attr(struct cbfs_file *file); + +/* Given a cbfs_file and a cbfs_file_attribute, return the attribute that + * follows it, or NULL. */ +struct cbfs_file_attribute *cbfs_file_next_attr(struct cbfs_file *file, + struct cbfs_file_attribute *attr); + +/* Adds to header a new extended attribute tagged 'tag', sized 'size'. + * Returns pointer to the new attribute, or NULL on error. */ +struct cbfs_file_attribute *cbfs_add_file_attr(struct cbfs_file *header, + uint32_t tag, + uint32_t size); #endif
1 0
0 0
Patch set updated for coreboot: cbfstool: support compressed files in cbfstool print
by Patrick Georgi Sept. 1, 2015

Sept. 1, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11359 -gerrit commit 59167ce809e5480d4e80c2038caac2e445ceb953 Author: Patrick Georgi <patrick(a)georgi-clan.de> Date: Wed Aug 26 12:13:03 2015 +0200 cbfstool: support compressed files in cbfstool print Display compressed and decompressed sizes, as well as the compression algorithm used, when a compressed file is encountered. Change-Id: I13c2332702c4a5bec379e1ebda72753e06f8e135 Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de> --- util/cbfstool/cbfs_image.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 49ff2cd..e64be9e 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -777,11 +777,36 @@ int cbfs_print_entry_info(struct cbfs_image *image, struct cbfs_file *entry, if (!fp) fp = stdout; - fprintf(fp, "%-30s 0x%-8x %-12s %d\n", - *name ? name : "(empty)", - cbfs_get_entry_addr(image, entry), - get_cbfs_entry_type_name(ntohl(entry->type)), - ntohl(entry->len)); + unsigned int compression = CBFS_COMPRESS_NONE; + unsigned int decompressed_size = 0; + for (struct cbfs_file_attribute *attr = cbfs_file_first_attr(entry); + attr != NULL; + attr = cbfs_file_next_attr(entry, attr)) { + if (ntohl(attr->tag) == CBFS_FILE_ATTR_TAG_COMPRESSION) { + struct cbfs_file_attr_compression *ac = + (struct cbfs_file_attr_compression *)attr; + compression = ntohl(ac->compression); + decompressed_size = ntohl(ac->decompressed_size); + } + } + + if (compression == CBFS_COMPRESS_NONE) { + fprintf(fp, "%-30s 0x%-8x %-12s %d\n", + *name ? name : "(empty)", + cbfs_get_entry_addr(image, entry), + get_cbfs_entry_type_name(ntohl(entry->type)), + ntohl(entry->len)); + } else { + fprintf(fp, "%-30s 0x%-8x %-12s %d (%d after %s decompression)\n", + *name ? name : "(empty)", + cbfs_get_entry_addr(image, entry), + get_cbfs_entry_type_name(ntohl(entry->type)), + ntohl(entry->len), + decompressed_size, + lookup_name_by_type(types_cbfs_compression, + compression, "(unknown)") + ); + } if (!verbose) return 0;
1 0
0 0
Patch merged into coreboot/master: northbridge/intel/gm45/Kconfig: Remove IOMMU symbol choice
by gerrit@coreboot.org Sept. 1, 2015

Sept. 1, 2015
the following patch was just integrated into master: commit 4a666423c6d71614b7c2b539afa33d823c1896d5 Author: Martin Roth <martinroth(a)google.com> Date: Tue Aug 25 17:04:59 2015 -0600 northbridge/intel/gm45/Kconfig: Remove IOMMU symbol choice In the gm45 code, IOMMU is always selected to be enabled. Instead this patch removes the Kconfig symbol and its dependencies. This leads to the same effect without the need for the symbol. The symbol is still used in the K8 code as it's not selected, simply defaulted to being enabled, and one of the mainboards disables it. Change-Id: Ibc5939cd1e297d497bf71b1787d852f7cc09a551 Signed-off-by: Martin Roth <martinroth(a)google.com> Reviewed-on: http://review.coreboot.org/11345 Reviewed-by: Patrick Georgi <pgeorgi(a)google.com> Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber <nico.h(a)gmx.de> See http://review.coreboot.org/11345 for details. -gerrit
1 0
0 0
Patch set updated for coreboot: cbfstool: implement decompression support for cbfstool extract
by Patrick Georgi Aug. 31, 2015

Aug. 31, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11363 -gerrit commit 121930b47b4c070b8e711447d437b9445b3f1a02 Author: Patrick Georgi <patrick(a)georgi-clan.de> Date: Wed Aug 26 13:01:10 2015 +0200 cbfstool: implement decompression support for cbfstool extract Change-Id: I5142b03d3c3e028eeb179f225848f762186f94a8 Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de> --- util/cbfstool/cbfs_image.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 082fe06..ff06f5d 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -661,9 +661,20 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, ERROR("File not found: %s\n", entry_name); return -1; } + + unsigned int decompressed_size = 0; + unsigned int compression = cbfs_file_get_compression_info(entry, + &decompressed_size); + + decomp_func_ptr decompress = decompression_function(compression); + if (!decompress) { + ERROR("looking up decompression routine failed\n"); + return -1; + } + LOG("Found file %.30s at 0x%x, type %.12s, size %d\n", entry_name, cbfs_get_entry_addr(image, entry), - get_cbfs_entry_type_name(ntohl(entry->type)), ntohl(entry->len)); + get_cbfs_entry_type_name(ntohl(entry->type)), decompressed_size); if (ntohl(entry->type) == CBFS_COMPONENT_STAGE) { WARN("Stages are extracted in SELF format.\n"); @@ -673,8 +684,13 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, WARN("Payloads are extracted in SELF format.\n"); } - buffer.data = CBFS_SUBHEADER(entry); - buffer.size = ntohl(entry->len); + buffer.data = malloc(decompressed_size); + buffer.size = decompressed_size; + if (decompress(CBFS_SUBHEADER(entry), ntohl(entry->len), + buffer.data, buffer.size)) { + ERROR("decompression failed for %s\n", entry_name); + return -1; + } buffer.name = strdup("(cbfs_export_entry)"); if (buffer_write_file(&buffer, filename) != 0) { ERROR("Failed to write %s into %s.\n", @@ -682,6 +698,7 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name, free(buffer.name); return -1; } + free(buffer.data); free(buffer.name); INFO("Successfully dumped the file to: %s\n", filename); return 0;
1 0
0 0
Patch set updated for coreboot: cbfstool: add decompression wrappers
by Patrick Georgi Aug. 31, 2015

Aug. 31, 2015
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11362 -gerrit commit 24d810208857f3cc27a69c9986b5bd9f9775f328 Author: Patrick Georgi <patrick(a)georgi-clan.de> Date: Wed Aug 26 12:53:41 2015 +0200 cbfstool: add decompression wrappers ... and document the interface. Change-Id: I86a071a61fd6c1ef842f8ffe51f12f0cefdaf2fe Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de> --- util/cbfstool/common.h | 16 +++++++++++++++- util/cbfstool/compress.c | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h index 5fb1906..4a97fed 100644 --- a/util/cbfstool/common.h +++ b/util/cbfstool/common.h @@ -146,10 +146,24 @@ void buffer_delete(struct buffer *buffer); const char *arch_to_string(uint32_t a); uint32_t string_to_arch(const char *arch_string); -typedef int (*comp_func_ptr) (char *, int, char *, int *); +/* Compress in_len bytes from in, storing the result at out, returning the + * resulting length in out_len. + * Returns 0 on error, + * != 0 otherwise, depending on the compressing function. + */ +typedef int (*comp_func_ptr) (char *in, int in_len, char *out, int *out_len); + +/* Decompress in_len bytes from in, storing the result at out, up to out_len + * bytes. + * Returns 0 on error, + * != 0 otherwise, depending on the decompressing function. + */ +typedef int (*decomp_func_ptr) (char *in, int in_len, char *out, int out_len); + enum comp_algo { CBFS_COMPRESS_NONE = 0, CBFS_COMPRESS_LZMA = 1 }; comp_func_ptr compression_function(enum comp_algo algo); +decomp_func_ptr decompression_function(enum comp_algo algo); uint64_t intfiletype(const char *name); diff --git a/util/cbfstool/compress.c b/util/cbfstool/compress.c index ab94b35..2bde7df 100644 --- a/util/cbfstool/compress.c +++ b/util/cbfstool/compress.c @@ -31,6 +31,10 @@ static int lzma_compress(char *in, int in_len, char *out, int *out_len) return do_lzma_compress(in, in_len, out, out_len); } +static int lzma_decompress(char *in, int in_len, char *out, unused int out_len) +{ + return do_lzma_uncompress(out, out_len, in, in_len); +} static int none_compress(char *in, int in_len, char *out, int *out_len) { memcpy(out, in, in_len); @@ -38,6 +42,12 @@ static int none_compress(char *in, int in_len, char *out, int *out_len) return 0; } +static int none_decompress(char *in, int in_len, char *out, unused int out_len) +{ + memcpy(out, in, in_len); + return 0; +} + comp_func_ptr compression_function(enum comp_algo algo) { comp_func_ptr compress; @@ -54,3 +64,20 @@ comp_func_ptr compression_function(enum comp_algo algo) } return compress; } + +decomp_func_ptr decompression_function(enum comp_algo algo) +{ + decomp_func_ptr decompress; + switch (algo) { + case CBFS_COMPRESS_NONE: + decompress = none_decompress; + break; + case CBFS_COMPRESS_LZMA: + decompress = lzma_decompress; + break; + default: + ERROR("Unknown compression algorithm %d!\n", algo); + return NULL; + } + return decompress; +}
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • ...
  • 82
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.