mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: util/nvramtool: Bail out on unaligned multi-byte entries
coreboot doesn't support CMOS options that are not byte aligned but
span multiple bytes. So treat them as error.
BUG=none
BRANCH=none
TEST=none
Change-Id: I6612546b44a3d50158b674106fb62e3948561b3e
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Original-Commit-Id: 3af6985050
Original-Change-Id: I2bcff62f153932e9c6646b4ce08e8da1c1532947
Original-Signed-off-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-on: https://review.coreboot.org/18246
Original-Reviewed-by: Philippe Mathieu-Daud <philippe.mathieu.daude@gmail.com>
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://chromium-review.googlesource.com/528189
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
This commit is contained in:
parent
67f3144f01
commit
335ef242e1
4 changed files with 16 additions and 0 deletions
|
@ -481,6 +481,12 @@ static void try_add_cmos_table_entry(cmos_entry_t * cmos_entry)
|
|||
*/
|
||||
return;
|
||||
|
||||
case LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED:
|
||||
fprintf(stderr,
|
||||
"%s: Unaligned CMOS option table entry %s "
|
||||
"spans multiple bytes.\n", prog_name, cmos_entry->name);
|
||||
break;
|
||||
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
|
|
@ -695,6 +695,12 @@ static void try_add_layout_file_entry(const cmos_entry_t * cmos_entry)
|
|||
*/
|
||||
return;
|
||||
|
||||
case LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED:
|
||||
fprintf(stderr,
|
||||
"%s: Unaligned CMOS option table entry %s "
|
||||
"spans multiple bytes.\n", prog_name, cmos_entry->name);
|
||||
break;
|
||||
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
|
|
@ -169,6 +169,9 @@ int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict)
|
|||
if (e->length < 1)
|
||||
return LAYOUT_ENTRY_BAD_LENGTH;
|
||||
|
||||
if (e->bit % 8 && e->bit / 8 != (e->bit + e->length - 1) / 8)
|
||||
return LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED;
|
||||
|
||||
if ((new_entry =
|
||||
(cmos_entry_item_t *) malloc(sizeof(*new_entry))) == NULL)
|
||||
out_of_memory();
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define LAYOUT_CHECKSUM_OVERLAPS_SUMMED_AREA (LAYOUT_RESULT_START + 7)
|
||||
#define LAYOUT_SUMMED_AREA_OUT_OF_RANGE (LAYOUT_RESULT_START + 8)
|
||||
#define LAYOUT_CHECKSUM_LOCATION_OUT_OF_RANGE (LAYOUT_RESULT_START + 9)
|
||||
#define LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED (LAYOUT_RESULT_START + 10)
|
||||
|
||||
typedef enum {
|
||||
CMOS_ENTRY_ENUM = 'e',
|
||||
|
|
Loading…
Add table
Reference in a new issue