refactor(measured-boot): accept metadata as a function's argument

Updated the event log driver's function to accept metadata as an
argument, to remove the platform function usage from the event log
driver to make it a standalone driver.

Change-Id: I512cf693d51dc3c0b9d2c1bfde4f89414e273049
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
This commit is contained in:
Manish V Badarkhe 2022-11-18 18:30:08 +00:00
parent 9881bb93a3
commit 5f32444443
2 changed files with 7 additions and 13 deletions

View file

@ -14,8 +14,6 @@
#include <drivers/auth/crypto_mod.h> #include <drivers/auth/crypto_mod.h>
#include <drivers/measured_boot/event_log/event_log.h> #include <drivers/measured_boot/event_log/event_log.h>
#include <plat/common/platform.h>
#if TPM_ALG_ID == TPM_ALG_SHA512 #if TPM_ALG_ID == TPM_ALG_SHA512
#define CRYPTO_MD_ID CRYPTO_MD_SHA512 #define CRYPTO_MD_ID CRYPTO_MD_SHA512
#elif TPM_ALG_ID == TPM_ALG_SHA384 #elif TPM_ALG_ID == TPM_ALG_SHA384
@ -32,9 +30,6 @@ static uint8_t *log_ptr;
/* Pointer to the first byte past end of the Event Log buffer */ /* Pointer to the first byte past end of the Event Log buffer */
static uintptr_t log_end; static uintptr_t log_end;
/* Pointer to event_log_metadata_t */
static const event_log_metadata_t *plat_metadata_ptr;
/* TCG_EfiSpecIdEvent */ /* TCG_EfiSpecIdEvent */
static const id_event_headers_t id_event_header = { static const id_event_headers_t id_event_header = {
.header = { .header = {
@ -173,10 +168,6 @@ void event_log_buf_init(uint8_t *event_log_start, uint8_t *event_log_finish)
void event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish) void event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish)
{ {
event_log_buf_init(event_log_start, event_log_finish); event_log_buf_init(event_log_start, event_log_finish);
/* Get pointer to platform's event_log_metadata_t structure */
plat_metadata_ptr = plat_event_log_get_metadata();
assert(plat_metadata_ptr != NULL);
} }
void event_log_write_specid_event(void) void event_log_write_specid_event(void)
@ -276,16 +267,19 @@ int event_log_measure(uintptr_t data_base, uint32_t data_size,
* @param[in] data_base Address of data * @param[in] data_base Address of data
* @param[in] data_size Size of data * @param[in] data_size Size of data
* @param[in] data_id Data ID * @param[in] data_id Data ID
* @param[in] metadata_ptr Event Log metadata
* @return: * @return:
* 0 = success * 0 = success
* < 0 = error * < 0 = error
*/ */
int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size, int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size,
uint32_t data_id) uint32_t data_id,
const event_log_metadata_t *metadata_ptr)
{ {
unsigned char hash_data[CRYPTO_MD_MAX_SIZE]; unsigned char hash_data[CRYPTO_MD_MAX_SIZE];
int rc; int rc;
const event_log_metadata_t *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 != EVLOG_INVALID_ID) && while ((metadata_ptr->id != EVLOG_INVALID_ID) &&

View file

@ -115,13 +115,13 @@ void event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish);
void event_log_write_specid_event(void); void event_log_write_specid_event(void);
void event_log_write_header(void); void event_log_write_header(void);
void dump_event_log(uint8_t *log_addr, size_t log_size); void dump_event_log(uint8_t *log_addr, size_t log_size);
const event_log_metadata_t *plat_event_log_get_metadata(void);
int event_log_measure(uintptr_t data_base, uint32_t data_size, int event_log_measure(uintptr_t data_base, uint32_t data_size,
unsigned char hash_data[CRYPTO_MD_MAX_SIZE]); unsigned char hash_data[CRYPTO_MD_MAX_SIZE]);
void event_log_record(const uint8_t *hash, uint32_t event_type, void event_log_record(const uint8_t *hash, uint32_t event_type,
const event_log_metadata_t *metadata_ptr); const event_log_metadata_t *metadata_ptr);
int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size, int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size,
uint32_t data_id); uint32_t data_id,
const event_log_metadata_t *metadata_ptr);
size_t event_log_get_cur_size(uint8_t *event_log_start); size_t event_log_get_cur_size(uint8_t *event_log_start);
#endif /* EVENT_LOG_H */ #endif /* EVENT_LOG_H */