drivers/intel/fsp2_0: Verify HOBs returned by FspMemoryInit
Verify that FSP is properly returning: * HOB list pointer * FSP_BOOTLOADER_TOLUM_HOB * FSP_RESERVED_MEMORY_RESOURCE_HOB TEST=Build and run on Galileo Gen2 Change-Id: I23005d10f7f3ccf06a2e29dab5fa11c7ed79f187 Signed-off-by: Lee Leahy <leroy.p.leahy@intel.com> Reviewed-on: https://review.coreboot.org/15850 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
@ -73,4 +73,11 @@ config FSP_M_XIP
|
|||||||
help
|
help
|
||||||
Select this value when FSP-M is execute-in-place.
|
Select this value when FSP-M is execute-in-place.
|
||||||
|
|
||||||
|
config VERIFY_HOBS
|
||||||
|
bool "Verify the FSP hand-off-blocks"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Verify that the HOBs required by coreboot are returned by FSP and
|
||||||
|
that the resource HOBs are in the correct order and position.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -19,6 +19,7 @@ romstage-y += debug.c
|
|||||||
romstage-y += hand_off_block.c
|
romstage-y += hand_off_block.c
|
||||||
romstage-$(CONFIG_DISPLAY_HOBS) += hob_display.c
|
romstage-$(CONFIG_DISPLAY_HOBS) += hob_display.c
|
||||||
romstage-$(CONFIG_DISPLAY_UPD_DATA) += upd_display.c
|
romstage-$(CONFIG_DISPLAY_UPD_DATA) += upd_display.c
|
||||||
|
romstage-$(CONFIG_VERIFY_HOBS) += hob_verify.c
|
||||||
romstage-y += util.c
|
romstage-y += util.c
|
||||||
romstage-y += memory_init.c
|
romstage-y += memory_init.c
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ ramstage-y += debug.c
|
|||||||
ramstage-y += graphics.c
|
ramstage-y += graphics.c
|
||||||
ramstage-y += hand_off_block.c
|
ramstage-y += hand_off_block.c
|
||||||
ramstage-$(CONFIG_DISPLAY_HOBS) += hob_display.c
|
ramstage-$(CONFIG_DISPLAY_HOBS) += hob_display.c
|
||||||
|
ramstage-$(CONFIG_VERIFY_HOBS) += hob_verify.c
|
||||||
ramstage-y += notify.c
|
ramstage-y += notify.c
|
||||||
ramstage-y += silicon_init.c
|
ramstage-y += silicon_init.c
|
||||||
ramstage-$(CONFIG_DISPLAY_UPD_DATA) += upd_display.c
|
ramstage-$(CONFIG_DISPLAY_UPD_DATA) += upd_display.c
|
||||||
|
@ -42,9 +42,15 @@ void fsp_debug_after_memory_init(enum fsp_status status)
|
|||||||
if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS))
|
if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS))
|
||||||
printk(BIOS_DEBUG, "FspMemoryInit returned 0x%08x\n", status);
|
printk(BIOS_DEBUG, "FspMemoryInit returned 0x%08x\n", status);
|
||||||
|
|
||||||
/* Display the HOBs */
|
/* Verify that the HOB list pointer was set */
|
||||||
|
if (fsp_get_hob_list() == NULL)
|
||||||
|
die("ERROR - HOB list pointer was not returned!\n");
|
||||||
|
|
||||||
|
/* Display and verify the HOBs */
|
||||||
if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
|
if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
|
||||||
fsp_display_hobs();
|
fsp_display_hobs();
|
||||||
|
if (IS_ENABLED(CONFIG_VERIFY_HOBS))
|
||||||
|
fsp_verify_memory_init_hobs();
|
||||||
|
|
||||||
/* Display the MTRRs */
|
/* Display the MTRRs */
|
||||||
if (IS_ENABLED(CONFIG_DISPLAY_MTRRS))
|
if (IS_ENABLED(CONFIG_DISPLAY_MTRRS))
|
||||||
|
@ -34,6 +34,11 @@ enum resource_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* GUIDs in little-endian, so they can be used with memcmp() */
|
/* GUIDs in little-endian, so they can be used with memcmp() */
|
||||||
|
const uint8_t fsp_bootloader_tolum_guid[16] = {
|
||||||
|
0x56, 0x4f, 0xff, 0x73, 0x8e, 0xaa, 0x51, 0x44,
|
||||||
|
0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44,
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t fsp_reserved_memory_guid[16] = {
|
const uint8_t fsp_reserved_memory_guid[16] = {
|
||||||
0x59, 0x97, 0xa7, 0x69, 0x73, 0x13, 0x67, 0x43,
|
0x59, 0x97, 0xa7, 0x69, 0x73, 0x13, 0x67, 0x43,
|
||||||
0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e,
|
0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e,
|
||||||
@ -146,20 +151,43 @@ struct hob_resource *find_resource_hob_by_guid(const struct hob_header *hob,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsp_find_reserved_memory(struct range_entry *re)
|
void fsp_print_guid(const void *base)
|
||||||
|
{
|
||||||
|
uint32_t big;
|
||||||
|
uint16_t mid[2];
|
||||||
|
|
||||||
|
const uint8_t *id = base;
|
||||||
|
big = read32(id + 0);
|
||||||
|
mid[0] = read16(id + 4);
|
||||||
|
mid[1] = read16(id + 6);
|
||||||
|
|
||||||
|
printk(BIOS_SPEW, "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||||
|
big, mid[0], mid[1],
|
||||||
|
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fsp_find_range_hob(struct range_entry *re, const uint8_t guid[16])
|
||||||
{
|
{
|
||||||
const struct hob_resource *fsp_mem;
|
const struct hob_resource *fsp_mem;
|
||||||
const void *hob_list = fsp_get_hob_list();
|
const void *hob_list = fsp_get_hob_list();
|
||||||
|
|
||||||
range_entry_init(re, 0, 0, 0);
|
range_entry_init(re, 0, 0, 0);
|
||||||
|
|
||||||
fsp_mem = find_resource_hob_by_guid(hob_list, fsp_reserved_memory_guid);
|
fsp_mem = find_resource_hob_by_guid(hob_list, guid);
|
||||||
|
|
||||||
if (!fsp_mem) {
|
if (!fsp_mem) {
|
||||||
return;
|
fsp_print_guid(guid);
|
||||||
|
printk(BIOS_SPEW, " not found!\n");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
range_entry_init(re, fsp_mem->addr, fsp_mem->addr + fsp_mem->length, 0);
|
range_entry_init(re, fsp_mem->addr, fsp_mem->addr + fsp_mem->length, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fsp_find_reserved_memory(struct range_entry *re)
|
||||||
|
{
|
||||||
|
return fsp_find_range_hob(re, fsp_reserved_memory_guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
|
const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
|
||||||
|
@ -47,11 +47,6 @@ static const uint8_t bootloader_temp_memory_guid[16] = {
|
|||||||
0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
|
0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t bootloader_tolum_guid[16] = {
|
|
||||||
0x56, 0x4f, 0xff, 0x73, 0x8e, 0xaa, 0x51, 0x44,
|
|
||||||
0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t empty_guid[16] = {
|
static const uint8_t empty_guid[16] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
@ -78,7 +73,7 @@ struct guid_name_map {
|
|||||||
|
|
||||||
static const struct guid_name_map guid_names[] = {
|
static const struct guid_name_map guid_names[] = {
|
||||||
{ bootloader_temp_memory_guid, "FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
|
{ bootloader_temp_memory_guid, "FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
|
||||||
{ bootloader_tolum_guid, "BOOTLOADER_TOLUM" },
|
{ fsp_bootloader_tolum_guid, "BOOTLOADER_TOLUM" },
|
||||||
{ empty_guid, "No GUID specified" },
|
{ empty_guid, "No GUID specified" },
|
||||||
{ fsp_info_header_guid, "FSP_INFO_HEADER_GUID" },
|
{ fsp_info_header_guid, "FSP_INFO_HEADER_GUID" },
|
||||||
{ fsp_reserved_memory_guid, "FSP_RESERVED_MEMORY" },
|
{ fsp_reserved_memory_guid, "FSP_RESERVED_MEMORY" },
|
||||||
@ -88,21 +83,6 @@ static const struct guid_name_map guid_names[] = {
|
|||||||
{ tseg_guid, "TSEG" },
|
{ tseg_guid, "TSEG" },
|
||||||
};
|
};
|
||||||
|
|
||||||
void fsp_print_guid(const void *base)
|
|
||||||
{
|
|
||||||
uint32_t big;
|
|
||||||
uint16_t mid[2];
|
|
||||||
|
|
||||||
const uint8_t *id = base;
|
|
||||||
big = read32(id + 0);
|
|
||||||
mid[0] = read16(id + 4);
|
|
||||||
mid[1] = read16(id + 6);
|
|
||||||
|
|
||||||
printk(BIOS_SPEW, "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x",
|
|
||||||
big, mid[0], mid[1],
|
|
||||||
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *resource_name(enum resource_type type)
|
static const char *resource_name(enum resource_type type)
|
||||||
{
|
{
|
||||||
if (type >= ARRAY_SIZE(resource_names))
|
if (type >= ARRAY_SIZE(resource_names))
|
||||||
|
69
src/drivers/intel/fsp2_0/hob_verify.c
Normal file
69
src/drivers/intel/fsp2_0/hob_verify.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Intel Corp.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cbmem.h>
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <fsp/util.h>
|
||||||
|
|
||||||
|
int fsp_find_bootloader_tolum(struct range_entry *re)
|
||||||
|
{
|
||||||
|
return fsp_find_range_hob(re, fsp_bootloader_tolum_guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fsp_verify_memory_init_hobs(void)
|
||||||
|
{
|
||||||
|
struct range_entry fsp_mem;
|
||||||
|
struct range_entry tolum;
|
||||||
|
|
||||||
|
/* Lookup the FSP_BOOTLOADER_TOLUM_HOB */
|
||||||
|
if (fsp_find_bootloader_tolum(&tolum))
|
||||||
|
die("9.3: FSP_BOOTLOADER_TOLUM_HOB missing!\n");
|
||||||
|
if (range_entry_size(&tolum) < cbmem_overhead_size()) {
|
||||||
|
printk(BIOS_CRIT,
|
||||||
|
"FSP_BOOTLOADER_TOLUM_SIZE: 0x%08llx < 0x%08lx\n",
|
||||||
|
range_entry_size(&tolum), cbmem_overhead_size());
|
||||||
|
die("FSP_BOOTLOADER_TOLUM_HOB too small!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Locate the FSP reserved memory area */
|
||||||
|
if (fsp_find_reserved_memory(&fsp_mem))
|
||||||
|
die("9.1: FSP_RESERVED_MEMORY_RESOURCE_HOB missing!\n");
|
||||||
|
|
||||||
|
/* Verify the the bootloader tolum is above the FSP reserved area */
|
||||||
|
if (range_entry_end(&tolum) <= range_entry_base(&fsp_mem)) {
|
||||||
|
printk(BIOS_CRIT,
|
||||||
|
"TOLUM end: 0x%08llx != 0x%08llx: FSP rsvd base\n",
|
||||||
|
range_entry_end(&tolum), range_entry_base(&fsp_mem));
|
||||||
|
die("FSP reserved region after BIOS TOLUM!\n");
|
||||||
|
}
|
||||||
|
if (range_entry_base(&tolum) < range_entry_end(&fsp_mem)) {
|
||||||
|
printk(BIOS_CRIT,
|
||||||
|
"TOLUM base: 0x%08llx < 0x%08llx: FSP rsvd end\n",
|
||||||
|
range_entry_base(&tolum), range_entry_end(&fsp_mem));
|
||||||
|
die("FSP reserved region overlaps BIOS TOLUM!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify that the FSP reserved area immediately follows the BIOS
|
||||||
|
* reserved area
|
||||||
|
*/
|
||||||
|
if (range_entry_base(&tolum) != range_entry_end(&fsp_mem)) {
|
||||||
|
printk(BIOS_CRIT,
|
||||||
|
"TOLUM base: 0x%08llx != 0x%08llx: FSP rsvd end\n",
|
||||||
|
range_entry_base(&tolum), range_entry_end(&fsp_mem));
|
||||||
|
die("Space between FSP reserved region and BIOS TOLUM!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (range_entry_end(&tolum) != (uintptr_t)cbmem_top()) {
|
||||||
|
printk(BIOS_CRIT, "TOLUM end: 0x%08llx != 0x%p: cbmem_top\n",
|
||||||
|
range_entry_end(&tolum), cbmem_top());
|
||||||
|
die("Space between cbmem_top and BIOS TOLUM!\n");
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@ void fsp_debug_after_notify(enum fsp_status status);
|
|||||||
void fspm_display_upd_values(const struct FSPM_UPD *old,
|
void fspm_display_upd_values(const struct FSPM_UPD *old,
|
||||||
const struct FSPM_UPD *new);
|
const struct FSPM_UPD *new);
|
||||||
void fsp_display_hobs(void);
|
void fsp_display_hobs(void);
|
||||||
|
void fsp_verify_memory_init_hobs(void);
|
||||||
|
|
||||||
/* Callbacks for displaying UPD parameters - place in a separate file
|
/* Callbacks for displaying UPD parameters - place in a separate file
|
||||||
* that is conditionally build with CONFIG_DISPLAY_UPD_DATA.
|
* that is conditionally build with CONFIG_DISPLAY_UPD_DATA.
|
||||||
@ -54,5 +55,6 @@ void fsp_print_resource_descriptor(const void *base);
|
|||||||
const char *fsp_get_hob_type_name(const struct hob_header *hob);
|
const char *fsp_get_hob_type_name(const struct hob_header *hob);
|
||||||
const char *fsp_get_guid_name(const uint8_t *guid);
|
const char *fsp_get_guid_name(const uint8_t *guid);
|
||||||
void fsp_print_guid_extension_hob(const struct hob_header *hob);
|
void fsp_print_guid_extension_hob(const struct hob_header *hob);
|
||||||
|
int fsp_find_bootloader_tolum(struct range_entry *re);
|
||||||
|
|
||||||
#endif /* _FSP2_0_DEBUG_H_ */
|
#endif /* _FSP2_0_DEBUG_H_ */
|
||||||
|
@ -52,6 +52,7 @@ enum hob_type {
|
|||||||
HOB_TYPE_END_OF_HOB_LIST = 0xFFFF,
|
HOB_TYPE_END_OF_HOB_LIST = 0xFFFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const uint8_t fsp_bootloader_tolum_guid[16];
|
||||||
extern const uint8_t fsp_graphics_info_guid[16];
|
extern const uint8_t fsp_graphics_info_guid[16];
|
||||||
extern const uint8_t fsp_nv_storage_guid[16];
|
extern const uint8_t fsp_nv_storage_guid[16];
|
||||||
extern const uint8_t fsp_reserved_memory_guid[16];
|
extern const uint8_t fsp_reserved_memory_guid[16];
|
||||||
@ -61,7 +62,8 @@ void *fsp_get_hob_list_ptr(void);
|
|||||||
const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size);
|
const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size);
|
||||||
const void *fsp_find_nv_storage_data(size_t *size);
|
const void *fsp_find_nv_storage_data(size_t *size);
|
||||||
enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
|
enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
|
||||||
void fsp_find_reserved_memory(struct range_entry *re);
|
int fsp_find_range_hob(struct range_entry *re, const uint8_t guid[16]);
|
||||||
|
int fsp_find_reserved_memory(struct range_entry *re);
|
||||||
const struct hob_resource *fsp_hob_header_to_resource(
|
const struct hob_resource *fsp_hob_header_to_resource(
|
||||||
const struct hob_header *hob);
|
const struct hob_header *hob);
|
||||||
const struct hob_header *fsp_next_hob(const struct hob_header *parent);
|
const struct hob_header *fsp_next_hob(const struct hob_header *parent);
|
||||||
|
@ -68,7 +68,8 @@ static enum fsp_status do_fsp_post_memory_init(bool s3wake,
|
|||||||
struct range_entry fsp_mem;
|
struct range_entry fsp_mem;
|
||||||
struct romstage_handoff *handoff;
|
struct romstage_handoff *handoff;
|
||||||
|
|
||||||
fsp_find_reserved_memory(&fsp_mem);
|
if (fsp_find_reserved_memory(&fsp_mem))
|
||||||
|
die("Failed to find FSP_RESERVED_MEMORY_RESOURCE_HOB!\n");
|
||||||
|
|
||||||
/* initialize cbmem by adding FSP reserved memory first thing */
|
/* initialize cbmem by adding FSP reserved memory first thing */
|
||||||
if (!s3wake) {
|
if (!s3wake) {
|
||||||
|
Reference in New Issue
Block a user