From 3e6d245772ccb4b43f1ba6cd9d1bb8abe86a516c Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Mon, 16 Oct 2023 09:30:16 -0500 Subject: [PATCH] feat(arm): add IO policy to use backup gpt header Add a IO block spec to use GPT backup header if primary fails. Currently we use only the primary gpt header which is in the second block(LBA-1) after the MBR block(LBA-0) so we restrict IO access to primary gpt header and its entries. But we plan to use backup GPT which is the last block of the partition (LBA-n) in case our primary GPT header fails verification or is corrupted. Offset and length of the block spec will be updated runtime from partition driver after parsing MBR data. Change-Id: Id1d49841d6f4cbcc3248af19faf2fbd8e24a8ba1 Signed-off-by: Govindraj Raja --- plat/arm/common/fconf/arm_fconf_io.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plat/arm/common/fconf/arm_fconf_io.c b/plat/arm/common/fconf/arm_fconf_io.c index 27acc3a64..8fe8c3372 100644 --- a/plat/arm/common/fconf/arm_fconf_io.c +++ b/plat/arm/common/fconf/arm_fconf_io.c @@ -50,6 +50,18 @@ static const io_block_spec_t gpt_spec = { .length = PLAT_PARTITION_BLOCK_SIZE * (PLAT_PARTITION_MAX_ENTRIES / 4 + 2), }; + +/* + * length will be assigned at runtime based on MBR header data. + * Backup GPT Header is present in Last LBA-1 and its entries + * are last 32 blocks starts at LBA-33, On runtime update these + * before device usage. Update offset to beginning LBA-33 and + * length to LBA-33. + */ +static io_block_spec_t bkup_gpt_spec = { + .offset = PLAT_ARM_FLASH_IMAGE_BASE, + .length = 0, +}; #endif /* ARM_GPT_SUPPORT */ const io_uuid_spec_t arm_uuid_spec[MAX_NUMBER_IDS] = { @@ -107,6 +119,11 @@ struct plat_io_policy policies[MAX_NUMBER_IDS] = { (uintptr_t)&gpt_spec, open_memmap }, + [BKUP_GPT_IMAGE_ID] = { + &memmap_dev_handle, + (uintptr_t)&bkup_gpt_spec, + open_memmap + }, #endif /* ARM_GPT_SUPPORT */ #if PSA_FWU_SUPPORT [FWU_METADATA_IMAGE_ID] = {