Merge changes from topic "rfa-related-fixes"
* changes:
fix: remove dependency on fixed PSCI version in smc32_fast
fix: ignore errors on optional General service queries
fix(psci): mask MBZ bits in PSCI target_cpu arguments
diff --git a/.gitmodules b/.gitmodules
index c753963..844ca3c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -5,3 +5,6 @@
path = contrib/libtl
url = https://review.trustedfirmware.org/shared/transfer-list-library
shallow = true
+[submodule "contrib/libeventlog"]
+ path = contrib/libeventlog
+ url = https://review.trustedfirmware.org/shared/libEventLog
diff --git a/contrib/libeventlog b/contrib/libeventlog
new file mode 160000
index 0000000..e2f92a9
--- /dev/null
+++ b/contrib/libeventlog
@@ -0,0 +1 @@
+Subproject commit e2f92a92245f9fb073ed995b4e80b71f9c4ff6a2
diff --git a/contrib/libtl b/contrib/libtl
index 38b309b..022175f 160000
--- a/contrib/libtl
+++ b/contrib/libtl
@@ -1 +1 @@
-Subproject commit 38b309b70f830280af038e03c51082df8f54a149
+Subproject commit 022175f49371aeb3bb267201ae06125fd6ae262e
diff --git a/docs/getting_started/requirements.rst b/docs/getting_started/requirements.rst
index 3c27b9d..eba75a2 100644
--- a/docs/getting_started/requirements.rst
+++ b/docs/getting_started/requirements.rst
@@ -26,6 +26,8 @@
Name Version
======================== =====================
Mbed TLS 3.6.3
+Transfer List Library 0.0.1
+Event Log Library 0.0.1
======================== =====================
Toolchain
diff --git a/include/lib/event_log/event_handoff.h b/include/lib/event_log/event_handoff.h
deleted file mode 100644
index f8c8716..0000000
--- a/include/lib/event_log/event_handoff.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2025, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-
-#ifndef HANDOFF_H
-#define HANDOFF_H
-
-#include <stdint.h>
-
-#include <transfer_list.h>
-
-/**
- * Initializes or extends the TPM event log in the transfer list.
- *
- * If an event log entry exists, attempts to resize it. Otherwise, adds a new entry.
- * Copies old data if needed. Updates free to reflect available space.
- *
- * @param tl Pointer to the transfer list header.
- * @param req_size Requested size (bytes)
- * @param free Available size (bytes)
- * @return Pointer to writable space in the log, or NULL on failure.
- */
-uint8_t *transfer_list_event_log_extend(struct transfer_list_header *tl,
- size_t req_size, size_t *free);
-
-/**
- * Finalizes the event log after writing is complete.
- *
- * Resizes the event log to match actual data written, updates checksum,
- * and flushes cache for the next stage.
- *
- * @param tl Pointer to the transfer list header.
- * @param cursor End offset of written log data.
- * @return Pointer to finalized log data (past reserved bytes), or NULL.
- */
-uint8_t *transfer_list_event_log_finish(struct transfer_list_header *tl,
- uintptr_t cursor);
-
-#define EVENT_LOG_RESERVED_BYTES U(4)
-
-#endif /* HANDOFF_H */
diff --git a/include/lib/event_log/event_log.h b/include/lib/event_log/event_log.h
deleted file mode 100644
index 964f80a..0000000
--- a/include/lib/event_log/event_log.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef EVENT_LOG_H
-#define EVENT_LOG_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include <lib/utils_def.h>
-#include <drivers/auth/crypto_mod.h>
-#include "event_handoff.h"
-#include "tcg.h"
-
-/*
- * Set Event Log debug level to one of:
- *
- * LOG_LEVEL_ERROR
- * LOG_LEVEL_INFO
- * LOG_LEVEL_WARNING
- * LOG_LEVEL_VERBOSE
- */
-#if EVENT_LOG_LEVEL == LOG_LEVEL_ERROR
-#define LOG_EVENT ERROR
-#elif EVENT_LOG_LEVEL == LOG_LEVEL_NOTICE
-#define LOG_EVENT NOTICE
-#elif EVENT_LOG_LEVEL == LOG_LEVEL_WARNING
-#define LOG_EVENT WARN
-#elif EVENT_LOG_LEVEL == LOG_LEVEL_INFO
-#define LOG_EVENT INFO
-#elif EVENT_LOG_LEVEL == LOG_LEVEL_VERBOSE
-#define LOG_EVENT VERBOSE
-#else
-#define LOG_EVENT printf
-#endif
-
-/* Number of hashing algorithms supported */
-#define HASH_ALG_COUNT 1U
-
-#define EVLOG_INVALID_ID UINT32_MAX
-
-#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
-
-typedef struct {
- unsigned int id;
- const char *name;
- unsigned int pcr;
-} event_log_metadata_t;
-
-#define ID_EVENT_SIZE (sizeof(id_event_headers_t) + \
- (sizeof(id_event_algorithm_size_t) * HASH_ALG_COUNT) + \
- sizeof(id_event_struct_data_t))
-
-#define LOC_EVENT_SIZE (sizeof(event2_header_t) + \
- sizeof(tpmt_ha) + TCG_DIGEST_SIZE + \
- sizeof(event2_data_t) + \
- sizeof(startup_locality_event_t))
-
-#define LOG_MIN_SIZE (ID_EVENT_SIZE + LOC_EVENT_SIZE)
-
-#define EVENT2_HDR_SIZE (sizeof(event2_header_t) + \
- sizeof(tpmt_ha) + TCG_DIGEST_SIZE + \
- sizeof(event2_data_t))
-
-/* Functions' declarations */
-
-/**
- * Initialize the Event Log buffer.
- *
- * Sets global pointers to manage the Event Log memory region,
- * allowing subsequent log operations to write into the buffer.
- *
- * @param[in] event_log_start Pointer to the start of the Event Log buffer.
- * @param[in] event_log_finish Pointer to the end of the buffer
- * (i.e., one byte past the last valid address).
- *
- * @return 0 on success, or -EINVAL if the input range is invalid.
- */
-int event_log_buf_init(uint8_t *event_log_start, uint8_t *event_log_finish);
-
-/**
- * Dump the contents of the Event Log.
- *
- * Outputs the raw contents of the Event Log buffer, typically
- * for debugging or audit purposes.
- *
- * @param[in] log_addr Pointer to the start of the Event Log buffer.
- * @param[in] log_size Size of the Event Log buffer in bytes.
- *
- * @return 0 on success, or a negative error code on failure.
- */
-int event_log_dump(uint8_t *log_addr, size_t log_size);
-
-/**
- * Initialize the Event Log subsystem.
- *
- * Wrapper around `event_log_buf_init()` to configure the memory range
- * for the Event Log buffer.
- *
- * @param[in] event_log_start Pointer to the start of the Event Log buffer.
- * @param[in] event_log_finish Pointer to the end of the buffer
- * (i.e., one byte past the last valid address).
- *
- * @return 0 on success, or a negative error code on failure.
- */
-int event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish);
-
-/**
- * Measure input data and log its hash to the Event Log.
- *
- * Computes the cryptographic hash of the specified data and records it
- * in the Event Log as a TCG_PCR_EVENT2 structure using event type EV_POST_CODE.
- * Useful for firmware or image attestation.
- *
- * @param[in] data_base Pointer to the base of the data to be measured.
- * @param[in] data_size Size of the data in bytes.
- * @param[in] data_id Identifier used to match against metadata.
- * @param[in] metadata_ptr Pointer to an array of event_log_metadata_t.
- *
- * @return 0 on success, or a negative error code on failure.
- */
-int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size,
- uint32_t data_id,
- const event_log_metadata_t *metadata_ptr);
-
-/**
- * Measure the input data and return its hash.
- *
- * Computes the cryptographic hash of the specified memory region using
- * the default hashing algorithm configured in the Event Log subsystem.
- *
- * @param[in] data_base Pointer to the base of the data to be measured.
- * @param[in] data_size Size of the data in bytes.
- * @param[out] hash_data Buffer to hold the resulting hash output
- * (must be at least CRYPTO_MD_MAX_SIZE bytes).
- *
- * @return 0 on success, or an error code on failure.
- */
-int event_log_measure(uintptr_t data_base, uint32_t data_size,
- unsigned char hash_data[CRYPTO_MD_MAX_SIZE]);
-
-/**
- * Record a measurement event in the Event Log.
- *
- * Writes a TCG_PCR_EVENT2 structure to the Event Log using the
- * provided hash and metadata. This function assumes the buffer
- * has enough space and that `event_log_buf_init()` has been called.
- *
- * @param[in] hash Pointer to the digest (TCG_DIGEST_SIZE bytes).
- * @param[in] event_type Type of the event, as defined in tcg.h.
- * @param[in] metadata_ptr Pointer to an event_log_metadata_t structure
- * providing event-specific context (e.g., PCR index, name).
- *
- * @return 0 on success, or -ENOMEM if the buffer has insufficient space.
- */
-int event_log_record(const uint8_t *hash, uint32_t event_type,
- const event_log_metadata_t *metadata_ptr);
-
-/**
- * Initialize the Event Log with mandatory header events.
- *
- * Writes the Specification ID (SpecID) and Startup Locality events
- * as required by the TCG PC Client Platform Firmware Profile.
- * These must be the first entries in the Event Log.
- *
- * @return 0 on success, or a negative error code on failure.
- */
-int event_log_write_header(void);
-
-/**
- * Write the SpecID event to the Event Log.
- *
- * Records the TCG_EfiSpecIDEventStruct to declare the structure
- * and supported algorithms of the Event Log format.
- *
- * @return 0 on success, or a negative error code on failure.
- */
-int event_log_write_specid_event(void);
-
-/**
- * Get the current size of the Event Log.
- *
- * Calculates how many bytes of the Event Log buffer have been used,
- * based on the current log pointer and the start of the buffer.
- *
- * @param[in] event_log_start Pointer to the start of the Event Log buffer.
- *
- * @return The number of bytes currently used in the Event Log.
- */
-size_t event_log_get_cur_size(uint8_t *event_log_start);
-
-#endif /* EVENT_LOG_H */
diff --git a/include/lib/event_log/tcg.h b/include/lib/event_log/tcg.h
deleted file mode 100644
index 653f9c2..0000000
--- a/include/lib/event_log/tcg.h
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef TCG_H
-#define TCG_H
-
-#include <stdint.h>
-#include <common/sha_common_macros.h>
-
-#define TCG_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
-#define TCG_STARTUP_LOCALITY_SIGNATURE "StartupLocality"
-
-#define TCG_SPEC_VERSION_MAJOR_TPM2 2
-#define TCG_SPEC_VERSION_MINOR_TPM2 0
-#define TCG_SPEC_ERRATA_TPM2 2
-
-/*
- * Event types
- * Ref. Table 9 Events
- * TCG PC Client Platform Firmware Profile Specification.
- */
-#define EV_PREBOOT_CERT U(0x00000000)
-#define EV_POST_CODE U(0x00000001)
-#define EV_UNUSED U(0x00000002)
-#define EV_NO_ACTION U(0x00000003)
-#define EV_SEPARATOR U(0x00000004)
-#define EV_ACTION U(0x00000005)
-#define EV_EVENT_TAG U(0x00000006)
-#define EV_S_CRTM_CONTENTS U(0x00000007)
-#define EV_S_CRTM_VERSION U(0x00000008)
-#define EV_CPU_MICROCODE U(0x00000009)
-#define EV_PLATFORM_CONFIG_FLAGS U(0x0000000A)
-#define EV_TABLE_OF_DEVICES U(0x0000000B)
-#define EV_COMPACT_HASH U(0x0000000C)
-#define EV_IPL U(0x0000000D)
-#define EV_IPL_PARTITION_DATA U(0x0000000E)
-#define EV_NONHOST_CODE U(0x0000000F)
-#define EV_NONHOST_CONFIG U(0x00000010)
-#define EV_NONHOST_INFO U(0x00000011)
-#define EV_OMIT_BOOT_DEVICE_EVENTS U(0x00000012)
-#define EV_EFI_EVENT_BASE U(0x80000000)
-#define EV_EFI_VARIABLE_DRIVER_CONFIG U(0x80000001)
-#define EV_EFI_VARIABLE_BOOT U(0x80000002)
-#define EV_EFI_BOOT_SERVICES_APPLICATION U(0x80000003)
-#define EV_EFI_BOOT_SERVICES_DRIVER U(0x80000004)
-#define EV_EFI_RUNTIME_SERVICES_DRIVER U(0x80000005)
-#define EV_EFI_GPT_EVENT U(0x80000006)
-#define EV_EFI_ACTION U(0x80000007)
-#define EV_EFI_PLATFORM_FIRMWARE_BLOB U(0x80000008)
-#define EV_EFI_HANDOFF_TABLES U(0x80000009)
-#define EV_EFI_HCRTM_EVENT U(0x80000010)
-#define EV_EFI_VARIABLE_AUTHORITY U(0x800000E0)
-
-/*
- * TPM_ALG_ID constants.
- * Ref. Table 9 - Definition of (UINT16) TPM_ALG_ID Constants
- * Trusted Platform Module Library. Part 2: Structures
- */
-#define TPM_ALG_SHA256 0x000B
-#define TPM_ALG_SHA384 0x000C
-#define TPM_ALG_SHA512 0x000D
-
-/* TCG Platform Type */
-#define PLATFORM_CLASS_CLIENT 0
-#define PLATFORM_CLASS_SERVER 1
-
-enum {
- /*
- * SRTM, BIOS, Host Platform Extensions, Embedded
- * Option ROMs and PI Drivers
- */
- PCR_0 = 0,
- /* Host Platform Configuration */
- PCR_1,
- /* UEFI driver and application Code */
- PCR_2,
- /* UEFI driver and application Configuration and Data */
- PCR_3,
- /* UEFI Boot Manager Code (usually the MBR) and Boot Attempts */
- PCR_4,
- /*
- * Boot Manager Code Configuration and Data (for use
- * by the Boot Manager Code) and GPT/Partition Table
- */
- PCR_5,
- /* Host Platform Manufacturer Specific */
- PCR_6,
- /* Secure Boot Policy */
- PCR_7,
- /* 8-15: Defined for use by the Static OS */
- PCR_8,
- /* Debug */
- PCR_16 = 16,
-
- /* D-CRTM-measurements by DRTM implementation */
- PCR_17 = 17,
- /* DCE measurements by DRTM implementation */
- PCR_18 = 18
-};
-
-#pragma pack(push, 1)
-
-/*
- * PCR Event Header
- * TCG EFI Protocol Specification
- * 5.3 Event Log Header
- */
-typedef struct {
- /* PCRIndex:
- * The PCR Index to which this event is extended
- */
- uint32_t pcr_index;
-
- /* EventType:
- * SHALL be an EV_NO_ACTION event
- */
- uint32_t event_type;
-
- /* SHALL be 20 Bytes of 0x00 */
- uint8_t digest[SHA1_DIGEST_SIZE];
-
- /* The size of the event */
- uint32_t event_size;
-
- /* SHALL be a TCG_EfiSpecIdEvent */
- uint8_t event[]; /* [event_data_size] */
-} tcg_pcr_event_t;
-
-/*
- * Log Header Entry Data
- * Ref. Table 14 TCG_EfiSpecIdEventAlgorithmSize
- * TCG PC Client Platform Firmware Profile 9.4.5.1
- */
-typedef struct {
- /* Algorithm ID (hashAlg) of the Hash used by BIOS */
- uint16_t algorithm_id;
-
- /* The size of the digest produced by the implemented Hash algorithm */
- uint16_t digest_size;
-} id_event_algorithm_size_t;
-
-/*
- * TCG_EfiSpecIdEvent structure
- * Ref. Table 15 TCG_EfiSpecIdEvent
- * TCG PC Client Platform Firmware Profile 9.4.5.1
- */
-typedef struct {
- /*
- * The NUL-terminated ASCII string "Spec ID Event03".
- * SHALL be set to {0x53, 0x70, 0x65, 0x63, 0x20, 0x49, 0x44,
- * 0x20, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x33, 0x00}.
- */
- uint8_t signature[16];
-
- /*
- * The value for the Platform Class.
- * The enumeration is defined in the TCG ACPI Specification Client
- * Common Header.
- */
- uint32_t platform_class;
-
- /*
- * The PC Client Platform Profile Specification minor version number
- * this BIOS supports.
- * Any BIOS supporting this version (2.0) MUST set this value to 0x00.
- */
- uint8_t spec_version_minor;
-
- /*
- * The PC Client Platform Profile Specification major version number
- * this BIOS supports.
- * Any BIOS supporting this version (2.0) MUST set this value to 0x02.
- */
- uint8_t spec_version_major;
-
- /*
- * The PC Client Platform Profile Specification errata version number
- * this BIOS supports.
- * Any BIOS supporting this version (2.0) MUST set this value to 0x02.
- */
- uint8_t spec_errata;
-
- /*
- * Specifies the size of the UINTN fields used in various data
- * structures used in this specification.
- * 0x01 indicates UINT32 and 0x02 indicates UINT64.
- */
- uint8_t uintn_size;
-
- /*
- * The number of Hash algorithms in the digestSizes field.
- * This field MUST be set to a value of 0x01 or greater.
- */
- uint32_t number_of_algorithms;
-
- /*
- * Each TCG_EfiSpecIdEventAlgorithmSize SHALL contain an algorithmId
- * and digestSize for each hash algorithm used in the TCG_PCR_EVENT2
- * structure, the first of which is a Hash algorithmID and the second
- * is the size of the respective digest.
- */
- id_event_algorithm_size_t digest_size[]; /* number_of_algorithms */
-} id_event_struct_header_t;
-
-typedef struct {
- /*
- * Size in bytes of the VendorInfo field.
- * Maximum value MUST be FFh bytes.
- */
- uint8_t vendor_info_size;
-
- /*
- * Provided for use by Platform Firmware implementer. The value might
- * be used, for example, to provide more detailed information about the
- * specific BIOS such as BIOS revision numbers, etc. The values within
- * this field are not standardized and are implementer-specific.
- * Platform-specific or -unique information MUST NOT be provided in
- * this field.
- *
- */
- uint8_t vendor_info[]; /* [vendorInfoSize] */
-} id_event_struct_data_t;
-
-typedef struct {
- id_event_struct_header_t struct_header;
- id_event_struct_data_t struct_data;
-} id_event_struct_t;
-
-typedef struct {
- tcg_pcr_event_t header;
- id_event_struct_header_t struct_header;
-} id_event_headers_t;
-
-/* TPMT_HA Structure */
-typedef struct {
- /* Selector of the hash contained in the digest that implies
- * the size of the digest
- */
- uint16_t algorithm_id; /* AlgorithmId */
-
- /* Digest, depends on AlgorithmId */
- uint8_t digest[]; /* Digest[] */
-} tpmt_ha;
-
-/*
- * TPML_DIGEST_VALUES Structure
- */
-typedef struct {
- /* The number of digests in the list */
- uint32_t count; /* Count */
-
- /* The list of tagged digests, as sent to the TPM as part of a
- * TPM2_PCR_Extend or as received from a TPM2_PCR_Event command
- */
- tpmt_ha digests[]; /* Digests[Count] */
-} tpml_digest_values;
-
-/*
- * TCG_PCR_EVENT2 header
- */
-typedef struct {
- /* The PCR Index to which this event was extended */
- uint32_t pcr_index; /* PCRIndex */
-
- /* Type of event */
- uint32_t event_type; /* EventType */
-
- /* Digests:
- * A counted list of tagged digests, which contain the digest of
- * the event data (or external data) for all active PCR banks
- */
- tpml_digest_values digests; /* Digests */
-} event2_header_t;
-
-typedef struct event2_data {
- /* The size of the event data */
- uint32_t event_size; /* EventSize */
-
- /* The data of the event */
- uint8_t event[]; /* Event[EventSize] */
-} event2_data_t;
-
-/*
- * Startup Locality Event
- * Ref. TCG PC Client Platform Firmware Profile 9.4.5.3
- */
-typedef struct {
- /*
- * The NUL-terminated ASCII string "StartupLocality" SHALL be
- * set to {0x53 0x74 0x61 0x72 0x74 0x75 0x70 0x4C 0x6F 0x63
- * 0x61 0x6C 0x69 0x74 0x79 0x00}
- */
- uint8_t signature[16];
-
- /* The Locality Indicator which sent the TPM2_Startup command */
- uint8_t startup_locality;
-} startup_locality_event_t;
-
-#pragma pack(pop)
-
-#endif /* TCG_H */
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index 67fd393..1675b6e 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -23,7 +23,8 @@
FFA_VERSION_1_0 = 0x10000,
FFA_VERSION_1_1 = 0x10001,
FFA_VERSION_1_2 = 0x10002,
- FFA_VERSION_COMPILED = FFA_VERSION_1_2,
+ FFA_VERSION_1_3 = 0x10003,
+ FFA_VERSION_COMPILED = FFA_VERSION_1_3,
};
#define FFA_VERSION_MBZ_BIT (1U << 31U)
diff --git a/lib/event_log/event_handoff.c b/lib/event_log/event_handoff.c
deleted file mode 100644
index 238ea27..0000000
--- a/lib/event_log/event_handoff.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2025, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stddef.h>
-
-#include <common/debug.h>
-#include <drivers/measured_boot/event_log/event_handoff.h>
-
-#include <platform_def.h>
-
-static uint8_t *get_log_ptr(struct transfer_list_entry *te, size_t offset)
-{
- uint8_t *base_ptr = transfer_list_entry_data(te);
-
- if (base_ptr == NULL) {
- return NULL;
- }
-
- return base_ptr + offset;
-}
-
-uint8_t *transfer_list_event_log_extend(struct transfer_list_header *tl,
- size_t req_size, size_t *free)
-{
- struct transfer_list_entry *existing_entry;
- struct transfer_list_entry *new_entry;
- uint8_t *old_data;
- size_t existing_offset;
- size_t old_size;
-
- if (tl == NULL || free == NULL || req_size == 0) {
- ERROR("Invalid arguments to event log extend.\n");
- return NULL;
- }
-
- existing_entry = transfer_list_find(tl, TL_TAG_TPM_EVLOG);
- existing_offset = EVENT_LOG_RESERVED_BYTES;
-
- if (existing_entry != NULL) {
- existing_offset = existing_entry->data_size;
-
- if (transfer_list_set_data_size(tl, existing_entry,
- req_size + existing_offset)) {
- VERBOSE("TPM event log entry resized: new space %zu bytes at offset %zu\n",
- req_size, existing_offset);
-
- *free = existing_entry->data_size - existing_offset;
-
- return get_log_ptr(existing_entry, existing_offset);
- }
- }
-
- /* Add new entry (resize failed or no existing entry) */
- new_entry = transfer_list_add(tl, TL_TAG_TPM_EVLOG,
- req_size + existing_offset, NULL);
-
- if (new_entry == NULL) {
- ERROR("Failed to add TPM event log entry to transfer list.\n");
- return NULL;
- }
-
- VERBOSE("New TPM event log entry added at %p\n",
- transfer_list_entry_data(new_entry));
-
- if (existing_entry != NULL) {
- old_data = transfer_list_entry_data(existing_entry);
- old_size = existing_offset;
-
- VERBOSE("Copying existing event log (%zu bytes) to new entry at %p\n",
- old_size, transfer_list_entry_data(new_entry));
-
- memmove(transfer_list_entry_data(new_entry), old_data,
- old_size);
-
- transfer_list_rem(tl, existing_entry);
- }
-
- *free = new_entry->data_size - existing_offset;
-
- return get_log_ptr(new_entry, existing_offset);
-}
-
-uint8_t *transfer_list_event_log_finish(struct transfer_list_header *tl,
- uintptr_t cursor)
-{
- uintptr_t entry_data_base;
- size_t final_log_size;
- struct transfer_list_entry *entry;
-
- entry = transfer_list_find(tl, TL_TAG_TPM_EVLOG);
- entry_data_base = (uintptr_t)transfer_list_entry_data(entry);
-
- if (cursor < entry_data_base ||
- cursor >= entry_data_base + entry->data_size) {
- ERROR("Invalid cursor: outside event log bounds.\n");
- return NULL;
- }
-
- final_log_size = cursor - entry_data_base;
-
- if (!transfer_list_set_data_size(tl, entry, final_log_size)) {
- ERROR("Unable to resize event log TE.\n");
- return NULL;
- }
-
- transfer_list_update_checksum(tl);
-
- VERBOSE("TPM event log finalized: trimmed to %zu bytes",
- final_log_size - EVENT_LOG_RESERVED_BYTES);
-
- /* Ensure changes are visible to the next stage. */
- flush_dcache_range((uintptr_t)tl, tl->size);
-
- return get_log_ptr(entry, EVENT_LOG_RESERVED_BYTES);
-}
diff --git a/lib/event_log/event_log.c b/lib/event_log/event_log.c
deleted file mode 100644
index 761ff29..0000000
--- a/lib/event_log/event_log.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <string.h>
-
-#include "crypto_mod.h"
-#include "event_log.h"
-
-#if TPM_ALG_ID == TPM_ALG_SHA512
-#define CRYPTO_MD_ID CRYPTO_MD_SHA512
-#elif TPM_ALG_ID == TPM_ALG_SHA384
-#define CRYPTO_MD_ID CRYPTO_MD_SHA384
-#elif TPM_ALG_ID == TPM_ALG_SHA256
-#define CRYPTO_MD_ID CRYPTO_MD_SHA256
-#else
-# error Invalid TPM algorithm.
-#endif /* TPM_ALG_ID */
-
-/* Running Event Log Pointer */
-static uint8_t *log_ptr;
-
-/* Pointer to the first byte past end of the Event Log buffer */
-static uintptr_t log_end;
-
-/* TCG_EfiSpecIdEvent */
-static const id_event_headers_t id_event_header = {
- .header = {
- .pcr_index = PCR_0,
- .event_type = EV_NO_ACTION,
- .digest = {0},
- .event_size = (uint32_t)(sizeof(id_event_struct_t) +
- (sizeof(id_event_algorithm_size_t) *
- HASH_ALG_COUNT))
- },
-
- .struct_header = {
- .signature = TCG_ID_EVENT_SIGNATURE_03,
- .platform_class = PLATFORM_CLASS_CLIENT,
- .spec_version_minor = TCG_SPEC_VERSION_MINOR_TPM2,
- .spec_version_major = TCG_SPEC_VERSION_MAJOR_TPM2,
- .spec_errata = TCG_SPEC_ERRATA_TPM2,
- .uintn_size = (uint8_t)(sizeof(unsigned int) /
- sizeof(uint32_t)),
- .number_of_algorithms = HASH_ALG_COUNT
- }
-};
-
-static const event2_header_t locality_event_header = {
- /*
- * All EV_NO_ACTION events SHALL set
- * TCG_PCR_EVENT2.pcrIndex = 0, unless otherwise specified
- */
- .pcr_index = PCR_0,
-
- /*
- * All EV_NO_ACTION events SHALL set
- * TCG_PCR_EVENT2.eventType = 03h
- */
- .event_type = EV_NO_ACTION,
-
- /*
- * All EV_NO_ACTION events SHALL set TCG_PCR_EVENT2.digests to all
- * 0x00's for each allocated Hash algorithm
- */
- .digests = {
- .count = HASH_ALG_COUNT
- }
-};
-
-int event_log_record(const uint8_t *hash, uint32_t event_type,
- const event_log_metadata_t *metadata_ptr)
-{
- void *ptr = log_ptr;
- uint32_t name_len = 0U;
-
- /* event_log_buf_init() must have been called prior to this. */
- if (hash == NULL || metadata_ptr == NULL || log_ptr == NULL) {
- return -EINVAL;
- }
-
- if (metadata_ptr->name != NULL) {
- name_len = (uint32_t)strlen(metadata_ptr->name) + 1U;
- }
-
- /* Check for space in Event Log buffer */
- if (((uintptr_t)ptr + (uint32_t)EVENT2_HDR_SIZE + name_len) > log_end) {
- return -ENOMEM;
- }
-
- /*
- * As per TCG specifications, firmware components that are measured
- * into PCR[0] must be logged in the event log using the event type
- * EV_POST_CODE.
- */
- /* TCG_PCR_EVENT2.PCRIndex */
- ((event2_header_t *)ptr)->pcr_index = metadata_ptr->pcr;
-
- /* TCG_PCR_EVENT2.EventType */
- ((event2_header_t *)ptr)->event_type = event_type;
-
- /* TCG_PCR_EVENT2.Digests.Count */
- ptr = (uint8_t *)ptr + offsetof(event2_header_t, digests);
- ((tpml_digest_values *)ptr)->count = HASH_ALG_COUNT;
-
- /* TCG_PCR_EVENT2.Digests[] */
- ptr = (uint8_t *)((uintptr_t)ptr +
- offsetof(tpml_digest_values, digests));
-
- /* TCG_PCR_EVENT2.Digests[].AlgorithmId */
- ((tpmt_ha *)ptr)->algorithm_id = TPM_ALG_ID;
-
- /* TCG_PCR_EVENT2.Digests[].Digest[] */
- ptr = (uint8_t *)((uintptr_t)ptr + offsetof(tpmt_ha, digest));
-
- /* Copy digest */
- (void)memcpy(ptr, (const void *)hash, TCG_DIGEST_SIZE);
-
- /* TCG_PCR_EVENT2.EventSize */
- ptr = (uint8_t *)((uintptr_t)ptr + TCG_DIGEST_SIZE);
- ((event2_data_t *)ptr)->event_size = name_len;
-
- /* Copy event data to TCG_PCR_EVENT2.Event */
- if (metadata_ptr->name != NULL) {
- (void)memcpy((void *)(((event2_data_t *)ptr)->event),
- (const void *)metadata_ptr->name, name_len);
- }
-
- /* End of event data */
- log_ptr = (uint8_t *)((uintptr_t)ptr +
- offsetof(event2_data_t, event) + name_len);
-
- return 0;
-}
-
-int event_log_buf_init(uint8_t *event_log_start, uint8_t *event_log_finish)
-{
- if (event_log_start == NULL || event_log_finish == NULL ||
- event_log_start > event_log_finish) {
- return -EINVAL;
- }
-
- log_ptr = event_log_start;
- log_end = (uintptr_t)event_log_finish;
-
- return 0;
-}
-
-int event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish)
-{
- return event_log_buf_init(event_log_start, event_log_finish);
-}
-
-int event_log_write_specid_event(void)
-{
- void *ptr;
-
- /* event_log_buf_init() must have been called prior to this. */
- if (log_ptr == NULL) {
- return -EFAULT;
- }
-
- if (((uintptr_t)log_ptr + ID_EVENT_SIZE) > log_end) {
- return -ENOMEM;
- }
-
- ptr = log_ptr;
-
- /*
- * Add Specification ID Event first
- *
- * Copy TCG_EfiSpecIDEventStruct structure header
- */
- (void)memcpy(ptr, (const void *)&id_event_header,
- sizeof(id_event_header));
- ptr = (uint8_t *)((uintptr_t)ptr + sizeof(id_event_header));
-
- /* TCG_EfiSpecIdEventAlgorithmSize structure */
- ((id_event_algorithm_size_t *)ptr)->algorithm_id = TPM_ALG_ID;
- ((id_event_algorithm_size_t *)ptr)->digest_size = TCG_DIGEST_SIZE;
- ptr = (uint8_t *)((uintptr_t)ptr + sizeof(id_event_algorithm_size_t));
-
- /*
- * TCG_EfiSpecIDEventStruct.vendorInfoSize
- * No vendor data
- */
- ((id_event_struct_data_t *)ptr)->vendor_info_size = 0;
- log_ptr = (uint8_t *)((uintptr_t)ptr +
- offsetof(id_event_struct_data_t, vendor_info));
-
- return 0;
-}
-
-int event_log_write_header(void)
-{
- const char locality_signature[] = TCG_STARTUP_LOCALITY_SIGNATURE;
- void *ptr;
- int rc;
-
- rc = event_log_write_specid_event();
- if (rc < 0) {
- return rc;
- }
-
- if (((uintptr_t)log_ptr + LOC_EVENT_SIZE) > log_end) {
- return -ENOMEM;
- }
-
- ptr = log_ptr;
-
- /*
- * The Startup Locality event should be placed in the log before
- * any event which extends PCR[0].
- *
- * Ref. TCG PC Client Platform Firmware Profile 9.4.5.3
- */
-
- /* Copy Startup Locality Event Header */
- (void)memcpy(ptr, (const void *)&locality_event_header,
- sizeof(locality_event_header));
- ptr = (uint8_t *)((uintptr_t)ptr + sizeof(locality_event_header));
-
- /* TCG_PCR_EVENT2.Digests[].AlgorithmId */
- ((tpmt_ha *)ptr)->algorithm_id = TPM_ALG_ID;
-
- /* TCG_PCR_EVENT2.Digests[].Digest[] */
- (void)memset(&((tpmt_ha *)ptr)->digest, 0, TCG_DIGEST_SIZE);
- ptr = (uint8_t *)((uintptr_t)ptr +
- offsetof(tpmt_ha, digest) + TCG_DIGEST_SIZE);
-
- /* TCG_PCR_EVENT2.EventSize */
- ((event2_data_t *)ptr)->event_size =
- (uint32_t)sizeof(startup_locality_event_t);
- ptr = (uint8_t *)((uintptr_t)ptr + offsetof(event2_data_t, event));
-
- /* TCG_EfiStartupLocalityEvent.Signature */
- (void)memcpy(ptr, (const void *)locality_signature,
- sizeof(TCG_STARTUP_LOCALITY_SIGNATURE));
-
- /*
- * TCG_EfiStartupLocalityEvent.StartupLocality = 0:
- * the platform's boot firmware
- */
- ((startup_locality_event_t *)ptr)->startup_locality = 0U;
- log_ptr = (uint8_t *)((uintptr_t)ptr + sizeof(startup_locality_event_t));
-
- return 0;
-}
-
-int event_log_measure(uintptr_t data_base, uint32_t data_size,
- unsigned char hash_data[CRYPTO_MD_MAX_SIZE])
-{
- /* Calculate hash */
- return crypto_mod_calc_hash(CRYPTO_MD_ID,
- (void *)data_base, data_size, hash_data);
-}
-
-int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size,
- uint32_t data_id,
- const event_log_metadata_t *metadata_ptr)
-{
- unsigned char hash_data[CRYPTO_MD_MAX_SIZE];
- int rc;
-
- if (metadata_ptr == NULL) {
- return -EINVAL;
- }
-
- /* Get the metadata associated with this image. */
- while (metadata_ptr->id != data_id) {
- if (metadata_ptr->id == EVLOG_INVALID_ID) {
- return -EINVAL;
- }
-
- metadata_ptr++;
- }
-
- /* Measure the payload with algorithm selected by EventLog driver */
- rc = event_log_measure(data_base, data_size, hash_data);
- if (rc != 0) {
- return rc;
- }
-
- rc = event_log_record(hash_data, EV_POST_CODE, metadata_ptr);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
-}
-
-size_t event_log_get_cur_size(uint8_t *event_log_start)
-{
- assert(event_log_start != NULL);
- assert(log_ptr >= event_log_start);
-
- return (size_t)((uintptr_t)log_ptr - (uintptr_t)event_log_start);
-}
diff --git a/lib/event_log/event_log.mk b/lib/event_log/event_log.mk
index df55c62..ae701c1 100644
--- a/lib/event_log/event_log.mk
+++ b/lib/event_log/event_log.mk
@@ -4,51 +4,11 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-# Path to library sources
-EVENT_LOG_SRC_DIR := lib/event_log/
+LIBEVLOG_PATH ?= contrib/libeventlog
-# Default log level to dump the event log (LOG_LEVEL_INFO)
-EVENT_LOG_LEVEL ?= 40
+EVENT_LOG_INCLUDES += -I$(LIBEVLOG_PATH)/include \
+ -I$(LIBEVLOG_PATH)/include/private
-EVENT_LOG_SOURCES := ${EVENT_LOG_SRC_DIR}event_print.c
-INCLUDES += -Iinclude/lib/event_log \
- -Iinclude/drivers/auth
-
-ifdef CRYPTO_SUPPORT
-# Measured Boot hash algorithm.
-# SHA-256 (or stronger) is required for all devices that are TPM 2.0 compliant.
-ifdef TPM_HASH_ALG
- $(warning "TPM_HASH_ALG is deprecated. Please use MBOOT_EL_HASH_ALG instead.")
- MBOOT_EL_HASH_ALG := ${TPM_HASH_ALG}
-else
- MBOOT_EL_HASH_ALG := sha256
-endif
-
-ifeq (${MBOOT_EL_HASH_ALG}, sha512)
- TPM_ALG_ID := TPM_ALG_SHA512
- TCG_DIGEST_SIZE := 64U
-else ifeq (${MBOOT_EL_HASH_ALG}, sha384)
- TPM_ALG_ID := TPM_ALG_SHA384
- TCG_DIGEST_SIZE := 48U
-else
- TPM_ALG_ID := TPM_ALG_SHA256
- TCG_DIGEST_SIZE := 32U
-endif #MBOOT_EL_HASH_ALG
-
-# Set definitions for event log library.
-$(eval $(call add_define,TFTF_DEFINES,TPM_ALG_ID))
-$(eval $(call add_define,TFTF_DEFINES,EVENT_LOG_LEVEL))
-$(eval $(call add_define,TFTF_DEFINES,TCG_DIGEST_SIZE))
-
-EVENT_LOG_SOURCES := ${EVENT_LOG_SRC_DIR}event_log.c
-
-INCLUDES += -Iinclude/lib/event_log \
- -Iinclude/drivers/auth
-
-ifeq (${TRANSFER_LIST}, 1)
-EVENT_LOG_SOURCES += ${EVENT_LOG_SRC_DIR}/event_handoff.c
-INCLUDES += -Iinclude/lib
-endif
-
-endif
+EVENT_LOG_SOURCES := $(LIBEVLOG_PATH)/src/event_print.c \
+ $(LIBEVLOG_PATH)/src/digest.c
diff --git a/lib/event_log/event_print.c b/lib/event_log/event_print.c
deleted file mode 100644
index 234a694..0000000
--- a/lib/event_log/event_print.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <errno.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <common/debug.h>
-#include "event_log.h"
-
-/**
- * Print a TCG_EfiSpecIDEventStruct entry from the event log.
- *
- * This function extracts and prints a TCG_EfiSpecIDEventStruct
- * entry from the event log for debugging or auditing purposes.
- *
- * @param[in,out] log_addr Pointer to the current position in the Event Log.
- * Updated to the next entry after processing.
- * @param[in,out] log_size Pointer to the remaining Event Log size.
- * Updated to reflect the remaining bytes.
- *
- * @return 0 on success, or a negative error code on failure.
- */
-static int event_log_print_id_event(uint8_t **log_addr, size_t *log_size)
-{
- unsigned int i;
- uint8_t info_size, *info_size_ptr;
- void *ptr = *log_addr;
- id_event_headers_t *event = (id_event_headers_t *)ptr;
- id_event_algorithm_size_t *alg_ptr;
- uint32_t event_size, number_of_algorithms;
- size_t digest_len;
- const uint8_t *end_ptr = (uint8_t *)((uintptr_t)*log_addr + *log_size);
-
- if (*log_size < sizeof(id_event_headers_t)) {
- return -EINVAL;
- }
-
- /* The fields of the event log header are defined to be PCRIndex of 0,
- * EventType of EV_NO_ACTION, Digest of 20 bytes of 0, and
- * Event content defined as TCG_EfiSpecIDEventStruct.
- */
- LOG_EVENT("TCG_EfiSpecIDEvent:\n");
- LOG_EVENT(" PCRIndex : %u\n", event->header.pcr_index);
- if (event->header.pcr_index != (uint32_t)PCR_0) {
- return -EINVAL;
- }
-
- LOG_EVENT(" EventType : %u\n", event->header.event_type);
- if (event->header.event_type != EV_NO_ACTION) {
- return -EINVAL;
- }
-
- LOG_EVENT(" Digest :");
- for (i = 0U; i < sizeof(event->header.digest); ++i) {
- uint8_t val = event->header.digest[i];
-
- (void)printf(" %02x", val);
- if ((i & U(0xF)) == 0U) {
- (void)printf("\n");
- LOG_EVENT("\t\t :");
- }
- }
-
- if ((i & U(0xF)) != 0U) {
- (void)printf("\n");
- }
-
- /* EventSize */
- event_size = event->header.event_size;
- LOG_EVENT(" EventSize : %u\n", event_size);
-
- LOG_EVENT(" Signature : %s\n",
- event->struct_header.signature);
- LOG_EVENT(" PlatformClass : %u\n",
- event->struct_header.platform_class);
- LOG_EVENT(" SpecVersion : %u.%u.%u\n",
- event->struct_header.spec_version_major,
- event->struct_header.spec_version_minor,
- event->struct_header.spec_errata);
- LOG_EVENT(" UintnSize : %u\n",
- event->struct_header.uintn_size);
-
- /* NumberOfAlgorithms */
- number_of_algorithms = event->struct_header.number_of_algorithms;
- LOG_EVENT(" NumberOfAlgorithms : %u\n", number_of_algorithms);
-
- /* Address of DigestSizes[] */
- alg_ptr = event->struct_header.digest_size;
-
- /* Size of DigestSizes[] */
- digest_len = number_of_algorithms * sizeof(id_event_algorithm_size_t);
- if (digest_len > (uintptr_t)end_ptr - (uintptr_t)alg_ptr) {
- return -EFAULT;
- }
-
- LOG_EVENT(" DigestSizes :\n");
- for (i = 0U; i < number_of_algorithms; ++i) {
- LOG_EVENT(" #%u AlgorithmId : SHA", i);
- uint16_t algorithm_id = alg_ptr[i].algorithm_id;
-
- switch (algorithm_id) {
- case TPM_ALG_SHA256:
- (void)printf("256\n");
- break;
- case TPM_ALG_SHA384:
- (void)printf("384\n");
- break;
- case TPM_ALG_SHA512:
- (void)printf("512\n");
- break;
- default:
- (void)printf("?\n");
- ERROR("Algorithm 0x%x not found\n", algorithm_id);
- return -ENOENT;
- }
-
- LOG_EVENT(" DigestSize : %u\n",
- alg_ptr[i].digest_size);
- }
-
- /* Address of VendorInfoSize */
- info_size_ptr = (uint8_t *)((uintptr_t)alg_ptr + digest_len);
- if ((uintptr_t)info_size_ptr > (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- info_size = *info_size_ptr++;
- LOG_EVENT(" VendorInfoSize : %u\n", info_size);
-
- /* Check VendorInfo end address */
- if (((uintptr_t)info_size_ptr + info_size) > (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- /* Check EventSize */
- if (event_size !=
- (sizeof(id_event_struct_t) + digest_len + info_size)) {
- return -EFAULT;
- }
-
- if (info_size != 0U) {
- LOG_EVENT(" VendorInfo :");
- for (i = 0U; i < info_size; ++i) {
- (void)printf(" %02x", *info_size_ptr++);
- }
- (void)printf("\n");
- }
-
- *log_size -= (uintptr_t)info_size_ptr - (uintptr_t)*log_addr;
- *log_addr = info_size_ptr;
-
- return 0;
-}
-
-/**
- * Print a TCG_PCR_EVENT2 entry from the event log.
- *
- * This function extracts and prints a TCG_PCR_EVENT2 structure
- * from the event log for debugging or auditing purposes.
- *
- * @param[in,out] log_addr Pointer to the current position in the Event Log.
- * Updated to the next entry after processing.
- * @param[in,out] log_size Pointer to the remaining Event Log size.
- * Updated to reflect the remaining bytes.
- *
- * @return 0 on success, or a negative error code on failure.
- */
-static int event_log_print_pcr_event2(uint8_t **log_addr, size_t *log_size)
-{
- uint32_t event_size, count;
- size_t sha_size, digests_size = 0U;
- void *ptr = *log_addr;
- const uint8_t *end_ptr = (uint8_t *)((uintptr_t)*log_addr + *log_size);
-
- if (*log_size < sizeof(event2_header_t)) {
- return -EINVAL;
- }
-
- LOG_EVENT("PCR_Event2:\n");
- LOG_EVENT(" PCRIndex : %u\n",
- ((event2_header_t *)ptr)->pcr_index);
- LOG_EVENT(" EventType : %u\n",
- ((event2_header_t *)ptr)->event_type);
-
- count = ((event2_header_t *)ptr)->digests.count;
- if (count < 1U) {
- LOG_EVENT("Invalid Digests Count : %u\n", count);
- return -EINVAL;
- }
-
- LOG_EVENT(" Digests Count : %u\n", count);
-
- /* Address of TCG_PCR_EVENT2.Digests[] */
- ptr = (uint8_t *)ptr + sizeof(event2_header_t);
- if ((uintptr_t)ptr > (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- for (unsigned int i = 0U; i < count; ++i) {
- /* Check AlgorithmId address */
- if (((uintptr_t)ptr + offsetof(tpmt_ha, digest)) >
- (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- LOG_EVENT(" #%u AlgorithmId : SHA", i);
- switch (((tpmt_ha *)ptr)->algorithm_id) {
- case TPM_ALG_SHA256:
- sha_size = SHA256_DIGEST_SIZE;
- (void)printf("256\n");
- break;
- case TPM_ALG_SHA384:
- sha_size = SHA384_DIGEST_SIZE;
- (void)printf("384\n");
- break;
- case TPM_ALG_SHA512:
- sha_size = SHA512_DIGEST_SIZE;
- (void)printf("512\n");
- break;
- default:
- (void)printf("?\n");
- printf("Algorithm 0x%x not found\n",
- ((tpmt_ha *)ptr)->algorithm_id);
- return -ENOENT;
- }
-
- /* End of Digest[] */
- ptr = (uint8_t *)((uintptr_t)ptr + offsetof(tpmt_ha, digest));
- if (((uintptr_t)ptr + sha_size) > (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- /* Total size of all digests */
- digests_size += sha_size;
-
- LOG_EVENT(" Digest :");
- for (unsigned int j = 0U; j < sha_size; ++j) {
- (void)printf(" %02x", *(uint8_t *)ptr++);
- if ((j & U(0xF)) == U(0xF)) {
- (void)printf("\n");
- if (j < (sha_size - 1U)) {
- LOG_EVENT("\t\t :");
- }
- }
- }
- }
-
- /* TCG_PCR_EVENT2.EventSize */
- if (((uintptr_t)ptr + offsetof(event2_data_t, event)) >
- (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- event_size = ((event2_data_t *)ptr)->event_size;
- LOG_EVENT(" EventSize : %u\n", event_size);
-
- /* Address of TCG_PCR_EVENT2.Event[EventSize] */
- ptr = (uint8_t *)((uintptr_t)ptr + offsetof(event2_data_t, event));
-
- /* End of TCG_PCR_EVENT2.Event[EventSize] */
- if (((uintptr_t)ptr + event_size) > (uintptr_t)end_ptr) {
- return -EFAULT;
- }
-
- if ((event_size == sizeof(startup_locality_event_t)) &&
- (strcmp((const char *)ptr, TCG_STARTUP_LOCALITY_SIGNATURE) == 0)) {
- LOG_EVENT(" Signature : %s\n",
- ((startup_locality_event_t *)ptr)->signature);
- LOG_EVENT(" StartupLocality : %u\n",
- ((startup_locality_event_t *)ptr)->startup_locality);
- } else {
- LOG_EVENT(" Event : %s\n", (uint8_t *)ptr);
- }
-
- *log_size -= (uintptr_t)ptr + event_size - (uintptr_t)*log_addr;
- *log_addr = (uint8_t *)ptr + event_size;
-
- return 0;
-}
-
-int event_log_dump(uint8_t *log_addr, size_t log_size)
-{
- int rc;
-
- if (log_addr == NULL) {
- return -EINVAL;
- }
-
- /* Print TCG_EfiSpecIDEvent */
- rc = event_log_print_id_event(&log_addr, &log_size);
-
- if (rc < 0) {
- return rc;
- }
-
- while (log_size != 0U) {
- rc = event_log_print_pcr_event2(&log_addr, &log_size);
- if (rc < 0) {
- return rc;
- }
- }
- return 0;
-}
diff --git a/lib/libtl/libtl.mk b/lib/libtl/libtl.mk
index 4e685d2..e400c0d 100644
--- a/lib/libtl/libtl.mk
+++ b/lib/libtl/libtl.mk
@@ -11,5 +11,6 @@
LIBTL_SOURCES += $(addprefix ${LIBTL_PATH}/src/generic/, \
transfer_list.c \
+ tpm_event_log.c \
logging.c \
)
diff --git a/plat/xilinx/versal_net/tests_to_skip.txt b/plat/xilinx/versal_net/tests_to_skip.txt
index f9668ee..c3d5d4e 100644
--- a/plat/xilinx/versal_net/tests_to_skip.txt
+++ b/plat/xilinx/versal_net/tests_to_skip.txt
@@ -70,3 +70,6 @@
#TESTS: debugfs
DebugFS
+
+#TESTS: SDEI
+SDEI/Test binding more events than are available in the PPI range
diff --git a/spm/cactus/cactus_tests/cactus_tests_smmuv3.c b/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
index 5308d93..ad98006 100644
--- a/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
+++ b/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -24,6 +24,30 @@
#define NO_SUBSTREAMID (0xFFFFFFFFU)
#define LOOP_COUNT (5000U)
+/*
+ * This function will configure an SMMUv3TestEngine to make access to the Secure
+ * PAS. To do that it uses a regularly (non-PCIe) connected device in place of
+ * the PL 330 cluster. This is non standard and must be enabled on the FVP
+ * commandline with:
+ * -C pci.dma330x4.use_smmuv3testengine_not_dmacs=1
+ *
+ * Some notes about the model:
+ *
+ * A DMAC is a DMA-Controller a DMA-330 (a.k.a. DMAC_PL_330, a.k.a. PL_330). It
+ * is an ancient (32b) device that has its own little instruction set and
+ * several concurrent threads of execution that can be used to move memory
+ * about.
+ *
+ * The original DMAC cluster was put in so that it provides an easy work-load to
+ * program for the SMMU rather than a full PCIe device.
+ *
+ * The PCIe block diagram is not quite right depending on your point of view.
+ * The PCIe Subsystem is above the SMMU – i.e. all accesses made by PCIe devices
+ * go through the SMMU.
+ *
+ * The DMAC cluster is also above the same SMMU and so is (mostly)
+ * indistinguishable from the PCIe device traffic.
+ */
static bool run_testengine(uint32_t operation, uintptr_t source_addr,
uintptr_t target_addr, size_t transfer_size,
uint32_t attributes)
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
index a8130c6..cae5884 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "Base-1";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0x092358d1 0xb94723f0 0x64447c82 0xc88f57f5>;
id = <2>;
auxiliary-id = <0xae>;
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
index 6c0ea57..af0d4a7 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "Base-1";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0x735cb579 0xb9448c1d 0xe1619385 0xd2d80a77>;
id = <3>;
auxiliary-id = <0xae>;
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus.dts b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
index 03a7d17..3ca54f4 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "Base-1";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0x1e67b5b4 0xe14f904a 0x13fb1fb8 0xcbdae1da>;
id = <1>;
auxiliary-id = <0xae>;
@@ -114,10 +114,10 @@
/*
* SMMUv3TestEngine is a DMA IP modeled in the
* Base-RevC FVP Model.
- * User Frame: 0x2bfe0000
- * Privileged Frame: 0x2bff0000
+ * User Frame: 0x2b500000
+ * Privileged Frame: 0x25100000
*/
- base-address = <0x00000000 0x2bfe0000>;
+ base-address = <0x00000000 0x2b500000>;
pages-count = <32>; /* Two 64KB pages */
attributes = <0x3>; /* read-write */
smmu-id = <0>;
diff --git a/spm/cactus/plat/arm/fvp/include/sp_platform_def.h b/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
index 390294f..173f4fd 100644
--- a/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
+++ b/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -32,8 +32,8 @@
#define PLAT_CACTUS_MEMCPY_RANGE ULL(0x8000)
/* Base address of user and PRIV frames in SMMUv3TestEngine */
-#define USR_BASE_FRAME ULL(0x2BFE0000)
-#define PRIV_BASE_FRAME ULL(0x2BFF0000)
+#define USR_BASE_FRAME ULL(0x2B500000)
+#define PRIV_BASE_FRAME ULL(0x2B510000)
/* Base address for memory sharing tests. */
#define CACTUS_SP1_MEM_SHARE_BASE 0x7500000
diff --git a/spm/cactus/plat/arm/tc/fdts/cactus-secondary.dts b/spm/cactus/plat/arm/tc/fdts/cactus-secondary.dts
index aa48e29..f883ee8 100644
--- a/spm/cactus/plat/arm/tc/fdts/cactus-secondary.dts
+++ b/spm/cactus/plat/arm/tc/fdts/cactus-secondary.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "cactus-2";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0x092358d1 0xb94723f0 0x64447c82 0xc88f57f5>;
id = <2>;
execution-ctx-count = <8>;
diff --git a/spm/cactus/plat/arm/tc/fdts/cactus-tertiary.dts b/spm/cactus/plat/arm/tc/fdts/cactus-tertiary.dts
index 145be36..0523bae 100644
--- a/spm/cactus/plat/arm/tc/fdts/cactus-tertiary.dts
+++ b/spm/cactus/plat/arm/tc/fdts/cactus-tertiary.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "cactus-3";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0x735cb579 0xb9448c1d 0xe1619385 0xd2d80a77>;
id = <3>;
execution-ctx-count = <1>;
diff --git a/spm/cactus/plat/arm/tc/fdts/cactus.dts b/spm/cactus/plat/arm/tc/fdts/cactus.dts
index a4c71fe..4bde6e2 100644
--- a/spm/cactus/plat/arm/tc/fdts/cactus.dts
+++ b/spm/cactus/plat/arm/tc/fdts/cactus.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "cactus-1";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0x1e67b5b4 0xe14f904a 0x13fb1fb8 0xcbdae1da>;
id = <1>;
execution-ctx-count = <8>;
diff --git a/spm/common/sp_tests/sp_test_ffa.c b/spm/common/sp_tests/sp_test_ffa.c
index fcc4780..951e44b 100644
--- a/spm/common/sp_tests/sp_test_ffa.c
+++ b/spm/common/sp_tests/sp_test_ffa.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2024, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -15,10 +15,6 @@
#include <spm_common.h>
#include <lib/libc/string.h>
-/* FFA version test helpers */
-#define FFA_MAJOR 1U
-#define FFA_MINOR 2U
-
static uint32_t spm_version;
static const struct ffa_uuid sp_uuids[] = {
@@ -207,9 +203,8 @@
struct ffa_value ret = ffa_version(FFA_VERSION_COMPILED);
spm_version = (uint32_t)ret.fid;
- EXPECT(spm_version, FFA_VERSION_COMPILED);
- bool compatible = ffa_versions_are_compatible(spm_version, FFA_VERSION_COMPILED);
+ bool compatible = ffa_versions_are_compatible(FFA_VERSION_COMPILED, spm_version);
INFO("Test FFA_VERSION. Return %u.%u; Compatible: %i\n",
ffa_version_get_major(spm_version),
diff --git a/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel0.dts b/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel0.dts
index f885c5f..c466356 100644
--- a/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel0.dts
+++ b/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel0.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2022-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "ivy-sel0-fvp";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0xd883baea 0xaf4eafba 0xfdf74481 0xa744e5cb>;
execution-ctx-count = <1>;
exception-level = <1>; /* S-EL0 */
diff --git a/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel1.dts b/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel1.dts
index 1dfca01..35af412 100644
--- a/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel1.dts
+++ b/spm/ivy/app/plat/arm/fvp/fdts/ivy-sel1.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -16,7 +16,7 @@
/* Properties */
description = "ivy-sel1-fvp";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0xd883baea 0xaf4eafba 0xfdf74481 0xa744e5cb>;
execution-ctx-count = <1>;
exception-level = <2>; /* S-EL1 */
diff --git a/spm/ivy/app/plat/arm/tc/fdts/ivy-sel0.dts b/spm/ivy/app/plat/arm/tc/fdts/ivy-sel0.dts
index 1dd3b61..2358393 100644
--- a/spm/ivy/app/plat/arm/tc/fdts/ivy-sel0.dts
+++ b/spm/ivy/app/plat/arm/tc/fdts/ivy-sel0.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2022-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -14,7 +14,7 @@
/* Properties */
description = "ivy-sel0-tc";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0xd883baea 0xaf4eafba 0xfdf74481 0xa744e5cb>;
execution-ctx-count = <1>;
exception-level = <1>; /* S-EL0 */
diff --git a/spm/ivy/app/plat/arm/tc/fdts/ivy-sel1.dts b/spm/ivy/app/plat/arm/tc/fdts/ivy-sel1.dts
index bcb3162..716d8dd 100644
--- a/spm/ivy/app/plat/arm/tc/fdts/ivy-sel1.dts
+++ b/spm/ivy/app/plat/arm/tc/fdts/ivy-sel1.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
/* Properties */
description = "ivy-sel1-tc";
- ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
+ ffa-version = <0x00010003>; /* 31:16 - Major, 15:0 - Minor */
uuid = <0xd883baea 0xaf4eafba 0xfdf74481 0xa744e5cb>;
execution-ctx-count = <1>;
exception-level = <2>; /* S-EL1 */
diff --git a/tftf/framework/main.c b/tftf/framework/main.c
index 0ac23b4..0ae03e5 100644
--- a/tftf/framework/main.c
+++ b/tftf/framework/main.c
@@ -23,9 +23,6 @@
#include <tftf.h>
#include <tftf_lib.h>
#include <timer.h>
-#if TRANSFER_LIST
-#include <transfer_list.h>
-#endif
#define MIN_RETRY_TO_POWER_ON_LEAD_CPU 10
diff --git a/tftf/tests/misc_tests/test_firmware_handoff.c b/tftf/tests/misc_tests/test_firmware_handoff.c
index 026f057..8d702d6 100644
--- a/tftf/tests/misc_tests/test_firmware_handoff.c
+++ b/tftf/tests/misc_tests/test_firmware_handoff.c
@@ -11,7 +11,7 @@
#include <tftf_lib.h>
#include <transfer_list.h>
-#include "event_log.h"
+#include "event_print.h"
extern u_register_t hw_config_base;
extern u_register_t ns_tl;
diff --git a/tftf/tests/neg_scenario_tests/neg_scenario_test_infra.c b/tftf/tests/neg_scenario_tests/neg_scenario_test_infra.c
new file mode 100644
index 0000000..e45a0b0
--- /dev/null
+++ b/tftf/tests/neg_scenario_tests/neg_scenario_test_infra.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2025, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "neg_scenario_test_infra.h"
+
+/*
+ Temporary variables to speed up the authentication parameters search. These
+ variables are assigned once during the integrity check and used any time an
+ authentication parameter is requested, so we do not have to parse the image
+ again
+ */
+
+
+int get_pubKey_from_cert(void *cert, size_t cert_len, void **returnPtr) {
+
+ int ret;
+ size_t len;
+ unsigned char *p, *end, *crt_end, *pk_end;
+ mbedtls_asn1_buf pk;
+
+ /*
+ * The unique ASN.1 DER encoding of [0] EXPLICIT INTEGER { v3(2} }.
+ */
+ const char v3[] = {
+ /* The outer CONTEXT SPECIFIC 0 tag */
+ MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_CONTEXT_SPECIFIC | 0,
+ /* The number bytes used to encode the inner INTEGER */
+ 3,
+ /* The tag of the inner INTEGER */
+ MBEDTLS_ASN1_INTEGER,
+ /* The number of bytes needed to represent 2 */
+ 1,
+ /* The actual value 2 */
+ 2,
+ };
+
+ p = (unsigned char *)cert;
+ len = cert_len;
+ crt_end = p + len;
+ end = crt_end;
+
+ /*
+ * Certificate ::= SEQUENCE {
+ * tbsCertificate TBSCertificate,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signatureValue BIT STRING }
+ */
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if ((ret != 0) || ((p + len) != end))
+ return -1;
+
+ /*
+ * TBSCertificate ::= SEQUENCE {
+ */
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if (ret != 0)
+ return -1;
+
+ end = p + len;
+
+ /*
+ * Version ::= [0] EXPLICIT INTEGER { v1(0), v2(1), v3(2) }
+ * -- only v3 accepted
+ */
+ if (((end - p) <= (ptrdiff_t)sizeof(v3)) ||
+ (memcmp(p, v3, sizeof(v3)) != 0)) {
+ return -1;
+ }
+ p += sizeof(v3);
+
+ /*
+ * CertificateSerialNumber ::= INTEGER
+ */
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_INTEGER);
+ if (ret != 0)
+ return -1;
+
+ p += len;
+
+ /*
+ * signature AlgorithmIdentifier
+ */
+
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if (ret != 0)
+ return -1;
+
+ p += len;
+
+ /*
+ * issuer Name
+ */
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if (ret != 0)
+ return -1;
+
+ p += len;
+
+ /*
+ * Validity ::= SEQUENCE {
+ * notBefore Time,
+ * notAfter Time }
+ *
+ */
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if (ret != 0)
+ return -1;
+
+ p += len;
+
+ /*
+ * subject Name
+ */
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if (ret != 0)
+ return -1;
+
+ p += len;
+
+ /*
+ * SubjectPublicKeyInfo
+ */
+ pk.p = p;
+ ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE);
+ if (ret != 0)
+ return -1;
+
+ pk_end = p + len;
+ pk.len = pk_end - pk.p;
+
+ *returnPtr = p;
+
+ return 0;
+}
diff --git a/tftf/tests/neg_scenario_tests/neg_scenario_test_infra.h b/tftf/tests/neg_scenario_tests/neg_scenario_test_infra.h
new file mode 100644
index 0000000..428f86b
--- /dev/null
+++ b/tftf/tests/neg_scenario_tests/neg_scenario_test_infra.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2025, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <string.h>
+#include <mbedtls/oid.h>
+#include <mbedtls/platform.h>
+#include <firmware_image_package.h>
+
+/*
+ cert:
+ cert_len:
+ returnPtr: ptr to pubKey in cert
+
+ return 0 upon success, -1 on fail
+*/
+int get_pubKey_from_cert(void *cert, size_t cert_len, void **returnPtr);
diff --git a/tftf/tests/neg_scenario_tests/test_invalid_rotpk.c b/tftf/tests/neg_scenario_tests/test_invalid_rotpk.c
new file mode 100644
index 0000000..9f465a0
--- /dev/null
+++ b/tftf/tests/neg_scenario_tests/test_invalid_rotpk.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2025, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include <uuid.h>
+#include <io_storage.h>
+#include <platform.h>
+#include <platform_def.h>
+#include <psci.h>
+#include <smccc.h>
+#include <status.h>
+#include <tftf_lib.h>
+#include <uuid_utils.h>
+#include "neg_scenario_test_infra.h"
+
+#define CRYPTO_SUPPORT 1
+
+static fip_toc_entry_t *
+find_fiptoc_entry_t(const int fip_base, const uuid_t *uuid)
+{
+ fip_toc_entry_t *current_file =
+ (fip_toc_entry_t *) (fip_base + sizeof(fip_toc_header_t));
+
+ while (!is_uuid_null(&(current_file->uuid))) {
+ if (uuid_equal(&(current_file->uuid), uuid)){
+ return current_file;
+ }
+
+ current_file += 1;
+ };
+
+ return NULL;
+}
+
+test_result_t test_invalid_rotpk(void)
+{
+ smc_args args = { SMC_PSCI_SYSTEM_RESET };
+ smc_ret_values ret = (smc_ret_values){0};
+ const uuid_t trusted_cert = UUID_TRUSTED_KEY_CERT;
+
+ uintptr_t handle;
+ fip_toc_entry_t * cert;
+ size_t exp_len, len;
+ int address, rc;
+ void * paramOut = NULL;
+
+ if(tftf_is_rebooted() ){
+ /* ROTPK is tampered with and upon reboot tfa should not reach this point */
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Locate Trusted Key certificate memory address by using UUID */
+ cert = find_fiptoc_entry_t(PLAT_ARM_FIP_BASE, &trusted_cert);
+ if (cert == NULL){
+ return TEST_RESULT_FAIL;
+ }
+
+ address = (uintptr_t)cert->offset_address;
+ exp_len = cert->size;
+ if (exp_len == 0U){
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Runtime-sized buffer on stack */
+ uint8_t cert_buffer[exp_len];
+
+ /* Open NVM and Read certicate */
+ plat_get_nvm_handle(&handle);
+ if(handle < 0) {
+ return TEST_RESULT_FAIL;
+ }
+
+ rc = io_seek(handle, IO_SEEK_SET, address);
+ if (rc < 0){
+ return TEST_RESULT_FAIL;
+ }
+
+ rc = io_read(handle, (uintptr_t) &cert_buffer, exp_len, &len);
+ if (rc < 0 || len != exp_len){
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Parse certifacte to retrieve public key */
+ rc = get_pubKey_from_cert(&cert_buffer, len, ¶mOut);
+ if ( rc != 0){
+ return TEST_RESULT_FAIL;
+ }
+
+ /*
+ * Corrupt part of the certificate in storage.
+ * Simple overwrite: just clobber the first 32 bytes so parsing/verification fails.
+ */
+ {
+ uint8_t junk[32] = {0};
+
+ rc = io_seek(handle, IO_SEEK_SET, address);
+ if (rc < 0){
+ return TEST_RESULT_FAIL;
+ }
+
+ rc = io_write(handle, (uintptr_t)junk, sizeof(junk), &len);
+ if (rc < 0 || len != sizeof(junk)){
+ return TEST_RESULT_FAIL;
+ }
+ }
+
+ /* Reboot */
+ tftf_notify_reboot();
+ ret = tftf_smc(&args);
+
+ /* The PSCI SYSTEM_RESET call is not supposed to return */
+ tftf_testcase_printf("System didn't reboot properly (%d)\n",
+ (unsigned int)ret.ret0);
+
+ /* If this point is reached, reboot failed to trigger*/
+ return TEST_RESULT_FAIL;
+}
diff --git a/tftf/tests/runtime_services/sip_service/test_debugfs.c b/tftf/tests/runtime_services/sip_service/test_debugfs.c
index 39a1bf9..dcc57b2 100644
--- a/tftf/tests/runtime_services/sip_service/test_debugfs.c
+++ b/tftf/tests/runtime_services/sip_service/test_debugfs.c
@@ -360,3 +360,51 @@
return TEST_RESULT_SUCCESS;
}
+
+/*
+ * @Test_Aim@ Verify that the I/O layer correctly handles out-of-bounds access.
+ *
+ * This test ensures robustness of seek/read APIs against invalid
+ * offsets and prevents potential memory or file corruption due to invalid
+ * access.
+ */
+test_result_t test_oob_access(void)
+{
+ int ret, fd;
+
+ /* Get debugfs interface version (if implemented)*/
+ ret = version();
+ if (ret != DEBUGFS_VERSION) {
+ /* Likely debugfs feature is not implemented */
+ return TEST_RESULT_SKIPPED;
+ }
+
+ /* Open BL2. */
+ fd = open("/fip/bl2.bin", O_READ);
+ if (fd < 0) {
+ tftf_testcase_printf("open failed fd=%d\n", fd);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Rewind to negative offset. */
+ ret = seek(fd, -1000, KSEEK_SET);
+
+ /* Reading with out-of-bounds cursor position should fail */
+ ret = read(fd, read_buffer, 128);
+ if (ret != 0) {
+ tftf_testcase_printf("Out-of-bounds read(%d)\n", __LINE__);
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Reset cursor position to valid range. */
+ ret = seek(fd, 0, KSEEK_SET);
+
+ /* Read 128 bytes from start */
+ ret = read(fd, read_buffer, 128);
+ if (ret != 128) {
+ tftf_testcase_printf("read failed(%d) ret=%d\n", __LINE__, ret);
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
\ No newline at end of file
diff --git a/tftf/tests/tests-corrupt-rotpk.mk b/tftf/tests/tests-corrupt-rotpk.mk
new file mode 100644
index 0000000..bf25158
--- /dev/null
+++ b/tftf/tests/tests-corrupt-rotpk.mk
@@ -0,0 +1,14 @@
+#
+# Copyright (c) 2025, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+TESTS_SOURCES += $(addprefix tftf/tests/neg_scenario_tests/, \
+ test_invalid_rotpk.c \
+ neg_scenario_test_infra.c \
+)
+
+include lib/ext_mbedtls/mbedtls.mk
+
+
diff --git a/tftf/tests/tests-corrupt-rotpk.xml b/tftf/tests/tests-corrupt-rotpk.xml
new file mode 100644
index 0000000..354752b
--- /dev/null
+++ b/tftf/tests/tests-corrupt-rotpk.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright (c) 2025, Arm Limited. All rights reserved.
+
+ SPDX-License-Identifier: BSD-3-Clause
+-->
+
+<testsuites>
+ <testsuite name="neg scenario test-rotpk" description="Stress test for when ROTPK in fip cert is corrupted" >
+ <testcase name="invalid rotpk" function="test_invalid_rotpk" />
+ </testsuite>
+
+</testsuites>
+
diff --git a/tftf/tests/tests-debugfs.xml b/tftf/tests/tests-debugfs.xml
index 4da3152..61342e8 100644
--- a/tftf/tests/tests-debugfs.xml
+++ b/tftf/tests/tests-debugfs.xml
@@ -12,6 +12,7 @@
-->
<testsuite name="DebugFS" description="Test ARM SiP DebugFS service">
<testcase name="Expose filesystem" function="test_debugfs" />
+ <testcase name="Out-of-bounds accesses" function="test_oob_access" />
</testsuite>
</testsuites>
diff --git a/tftf/tests/tests-firmware-handoff.mk b/tftf/tests/tests-firmware-handoff.mk
index c7ca2cd..a09ea28 100644
--- a/tftf/tests/tests-firmware-handoff.mk
+++ b/tftf/tests/tests-firmware-handoff.mk
@@ -9,6 +9,8 @@
include lib/event_log/event_log.mk
include lib/libtl/libtl.mk
+TFTF_INCLUDES += $(EVENT_LOG_INCLUDES)
+
TESTS_SOURCES += $(addprefix tftf/tests/misc_tests/, \
test_firmware_handoff.c \
)