Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/aspeed-dev' into aspeed-master
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTroy committed Jan 12, 2023
2 parents c7f1ce8 + 4e27ed4 commit a0aee8d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
23 changes: 19 additions & 4 deletions apps/aspeed-pfr/src/intel_pfr/intel_pfr_recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "flash/flash_util.h"
#include "Smbus_mailbox/Smbus_mailbox.h"
#include "intel_pfr_svn.h"
#include "intel_pfr_update.h"

LOG_MODULE_DECLARE(pfr, CONFIG_LOG_DEFAULT_LEVEL);

Expand Down Expand Up @@ -185,14 +186,28 @@ int pfr_recover_active_region(struct pfr_manifest *manifest)
}
#if defined(CONFIG_PFR_SPDM_ATTESTATION)
else if (manifest->image_type == AFM_TYPE) {
manifest->image_type = BMC_TYPE;
manifest->address = CONFIG_BMC_AFM_RECOVERY_OFFSET;
return ast1060_update(manifest);
manifest->image_type = BMC_TYPE;
if (pfr_spi_read(manifest->image_type, manifest->address,
sizeof(PFR_AUTHENTICATION_BLOCK0), buffer)) {
LOG_ERR("Block0: Flash read data failed");
return Failure;
}

block0_buffer = (PFR_AUTHENTICATION_BLOCK0 *)buffer;
manifest->pc_length = block0_buffer->PcLength;
manifest->address += PFM_SIG_BLOCK_SIZE;

LOG_INF("AFM update start payload_address=%08x pc_length=%x", manifest->address, manifest->pc_length);
if (update_afm(AFM_PART_ACT_1, manifest->address, manifest->pc_length))
return Failure;

LOG_INF("Repair success");
return Success;
}
#endif
else {
else
return Failure;
}

manifest->recovery_address = read_address;
manifest->staging_address = staging_address;
Expand Down
30 changes: 15 additions & 15 deletions apps/aspeed-pfr/src/intel_pfr/intel_pfr_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,6 @@ int update_rot_fw(uint32_t address, uint32_t length)
}

#if defined(CONFIG_PFR_SPDM_ATTESTATION)
enum AFM_PARTITION_TYPE {
AFM_PART_ACT_1,
AFM_PART_RCV_1,
// Reserved for Intel PFR 4.0
AFM_PART_ACT_2,
AFM_PART_RCV_2,
};

int update_afm(enum AFM_PARTITION_TYPE part, uint32_t address, size_t length)
{
uint32_t region_size = pfr_spi_get_device_size(ROT_INTERNAL_AFM);
Expand All @@ -284,6 +276,11 @@ int update_afm(enum AFM_PARTITION_TYPE part, uint32_t address, size_t length)
(length % PAGE_SIZE) ? (length + (PAGE_SIZE - (length % PAGE_SIZE))) : length;

if (part == AFM_PART_ACT_1) {
if (length_page_align > region_size) {
LOG_ERR("length(%x) exceed region size(%x)", length_page_align, region_size);
return Failure;
}

if (pfr_spi_erase_region(ROT_INTERNAL_AFM, true, 0, region_size)) {
LOG_ERR("Failed to erase AFM Active Partition");
return Failure;
Expand Down Expand Up @@ -321,7 +318,6 @@ int update_afm_image(struct pfr_manifest *manifest, uint32_t flash_select, void
{
AO_DATA *ActiveObjectData = (AO_DATA *) AoData;
uint32_t payload_address;
uint32_t pc_type_status;
uint32_t pc_length = 0;
uint32_t hrot_svn = 0;
uint32_t pc_type;
Expand Down Expand Up @@ -372,6 +368,10 @@ int update_afm_image(struct pfr_manifest *manifest, uint32_t flash_select, void
}

status = update_afm(AFM_PART_ACT_1, payload_address, pc_length);
if (status != Success) {
LOG_ERR("Update AFM Active failed");
return Failure;
}
} else if (flash_select == SECONDARY_FLASH_REGION) {
if (ActiveObjectData->RestrictActiveUpdate == 1) {
manifest->image_type = AFM_TYPE;
Expand All @@ -382,15 +382,15 @@ int update_afm_image(struct pfr_manifest *manifest, uint32_t flash_select, void
}
}

status = update_afm(AFM_PART_RCV_1, payload_address, 64*1024 /*pc_length*/);
}
status = update_afm(AFM_PART_RCV_1, payload_address, pc_length);
if (status != Success) {
LOG_ERR("Update AFM Recovery failed");
return Failure;
}

if (status != Success) {
LOG_ERR("Update AFM failed");
return Failure;
set_ufm_svn(SVN_POLICY_FOR_AFM, hrot_svn);
}

set_ufm_svn(SVN_POLICY_FOR_AFM, hrot_svn);
LOG_INF("AFM update end");

return Success;
Expand Down
12 changes: 12 additions & 0 deletions apps/aspeed-pfr/src/intel_pfr/intel_pfr_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

#include <stdint.h>

#if defined(CONFIG_PFR_SPDM_ATTESTATION)
enum AFM_PARTITION_TYPE {
AFM_PART_ACT_1,
AFM_PART_RCV_1,
// Reserved for Intel PFR 4.0
AFM_PART_ACT_2,
AFM_PART_RCV_2,
};

int update_afm(enum AFM_PARTITION_TYPE part, uint32_t address, size_t length);
#endif

int intel_pfr_update_verify(struct firmware_image *fw, struct hash_engine *hash, struct rsa_engine *rsa);
int update_firmware_image(uint32_t image_type, void *AoData, void *EventContext);

Expand Down
1 change: 0 additions & 1 deletion apps/aspeed-pfr/src/pfr/pfr_recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ int recover_image(void *AoData, void *EventContext)
if (EventData->image == BMC_EVENT) {
LOG_INF("Image Type: BMC");
pfr_manifest->image_type = BMC_TYPE;

} else if (EventData->image == PCH_EVENT) {
LOG_INF("Image Type: PCH");
pfr_manifest->image_type = PCH_TYPE;
Expand Down

0 comments on commit a0aee8d

Please sign in to comment.