Browse Source

refactor(rss): make RSS driver standalone for Measured Boot

Currently, Measured Boot RSS driver gathers data from platform calls,
specifically RSS metadata. Generally, the driver should use the least
amount of platform calls possible, and the platform should provide the
data directly to the driver via the driver interface.

For this purpose, RSS Measured Boot driver interface APIs were updated
and platform calls were removed from RSS Measured Boot driver.

Change-Id: I6c797d9ac2d70215f32a084a7643884b399ee28c
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
pull/1999/head
Manish V Badarkhe 1 year ago
parent
commit
36bcf10c23
  1. 31
      drivers/measured_boot/rss/rss_measured_boot.c
  2. 12
      include/drivers/measured_boot/rss/rss_measured_boot.h

31
drivers/measured_boot/rss/rss_measured_boot.c

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Arm Limited. All rights reserved. * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -32,23 +32,10 @@
# error Invalid Measured Boot algorithm. # error Invalid Measured Boot algorithm.
#endif /* MBOOT_ALG_ID */ #endif /* MBOOT_ALG_ID */
/* Pointer to struct rss_mboot_metadata */
static struct rss_mboot_metadata *plat_metadata_ptr;
/* Functions' declarations */ /* Functions' declarations */
void rss_measured_boot_init(void) void rss_measured_boot_init(struct rss_mboot_metadata *metadata_ptr)
{ {
/* At this point it is expected that communication channel over MHU assert(metadata_ptr != NULL);
* is already initialised by platform init.
*/
struct rss_mboot_metadata *metadata_ptr;
/* Get pointer to platform's struct rss_mboot_metadata structure */
plat_metadata_ptr = plat_rss_mboot_get_metadata();
assert(plat_metadata_ptr != NULL);
/* Use a local variable to preserve the value of the global pointer */
metadata_ptr = plat_metadata_ptr;
/* Init the non-const members of the metadata structure */ /* Init the non-const members of the metadata structure */
while (metadata_ptr->id != RSS_MBOOT_INVALID_ID) { while (metadata_ptr->id != RSS_MBOOT_INVALID_ID) {
@ -58,13 +45,15 @@ void rss_measured_boot_init(void)
} }
} }
int rss_mboot_measure_and_record(uintptr_t data_base, uint32_t data_size, int rss_mboot_measure_and_record(struct rss_mboot_metadata *metadata_ptr,
uintptr_t data_base, uint32_t data_size,
uint32_t data_id) uint32_t data_id)
{ {
unsigned char hash_data[CRYPTO_MD_MAX_SIZE]; unsigned char hash_data[CRYPTO_MD_MAX_SIZE];
int rc; int rc;
psa_status_t ret; psa_status_t ret;
const struct rss_mboot_metadata *metadata_ptr = plat_metadata_ptr;
assert(metadata_ptr != NULL);
/* Get the metadata associated with this image. */ /* Get the metadata associated with this image. */
while ((metadata_ptr->id != RSS_MBOOT_INVALID_ID) && while ((metadata_ptr->id != RSS_MBOOT_INVALID_ID) &&
@ -103,14 +92,16 @@ int rss_mboot_measure_and_record(uintptr_t data_base, uint32_t data_size,
return 0; return 0;
} }
int rss_mboot_set_signer_id(unsigned int img_id, int rss_mboot_set_signer_id(struct rss_mboot_metadata *metadata_ptr,
unsigned int img_id,
const void *pk_ptr, const void *pk_ptr,
size_t pk_len) size_t pk_len)
{ {
unsigned char hash_data[CRYPTO_MD_MAX_SIZE]; unsigned char hash_data[CRYPTO_MD_MAX_SIZE];
struct rss_mboot_metadata *metadata_ptr = plat_metadata_ptr;
int rc; int rc;
assert(metadata_ptr != NULL);
/* Get the metadata associated with this image. */ /* Get the metadata associated with this image. */
while ((metadata_ptr->id != RSS_MBOOT_INVALID_ID) && while ((metadata_ptr->id != RSS_MBOOT_INVALID_ID) &&
(metadata_ptr->id != img_id)) { (metadata_ptr->id != img_id)) {

12
include/drivers/measured_boot/rss/rss_measured_boot.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Arm Limited. All rights reserved. * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -44,12 +44,14 @@ struct rss_mboot_metadata {
}; };
/* Functions' declarations */ /* Functions' declarations */
void rss_measured_boot_init(void); void rss_measured_boot_init(struct rss_mboot_metadata *metadata_ptr);
struct rss_mboot_metadata *plat_rss_mboot_get_metadata(void); int rss_mboot_measure_and_record(struct rss_mboot_metadata *metadata_ptr,
int rss_mboot_measure_and_record(uintptr_t data_base, uint32_t data_size, uintptr_t data_base, uint32_t data_size,
uint32_t data_id); uint32_t data_id);
/* TODO: These metadata are currently not available during TF-A boot */ /* TODO: These metadata are currently not available during TF-A boot */
int rss_mboot_set_signer_id(unsigned int img_id, const void *pk_ptr, size_t pk_len); int rss_mboot_set_signer_id(struct rss_mboot_metadata *metadata_ptr,
unsigned int img_id, const void *pk_ptr,
size_t pk_len);
#endif /* RSS_MEASURED_BOOT_H */ #endif /* RSS_MEASURED_BOOT_H */

Loading…
Cancel
Save