diff options
author | Olivier Deprez <olivier.deprez@arm.com> | 2022-11-09 10:15:28 +0100 |
---|---|---|
committer | Olivier Deprez <olivier.deprez@arm.com> | 2022-11-22 13:36:28 +0100 |
commit | 40777f82efb1854ab815f501059ac58430cba888 (patch) | |
tree | 349cef469973eb41ef7a58e914baeb57a67d5284 | |
parent | f7b3be91ab954c495912fc7bc48383cd83bfec2d (diff) | |
download | tf-a-tests-40777f82efb1854ab815f501059ac58430cba888.tar.gz |
refactor: remove deprecated spm libs and test code
Remove references to former SPCI/SPRT implementation pre-dating now
released FF-A specification.
Remove the sample quark partition image based on those deprecated
specifications.
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I5b4e51457307c4ff5befd46132fd26d4ef21cdfa
33 files changed, 5 insertions, 2224 deletions
@@ -115,10 +115,9 @@ include fwu/ns_bl2u/ns_bl2u.mk # List of secure partitions present. SECURE_PARTITIONS := -# Only platform fvp supports cactus_mm, quark +# Only platform fvp supports cactus_mm ifeq (${ARCH}-${PLAT},aarch64-fvp) include spm/cactus_mm/cactus_mm.mk -include spm/quark/quark.mk include realm/realm.mk endif @@ -256,7 +255,6 @@ NS_BL2U_CFLAGS += -mbranch-protection=${BP_OPTION} CACTUS_MM_CFLAGS += -mbranch-protection=${BP_OPTION} CACTUS_CFLAGS += -mbranch-protection=${BP_OPTION} IVY_CFLAGS += -mbranch-protection=${BP_OPTION} -QUARK_CFLAGS += -mbranch-protection=${BP_OPTION} endif ifeq ($(SMC_FUZZING), 1) @@ -301,12 +299,6 @@ IVY_CFLAGS += ${COMMON_CFLAGS} -fpie IVY_ASFLAGS += ${COMMON_ASFLAGS} IVY_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS) -QUARK_SOURCES += ${LIBC_SRCS} -QUARK_INCLUDES += ${PLAT_INCLUDES} -QUARK_CFLAGS += ${COMMON_CFLAGS} -QUARK_ASFLAGS += ${COMMON_ASFLAGS} -QUARK_LDFLAGS += ${COMMON_LDFLAGS} - REALM_SOURCES += ${LIBC_SRCS} REALM_CFLAGS += ${COMMON_CFLAGS} -fpie REALM_ASFLAGS += ${COMMON_ASFLAGS} @@ -384,11 +376,6 @@ cactus_mm: @echo "ERROR: $@ is supported only on AArch64 FVP." @exit 1 -.PHONY: quark -quark: - @echo "ERROR: $@ is supported only on AArch64 FVP." - @exit 1 - .PHONY: realm realm: @echo "ERROR: $@ is supported only on AArch64 FVP." @@ -546,7 +533,6 @@ ifeq (${ARCH}-${PLAT},aarch64-fvp) $(eval $(call MAKE_IMG,cactus_mm)) $(eval $(call MAKE_IMG,cactus)) $(eval $(call MAKE_IMG,ivy)) - $(eval $(call MAKE_IMG,quark)) $(eval $(call MAKE_IMG,realm)) endif @@ -594,7 +580,7 @@ cscope: .SILENT: help help: echo "usage: ${MAKE} PLAT=<${PLATFORMS}> \ -<all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|quark|realm|pack_realm|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>" +<all|tftf|ns_bl1u|ns_bl2u|cactus|ivy|realm|pack_realm|el3_payload|distclean|clean|checkcodebase|checkpatch|help_tests>" echo "" echo "PLAT is used to specify which platform you wish to build." echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}" @@ -605,12 +591,11 @@ help: echo " tftf Build the TFTF image" echo " ns_bl1u Build the NS_BL1U image" echo " ns_bl2u Build the NS_BL2U image" - echo " cactus Build the Cactus image (Test S-EL0 payload) and resource description." echo " realm Build the Realm image (Test R-EL1 payload)." echo " pack_realm Pack the realm image to tftf.bin." - echo " cactus_mm Build the Cactus-MM image (Test S-EL0 payload)." - echo " ivy Build the Ivy image (Test S-EL0 payload) and resource description." - echo " quark Build the Quark image (Test S-EL0 payload) and resource description." + echo " cactus Build the Cactus image (FF-A S-EL1 test payload)." + echo " cactus_mm Build the Cactus-MM image (SPM-MM S-EL0 test payload)." + echo " ivy Build the Ivy image (FF-A S-EL0 test payload)." echo " el3_payload Build the EL3 test payload" echo " checkcodebase Check the coding style of the entire source tree" echo " checkpatch Check the coding style on changes in the current" diff --git a/docs/getting_started/build.rst b/docs/getting_started/build.rst index c8eca6749..034a99e6e 100644 --- a/docs/getting_started/build.rst +++ b/docs/getting_started/build.rst @@ -51,7 +51,6 @@ Building TF-A Tests - ``build/<platform>/<build-type>/cactus_mm.bin`` - ``build/<platform>/<build-type>/cactus.bin`` - ``build/<platform>/<build-type>/ivy.bin`` - - ``build/<platform>/<build-type>/quark.bin`` where ``<platform>`` is the name of the chosen platform and ``<build-type>`` is either ``debug`` or ``release``. The actual number of images might differ diff --git a/include/lib/sprt/sprt_client.h b/include/lib/sprt/sprt_client.h deleted file mode 100644 index 44c3c2560..000000000 --- a/include/lib/sprt/sprt_client.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef SPRT_CLIENT_H -#define SPRT_CLIENT_H - -#include <stdint.h> - -#include "sprt_common.h" - -/* - * Point the SPRT library at a shared buffer between SPM and SP. - */ -void sprt_initialize_queues(void *buffer_base); - -/* - * Return SPRT version. - */ -uint32_t sprt_version(void); - -/* - * Called by the main SPRT client execution context when there are no more - * messages available via sprt_get_next_message(), or if the SPRT client wishes - * to yield execution to allow other SPs to run. - */ -void sprt_wait_for_messages(void); - -/* - * Returns the next message to be processed by the SPRT client. There can be - * multiple queues of messages for a partition, `queue_num` specifies which - * queue to read from. Each message can be retrieved only once. The message - * pointer must point to a valid memory owned by the caller. A zero return - * value indicates there is a message for the SP, -ENOENT means there are no - * messages. - */ -int sprt_get_next_message(struct sprt_queue_entry_message *message, - int queue_num); - -/* - * End processing of the message passing arg0 to arg3 back to the SPCI client. - */ -void sprt_message_end(struct sprt_queue_entry_message *message, - u_register_t arg0, u_register_t arg1, u_register_t arg2, - u_register_t arg3); - -#endif /* SPRT_CLIENT_H */ diff --git a/include/lib/sprt/sprt_common.h b/include/lib/sprt/sprt_common.h deleted file mode 100644 index 787e7b65a..000000000 --- a/include/lib/sprt/sprt_common.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef SPRT_COMMON_H -#define SPRT_COMMON_H - -#define SPRT_MAX_MSG_ARGS 6 - -/* - * Message types supported. - */ -#define SPRT_MSG_TYPE_SERVICE_HANDLE_OPEN 1 -#define SPRT_MSG_TYPE_SERVICE_HANDLE_CLOSE 2 -/* TODO: Add other types of SPRT messages. */ -#define SPRT_MSG_TYPE_SERVICE_REQUEST 10 - -/* - * Struct that defines the layout of the fields corresponding to a request in - * shared memory. - */ -struct __attribute__((__packed__)) sprt_queue_entry_message { - uint32_t type; /* Type of message (result of an SPCI call). */ - uint16_t client_id; /* SPCI client ID */ - uint16_t service_handle;/* SPCI service handle */ - uint32_t session_id; /* Optional SPCI session ID */ - uint32_t token; /* SPCI request token */ - uint64_t args[SPRT_MAX_MSG_ARGS]; -}; - -#define SPRT_QUEUE_ENTRY_MSG_SIZE (sizeof(struct sprt_queue_entry_message)) - -#define SPRT_QUEUE_NUM_BLOCKING 0 -#define SPRT_QUEUE_NUM_NON_BLOCKING 1 - -#endif /* SPRT_COMMON_H */ diff --git a/include/runtime_services/sprt_svc.h b/include/runtime_services/sprt_svc.h deleted file mode 100644 index e662c28e8..000000000 --- a/include/runtime_services/sprt_svc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef SPRT_SVC_H -#define SPRT_SVC_H - -#include <smccc.h> -#include <utils_def.h> - -/* SPRT_VERSION helpers */ - -#define SPRT_VERSION_MAJOR U(0) -#define SPRT_VERSION_MAJOR_SHIFT 16 -#define SPRT_VERSION_MAJOR_MASK U(0x7FFF) -#define SPRT_VERSION_MINOR U(1) -#define SPRT_VERSION_MINOR_SHIFT 0 -#define SPRT_VERSION_MINOR_MASK U(0xFFFF) -#define SPRT_VERSION_FORM(major, minor) ((((major) & SPRT_VERSION_MAJOR_MASK) \ - << SPRT_VERSION_MAJOR_SHIFT) | \ - ((minor) & SPRT_VERSION_MINOR_MASK)) -#define SPRT_VERSION_COMPILED SPRT_VERSION_FORM(SPRT_VERSION_MAJOR, \ - SPRT_VERSION_MINOR) - -/* SPRT function IDs */ - -#define SPRT_FID_VERSION U(0x0) -#define SPRT_FID_PUT_RESPONSE U(0x1) -#define SPRT_FID_YIELD U(0x5) -#define SPRT_FID_PANIC U(0x7) -#define SPRT_FID_MEMORY_PERM_ATTR_GET U(0xB) -#define SPRT_FID_MEMORY_PERM_ATTR_SET U(0xC) - -#define SPRT_FID_MASK U(0xFF) - -/* Definitions to build the complete SMC ID */ - -#define OEN_SPRT_START U(0x20) -#define OEN_SPRT_END U(0x2F) - -#define SPRT_SMC_64(sprt_fid) ((OEN_SPRT_START << FUNCID_OEN_SHIFT) | \ - (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \ - (SMC_64 << FUNCID_CC_SHIFT)) -#define SPRT_SMC_32(sprt_fid) ((OEN_SPRT_START << FUNCID_OEN_SHIFT) | \ - (U(1) << 31) | ((sprt_fid) & SPRT_FID_MASK) | \ - (SMC_32 << FUNCID_CC_SHIFT)) - -/* Complete SMC IDs */ - -#define SPRT_VERSION SPRT_SMC_32(SPRT_FID_VERSION) -#define SPRT_PUT_RESPONSE_AARCH64 SPRT_SMC_64(SPRT_FID_PUT_RESPONSE) -#define SPRT_YIELD_AARCH64 SPRT_SMC_64(SPRT_FID_YIELD) -#define SPRT_PANIC_AARCH64 SPRT_SMC_64(SPRT_FID_PANIC) -#define SPRT_MEMORY_PERM_ATTR_GET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_GET) -#define SPRT_MEMORY_PERM_ATTR_SET_AARCH64 SPRT_SMC_64(SPRT_FID_MEMORY_PERM_ATTR_SET) - -/* Defines used by SPRT_MEMORY_PERM_ATTR_{GET,SET}_AARCH64 */ - -#define SPRT_MEMORY_PERM_ATTR_RO U(0) -#define SPRT_MEMORY_PERM_ATTR_RW U(1) -#define SPRT_MEMORY_PERM_ATTR_RO_EXEC U(2) -/* U(3) is reserved */ -#define SPRT_MEMORY_PERM_ATTR_MASK U(3) -#define SPRT_MEMORY_PERM_ATTR_SHIFT 3 - -/* SPRT error codes. */ - -#define SPRT_SUCCESS 0 -#define SPRT_NOT_SUPPORTED -1 -#define SPRT_INVALID_PARAMETER -2 - -#endif /* SPRT_SVC_H */ diff --git a/lib/sprt/aarch64/sprt_client_helpers.S b/lib/sprt/aarch64/sprt_client_helpers.S deleted file mode 100644 index 46068540c..000000000 --- a/lib/sprt/aarch64/sprt_client_helpers.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <asm_macros.S> - - .globl sprt_client_svc - -func sprt_client_svc - /* - * Save the address of the svc_args structure on the stack. - * - * Although x0 contains an 8-byte value, we are allocating 16 bytes - * on the stack to respect the 16-byte stack-alignment. - */ - str x0, [sp, #-16]! - - /* Load the SVC arguments values into the appropriate registers. */ - ldp x6, x7, [x0, #48] - ldp x4, x5, [x0, #32] - ldp x2, x3, [x0, #16] - ldp x0, x1, [x0, #0] - - svc #0 - - /* - * Pop the svc_args structure address from the stack into a caller-saved - * register. - */ - ldr x9, [sp], #16 - - /* - * The return values are stored in x0-x3, put them in the svc_args - * return structure. - */ - stp x0, x1, [x9, #0] - stp x2, x3, [x9, #16] - ret -endfunc sprt_client_svc diff --git a/lib/sprt/sprt_client.c b/lib/sprt/sprt_client.c deleted file mode 100644 index 41f530762..000000000 --- a/lib/sprt/sprt_client.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <assert.h> -#include <errno.h> -#include <sprt_svc.h> -#include <stddef.h> - -#include "sprt_client.h" -#include "sprt_client_private.h" -#include "sprt_common.h" -#include "sprt_queue.h" - -uint32_t sprt_version(void) -{ - struct svc_args args; - - args.arg0 = SPRT_VERSION; - - return sprt_client_svc(&args); -} - -void sprt_wait_for_messages(void) -{ - struct svc_args args; - - args.arg0 = SPRT_YIELD_AARCH64; - - sprt_client_svc(&args); -} - -/* - * Variable that points to the memory buffer that contains the queues used by - * this Secure Partition. - */ -static void *queue_messages; - -void sprt_initialize_queues(void *buffer_base) -{ - queue_messages = buffer_base; -} - -int sprt_get_next_message(struct sprt_queue_entry_message *message, - int queue_num) -{ - struct sprt_queue *q = queue_messages; - - while (queue_num-- > 0) { - uintptr_t next_addr = (uintptr_t)q + sizeof(struct sprt_queue) + - q->entry_num * q->entry_size; - q = (struct sprt_queue *) next_addr; - } - - return sprt_queue_pop(q, message); -} - -void sprt_message_end(struct sprt_queue_entry_message *message, - u_register_t arg0, u_register_t arg1, u_register_t arg2, - u_register_t arg3) -{ - struct svc_args args; - - if (message->type == SPRT_MSG_TYPE_SERVICE_REQUEST) { - args.arg0 = SPRT_PUT_RESPONSE_AARCH64; - args.arg1 = message->token; - } - - args.arg2 = arg0; - args.arg3 = arg1; - args.arg4 = arg2; - args.arg5 = arg3; - args.arg6 = ((uint32_t)message->service_handle << 16U) - | message->client_id; - args.arg7 = message->session_id; - - sprt_client_svc(&args); -} diff --git a/lib/sprt/sprt_client.mk b/lib/sprt/sprt_client.mk deleted file mode 100644 index 8d2243044..000000000 --- a/lib/sprt/sprt_client.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# Copyright (c) 2018, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# - -SPRT_LIB_SOURCES := $(addprefix lib/sprt/, \ - ${ARCH}/sprt_client_helpers.S \ - sprt_client.c \ - sprt_queue.c) - -SPRT_LIB_INCLUDES := -Iinclude/lib/sprt/ diff --git a/lib/sprt/sprt_client_private.h b/lib/sprt/sprt_client_private.h deleted file mode 100644 index 57d8dc5a2..000000000 --- a/lib/sprt/sprt_client_private.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef SPRT_CLIENT_PRIVATE_H -#define SPRT_CLIENT_PRIVATE_H - -#include <stdint.h> - -struct svc_args { - u_register_t arg0; - u_register_t arg1; - u_register_t arg2; - u_register_t arg3; - u_register_t arg4; - u_register_t arg5; - u_register_t arg6; - u_register_t arg7; -}; - -/* - * Invoke an SVC call. - * - * The arguments to pass through the SVC call must be stored in the svc_args - * structure. The return values of the SVC call will be stored in the same - * structure (overriding the input arguments). - * - * Returns the first return value. It is equivalent to args.arg0 but is also - * provided as the return value for convenience. - */ -u_register_t sprt_client_svc(struct svc_args *args); - -#endif /* SPRT_CLIENT_PRIVATE_H */ diff --git a/lib/sprt/sprt_queue.c b/lib/sprt/sprt_queue.c deleted file mode 100644 index 2bd4139ea..000000000 --- a/lib/sprt/sprt_queue.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <assert.h> -#include <errno.h> -#include <stdint.h> -#include <string.h> - -#include "sprt_queue.h" - -void sprt_queue_init(void *queue_base, uint32_t entry_num, uint32_t entry_size) -{ - assert(queue_base != NULL); - assert(entry_size > 0U); - assert(entry_num > 0U); - - struct sprt_queue *queue = (struct sprt_queue *)queue_base; - - queue->entry_num = entry_num; - queue->entry_size = entry_size; - queue->idx_write = 0U; - queue->idx_read = 0U; - - memset(queue->data, 0, entry_num * entry_size); -} - -int sprt_queue_is_empty(void *queue_base) -{ - assert(queue_base != NULL); - - struct sprt_queue *queue = (struct sprt_queue *)queue_base; - - return (queue->idx_write == queue->idx_read); -} - -int sprt_queue_is_full(void *queue_base) -{ - assert(queue_base != NULL); - - struct sprt_queue *queue = (struct sprt_queue *)queue_base; - - uint32_t idx_next_write = (queue->idx_write + 1) % queue->entry_num; - - return (idx_next_write == queue->idx_read); -} - -int sprt_queue_push(void *queue_base, const void *entry) -{ - assert(entry != NULL); - assert(queue_base != NULL); - - if (sprt_queue_is_full(queue_base) != 0) { - return -ENOMEM; - } - - struct sprt_queue *queue = (struct sprt_queue *)queue_base; - - uint8_t *dst_entry = &queue->data[queue->entry_size * queue->idx_write]; - - memcpy(dst_entry, entry, queue->entry_size); - - /* - * Make sure that the message data is visible before increasing the - * counter of available messages. - */ - __asm__ volatile("dmb st" ::: "memory"); - - queue->idx_write = (queue->idx_write + 1) % queue->entry_num; - - __asm__ volatile("dmb st" ::: "memory"); - - return 0; -} - -int sprt_queue_pop(void *queue_base, void *entry) -{ - assert(entry != NULL); - assert(queue_base != NULL); - - if (sprt_queue_is_empty(queue_base) != 0) { - return -ENOENT; - } - - struct sprt_queue *queue = (struct sprt_queue *)queue_base; - - uint8_t *src_entry = &queue->data[queue->entry_size * queue->idx_read]; - - memcpy(entry, src_entry, queue->entry_size); - - /* - * Make sure that the message data is visible before increasing the - * counter of read messages. - */ - __asm__ volatile("dmb st" ::: "memory"); - - queue->idx_read = (queue->idx_read + 1) % queue->entry_num; - - __asm__ volatile("dmb st" ::: "memory"); - - return 0; -} diff --git a/lib/sprt/sprt_queue.h b/lib/sprt/sprt_queue.h deleted file mode 100644 index 4ea1bc231..000000000 --- a/lib/sprt/sprt_queue.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef SPRT_QUEUE_H -#define SPRT_QUEUE_H - -#include <stdint.h> - -/* Struct that defines a queue. Not to be used directly. */ -struct __attribute__((__packed__)) sprt_queue { - uint32_t entry_num; /* Number of entries */ - uint32_t entry_size; /* Size of an entry */ - uint32_t idx_write; /* Index of first empty entry */ - uint32_t idx_read; /* Index of first entry to read */ - uint8_t data[0]; /* Start of data */ -}; - -#define SPRT_QUEUE_HEADER_SIZE (sizeof(struct sprt_queue)) - -/* - * Initializes a memory region to be used as a queue of the given number of - * entries with the specified size. - */ -void sprt_queue_init(void *queue_base, uint32_t entry_num, uint32_t entry_size); - -/* Returns 1 if the queue is empty, 0 otherwise */ -int sprt_queue_is_empty(void *queue_base); - -/* Returns 1 if the queue is full, 0 otherwise */ -int sprt_queue_is_full(void *queue_base); - -/* - * Pushes a new entry intro the queue. Returns 0 on success, -ENOMEM if the - * queue is full. - */ -int sprt_queue_push(void *queue_base, const void *entry); - -/* - * Pops an entry from the queue. Returns 0 on success, -ENOENT if the queue is - * empty. - */ -int sprt_queue_pop(void *queue_base, void *entry); - -#endif /* SPRT_QUEUE_H */ diff --git a/spm/README.txt b/spm/README.txt deleted file mode 100644 index a96a9fd61..000000000 --- a/spm/README.txt +++ /dev/null @@ -1,12 +0,0 @@ -This directory provides sample Secure Partitions: - --Cactus is the main test Secure Partition run at S-EL1 on top of the S-EL2 -firmware. It complies with the FF-A 1.0 specification and provides sample -ABI calls for setup and discovery, direct request/response messages, and -memory sharing interfaces. - --Cactus-MM is a sample partition complying with the MM communication -interface (not related to FF-A). It is run at S-EL0 on top of TF-A's -SPM-MM implementation at EL3. - --Ivy and Quark are currently deprecated. diff --git a/spm/cactus/cactus_tests_memory_attributes.c b/spm/cactus/cactus_tests_memory_attributes.c deleted file mode 100644 index bed6f0b55..000000000 --- a/spm/cactus/cactus_tests_memory_attributes.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <assert.h> -#include <debug.h> -#include <errno.h> -#include <platform_def.h> -#include <secure_partition.h> -#include <sp_helpers.h> -#include <sprt_svc.h> -#include <stdio.h> -#include <stdint.h> -#include <xlat_tables_defs.h> - -#include "cactus.h" -#include "cactus_def.h" -#include "cactus_tests.h" - -/* This is filled at runtime. */ -static uintptr_t cactus_tests_start; -static uintptr_t cactus_tests_end; -static uintptr_t cactus_tests_size; - -/* - * Send an SPRT_MEMORY_PERM_ATTR_SET_AARCH64 SVC with the given arguments. - * Return the return value of the SVC. - */ -static int32_t request_mem_attr_changes(uintptr_t base_address, - int pages_count, - uint32_t memory_access_controls) -{ - INFO("Requesting memory attributes change\n"); - INFO(" Start address : %p\n", (void *) base_address); - INFO(" Number of pages: %i\n", pages_count); - INFO(" Attributes : 0x%x\n", memory_access_controls); - - svc_args svc_values = { SPRT_MEMORY_PERM_ATTR_SET_AARCH64, - base_address, - pages_count, - memory_access_controls }; - return sp_svc(&svc_values); -} - -/* - * Send an SPRT_MEMORY_PERM_ATTR_GET_AARCH64 SVC with the given arguments. - * Return the return value of the SVC. - */ -static int32_t request_get_mem_attr(uintptr_t base_address) -{ - INFO("Requesting memory attributes\n"); - INFO(" Base address : %p\n", (void *) base_address); - - svc_args svc_values = { SPRT_MEMORY_PERM_ATTR_GET_AARCH64, - base_address }; - return sp_svc(&svc_values); -} - -/* - * This function expects a base address and number of pages identifying the - * extents of some memory region mapped as non-executable, read-only. - * - * 1) It changes its data access permissions to read-write. - * 2) It checks this memory can now be written to. - * 3) It restores the original data access permissions. - * - * If any check fails, it loops forever. It could also trigger a permission - * fault while trying to write to the memory. - */ -static void mem_attr_changes_unittest(uintptr_t addr, int pages_count) -{ - int32_t ret; - uintptr_t end_addr = addr + pages_count * PAGE_SIZE; - uint32_t old_attr, new_attr; - - char test_desc[50]; - - snprintf(test_desc, sizeof(test_desc), - "RO -> RW (%i page(s) from address 0x%lx)", pages_count, addr); - announce_test_start(test_desc); - - /* - * Ensure we don't change the attributes of some random memory - * location - */ - assert(addr >= cactus_tests_start); - assert(end_addr < (cactus_tests_start + cactus_tests_size)); - - old_attr = SPRT_MEMORY_PERM_ATTR_RO; - /* Memory was read-only, let's try changing that to RW */ - new_attr = SPRT_MEMORY_PERM_ATTR_RW; - - ret = request_mem_attr_changes(addr, pages_count, new_attr); - expect(ret, SPRT_SUCCESS); - printf("Successfully changed memory attributes\n"); - - /* The attributes should be the ones we have just written. */ - ret = request_get_mem_attr(addr); - expect(ret, SPRT_SUCCESS | (new_attr << SPRT_MEMORY_PERM_ATTR_SHIFT)); - - /* If it worked, we should be able to write to this memory now! */ - for (unsigned char *data = (unsigned char *) addr; - (uintptr_t) data != end_addr; - ++data) { - *data = 42; - } - printf("Successfully wrote to the memory\n"); - - /* Let's revert back to the original attributes for the next test */ - ret = request_mem_attr_changes(addr, pages_count, old_attr); - expect(ret, SPRT_SUCCESS); - printf("Successfully restored the old attributes\n"); - - /* The attributes should be the original ones again. */ - ret = request_get_mem_attr(addr); - expect(ret, SPRT_SUCCESS | (old_attr << SPRT_MEMORY_PERM_ATTR_SHIFT)); - - announce_test_end(test_desc); -} - -/* - * Exercise the ability of the Trusted Firmware to change the data access - * permissions and instruction execution permissions of some memory region. - */ -void mem_attr_changes_tests(void) -{ - uint32_t attributes; - int32_t ret; - uintptr_t addr; - - cactus_tests_start = CACTUS_TEST_MEM_BASE; - cactus_tests_size = CACTUS_TEST_MEM_SIZE; - cactus_tests_end = cactus_tests_start + cactus_tests_size; - - const char *test_sect_desc = "memory attributes changes"; - - announce_test_section_start(test_sect_desc); - /* - * Start with error cases, i.e. requests that are expected to be denied - */ - const char *test_desc1 = "Reserved attributes value"; - - announce_test_start(test_desc1); - attributes = U(3); - ret = request_mem_attr_changes(cactus_tests_start, 1, attributes); - expect(ret, SPRT_INVALID_PARAMETER); - announce_test_end(test_desc1); - - const char *test_desc2 = "Size == 0"; - - announce_test_start(test_desc2); - attributes = SPRT_MEMORY_PERM_ATTR_RW; - ret = request_mem_attr_changes(cactus_tests_start, 0, attributes); - expect(ret, SPRT_INVALID_PARAMETER); - announce_test_end(test_desc2); - - const char *test_desc3 = "Unaligned address"; - - announce_test_start(test_desc3); - attributes = SPRT_MEMORY_PERM_ATTR_RW; - /* Choose an address not aligned to a page boundary. */ - addr = cactus_tests_start + 5; - ret = request_mem_attr_changes(addr, 1, attributes); - expect(ret, SPRT_INVALID_PARAMETER); - announce_test_end(test_desc3); - - const char *test_desc4 = "Unmapped memory region"; - - announce_test_start(test_desc4); - addr = cactus_tests_end + 2 * PAGE_SIZE; - attributes = SPRT_MEMORY_PERM_ATTR_RW; - ret = request_mem_attr_changes(addr, 3, attributes); - expect(ret, SPRT_INVALID_PARAMETER); - announce_test_end(test_desc4); - - const char *test_desc5 = "Partially unmapped memory region"; - - announce_test_start(test_desc5); - addr = cactus_tests_end - 2 * PAGE_SIZE; - attributes = SPRT_MEMORY_PERM_ATTR_RW; - ret = request_mem_attr_changes(addr, 6, attributes); - expect(ret, SPRT_INVALID_PARAMETER); - announce_test_end(test_desc5); - - const char *test_desc6 = "Memory region mapped with the wrong granularity"; - - announce_test_start(test_desc6); - /* - * This address is usually mapped at a 2 MiB granularity. By using as - * test address the block after the console we make sure that in case - * the attributes of the block actually changed, the console would work - * and we would get the error message. - */ - addr = ((uintptr_t)PLAT_ARM_UART_BASE + 0x200000ULL) & ~(0x200000ULL - 1ULL); - attributes = SPRT_MEMORY_PERM_ATTR_RW; - ret = request_mem_attr_changes(addr, 1, attributes); - expect(ret, SPRT_INVALID_PARAMETER); - announce_test_end(test_desc6); - - const char *test_desc7 = "Try some valid memory change requests"; - - announce_test_start(test_desc7); - for (unsigned int i = 0; i < 20; ++i) { - /* - * Choose some random address in the pool of memory reserved - * for these tests. - */ - const int pages_max = cactus_tests_size / PAGE_SIZE; - int pages_count = bound_rand(1, pages_max); - - addr = bound_rand( - cactus_tests_start, - cactus_tests_end - (pages_count * PAGE_SIZE)); - /* Align to PAGE_SIZE. */ - addr &= ~(PAGE_SIZE - 1); - - mem_attr_changes_unittest(addr, pages_count); - } - announce_test_end(test_desc7); - - announce_test_section_end(test_sect_desc); -} diff --git a/spm/cactus/cactus_tests_system_setup.c b/spm/cactus/cactus_tests_system_setup.c deleted file mode 100644 index cead8e3be..000000000 --- a/spm/cactus/cactus_tests_system_setup.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <debug.h> -#include <sp_helpers.h> -#include <stdint.h> - -#include "cactus.h" - -extern uintptr_t __TEXT_START__; - -void system_setup_tests(void) -{ - const char *test_sect_desc = "system setup"; - - announce_test_section_start(test_sect_desc); - - /* - * Try accessing CTR_EL0 register. This should work if SCTLR_EL1.UCT bit - * has been correctly setup by TF. - */ - const char *test_desc1 = "Read CTR_EL0 register"; - - announce_test_start(test_desc1); - - uint32_t ctr __unused = read_ctr_el0(); - - INFO("CTR_EL0 = 0x%x\n", ctr); - announce_test_end(test_desc1); - - /* - * Try to execute a cache maintenance instruction. This should work if - * SCTLR_EL1.UCI bit has been correctly setup by TF. - */ - const char *test_desc2 = "Access to cache maintenance operations"; - - announce_test_start(test_desc2); - flush_dcache_range((uintptr_t)&__TEXT_START__, 1); - announce_test_end(test_desc2); - - /* - * Try accessing a floating point register. This should not trap to - * S-EL1. - */ - const char *test_desc3 = "Access to FP regs"; - - announce_test_start(test_desc3); - /* - * Can't use the 'double' type here because Cactus (like the rest of - * the TF code) is compiled with GCC's -mgeneral-regs-only compiler flag - * that disables floating point support in GCC. - */ - uint64_t fp_reg; - - __asm__ volatile("fmov %0, d0" : "=r" (fp_reg) :: "d0"); - INFO("D0 = 0x%llx\n", fp_reg); - __asm__ volatile( - "fmov d0, #1.0 \n\t" - "fmov %0, d0 \n\t" - : "=r" (fp_reg) - : - : "d0"); - INFO("D0 = 0x%llx\n", fp_reg); - announce_test_end(test_desc3); - - announce_test_section_end(test_sect_desc); -} diff --git a/spm/common/sp_tests/sp_tests.h b/spm/common/sp_tests/sp_tests.h index 1039ba5d7..10d3b9bcc 100644 --- a/spm/common/sp_tests/sp_tests.h +++ b/spm/common/sp_tests/sp_tests.h @@ -15,30 +15,4 @@ void ffa_tests(struct mailbox_buffers *mb); -/* - * Test other things like the version number returned by SPM. - */ -void misc_tests(void); - -/* - * The Arm TF is responsible for setting up system registers on behalf of the - * Secure Partition. For example, TF is supposed to allow Secure Partitions to - * perform cache maintenance operations (by setting the SCTLR_EL1.UCI bit). - * - * This function attempts to verify that we indeed have access to these system - * features from S-EL0. These tests report their results on the UART. They do - * not recover from a failure : when an error is encountered they will most - * likely trigger an exception into S-EL1. - */ -void system_setup_tests(void); - -/* - * Exercise the SP_MEMORY_ATTRIBUTES_SET_AARCH64 SMC interface. A variety of - * valid and invalid requests to change memory attributes are tested. - * - * These tests report their results on the UART. They do not recover from a - * failure : when an error is encountered they endlessly loop. - */ -void mem_attr_changes_tests(void); - #endif /* CACTUS_TESTS_H */ diff --git a/spm/include/sp_res_desc_def.h b/spm/include/sp_res_desc_def.h deleted file mode 100644 index 68df297a8..000000000 --- a/spm/include/sp_res_desc_def.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef SPM_RES_DESC_DEFS_H -#define SPM_RES_DESC_DEFS_H - -#include <utils_def.h> - -/******************************************************************************* - * Attribute Section - ******************************************************************************/ - -#define RD_ATTR_TYPE_UP_MIGRATABLE U(0) -#define RD_ATTR_TYPE_UP_PINNED U(2) -#define RD_ATTR_TYPE_MP U(1) - -#define RD_ATTR_RUNTIME_SEL0 U(0) -#define RD_ATTR_RUNTIME_SEL1 U(1) - -#define RD_ATTR_INIT_ONLY U(0) -#define RD_ATTR_RUNTIME U(1) - -#define RD_ATTR_PANIC_RESTART U(0) -#define RD_ATTR_PANIC_ONESHOT U(1) - -#define RD_ATTR_XLAT_GRANULE_4KB U(0) -#define RD_ATTR_XLAT_GRANULE_16KB U(1) -#define RD_ATTR_XLAT_GRANULE_64KB U(2) - -/******************************************************************************* - * Memory Region Section - ******************************************************************************/ - -#define RD_MEM_REGION_NAME_LEN U(32) - -#define RD_MEM_DEVICE U(0) -#define RD_MEM_NORMAL_CODE U(1) -#define RD_MEM_NORMAL_DATA U(2) -#define RD_MEM_NORMAL_BSS U(3) -#define RD_MEM_NORMAL_RODATA U(4) -#define RD_MEM_NORMAL_SPM_SP_SHARED_MEM U(5) -#define RD_MEM_NORMAL_CLIENT_SHARED_MEM U(6) -#define RD_MEM_NORMAL_MISCELLANEOUS U(7) - -#define RD_MEM_MASK U(15) - -#define RD_MEM_IS_PIE (U(1) << 4) - -/******************************************************************************* - * Notification Section - ******************************************************************************/ - -#define RD_NOTIF_TYPE_PLATFORM (U(0) << 31) -#define RD_NOTIF_TYPE_INTERRUPT (U(1) << 31) - -#define RD_NOTIF_PLAT_ID_MASK U(0xFFFF) -#define RD_NOTIF_PLAT_ID_SHIFT U(0) - -#define RD_NOTIF_PLATFORM(id) \ - (RD_NOTIF_TYPE_PLATFORM \ - | (((id) & RD_NOTIF_PLAT_ID_MASK) << RD_NOTIF_PLAT_ID_SHIFT)) - -#define RD_NOTIF_IRQ_NUM_MASK U(0xFFFF) -#define RD_NOTIF_IRQ_NUM_SHIFT U(0) -#define RD_NOTIF_IRQ_PRIO_MASK U(0xFF) -#define RD_NOTIF_IRQ_PRIO_SHIFT U(16) - -#define RD_NOTIF_IRQ_EDGE_FALLING U(0) -#define RD_NOTIF_IRQ_EDGE_RISING U(2) -#define RD_NOTIF_IRQ_LEVEL_LOW U(1) -#define RD_NOTIF_IRQ_LEVEL_HIGH U(3) -#define RD_NOTIF_IRQ_TRIGGER_SHIFT U(24) - -#define RD_NOTIF_IRQ(num, prio, trig) \ - (RD_NOTIF_TYPE_IRQ \ - | (((num) & RD_NOTIF_IRQ_NUM_MASK) << RD_NOTIF_IRQ_NUM_SHIFT) \ - | (((prio) & RD_NOTIF_IRQ_PRIO_MASK) << RD_NOTIF_IRQ_PRIO_SHIFT) \ - | (((trig) << RD_NOTIF_IRQ_TRIGGER_SHIFT))) - -/******************************************************************************* - * Service Description Section - ******************************************************************************/ - -#define RD_SERV_ACCESS_SECURE (U(1) << 0) -#define RD_SERV_ACCESS_EL3 (U(1) << 1) -#define RD_SERV_ACCESS_NORMAL (U(1) << 2) - -#define RD_SERV_SUPPORT_BLOCKING (U(1) << 0) -#define RD_SERV_SUPPORT_NON_BLOCKING (U(1) << 0) - -#endif /* SPM_RES_DESC_DEFS_H */ diff --git a/spm/quark/aarch64/quark_entrypoint.S b/spm/quark/aarch64/quark_entrypoint.S deleted file mode 100644 index 9cbed976d..000000000 --- a/spm/quark/aarch64/quark_entrypoint.S +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <asm_macros.S> -#include <quark_def.h> -#include <platform_def.h> - - .globl quark_entrypoint - -.section .bss.stacks - .balign CACHE_WRITEBACK_GRANULE - .fill QUARK_STACKS_SIZE -stacks_end: - -func quark_entrypoint - - /* Setup the stack pointer. */ - adr x0, stacks_end - mov sp, x0 - - /* And jump to the C entrypoint. */ - b quark_main - -endfunc quark_entrypoint diff --git a/spm/quark/quark.dts b/spm/quark/quark.dts deleted file mode 100644 index a8fb4a709..000000000 --- a/spm/quark/quark.dts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <sp_res_desc_def.h> - -#include "quark_def.h" - -/* 4 KiB pages */ -#define PAGE_SIZE U(0x1000) - -/dts-v1/; - -/ { - compatible = "arm,sp_rd"; - - attribute { - version = <0x00000001>; - sp_type = <RD_ATTR_TYPE_UP_MIGRATABLE>; - pe_mpidr = <0>; /* Unused */ - runtime_el = <RD_ATTR_RUNTIME_SEL0>; - exec_type = <RD_ATTR_RUNTIME>; - panic_policy = <RD_ATTR_PANIC_ONESHOT>; - xlat_granule = <RD_ATTR_XLAT_GRANULE_4KB>; - binary_size = <QUARK_IMAGE_SIZE>; - load_address = <0x00000000 QUARK_IMAGE_BASE>; - entrypoint = <0x00000000 QUARK_IMAGE_BASE>; - }; - - memory_regions { - spm_buffer { - str = "SPM buffer"; - base = <0x00000000 QUARK_SPM_BUF_BASE>; - size = <0x00000000 QUARK_SPM_BUF_SIZE>; - attr = <RD_MEM_NORMAL_SPM_SP_SHARED_MEM>; - }; - }; - - notifications { - notification_0 { - attr = <0>; - pe = <0>; - }; - }; - - services { - test_service_1 { - uuid = <QUARK_SERVICE1_UUID_RD>; - - accessibility = <(RD_SERV_ACCESS_SECURE | - RD_SERV_ACCESS_EL3 | - RD_SERV_ACCESS_NORMAL)>; - request_type = <(RD_SERV_SUPPORT_BLOCKING | - RD_SERV_SUPPORT_NON_BLOCKING)>; - connection_quota = <10>; - sec_mem_size = <0>; - interrupt_num = <0>; - }; - }; -}; diff --git a/spm/quark/quark.h b/spm/quark/quark.h deleted file mode 100644 index 2b4fd3964..000000000 --- a/spm/quark/quark.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef QUARK_H -#define QUARK_H - -#include <stdint.h> - -/* Linker symbols used to figure out the memory layout of Quark. */ -extern uintptr_t __TEXT_START__, __TEXT_END__; -#define QUARK_TEXT_START ((uintptr_t)&__TEXT_START__) -#define QUARK_TEXT_END ((uintptr_t)&__TEXT_END__) - -extern uintptr_t __RODATA_START__, __RODATA_END__; -#define QUARK_RODATA_START ((uintptr_t)&__RODATA_START__) -#define QUARK_RODATA_END ((uintptr_t)&__RODATA_END__) - -extern uintptr_t __DATA_START__, __DATA_END__; -#define QUARK_DATA_START ((uintptr_t)&__DATA_START__) -#define QUARK_DATA_END ((uintptr_t)&__DATA_END__) - -extern uintptr_t __BSS_START__, __BSS_END__; -#define QUARK_BSS_START ((uintptr_t)&__BSS_START__) -#define QUARK_BSS_END ((uintptr_t)&__BSS_END__) - -#endif /* QUARK_H */ diff --git a/spm/quark/quark.ld.S b/spm/quark/quark.ld.S deleted file mode 100644 index 8f51edb08..000000000 --- a/spm/quark/quark.ld.S +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <quark_def.h> -#include <platform_def.h> -#include <xlat_tables_defs.h> - -OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT) -OUTPUT_ARCH(PLATFORM_LINKER_ARCH) -ENTRY(quark_entrypoint) - -SECTIONS -{ - . = QUARK_IMAGE_BASE; - - ASSERT(. == ALIGN(PAGE_SIZE), - "TEXT_START address is not aligned to PAGE_SIZE.") - - .text : { - __TEXT_START__ = .; - *quark_entrypoint.o(.text*) - *(.text*) - *(.vectors) - . = NEXT(PAGE_SIZE); - __TEXT_END__ = .; - } - - .rodata : { - . = ALIGN(PAGE_SIZE); - __RODATA_START__ = .; - *(.rodata*) - . = NEXT(PAGE_SIZE); - __RODATA_END__ = .; - } - - .data : { - . = ALIGN(PAGE_SIZE); - __DATA_START__ = .; - *(.data*) - . = NEXT(PAGE_SIZE); - __DATA_END__ = .; - } - - .bss (NOLOAD) : { - . = ALIGN(PAGE_SIZE); - __BSS_START__ = .; - *(SORT_BY_ALIGNMENT(.bss*)) - *(COMMON) - . = NEXT(PAGE_SIZE); - __BSS_END__ = .; - } -} diff --git a/spm/quark/quark.mk b/spm/quark/quark.mk deleted file mode 100644 index fb2851dce..000000000 --- a/spm/quark/quark.mk +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright (c) 2018-2022, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# - -include branch_protection.mk -include lib/sprt/sprt_client.mk - -QUARK_DTB := $(BUILD_PLAT)/quark.dtb - -QUARK_INCLUDES := \ - -Iinclude \ - -Iinclude/common \ - -Iinclude/common/${ARCH} \ - -Iinclude/lib \ - -Iinclude/lib/${ARCH} \ - -Iinclude/lib/sprt \ - -Iinclude/lib/utils \ - -Iinclude/lib/xlat_tables \ - -Iinclude/runtime_services \ - -Iinclude/runtime_services/secure_el0_payloads \ - -Ispm/quark \ - -Ispm/common \ - ${SPRT_LIB_INCLUDES} - -QUARK_SOURCES := \ - $(addprefix spm/quark/, \ - aarch64/quark_entrypoint.S \ - quark_main.c \ - ) \ - $(addprefix spm/common/, \ - aarch64/sp_arch_helpers.S \ - sp_helpers.c \ - ) \ - -# TODO: Remove dependency on TFTF files. -QUARK_SOURCES += \ - tftf/framework/debug.c \ - tftf/framework/${ARCH}/asm_debug.S - -QUARK_SOURCES += drivers/console/${ARCH}/dummy_console.S \ - lib/locks/${ARCH}/spinlock.S \ - lib/utils/mp_printf.c \ - ${SPRT_LIB_SOURCES} - -QUARK_LINKERFILE := spm/quark/quark.ld.S - -QUARK_DEFINES := - -$(eval $(call add_define,QUARK_DEFINES,ARM_ARCH_MAJOR)) -$(eval $(call add_define,QUARK_DEFINES,ARM_ARCH_MINOR)) -$(eval $(call add_define,QUARK_DEFINES,DEBUG)) -$(eval $(call add_define,QUARK_DEFINES,ENABLE_ASSERTIONS)) -$(eval $(call add_define,QUARK_DEFINES,ENABLE_BTI)) -$(eval $(call add_define,QUARK_DEFINES,ENABLE_PAUTH)) -$(eval $(call add_define,QUARK_DEFINES,FVP_CLUSTER_COUNT)) -$(eval $(call add_define,QUARK_DEFINES,FVP_MAX_CPUS_PER_CLUSTER)) -$(eval $(call add_define,QUARK_DEFINES,FVP_MAX_PE_PER_CPU)) -$(eval $(call add_define,QUARK_DEFINES,PLAT_${PLAT})) - -$(QUARK_DTB) : $(BUILD_PLAT)/quark $(BUILD_PLAT)/quark/quark.elf -$(QUARK_DTB) : spm/quark/quark.dts - @echo " DTBGEN spm/quark/quark.dts" - ${Q}tools/generate_dtb/generate_dtb.sh \ - quark spm/quark/quark.dts $(BUILD_PLAT) $(QUARK_DTB) - @echo - @echo "Built $@ successfully" - @echo - -quark: $(QUARK_DTB) diff --git a/spm/quark/quark_def.h b/spm/quark/quark_def.h deleted file mode 100644 index 7a0ec15f8..000000000 --- a/spm/quark/quark_def.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef QUARK_DEF_H -#define QUARK_DEF_H - -#include <utils_def.h> - -/* - * Layout of the Secure Partition image. - */ - -/* The base address is 0 to reduce the address space size */ -#define QUARK_IMAGE_BASE ULL(0x00000000) -#define QUARK_IMAGE_SIZE ULL(0x10000) - -/* Memory reserved for stacks */ -#define QUARK_STACKS_SIZE ULL(0x1000) - -/* Memory shared between EL3 and S-EL0 (64 KiB). */ -#define QUARK_SPM_BUF_BASE (QUARK_IMAGE_BASE + QUARK_IMAGE_SIZE) -#define QUARK_SPM_BUF_SIZE ULL(0x10000) - -/* - * UUIDs of Secure Services provided by Quark - */ - -/* Mass (MeV/c^2): Up, down, charm, strange */ -#define QUARK_SERVICE1_UUID U(0x23), U(0x48), U(0x1275), U(0x95) - -#define QUARK_SERVICE1_UUID_RD U(0x23) U(0x48) U(0x1275) U(0x95) - -/* - * Service IDs - */ -/* Return a magic number unique to QUARK */ -#define QUARK_GET_MAGIC U(2002) - -/* Mass (MeV/c^2): Top */ -#define QUARK_MAGIC_NUMBER U(0x173210) - -#endif /* QUARK_DEF_H */ diff --git a/spm/quark/quark_main.c b/spm/quark/quark_main.c deleted file mode 100644 index 145560bf0..000000000 --- a/spm/quark/quark_main.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <assert.h> -#include <cdefs.h> -#include <errno.h> -#include <quark_def.h> -#include <sprt_client.h> -#include <sprt_svc.h> -#include <utils_def.h> - -#include "quark.h" -#include "quark_def.h" - -/* NOTE: This partition doesn't have text output capabilities */ - -static void quark_message_handler(struct sprt_queue_entry_message *message) -{ - u_register_t ret0 = 0U, ret1 = 0U, ret2 = 0U, ret3 = 0U; - - if (message->type == SPRT_MSG_TYPE_SERVICE_REQUEST) { - switch (message->args[1]) { - - case QUARK_GET_MAGIC: - ret1 = QUARK_MAGIC_NUMBER; - ret0 = SPRT_SUCCESS; - break; - - default: - ret0 = SPRT_NOT_SUPPORTED; - break; - } - } else { - ret0 = SPRT_NOT_SUPPORTED; - } - - sprt_message_end(message, ret0, ret1, ret2, ret3); -} - -void __dead2 quark_main(void) -{ - /* - * Handle secure service requests. - */ - sprt_initialize_queues((void *)QUARK_SPM_BUF_BASE); - - while (1) { - struct sprt_queue_entry_message message; - - /* - * Try to fetch a message from the blocking requests queue. If - * it is empty, try to fetch from the non-blocking requests - * queue. Repeat until both of them are empty. - */ - while (1) { - int err = sprt_get_next_message(&message, - SPRT_QUEUE_NUM_BLOCKING); - if (err == -ENOENT) { - err = sprt_get_next_message(&message, - SPRT_QUEUE_NUM_NON_BLOCKING); - if (err == -ENOENT) { - break; - } else { - assert(err == 0); - quark_message_handler(&message); - } - } else { - assert(err == 0); - quark_message_handler(&message); - } - } - - sprt_wait_for_messages(); - } -} diff --git a/tftf/framework/framework.mk b/tftf/framework/framework.mk index a2c2a665e..aff0fef5a 100644 --- a/tftf/framework/framework.mk +++ b/tftf/framework/framework.mk @@ -27,7 +27,6 @@ TFTF_INCLUDES := \ -Iinclude/runtime_services/secure_el1_payloads \ -Ispm/cactus \ -Ispm/ivy \ - -Ispm/quark \ -Irealm \ -Ismc_fuzz/include diff --git a/tftf/tests/runtime_services/secure_service/test_quark_request.c b/tftf/tests/runtime_services/secure_service/test_quark_request.c deleted file mode 100644 index 0f9556fe2..000000000 --- a/tftf/tests/runtime_services/secure_service/test_quark_request.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2018-2019, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <quark_def.h> -#include <spci_helpers.h> -#include <test_helpers.h> - -/* - * @Test_Aim@ This tests opens a Secure Service handle and performs a simple - * request to Quark to verify that its memory map is correct and that it is - * working as expected. - */ -test_result_t test_quark_request(void) -{ - int ret; - uint16_t handle_quark; - u_register_t rx1, rx2, rx3; - test_result_t result = TEST_RESULT_SUCCESS; - - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - /* Open handles. */ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_quark, - QUARK_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - return TEST_RESULT_FAIL; - } - - /* Send request to Quark */ - - ret = spci_service_request_blocking(QUARK_GET_MAGIC, - 0, 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_quark, - &rx1, &rx2, &rx3); - - if (ret == SPCI_SUCCESS) { - if (rx1 != QUARK_MAGIC_NUMBER) { - tftf_testcase_printf("%d: Quark returned 0x%x 0x%lx 0x%lx 0x%lx\n", - __LINE__, (uint32_t)ret, rx1, rx2, rx3); - result = TEST_RESULT_FAIL; - } - } else { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - - /* Close handle */ - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_quark); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - - return result; -} diff --git a/tftf/tests/runtime_services/secure_service/test_spci_blocking_request.c b/tftf/tests/runtime_services/secure_service/test_spci_blocking_request.c deleted file mode 100644 index d2aa20b82..000000000 --- a/tftf/tests/runtime_services/secure_service/test_spci_blocking_request.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <cactus_def.h> -#include <debug.h> -#include <events.h> -#include <ivy_def.h> -#include <plat_topology.h> -#include <platform.h> -#include <power_management.h> -#include <smccc.h> -#include <spci_helpers.h> -#include <spci_svc.h> -#include <test_helpers.h> -#include <tftf_lib.h> - -#define TEST_NUM_ITERATIONS 1000U - -static event_t cpu_has_entered_test[PLATFORM_CORE_COUNT]; - -static test_result_t test_spci_blocking_multicore_fn(void) -{ - int ret; - uint16_t handle_cactus, handle_ivy; - u_register_t rx1, rx2, rx3; - test_result_t result = TEST_RESULT_SUCCESS; - - unsigned int core_pos = get_current_core_id(); - - tftf_send_event(&cpu_has_entered_test[core_pos]); - - /* Open handles. */ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_cactus, - CACTUS_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - goto exit_none; - } - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_ivy, - IVY_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - goto exit_cactus; - } - - /* Request services. */ - - for (unsigned int i = 0U; i < TEST_NUM_ITERATIONS; i++) { - - /* Send request to Cactus */ - - ret = spci_service_request_blocking(CACTUS_GET_MAGIC, - 0, 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_cactus, - &rx1, &rx2, &rx3); - - if (ret == SPCI_BUSY) { - /* - * Another CPU is already using Cactus, this is not a - * failure. - */ - } else if (ret == SPCI_SUCCESS) { - if (rx1 != CACTUS_MAGIC_NUMBER) { - tftf_testcase_printf("%d: Cactus returned 0x%x 0x%lx 0x%lx 0x%lx\n", - __LINE__, (uint32_t)ret, rx1, rx2, rx3); - result = TEST_RESULT_FAIL; - break; - } - } else { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - break; - } - - /* Send request to Ivy */ - - ret = spci_service_request_blocking(IVY_GET_MAGIC, - 0, 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_ivy, - &rx1, &rx2, &rx3); - if (ret == SPCI_BUSY) { - /* - * Another CPU is already using Ivy, this is not a - * failure. - */ - } else if (ret == SPCI_SUCCESS) { - if (rx1 != IVY_MAGIC_NUMBER) { - tftf_testcase_printf("%d: Ivy returned 0x%x 0x%lx 0x%lx 0x%lx\n", - __LINE__, (uint32_t)ret, rx1, rx2, rx3); - result = TEST_RESULT_FAIL; - break; - } - } else { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - break; - } - - } - - /* Close handles. */ - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_ivy); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - -exit_cactus: - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - - /* All tests finished. */ -exit_none: - return result; -} - -/* - * @Test_Aim@ This tests opens a Secure Service handle and performs many simple - * blocking requests to Cactus and Ivy from multiple cores - */ -test_result_t test_spci_blocking_request_multicore(void) -{ - unsigned int cpu_node, core_pos; - int psci_ret; - u_register_t cpu_mpid; - u_register_t lead_mpid = read_mpidr_el1() & MPID_MASK; - - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - for (int i = 0; i < PLATFORM_CORE_COUNT; i++) { - tftf_init_event(&cpu_has_entered_test[i]); - } - - /* Power on all CPUs */ - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - /* Skip lead CPU as it is already powered on */ - if (cpu_mpid == lead_mpid) { - continue; - } - - psci_ret = tftf_cpu_on(cpu_mpid, - (uintptr_t)test_spci_blocking_multicore_fn, 0); - if (psci_ret != PSCI_E_SUCCESS) { - core_pos = platform_get_core_pos(cpu_mpid); - - tftf_testcase_printf( - "Failed to power on CPU %d (rc = %d)\n", - core_pos, psci_ret); - return TEST_RESULT_FAIL; - } - } - - /* Wait until all CPUs have started the test. */ - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - /* Skip lead CPU */ - if (cpu_mpid == lead_mpid) { - continue; - } - - core_pos = platform_get_core_pos(cpu_mpid); - tftf_wait_for_event(&cpu_has_entered_test[core_pos]); - } - - /* Enter the test on lead CPU and return the result. */ - return test_spci_blocking_multicore_fn(); -} diff --git a/tftf/tests/runtime_services/secure_service/test_spci_blocking_while_busy.c b/tftf/tests/runtime_services/secure_service/test_spci_blocking_while_busy.c deleted file mode 100644 index dffd910f8..000000000 --- a/tftf/tests/runtime_services/secure_service/test_spci_blocking_while_busy.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <assert.h> -#include <cactus_def.h> -#include <debug.h> -#include <smccc.h> -#include <spci_helpers.h> -#include <spci_svc.h> -#include <string.h> -#include <test_helpers.h> -#include <tftf_lib.h> -#include <timer.h> - -static volatile int timer_irq_received; - -/* - * ISR for the timer interrupt. Update a global variable to check it has been - * called. - */ -static int timer_handler(void *data) -{ - assert(timer_irq_received == 0); - timer_irq_received = 1; - return 0; -} - -/* - * @Test_Aim@ Test that blocking requests can only be done when there are no - * active non-blocking requests in a partition. - * - * 1. Register a handler for the non-secure timer interrupt. Program it to fire - * in a certain time. - * - * 2. Send a non-blocking request to Cactus to sleep for more time than the - * timer. - * - * 3. While servicing the timer sleep request, the non-secure timer should - * fire and interrupt Cactus. - * - * 5. Check that the interrupt has been handled. - * - * 6. Make sure that the response isn't ready yet. - * - * 7. Try to send a blocking request. It should be denied because the partition - * is busy. - * - * 8. Return to Cactus to finish the request. - */ -test_result_t test_spci_blocking_while_busy(void) -{ - int ret; - u_register_t rx1, rx2, rx3; - uint16_t handle_cactus; - uint32_t token_cactus; - test_result_t result = TEST_RESULT_SUCCESS; - - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - /* Open handle. */ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_cactus, - CACTUS_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - /* Program timer */ - - timer_irq_received = 0; - tftf_timer_register_handler(timer_handler); - - ret = tftf_program_timer(100); - if (ret < 0) { - tftf_testcase_printf("Failed to program timer (%d)\n", ret); - result = TEST_RESULT_FAIL; - goto exit_close_handle; - } - - enable_irq(); - - /* Send request to Cactus */ - - ret = spci_service_request_start(CACTUS_SLEEP_MS, 200U, - 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_cactus, - &token_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: %d\n", - __LINE__, ret); - result = TEST_RESULT_FAIL; - } - - /* Check that the interrupt has been handled. */ - - if (timer_irq_received == 0) { - tftf_testcase_printf("%d: Didn't handle interrupt\n", __LINE__); - result = TEST_RESULT_FAIL; - } - - tftf_cancel_timer(); - tftf_timer_unregister_handler(); - - /* Make sure that the response is not ready yet. */ - - ret = spci_service_get_response(TFTF_SPCI_CLIENT_ID, - handle_cactus, - token_cactus, - NULL, NULL, NULL); - - if (ret == SPCI_SUCCESS) { - tftf_testcase_printf("%d: Cactus returned SPCI_SUCCESS\n", - __LINE__); - result = TEST_RESULT_FAIL; - goto exit_close_handle; - } - - /* - * Try to send a blocking request. It should be denied because the - * partition is busy. - */ - - ret = spci_service_request_blocking(CACTUS_GET_MAGIC, - 0, 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_cactus, - &rx1, &rx2, &rx3); - if (ret != SPCI_BUSY) { - tftf_testcase_printf("%d: Cactus should have returned SPCI_BUSY. Returned %d 0x%lx 0x%lx 0x%lx\n", - __LINE__, ret, rx1, rx2, rx3); - result = TEST_RESULT_FAIL; - goto exit_close_handle; - } - - /* Re-enter Cactus to finish the request */ - - do { - ret = spci_service_request_resume(TFTF_SPCI_CLIENT_ID, - handle_cactus, - token_cactus, - &rx1, NULL, NULL); - } while (ret == SPCI_QUEUED); - - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: Cactus returned %d\n", - __LINE__, ret); - result = TEST_RESULT_FAIL; - } - - /* Close handle. */ -exit_close_handle: - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: %d\n", - __LINE__, ret); - result = TEST_RESULT_FAIL; - } - - /* All tests finished. */ - - return result; -} diff --git a/tftf/tests/runtime_services/secure_service/test_spci_handle_open.c b/tftf/tests/runtime_services/secure_service/test_spci_handle_open.c deleted file mode 100644 index 522465ee1..000000000 --- a/tftf/tests/runtime_services/secure_service/test_spci_handle_open.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <cactus_def.h> -#include <debug.h> -#include <events.h> -#include <plat_topology.h> -#include <platform.h> -#include <smccc.h> -#include <spci_helpers.h> -#include <spci_svc.h> -#include <test_helpers.h> -#include <tftf_lib.h> - -/* - * @Test_Aim@ This tests that we can get the handle of a Secure Service and - * close it correctly. - */ -test_result_t test_spci_handle_open(void) -{ - int ret; - uint16_t handle1, handle2; - - /********************************************************************** - * Verify that SPCI is there and that it has the correct version. - **********************************************************************/ - - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - /********************************************************************** - * Try to get handle of an invalid Secure Service. - **********************************************************************/ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle1, - CACTUS_INVALID_UUID); - - if (ret != SPCI_NOT_PRESENT) { - tftf_testcase_printf("%d: SPM should have returned SPCI_NOT_PRESENT. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - /********************************************************************** - * Get handle of valid Secure Services. - **********************************************************************/ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle1, - CACTUS_SERVICE1_UUID); - - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle2, - CACTUS_SERVICE2_UUID); - - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - /********************************************************************** - * Close invalid handle. - **********************************************************************/ - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, ~handle1); - - if (ret != SPCI_INVALID_PARAMETER) { - tftf_testcase_printf("%d: SPM didn't fail to close the handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - /********************************************************************** - * Close valid handles. - **********************************************************************/ - - /* Close in the reverse order to test that it can be done. */ - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle2); - - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle1); - - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - /********************************************************************** - * All tests passed. - **********************************************************************/ - - return TEST_RESULT_SUCCESS; -} diff --git a/tftf/tests/runtime_services/secure_service/test_spci_non_blocking_interrupt.c b/tftf/tests/runtime_services/secure_service/test_spci_non_blocking_interrupt.c deleted file mode 100644 index cb5dd6b0c..000000000 --- a/tftf/tests/runtime_services/secure_service/test_spci_non_blocking_interrupt.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <assert.h> -#include <cactus_def.h> -#include <debug.h> -#include <smccc.h> -#include <spci_helpers.h> -#include <spci_svc.h> -#include <string.h> -#include <test_helpers.h> -#include <tftf_lib.h> -#include <timer.h> - -static volatile int timer_irq_received; - -/* - * ISR for the timer interrupt. Update a global variable to check it has been - * called. - */ -static int timer_handler(void *data) -{ - assert(timer_irq_received == 0); - timer_irq_received = 1; - return 0; -} - -/* - * @Test_Aim@ Test that non-secure interrupts interrupt non-blocking requests. - * - * 1. Register a handler for the non-secure timer interrupt. Program it to fire - * in a certain time. - * - * 2. Send a non-blocking request to Cactus to sleep for more time than the - * timer. - * - * 3. While servicing the timer sleep request, the non-secure timer should - * fire and interrupt Cactus. - * - * 4. Make sure that the response isn't ready yet. - * - * 5. In the TFTF, check that the interrupt has been handled. - * - * 6. Return to Cactus to finish the request. - */ -test_result_t test_spci_non_blocking_interrupt_by_ns(void) -{ - int ret; - u_register_t ret1; - uint16_t handle_cactus; - uint32_t token_cactus; - test_result_t result = TEST_RESULT_SUCCESS; - - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - /* Open handle */ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_cactus, - CACTUS_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: %d\n", - __LINE__, ret); - return TEST_RESULT_FAIL; - } - - /* Program timer */ - - timer_irq_received = 0; - tftf_timer_register_handler(timer_handler); - - ret = tftf_program_timer(100); - if (ret < 0) { - tftf_testcase_printf("Failed to program timer (%d)\n", ret); - result = TEST_RESULT_FAIL; - } - - /* Send request to Cactus */ - - ret = spci_service_request_start(CACTUS_SLEEP_MS, 200U, - 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_cactus, - &token_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: %d\n", - __LINE__, ret); - result = TEST_RESULT_FAIL; - } - - /* Check that the interrupt has been handled */ - - tftf_cancel_timer(); - tftf_timer_unregister_handler(); - - if (timer_irq_received == 0) { - tftf_testcase_printf("%d: Didn't handle interrupt\n", __LINE__); - result = TEST_RESULT_FAIL; - } - - /* Make sure that the response is not ready yet */ - - ret = spci_service_get_response(TFTF_SPCI_CLIENT_ID, - handle_cactus, - token_cactus, - NULL, NULL, NULL); - - if (ret == SPCI_SUCCESS) { - tftf_testcase_printf("%d: Cactus returned SPCI_SUCCESS\n", - __LINE__); - result = TEST_RESULT_FAIL; - goto exit_close_handle; - } - - /* Re-enter Cactus to finish the request */ - - do { - ret = spci_service_request_resume(TFTF_SPCI_CLIENT_ID, - handle_cactus, - token_cactus, - &ret1, NULL, NULL); - } while (ret == SPCI_QUEUED); - - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: Cactus returned 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - - /* Close handle */ -exit_close_handle: - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: %d\n", - __LINE__, ret); - result = TEST_RESULT_FAIL; - } - - /* All tests finished */ - - return result; -} diff --git a/tftf/tests/runtime_services/secure_service/test_spci_non_blocking_request.c b/tftf/tests/runtime_services/secure_service/test_spci_non_blocking_request.c deleted file mode 100644 index 8d3506b55..000000000 --- a/tftf/tests/runtime_services/secure_service/test_spci_non_blocking_request.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2018, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include <arch_helpers.h> -#include <cactus_def.h> -#include <debug.h> -#include <events.h> -#include <ivy_def.h> -#include <plat_topology.h> -#include <platform.h> -#include <power_management.h> -#include <smccc.h> -#include <stdbool.h> -#include <spci_helpers.h> -#include <spci_svc.h> -#include <test_helpers.h> -#include <tftf_lib.h> - -#define TEST_NUM_ITERATIONS 1000U - -test_result_t test_spci_non_blocking_fn(void) -{ - int ret; - u_register_t ret1; - uint16_t handle_cactus, handle_ivy; - uint32_t token_cactus, token_ivy; - test_result_t result = TEST_RESULT_SUCCESS; - - /* Open handles. */ - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_cactus, - CACTUS_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - goto exit_none; - } - - ret = spci_service_handle_open(TFTF_SPCI_CLIENT_ID, &handle_ivy, - IVY_SERVICE1_UUID); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to return a valid handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - goto exit_cactus; - } - - /* Request services. */ - - for (unsigned int i = 0U; i < TEST_NUM_ITERATIONS; i++) { - - bool exit_loop = false; - - /* Send request to Cactus */ - - ret = spci_service_request_start(CACTUS_GET_MAGIC, - 0, 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_cactus, - &token_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - exit_loop = true; - } - - /* Send request to Ivy */ - - ret = spci_service_request_start(IVY_GET_MAGIC, - 0, 0, 0, 0, 0, - TFTF_SPCI_CLIENT_ID, - handle_ivy, - &token_ivy); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM should have returned SPCI_SUCCESS. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - exit_loop = true; - } - - /* Get response from Ivy */ - - do { - ret = spci_service_request_resume(TFTF_SPCI_CLIENT_ID, - handle_ivy, - token_ivy, - &ret1, NULL, NULL); - } while (ret == SPCI_QUEUED); - - if ((ret != SPCI_SUCCESS) || (ret1 != IVY_MAGIC_NUMBER)) { - tftf_testcase_printf("%d: Ivy returned 0x%x 0x%lx\n", - __LINE__, (uint32_t)ret, ret1); - result = TEST_RESULT_FAIL; - exit_loop = true; - } - - /* Get response from Cactus */ - - do { - ret = spci_service_request_resume(TFTF_SPCI_CLIENT_ID, - handle_cactus, - token_cactus, - &ret1, NULL, NULL); - } while (ret == SPCI_QUEUED); - - if ((ret != SPCI_SUCCESS) || (ret1 != CACTUS_MAGIC_NUMBER)) { - tftf_testcase_printf("%d: Cactus returned 0x%x 0x%lx\n", - __LINE__, (uint32_t)ret, ret1); - result = TEST_RESULT_FAIL; - exit_loop = true; - } - - /* If there has been an error, exit early. */ - if (exit_loop) { - break; - } - } - - /* Close handles. */ - - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_ivy); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - -exit_cactus: - ret = spci_service_handle_close(TFTF_SPCI_CLIENT_ID, handle_cactus); - if (ret != SPCI_SUCCESS) { - tftf_testcase_printf("%d: SPM failed to close the handle. Returned: 0x%x\n", - __LINE__, (uint32_t)ret); - result = TEST_RESULT_FAIL; - } - - /* All tests passed. */ -exit_none: - return result; -} - -/* - * @Test_Aim@ This tests opens a Secure Service handle and performs many simple - * non-blocking requests to Cactus and Ivy. - */ -test_result_t test_spci_request(void) -{ - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - return test_spci_non_blocking_fn(); -} - -/******************************************************************************/ - -static event_t cpu_has_entered_test[PLATFORM_CORE_COUNT]; - -static test_result_t test_spci_non_blocking_multicore_fn(void) -{ - u_register_t cpu_mpid = read_mpidr_el1() & MPID_MASK; - unsigned int core_pos = platform_get_core_pos(cpu_mpid); - - tftf_send_event(&cpu_has_entered_test[core_pos]); - - return test_spci_non_blocking_fn(); -} - -/* - * @Test_Aim@ This tests opens a Secure Service handle and performs many simple - * non-blocking requests to Cactus and Ivy from multiple cores - */ -test_result_t test_spci_request_multicore(void) -{ - unsigned int cpu_node, core_pos; - int psci_ret; - u_register_t cpu_mpid; - u_register_t lead_mpid = read_mpidr_el1() & MPID_MASK; - - SKIP_TEST_IF_SPCI_VERSION_LESS_THAN(0, 1); - - for (int i = 0; i < PLATFORM_CORE_COUNT; i++) { - tftf_init_event(&cpu_has_entered_test[i]); - } - - /* Power on all CPUs */ - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - /* Skip lead CPU as it is already powered on */ - if (cpu_mpid == lead_mpid) { - continue; - } - - core_pos = platform_get_core_pos(cpu_mpid); - - psci_ret = tftf_cpu_on(cpu_mpid, - (uintptr_t)test_spci_non_blocking_multicore_fn, 0); - if (psci_ret != PSCI_E_SUCCESS) { - tftf_testcase_printf( - "Failed to power on CPU %d (rc = %d)\n", - core_pos, psci_ret); - return TEST_RESULT_FAIL; - } - } - - /* Wait until all CPUs have started the test. */ - for_each_cpu(cpu_node) { - cpu_mpid = tftf_get_mpidr_from_node(cpu_node); - /* Skip lead CPU */ - if (cpu_mpid == lead_mpid) { - continue; - } - - core_pos = platform_get_core_pos(cpu_mpid); - tftf_wait_for_event(&cpu_has_entered_test[core_pos]); - } - - /* Enter the test on lead CPU and return the result. */ - return test_spci_non_blocking_fn(); -} diff --git a/tftf/tests/tests-quark.mk b/tftf/tests/tests-quark.mk deleted file mode 100644 index 0504936b0..000000000 --- a/tftf/tests/tests-quark.mk +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright (c) 2019, Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# - -TESTS_SOURCES += \ - tftf/tests/runtime_services/secure_service/spci_helpers.c \ - tftf/tests/runtime_services/secure_service/test_quark_request.c diff --git a/tftf/tests/tests-quark.xml b/tftf/tests/tests-quark.xml deleted file mode 100644 index 109fa229f..000000000 --- a/tftf/tests/tests-quark.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<!-- - Copyright (c) 2019, Arm Limited. All rights reserved. - - SPDX-License-Identifier: BSD-3-Clause ---> - -<testsuites> - - <testsuite name="Secure Partition Quark tests" - description="Test related to the Secure Partition Quark"> - - <testcase name="Send simple request to Quark" - function="test_quark_request" /> - - </testsuite> - -</testsuites> diff --git a/tools/generate_dtb/generate_dtb.sh b/tools/generate_dtb/generate_dtb.sh index f4a427164..1e0797b06 100755 --- a/tools/generate_dtb/generate_dtb.sh +++ b/tools/generate_dtb/generate_dtb.sh @@ -44,7 +44,6 @@ cat "$ORIGINAL_DTS" > "$COMBINED_DTS" INCLUDES="-I spm/cactus -I spm/ivy - -I spm/quark -I spm/include -I include/lib" |