From 6be908426e95bf1608fcf861fec12ef5379bbf8b Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 11 Dec 2018 19:12:25 +0200 Subject: [PATCH 1/7] x86: edison: move CONFIG_CMD_PCI from header file to defconfig Use defconfig instead of header file for CONFIG_CMD_PCI. Signed-off-by: Andy Shevchenko Reviewed-by: Bin Meng --- configs/edison_defconfig | 1 - include/configs/edison.h | 3 --- 2 files changed, 4 deletions(-) diff --git a/configs/edison_defconfig b/configs/edison_defconfig index eb9f9a089f..234dbac4e8 100644 --- a/configs/edison_defconfig +++ b/configs/edison_defconfig @@ -18,7 +18,6 @@ CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_PART=y -# CONFIG_CMD_PCI is not set # CONFIG_CMD_NFS is not set CONFIG_CMD_TIMER=y CONFIG_CMD_HASH=y diff --git a/include/configs/edison.h b/include/configs/edison.h index 86c584d73d..8e312da2da 100644 --- a/include/configs/edison.h +++ b/include/configs/edison.h @@ -43,9 +43,6 @@ #define CONFIG_ENV_OFFSET_REDUND (6 * 1024 * 1024) #define CONFIG_SUPPORT_EMMC_BOOT -/* PCI */ -#define CONFIG_CMD_PCI - /* RTC */ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0 From 62ef268db92820ac86ce338bf80536a62fa31cc6 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 11 Dec 2018 19:12:26 +0200 Subject: [PATCH 2/7] x86: edison: move CONFIG_BOOTCOMMAND from header file to defconfig Use defconfig instead of header file for CONFIG_BOOTCOMMAND. Signed-off-by: Andy Shevchenko Reviewed-by: Bin Meng --- include/configs/edison.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/configs/edison.h b/include/configs/edison.h index 8e312da2da..7e2f9c129e 100644 --- a/include/configs/edison.h +++ b/include/configs/edison.h @@ -10,9 +10,6 @@ /* ACPI */ -/* Boot */ -#define CONFIG_BOOTCOMMAND "run bootcmd" - /* DISK Partition support */ /* Miscellaneous configurable options */ From 2fc7024d7ba370fe1fa416bfd67f1d44afb09aeb Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 11 Dec 2018 19:12:27 +0200 Subject: [PATCH 3/7] x86: edison: Remove staled comments from configuration header Since some options had been moved to defconfig from header, the leftover comments are not needed anymore. Remove them. Signed-off-by: Andy Shevchenko Reviewed-by: Bin Meng --- include/configs/edison.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/configs/edison.h b/include/configs/edison.h index 7e2f9c129e..a6155ba5a8 100644 --- a/include/configs/edison.h +++ b/include/configs/edison.h @@ -8,10 +8,6 @@ #include -/* ACPI */ - -/* DISK Partition support */ - /* Miscellaneous configurable options */ #define CONFIG_SYS_CBSIZE 2048 From 9914c73261b198bf26df70cce8aa098f204cd763 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Sat, 22 Dec 2018 01:55:48 -0800 Subject: [PATCH 4/7] fs: cbfs: remove wrong header validation cbfs_fileheader.len indicates the content size of the file in the cbfs, and it has nothing to do with cbfs_fileheader.offset which is the starting address of the file in the cbfs. Remove such check in file_cbfs_next_file(). Before this change 'cbfsinit' failed with 'Bad CBFS file'. After this change all cbfs commands are working as expected. Signed-off-by: Christian Gmeiner [bmeng: keep the necessary header sanity check] Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- fs/cbfs/cbfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c index 0dce639b49..e943325297 100644 --- a/fs/cbfs/cbfs.c +++ b/fs/cbfs/cbfs.c @@ -96,8 +96,7 @@ static int file_cbfs_next_file(u8 *start, u32 size, u32 align, } swap_file_header(&header, fileHeader); - if (header.offset < sizeof(struct cbfs_fileheader) || - header.offset > header.len) { + if (header.offset < sizeof(struct cbfs_fileheader)) { file_cbfs_result = CBFS_BAD_FILE; return -1; } From d94bf13c85c2773c8782bc7d6b4ac0190b5d489d Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sat, 22 Dec 2018 01:55:49 -0800 Subject: [PATCH 5/7] fs: cbfs: Fix out of bound access during CBFS walking through The call to file_cbfs_fill_cache() is given with the parameter 'start' pointing to the offset by the CBFS base address, but with the parameter 'size' that equals to the whole CBFS size. During CBFS walking through, it checks files one by one and after it pass over the end of the CBFS which is 4GiB boundary it tries to check files from address 0 and so on, until the overall size the codes checked hits to the given 'size'. Fix this by passing 'start' pointing to the CBFS base address. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- fs/cbfs/cbfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c index e943325297..7b2513cb24 100644 --- a/fs/cbfs/cbfs.c +++ b/fs/cbfs/cbfs.c @@ -189,8 +189,8 @@ void file_cbfs_init(uintptr_t end_of_rom) start_of_rom = (u8 *)(end_of_rom + 1 - cbfs_header.rom_size); - file_cbfs_fill_cache(start_of_rom + cbfs_header.offset, - cbfs_header.rom_size, cbfs_header.align); + file_cbfs_fill_cache(start_of_rom, cbfs_header.rom_size, + cbfs_header.align); if (file_cbfs_result == CBFS_SUCCESS) initialized = 1; } From 14fdf91ebfce7b8dd98177e873a7245f1bc21125 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sat, 22 Dec 2018 01:55:50 -0800 Subject: [PATCH 6/7] fs: cbfs: Make all CBFS_TYPE_xxx macros consistent At present there are 2 macros that are named as CBFS_COMPONENT_xxx. Change them to CBFS_TYPE_xxx for consistency. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- cmd/cbfs.c | 4 ++-- include/cbfs.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/cbfs.c b/cmd/cbfs.c index ece790e56e..4d3e0062df 100644 --- a/cmd/cbfs.c +++ b/cmd/cbfs.c @@ -136,10 +136,10 @@ static int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, case CBFS_TYPE_MICROCODE: type_name = "microcode"; break; - case CBFS_COMPONENT_CMOS_DEFAULT: + case CBFS_TYPE_CMOS_DEFAULT: type_name = "cmos default"; break; - case CBFS_COMPONENT_CMOS_LAYOUT: + case CBFS_TYPE_CMOS_LAYOUT: type_name = "cmos layout"; break; case -1: diff --git a/include/cbfs.h b/include/cbfs.h index 1b88ec04ae..dd4b574869 100644 --- a/include/cbfs.h +++ b/include/cbfs.h @@ -26,8 +26,8 @@ enum cbfs_filetype { CBFS_TYPE_VSA = 0x51, CBFS_TYPE_MBI = 0x52, CBFS_TYPE_MICROCODE = 0x53, - CBFS_COMPONENT_CMOS_DEFAULT = 0xaa, - CBFS_COMPONENT_CMOS_LAYOUT = 0x01aa + CBFS_TYPE_CMOS_DEFAULT = 0xaa, + CBFS_TYPE_CMOS_LAYOUT = 0x01aa }; struct cbfs_header { From 881bb9ab398419c33c9021ee8b2bbd8412882230 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sat, 22 Dec 2018 01:55:51 -0800 Subject: [PATCH 7/7] fs: cbfs: Add missing standard CBFS component types Current CBFS component type list is incomplete. Add missing ones. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- cmd/cbfs.c | 30 ++++++++++++++++++++++++++++++ include/cbfs.h | 10 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/cmd/cbfs.c b/cmd/cbfs.c index 4d3e0062df..c118a952ac 100644 --- a/cmd/cbfs.c +++ b/cmd/cbfs.c @@ -112,12 +112,21 @@ static int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, printf(" %8d", file_cbfs_size(file)); switch (type) { + case CBFS_TYPE_BOOTBLOCK: + type_name = "bootblock"; + break; + case CBFS_TYPE_CBFSHEADER: + type_name = "cbfs header"; + break; case CBFS_TYPE_STAGE: type_name = "stage"; break; case CBFS_TYPE_PAYLOAD: type_name = "payload"; break; + case CBFS_TYPE_FIT: + type_name = "fit"; + break; case CBFS_TYPE_OPTIONROM: type_name = "option rom"; break; @@ -136,9 +145,30 @@ static int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, case CBFS_TYPE_MICROCODE: type_name = "microcode"; break; + case CBFS_TYPE_FSP: + type_name = "fsp"; + break; + case CBFS_TYPE_MRC: + type_name = "mrc"; + break; + case CBFS_TYPE_MMA: + type_name = "mma"; + break; + case CBFS_TYPE_EFI: + type_name = "efi"; + break; + case CBFS_TYPE_STRUCT: + type_name = "struct"; + break; case CBFS_TYPE_CMOS_DEFAULT: type_name = "cmos default"; break; + case CBFS_TYPE_SPD: + type_name = "spd"; + break; + case CBFS_TYPE_MRC_CACHE: + type_name = "mrc cache"; + break; case CBFS_TYPE_CMOS_LAYOUT: type_name = "cmos layout"; break; diff --git a/include/cbfs.h b/include/cbfs.h index dd4b574869..bd1bf75bbf 100644 --- a/include/cbfs.h +++ b/include/cbfs.h @@ -18,15 +18,25 @@ enum cbfs_result { }; enum cbfs_filetype { + CBFS_TYPE_BOOTBLOCK = 0x01, + CBFS_TYPE_CBFSHEADER = 0x02, CBFS_TYPE_STAGE = 0x10, CBFS_TYPE_PAYLOAD = 0x20, + CBFS_TYPE_FIT = 0x21, CBFS_TYPE_OPTIONROM = 0x30, CBFS_TYPE_BOOTSPLASH = 0x40, CBFS_TYPE_RAW = 0x50, CBFS_TYPE_VSA = 0x51, CBFS_TYPE_MBI = 0x52, CBFS_TYPE_MICROCODE = 0x53, + CBFS_TYPE_FSP = 0x60, + CBFS_TYPE_MRC = 0x61, + CBFS_TYPE_MMA = 0x62, + CBFS_TYPE_EFI = 0x63, + CBFS_TYPE_STRUCT = 0x70, CBFS_TYPE_CMOS_DEFAULT = 0xaa, + CBFS_TYPE_SPD = 0xab, + CBFS_TYPE_MRC_CACHE = 0xac, CBFS_TYPE_CMOS_LAYOUT = 0x01aa };