Commit 91ecca23 authored by Olivier Deprez's avatar Olivier Deprez Committed by TrustedFirmware Code Review
Browse files

Merge changes from topic "spm-devel" into integration

* changes:
  spm-mm: Rename aarch64 assembly files
  spm-mm: Rename source files
  spm-mm: Rename spm_shim_private.h
  spm-mm: Rename spm_private.h
  spm-mm: Rename component makefile
  spm-mm: Remove mm_svc.h header
  spm-mm: Refactor spm_svc.h and its contents
  spm-mm: Refactor secure_partition.h and its contents
  spm: Remove SPM Alpha 1 prototype and support files
  Remove dependency between SPM_MM and ENABLE_SPM build flags
parents b8e17967 99c69109
...@@ -711,7 +711,6 @@ $(eval $(call assert_boolean,ENABLE_PMF)) ...@@ -711,7 +711,6 @@ $(eval $(call assert_boolean,ENABLE_PMF))
$(eval $(call assert_boolean,ENABLE_PSCI_STAT)) $(eval $(call assert_boolean,ENABLE_PSCI_STAT))
$(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION)) $(eval $(call assert_boolean,ENABLE_RUNTIME_INSTRUMENTATION))
$(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS)) $(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS))
$(eval $(call assert_boolean,ENABLE_SPM))
$(eval $(call assert_boolean,ENABLE_SVE_FOR_NS)) $(eval $(call assert_boolean,ENABLE_SVE_FOR_NS))
$(eval $(call assert_boolean,ERROR_DEPRECATED)) $(eval $(call assert_boolean,ERROR_DEPRECATED))
$(eval $(call assert_boolean,FAULT_INJECTION_SUPPORT)) $(eval $(call assert_boolean,FAULT_INJECTION_SUPPORT))
...@@ -776,7 +775,6 @@ $(eval $(call add_define,ENABLE_PMF)) ...@@ -776,7 +775,6 @@ $(eval $(call add_define,ENABLE_PMF))
$(eval $(call add_define,ENABLE_PSCI_STAT)) $(eval $(call add_define,ENABLE_PSCI_STAT))
$(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION)) $(eval $(call add_define,ENABLE_RUNTIME_INSTRUMENTATION))
$(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS)) $(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS))
$(eval $(call add_define,ENABLE_SPM))
$(eval $(call add_define,ENABLE_SVE_FOR_NS)) $(eval $(call add_define,ENABLE_SVE_FOR_NS))
$(eval $(call add_define,ERROR_DEPRECATED)) $(eval $(call add_define,ERROR_DEPRECATED))
$(eval $(call add_define,FAULT_INJECTION_SUPPORT)) $(eval $(call add_define,FAULT_INJECTION_SUPPORT))
......
...@@ -142,7 +142,7 @@ SECTIONS ...@@ -142,7 +142,7 @@ SECTIONS
ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__, ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
"cpu_ops not defined for this platform.") "cpu_ops not defined for this platform.")
#if ENABLE_SPM #if SPM_MM
#ifndef SPM_SHIM_EXCEPTIONS_VMA #ifndef SPM_SHIM_EXCEPTIONS_VMA
#define SPM_SHIM_EXCEPTIONS_VMA RAM #define SPM_SHIM_EXCEPTIONS_VMA RAM
#endif #endif
......
...@@ -5,22 +5,17 @@ ...@@ -5,22 +5,17 @@
# #
################################################################################ ################################################################################
# Include SPM Makefile # Include Makefile for the SPM-MM implementation
################################################################################ ################################################################################
ifeq (${ENABLE_SPM},1) ifeq (${SPM_MM},1)
ifeq (${SPM_MM},1)
ifeq (${EL3_EXCEPTION_HANDLING},0) ifeq (${EL3_EXCEPTION_HANDLING},0)
$(error EL3_EXCEPTION_HANDLING must be 1 for SPM support) $(error EL3_EXCEPTION_HANDLING must be 1 for SPM-MM support)
endif
$(info Including makefile of SPM based on MM)
include services/std_svc/spm_mm/spm.mk
else else
$(info Including SPM makefile) $(info Including SPM Management Mode (MM) makefile)
include services/std_svc/spm/spm.mk include services/std_svc/spm_mm/spm_mm.mk
endif endif
endif endif
include lib/psci/psci_lib.mk include lib/psci/psci_lib.mk
BL31_SOURCES += bl31/bl31_main.c \ BL31_SOURCES += bl31/bl31_main.c \
......
...@@ -160,7 +160,7 @@ are implemented. ...@@ -160,7 +160,7 @@ are implemented.
Partition. Partition.
- ``plat_get_secure_partition_boot_info()`` returns a - ``plat_get_secure_partition_boot_info()`` returns a
``secure_partition_boot_info_t`` struct that is populated by the platform ``spm_mm_boot_info_t`` struct that is populated by the platform
with information about the memory map of the Secure Partition. with information about the memory map of the Secure Partition.
For an example of all the changes in context, you may refer to commit For an example of all the changes in context, you may refer to commit
...@@ -308,8 +308,8 @@ allows the Secure Partition to: ...@@ -308,8 +308,8 @@ allows the Secure Partition to:
Miscellaneous interfaces Miscellaneous interfaces
------------------------ ------------------------
``SPM_VERSION_AARCH32`` ``SPM_MM_VERSION_AARCH32``
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
- Description - Description
...@@ -369,7 +369,7 @@ Secure Partition Initialisation ...@@ -369,7 +369,7 @@ Secure Partition Initialisation
The SPM is responsible for initialising the architectural execution context to The SPM is responsible for initialising the architectural execution context to
enable initialisation of a service in S-EL0. The responsibilities of the SPM are enable initialisation of a service in S-EL0. The responsibilities of the SPM are
listed below. At the end of initialisation, the partition issues a listed below. At the end of initialisation, the partition issues a
``SP_EVENT_COMPLETE_AARCH64`` call (described later) to signal readiness for ``MM_SP_EVENT_COMPLETE_AARCH64`` call (described later) to signal readiness for
handling requests for services implemented by the Secure Partition. The handling requests for services implemented by the Secure Partition. The
initialisation event is executed as a Fast Call. initialisation event is executed as a Fast Call.
...@@ -488,12 +488,12 @@ Runtime Event Delegation ...@@ -488,12 +488,12 @@ Runtime Event Delegation
The SPM receives requests for Secure Partition services through a synchronous The SPM receives requests for Secure Partition services through a synchronous
invocation (i.e. a SMC from the Non-secure world). These requests are delegated invocation (i.e. a SMC from the Non-secure world). These requests are delegated
to the partition by programming a return from the last to the partition by programming a return from the last
``SP_EVENT_COMPLETE_AARCH64`` call received from the partition. The last call ``MM_SP_EVENT_COMPLETE_AARCH64`` call received from the partition. The last call
was made to signal either completion of Secure Partition initialisation or was made to signal either completion of Secure Partition initialisation or
completion of a partition service request. completion of a partition service request.
``SP_EVENT_COMPLETE_AARCH64`` ``MM_SP_EVENT_COMPLETE_AARCH64``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Description - Description
...@@ -569,7 +569,7 @@ completion of a partition service request. ...@@ -569,7 +569,7 @@ completion of a partition service request.
- Caller responsibilities - Caller responsibilities
A Secure Partition must only call ``SP_EVENT_COMPLETE_AARCH64`` to signal A Secure Partition must only call ``MM_SP_EVENT_COMPLETE_AARCH64`` to signal
completion of a request that was delegated to it by the SPM. completion of a request that was delegated to it by the SPM.
- Callee responsibilities - Callee responsibilities
...@@ -613,18 +613,19 @@ data and code) will be known only when the file is loaded into memory. ...@@ -613,18 +613,19 @@ data and code) will be known only when the file is loaded into memory.
In this case, the Secure Partition needs a way to change the access permissions In this case, the Secure Partition needs a way to change the access permissions
of its memory regions. The SPM provides this feature through the of its memory regions. The SPM provides this feature through the
``SP_MEMORY_ATTRIBUTES_SET_AARCH64`` SVC interface. This interface is available ``MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64`` SVC interface. This interface is
to the Secure Partition during a specific time window: from the first entry into available to the Secure Partition during a specific time window: from the first
the Secure Partition up to the first ``SP_EVENT_COMPLETE`` call that signals the entry into the Secure Partition up to the first ``SP_EVENT_COMPLETE`` call that
Secure Partition has finished its initialisation. Once the initialisation is signals the Secure Partition has finished its initialisation. Once the
complete, the SPM does not allow changes to the memory attributes. initialisation is complete, the SPM does not allow changes to the memory
attributes.
This section describes the standard SVC interface that is implemented by the SPM This section describes the standard SVC interface that is implemented by the SPM
to determine and change permission attributes of memory regions that belong to a to determine and change permission attributes of memory regions that belong to a
Secure Partition. Secure Partition.
``SP_MEMORY_ATTRIBUTES_GET_AARCH64`` ``MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Description - Description
...@@ -673,7 +674,7 @@ Secure Partition. ...@@ -673,7 +674,7 @@ Secure Partition.
- ``NOT_SUPPORTED`` : The SPM does not support retrieval of attributes of - ``NOT_SUPPORTED`` : The SPM does not support retrieval of attributes of
any memory page that is accessible by the Secure Partition, or the any memory page that is accessible by the Secure Partition, or the
function was called from the Non-secure world. Also returned if it is function was called from the Non-secure world. Also returned if it is
used after ``SP_EVENT_COMPLETE_AARCH64``. used after ``MM_SP_EVENT_COMPLETE_AARCH64``.
See `Error Codes`_ for integer values that are associated with each return See `Error Codes`_ for integer values that are associated with each return
code. code.
...@@ -696,8 +697,8 @@ Secure Partition. ...@@ -696,8 +697,8 @@ Secure Partition.
The SPM must not return the memory access controls for a page of memory that The SPM must not return the memory access controls for a page of memory that
is not accessible from a Secure Partition. is not accessible from a Secure Partition.
``SP_MEMORY_ATTRIBUTES_SET_AARCH64`` ``MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Description - Description
...@@ -762,7 +763,7 @@ Secure Partition. ...@@ -762,7 +763,7 @@ Secure Partition.
- ``NOT_SUPPORTED``: The SPM does not permit change of attributes of any - ``NOT_SUPPORTED``: The SPM does not permit change of attributes of any
memory region that is accessible by the Secure Partition. Function was memory region that is accessible by the Secure Partition. Function was
called from the Non-secure world. Also returned if it is used after called from the Non-secure world. Also returned if it is used after
``SP_EVENT_COMPLETE_AARCH64``. ``MM_SP_EVENT_COMPLETE_AARCH64``.
See `Error Codes`_ for integer values that are associated with each return See `Error Codes`_ for integer values that are associated with each return
code. code.
...@@ -776,8 +777,8 @@ Secure Partition. ...@@ -776,8 +777,8 @@ Secure Partition.
currently supported. currently supported.
This function is only available at boot time. This interface is revoked after This function is only available at boot time. This interface is revoked after
the Secure Partition sends the first ``SP_EVENT_COMPLETE_AARCH64`` to signal the Secure Partition sends the first ``MM_SP_EVENT_COMPLETE_AARCH64`` to
that it is initialised and ready to receive run-time requests. signal that it is initialised and ready to receive run-time requests.
- Caller responsibilities - Caller responsibilities
......
...@@ -235,10 +235,6 @@ Common build options ...@@ -235,10 +235,6 @@ Common build options
The default is 1 but is automatically disabled when the target architecture The default is 1 but is automatically disabled when the target architecture
is AArch32. is AArch32.
- ``ENABLE_SPM`` : Boolean option to enable the Secure Partition Manager (SPM).
Refer to :ref:`Secure Partition Manager` for more details about
this feature. Default is 0.
- ``ENABLE_SVE_FOR_NS``: Boolean option to enable Scalable Vector Extension - ``ENABLE_SVE_FOR_NS``: Boolean option to enable Scalable Vector Extension
(SVE) for the Non-secure world only. SVE is an optional architectural feature (SVE) for the Non-secure world only. SVE is an optional architectural feature
for AArch64. Note that when SVE is enabled for the Non-secure world, access for AArch64. Note that when SVE is enabled for the Non-secure world, access
...@@ -507,6 +503,9 @@ Common build options ...@@ -507,6 +503,9 @@ Common build options
firmware images have been loaded in memory, and the MMU and caches are firmware images have been loaded in memory, and the MMU and caches are
turned off. Refer to the "Debugging options" section for more details. turned off. Refer to the "Debugging options" section for more details.
- ``SPM_MM`` : Boolean option to enable the Management Mode (MM)-based Secure
Partition Manager (SPM) implementation. The default value is ``0``.
- ``SP_MIN_WITH_SECURE_FIQ``: Boolean flag to indicate the SP_MIN handles - ``SP_MIN_WITH_SECURE_FIQ``: Boolean flag to indicate the SP_MIN handles
secure interrupts (caught through the FIQ line). Platforms can enable secure interrupts (caught through the FIQ line). Platforms can enable
this directive if they need to handle such interruption. When enabled, this directive if they need to handle such interruption. When enabled,
......
/*
* 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_TUN_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 */
/*
* Copyright (c) 2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SPRT_HOST_H
#define SPRT_HOST_H
#include <stddef.h>
#include "sprt_common.h"
/*
* Initialize the specified buffer to be used by SPM.
*/
void sprt_initialize_queues(void *buffer_base, size_t buffer_size);
/*
* Push a message to the queue number `queue_num` in a buffer that has been
* initialized by `sprt_initialize_queues`.
*/
int sprt_push_message(void *buffer_base,
const struct sprt_queue_entry_message *message,
int queue_num);
#endif /* SPRT_HOST_H */
...@@ -457,7 +457,7 @@ ...@@ -457,7 +457,7 @@
* Trusted DRAM (if available) or the DRAM region secured by the TrustZone * Trusted DRAM (if available) or the DRAM region secured by the TrustZone
* controller. * controller.
*/ */
# if ENABLE_SPM # if SPM_MM
# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) # define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000)) # define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000))
# define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) # define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000))
...@@ -500,9 +500,9 @@ ...@@ -500,9 +500,9 @@
* SPD and no SPM, as they are the only ones that can be used as BL32. * SPD and no SPM, as they are the only ones that can be used as BL32.
*/ */
#if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME #if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME
# if defined(SPD_none) && !ENABLE_SPM # if defined(SPD_none) && !SPM_MM
# undef BL32_BASE # undef BL32_BASE
# endif /* defined(SPD_none) && !ENABLE_SPM */ # endif /* defined(SPD_none) && !SPM_MM*/
#endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */ #endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */
/******************************************************************************* /*******************************************************************************
......
...@@ -9,31 +9,6 @@ ...@@ -9,31 +9,6 @@
#include <lib/utils_def.h> #include <lib/utils_def.h>
#include <lib/xlat_tables/xlat_tables_defs.h> #include <lib/xlat_tables/xlat_tables_defs.h>
/*
* Reserve 4 MiB for binaries of Secure Partitions and Resource Description
* blobs.
*/
#define PLAT_SP_PACKAGE_BASE BL32_BASE
#define PLAT_SP_PACKAGE_SIZE ULL(0x400000)
#define PLAT_MAP_SP_PACKAGE_MEM_RO MAP_REGION_FLAT( \
PLAT_SP_PACKAGE_BASE, \
PLAT_SP_PACKAGE_SIZE, \
MT_MEMORY | MT_RO | MT_SECURE)
#define PLAT_MAP_SP_PACKAGE_MEM_RW MAP_REGION_FLAT( \
PLAT_SP_PACKAGE_BASE, \
PLAT_SP_PACKAGE_SIZE, \
MT_MEMORY | MT_RW | MT_SECURE)
/*
* The rest of the memory reserved for BL32 is free for SPM to use it as memory
* pool to allocate memory regions requested in the resource description.
*/
#define PLAT_SPM_HEAP_BASE (PLAT_SP_PACKAGE_BASE + PLAT_SP_PACKAGE_SIZE)
#define PLAT_SPM_HEAP_SIZE (BL32_LIMIT - BL32_BASE - PLAT_SP_PACKAGE_SIZE)
#if SPM_MM
/* /*
* If BL31 is placed in DRAM, place the Secure Partition in DRAM right after the * If BL31 is placed in DRAM, place the Secure Partition in DRAM right after the
* region used by BL31. If BL31 it is placed in SRAM, put the Secure Partition * region used by BL31. If BL31 it is placed in SRAM, put the Secure Partition
...@@ -121,23 +96,8 @@ ...@@ -121,23 +96,8 @@
/* Total number of memory regions with distinct properties */ /* Total number of memory regions with distinct properties */
#define ARM_SP_IMAGE_NUM_MEM_REGIONS 6 #define ARM_SP_IMAGE_NUM_MEM_REGIONS 6
#endif /* SPM_MM */
/* Cookies passed to the Secure Partition at boot. Not used by ARM platforms. */ /* Cookies passed to the Secure Partition at boot. Not used by ARM platforms. */
#define PLAT_SPM_COOKIE_0 ULL(0) #define PLAT_SPM_COOKIE_0 ULL(0)
#define PLAT_SPM_COOKIE_1 ULL(0) #define PLAT_SPM_COOKIE_1 ULL(0)
/*
* Max number of elements supported by SPM in this platform. The defines below
* are used to allocate memory at compile time for different arrays in SPM.
*/
#define PLAT_SPM_MAX_PARTITIONS U(2)
#define PLAT_SPM_MEM_REGIONS_MAX U(80)
#define PLAT_SPM_NOTIFICATIONS_MAX U(30)
#define PLAT_SPM_SERVICES_MAX U(30)
#define PLAT_SPCI_HANDLES_MAX_NUM U(20)
#define PLAT_SPM_RESPONSES_MAX U(30)
#endif /* ARM_SPM_DEF_H */ #endif /* ARM_SPM_DEF_H */
...@@ -38,7 +38,7 @@ typedef struct arm_tzc_regions_info { ...@@ -38,7 +38,7 @@ typedef struct arm_tzc_regions_info {
* - Region 1 with secure access only; * - Region 1 with secure access only;
* - the remaining DRAM regions access from the given Non-Secure masters. * - the remaining DRAM regions access from the given Non-Secure masters.
******************************************************************************/ ******************************************************************************/
#if ENABLE_SPM && SPM_MM #if SPM_MM
#define ARM_TZC_REGIONS_DEF \ #define ARM_TZC_REGIONS_DEF \
{ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END, \ {ARM_AP_TZC_DRAM1_BASE, ARM_EL3_TZC_DRAM1_END, \
TZC_REGION_S_RDWR, 0}, \ TZC_REGION_S_RDWR, 0}, \
......
...@@ -22,7 +22,7 @@ struct image_desc; ...@@ -22,7 +22,7 @@ struct image_desc;
struct bl_load_info; struct bl_load_info;
struct bl_params; struct bl_params;
struct mmap_region; struct mmap_region;
struct secure_partition_boot_info; struct spm_mm_boot_info;
struct sp_res_desc; struct sp_res_desc;
/******************************************************************************* /*******************************************************************************
...@@ -267,7 +267,7 @@ int get_mbedtls_heap_helper(void **heap_addr, size_t *heap_size); ...@@ -267,7 +267,7 @@ int get_mbedtls_heap_helper(void **heap_addr, size_t *heap_size);
* Secure Partitions functions * Secure Partitions functions
******************************************************************************/ ******************************************************************************/
const struct mmap_region *plat_get_secure_partition_mmap(void *cookie); const struct mmap_region *plat_get_secure_partition_mmap(void *cookie);
const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
void *cookie); void *cookie);
int plat_spm_sp_rd_load(struct sp_res_desc *rd, const void *ptr, size_t size); int plat_spm_sp_rd_load(struct sp_res_desc *rd, const void *ptr, size_t size);
int plat_spm_sp_get_next_address(void **sp_base, size_t *sp_size, int plat_spm_sp_get_next_address(void **sp_base, size_t *sp_size,
......
/*
* Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MM_SVC_H
#define MM_SVC_H
#if SPM_MM
#include <lib/utils_def.h>
#define MM_VERSION_MAJOR U(1)
#define MM_VERSION_MAJOR_SHIFT 16
#define MM_VERSION_MAJOR_MASK U(0x7FFF)
#define MM_VERSION_MINOR U(0)
#define MM_VERSION_MINOR_SHIFT 0
#define MM_VERSION_MINOR_MASK U(0xFFFF)
#define MM_VERSION_FORM(major, minor) ((major << MM_VERSION_MAJOR_SHIFT) | (minor))
#define MM_VERSION_COMPILED MM_VERSION_FORM(MM_VERSION_MAJOR, MM_VERSION_MINOR)
/*
* SMC IDs defined in [1] for accessing MM services from the Non-secure world.
* These FIDs occupy the range 0x40 - 0x5f.
* [1] DEN0060A_ARM_MM_Interface_Specification.pdf
*/
#define MM_VERSION_AARCH32 U(0x84000040)
#define MM_COMMUNICATE_AARCH64 U(0xC4000041)
#define MM_COMMUNICATE_AARCH32 U(0x84000041)
#endif /* SPM_MM */
#endif /* MM_SVC_H */
/*
* Copyright (c) 2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SPM_RES_DESC_H
#define SPM_RES_DESC_H
#include <stdint.h>
#include <services/sp_res_desc_def.h>
/*******************************************************************************
* Attribute Section
******************************************************************************/
struct sp_rd_sect_attribute {
/*
* Version of the resource description.
*/
uint16_t version;
/*
* Type of the Secure Partition:
* - bit[0]: SP Type
* - b'0: UP SP
* - b'1: MP SP
* If UP SP:
* - bit[1]: Type of UP SP
* - b'0: Migratable UP SP
* - b'1: Pinned UP SP
*/
uint16_t sp_type;
/*
* If this is a Pinned UP SP, PE on which the Pinned UP SP will run.
*/
uint32_t pe_mpidr;
/*
* Run-Time Exception Level:
* - 0: SEL0 SP
* - 1: SEL1 SP
*/
uint8_t runtime_el;
/*
* Type of Execution:
* - 0: Init-time only
* - 1: Run-time Execution
*/
uint8_t exec_type;
/*
* Expected behavior upon failure:
* - 0: Restartable
* - 1: One-Shot
*/
uint8_t panic_policy;
/*
* Translation Granule to use in the SP translation regime:
* - 0: 4KB
* - 1: 16KB
* - 2: 64KB
*/
uint8_t xlat_granule;
/*
* Size of the SP binary in bytes.
*/
uint32_t binary_size;
/*
* - If SP is NOT PIE:
* - VA Address where the SP expects to be loaded.
* - If SP is PIE:
* - Ignored.
*/
uint64_t load_address;
/*
* Initial execution address. This is a VA as the SP sees it.
*/
uint64_t entrypoint;
};
/*******************************************************************************
* Memory Region Section
******************************************************************************/
struct sp_rd_sect_mem_region {
/*
* Name of a Memory region, including null terminator. Reserved names:
* - "Client Shared Memory Region":
* Memory region where memory shared by clients shall be mapped.
* - "Queue Memory Region":
* Memory region shared with SPM for SP queue management.
*/
char name[RD_MEM_REGION_NAME_LEN];
/*
* Memory Attributes:
* - bits[3:0]: Type of memory
* - 0: Device
* - 1: Code
* - 2: Data
* - 3: BSS
* - 4: Read-only Data
* - 5: SPM-to-SP Shared Memory Region
* - 6: Client Shared Memory Region
* - 7: Miscellaneous
* - If memory is { SPM-to-SP shared Memory, Client Shared Memory,
* Miscellaneous }
* - bits[4]: Position Independent
* - b'0: Position Dependent
* - b'1: Position Independent
*/
uint32_t attr;
/*
* Base address of the memory region.
*/
uint64_t base;
/*
* Size of the memory region.
*/
uint64_t size;
/*
* Pointer to next memory region (or NULL if this is the last one).
*/
struct sp_rd_sect_mem_region *next;
};
/*******************************************************************************
* Notification Section
******************************************************************************/
struct sp_rd_sect_notification {
/*
* Notification attributes:
* - bit[31]: Notification Type
* - b'0: Platform Notification
* - b'1: Interrupt
* If Notification Type == Platform Notification
* - bits[15:0]: Implementation-defined Notification ID
* If Notification Type == Interrupt
* - bits[15:0]: IRQ number
* - bits[23:16]: Interrupt Priority
* - bit[24]: Trigger Type
* - b'0: Edge Triggered
* - b'1: Level Triggered
* - bit[25]: Trigger Level
* - b'0: Falling or Low
* - b'1: Rising or High
*/
uint32_t attr;
/*
* Processing Element.
* If Notification Type == Interrupt && IRQ number is { SGI, LPI }
* - PE ID to which IRQ will be forwarded
*/
uint32_t pe;
/*
* Pointer to next notification (or NULL if this is the last one).
*/
struct sp_rd_sect_notification *next;
};
/*******************************************************************************
* Service Description Section
******************************************************************************/
struct sp_rd_sect_service {
/*
* Service identifier.
*/
uint32_t uuid[4];
/*
* Accessibility Options:
* - bit[0]: Accessibility by secure-world clients
* - b'0: Not Accessible
* - b'1: Accessible
* - bit[1]: Accessible by EL3
* - b'0: Not Accessible
* - b'1: Accessible
* - bit[2]: Accessible by normal-world clients
* - b'0: Not Accessible
* - b'1: Accessible
*/
uint8_t accessibility;
/*
* Request type supported:
* - bit[0]: Blocking request
* - b'0: Not Enable
* - b'1: Enable
* - bit[1]: Non-blocking request
* - b'0: Not Enable
* - b'1: Enable
*/
uint8_t request_type;
/*
* Maximum number of client connections that the service can support.
*/
uint16_t connection_quota;
/*
* If the service requires secure world memory to be shared with its
* clients:
* - Maximum amount of secure world memory in bytes to reserve from the
* secure world memory pool for the service.
*/
uint32_t secure_mem_size;
/*
* Interrupt number used to notify the SP for the service.
* - Should also be enabled in the Notification Section.
*/
uint32_t interrupt_num;
/*
* Pointer to next service (or NULL if this is the last one).
*/
struct sp_rd_sect_service *next;
};
/*******************************************************************************
* Complete resource description struct
******************************************************************************/
struct sp_res_desc {
/* Attribute Section */
struct sp_rd_sect_attribute attribute;
/* System Resource Section */
struct sp_rd_sect_mem_region *mem_region;
struct sp_rd_sect_notification *notification;
/* Service Section */
struct sp_rd_sect_service *service;
};
#endif /* SPM_RES_DESC_H */
/*
* 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 <lib/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 */
/*
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SPCI_SVC_H
#define SPCI_SVC_H
#include <lib/smccc.h>
#include <lib/utils_def.h>
/* SPCI_VERSION helpers */
#define SPCI_VERSION_MAJOR U(0)
#define SPCI_VERSION_MAJOR_SHIFT 16
#define SPCI_VERSION_MAJOR_MASK U(0x7FFF)
#define SPCI_VERSION_MINOR U(1)
#define SPCI_VERSION_MINOR_SHIFT 0
#define SPCI_VERSION_MINOR_MASK U(0xFFFF)
#define SPCI_VERSION_FORM(major, minor) ((((major) & SPCI_VERSION_MAJOR_MASK) \
<< SPCI_VERSION_MAJOR_SHIFT) | \
((minor) & SPCI_VERSION_MINOR_MASK))
#define SPCI_VERSION_COMPILED SPCI_VERSION_FORM(SPCI_VERSION_MAJOR, \
SPCI_VERSION_MINOR)
/* Definitions to build the complete SMC ID */
#define SPCI_FID_MISC_FLAG (U(0) << 27)
#define SPCI_FID_MISC_SHIFT U(20)
#define SPCI_FID_MISC_MASK U(0x7F)
#define SPCI_FID_TUN_FLAG (U(1) << 27)
#define SPCI_FID_TUN_SHIFT U(24)
#define SPCI_FID_TUN_MASK U(0x7)
#define OEN_SPCI_START U(0x30)
#define OEN_SPCI_END U(0x3F)
#define SPCI_SMC(spci_fid) ((OEN_SPCI_START << FUNCID_OEN_SHIFT) | \
(U(1) << 31) | (spci_fid))
#define SPCI_MISC_32(misc_fid) ((SMC_32 << FUNCID_CC_SHIFT) | \
SPCI_FID_MISC_FLAG | \
SPCI_SMC((misc_fid) << SPCI_FID_MISC_SHIFT))
#define SPCI_MISC_64(misc_fid) ((SMC_64 << FUNCID_CC_SHIFT) | \
SPCI_FID_MISC_FLAG | \
SPCI_SMC((misc_fid) << SPCI_FID_MISC_SHIFT))
#define SPCI_TUN_32(tun_fid) ((SMC_32 << FUNCID_CC_SHIFT) | \
SPCI_FID_TUN_FLAG | \
SPCI_SMC((tun_fid) << SPCI_FID_TUN_SHIFT))
#define SPCI_TUN_64(tun_fid) ((SMC_64 << FUNCID_CC_SHIFT) | \
SPCI_FID_TUN_FLAG | \
SPCI_SMC((tun_fid) << SPCI_FID_TUN_SHIFT))
/* SPCI miscellaneous functions */
#define SPCI_FID_VERSION U(0x0)
#define SPCI_FID_SERVICE_HANDLE_OPEN U(0x2)
#define SPCI_FID_SERVICE_HANDLE_CLOSE U(0x3)
#define SPCI_FID_SERVICE_MEM_REGISTER U(0x4)
#define SPCI_FID_SERVICE_MEM_UNREGISTER U(0x5)
#define SPCI_FID_SERVICE_MEM_PUBLISH U(0x6)
#define SPCI_FID_SERVICE_REQUEST_BLOCKING U(0x7)
#define SPCI_FID_SERVICE_REQUEST_START U(0x8)
#define SPCI_FID_SERVICE_GET_RESPONSE U(0x9)
#define SPCI_FID_SERVICE_RESET_CLIENT_STATE U(0xA)
/* SPCI tunneling functions */
#define SPCI_FID_SERVICE_TUN_REQUEST_START U(0x0)
#define SPCI_FID_SERVICE_REQUEST_RESUME U(0x1)
#define SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING U(0x2)
/* Complete SMC IDs and associated values */
#define SPCI_VERSION SPCI_MISC_32(SPCI_FID_VERSION)
#define SPCI_SERVICE_HANDLE_OPEN SPCI_MISC_32(SPCI_FID_SERVICE_HANDLE_OPEN)
#define SPCI_SERVICE_HANDLE_OPEN_NOTIFY_BIT U(1)
#define SPCI_SERVICE_HANDLE_CLOSE SPCI_MISC_32(SPCI_FID_SERVICE_HANDLE_CLOSE)
#define SPCI_SERVICE_MEM_REGISTER_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_REGISTER)
#define SPCI_SERVICE_MEM_REGISTER_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_REGISTER)
#define SPCI_SERVICE_MEM_UNREGISTER_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_UNREGISTER)
#define SPCI_SERVICE_MEM_UNREGISTER_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_UNREGISTER)
#define SPCI_SERVICE_MEM_PUBLISH_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_MEM_PUBLISH)
#define SPCI_SERVICE_MEM_PUBLISH_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_MEM_PUBLISH)
#define SPCI_SERVICE_REQUEST_BLOCKING_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_REQUEST_BLOCKING)
#define SPCI_SERVICE_REQUEST_BLOCKING_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_REQUEST_BLOCKING)
#define SPCI_SERVICE_REQUEST_START_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_REQUEST_START)
#define SPCI_SERVICE_REQUEST_START_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_REQUEST_START)
#define SPCI_SERVICE_GET_RESPONSE_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_GET_RESPONSE)
#define SPCI_SERVICE_GET_RESPONSE_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_GET_RESPONSE)
#define SPCI_SERVICE_RESET_CLIENT_STATE_AARCH32 SPCI_MISC_32(SPCI_FID_SERVICE_RESET_CLIENT_STATE)
#define SPCI_SERVICE_RESET_CLIENT_STATE_AARCH64 SPCI_MISC_64(SPCI_FID_SERVICE_RESET_CLIENT_STATE)
#define SPCI_SERVICE_TUN_REQUEST_START_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_TUN_REQUEST_START)
#define SPCI_SERVICE_TUN_REQUEST_START_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_TUN_REQUEST_START)
#define SPCI_SERVICE_REQUEST_RESUME_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_REQUEST_RESUME)
#define SPCI_SERVICE_REQUEST_RESUME_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_REQUEST_RESUME)
#define SPCI_SERVICE_TUN_REQUEST_BLOCKING_AARCH32 SPCI_TUN_32(SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING)
#define SPCI_SERVICE_TUN_REQUEST_BLOCKING_AARCH64 SPCI_TUN_64(SPCI_FID_SERVICE_TUN_REQUEST_BLOCKING)
/* SPCI error codes. */
#define SPCI_SUCCESS 0
#define SPCI_NOT_SUPPORTED -1
#define SPCI_INVALID_PARAMETER -2
#define SPCI_NO_MEMORY -3
#define SPCI_BUSY -4
#define SPCI_QUEUED -5
#define SPCI_DENIED -6
#define SPCI_NOT_PRESENT -7
#endif /* SPCI_SVC_H */
...@@ -4,17 +4,15 @@ ...@@ -4,17 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#ifndef SECURE_PARTITION_H #ifndef SPM_MM_PARTITION_H
#define SECURE_PARTITION_H #define SPM_MM_PARTITION_H
#if SPM_MM
#include <stdint.h> #include <stdint.h>
#include <lib/utils_def.h> #include <lib/utils_def.h>
/* /*
* Flags used by the secure_partition_mp_info structure to describe the * Flags used by the spm_mm_mp_info structure to describe the
* characteristics of a cpu. Only a single flag is defined at the moment to * characteristics of a cpu. Only a single flag is defined at the moment to
* indicate the primary cpu. * indicate the primary cpu.
*/ */
...@@ -24,13 +22,13 @@ ...@@ -24,13 +22,13 @@
* This structure is used to provide information required to initialise a S-EL0 * This structure is used to provide information required to initialise a S-EL0
* partition. * partition.
*/ */
typedef struct secure_partition_mp_info { typedef struct spm_mm_mp_info {
uint64_t mpidr; uint64_t mpidr;
uint32_t linear_id; uint32_t linear_id;
uint32_t flags; uint32_t flags;
} secure_partition_mp_info_t; } spm_mm_mp_info_t;
typedef struct secure_partition_boot_info { typedef struct spm_mm_boot_info {
param_header_t h; param_header_t h;
uint64_t sp_mem_base; uint64_t sp_mem_base;
uint64_t sp_mem_limit; uint64_t sp_mem_limit;
...@@ -46,9 +44,7 @@ typedef struct secure_partition_boot_info { ...@@ -46,9 +44,7 @@ typedef struct secure_partition_boot_info {
uint64_t sp_shared_buf_size; uint64_t sp_shared_buf_size;
uint32_t num_sp_mem_regions; uint32_t num_sp_mem_regions;
uint32_t num_cpus; uint32_t num_cpus;
secure_partition_mp_info_t *mp_info; spm_mm_mp_info_t *mp_info;
} secure_partition_boot_info_t; } spm_mm_boot_info_t;
#endif /* SPM_MM */
#endif /* SECURE_PARTITION_H */ #endif /* SPM_MM_PARTITION_H */
/*
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SPM_MM_SVC_H
#define SPM_MM_SVC_H
#include <lib/utils_def.h>
/*
* The MM_VERSION_XXX definitions are used when responding to the
* MM_VERSION_AARCH32 service request. The version returned is different between
* this request and the SPM_MM_VERSION_AARCH32 request - both have been retained
* for compatibility.
*/
#define MM_VERSION_MAJOR U(1)
#define MM_VERSION_MAJOR_SHIFT 16
#define MM_VERSION_MAJOR_MASK U(0x7FFF)
#define MM_VERSION_MINOR U(0)
#define MM_VERSION_MINOR_SHIFT 0
#define MM_VERSION_MINOR_MASK U(0xFFFF)
#define MM_VERSION_FORM(major, minor) ((major << MM_VERSION_MAJOR_SHIFT) | \
(minor))
#define MM_VERSION_COMPILED MM_VERSION_FORM(MM_VERSION_MAJOR, \
MM_VERSION_MINOR)
#define SPM_MM_VERSION_MAJOR U(0)
#define SPM_MM_VERSION_MAJOR_SHIFT 16
#define SPM_MM_VERSION_MAJOR_MASK U(0x7FFF)
#define SPM_MM_VERSION_MINOR U(1)
#define SPM_MM_VERSION_MINOR_SHIFT 0
#define SPM_MM_VERSION_MINOR_MASK U(0xFFFF)
#define SPM_MM_VERSION_FORM(major, minor) ((major << \
SPM_MM_VERSION_MAJOR_SHIFT) | \
(minor))
#define SPM_MM_VERSION_COMPILED SPM_MM_VERSION_FORM(SPM_MM_VERSION_MAJOR, \
SPM_MM_VERSION_MINOR)
/* These macros are used to identify SPM-MM calls using the SMC function ID */
#define SPM_MM_FID_MASK U(0xffff)
#define SPM_MM_FID_MIN_VALUE U(0x40)
#define SPM_MM_FID_MAX_VALUE U(0x7f)
#define is_spm_mm_fid(_fid) \
((((_fid) & SPM_MM_FID_MASK) >= SPM_MM_FID_MIN_VALUE) && \
(((_fid) & SPM_MM_FID_MASK) <= SPM_MM_FID_MAX_VALUE))
/*
* SMC IDs defined in [1] for accessing MM services from the Non-secure world.
* These FIDs occupy the range 0x40 - 0x5f.
* [1] DEN0060A_ARM_MM_Interface_Specification.pdf
*/
#define MM_VERSION_AARCH32 U(0x84000040)
#define MM_COMMUNICATE_AARCH64 U(0xC4000041)
#define MM_COMMUNICATE_AARCH32 U(0x84000041)
/*
* SMC IDs defined for accessing services implemented by the Secure Partition
* Manager from the Secure Partition(s). These services enable a partition to
* handle delegated events and request privileged operations from the manager.
* They occupy the range 0x60-0x7f.
*/
#define SPM_MM_VERSION_AARCH32 U(0x84000060)
#define MM_SP_EVENT_COMPLETE_AARCH64 U(0xC4000061)
#define MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64 U(0xC4000064)
#define MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64 U(0xC4000065)
/*
* Macros used by MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
*/
#define MM_SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS U(0)
#define MM_SP_MEMORY_ATTRIBUTES_ACCESS_RW U(1)
/* Value U(2) is reserved. */
#define MM_SP_MEMORY_ATTRIBUTES_ACCESS_RO U(3)
#define MM_SP_MEMORY_ATTRIBUTES_ACCESS_MASK U(3)
#define MM_SP_MEMORY_ATTRIBUTES_ACCESS_SHIFT 0
#define MM_SP_MEMORY_ATTRIBUTES_EXEC (U(0) << 2)
#define MM_SP_MEMORY_ATTRIBUTES_NON_EXEC (U(1) << 2)
/* SPM error codes. */
#define SPM_MM_SUCCESS 0
#define SPM_MM_NOT_SUPPORTED -1
#define SPM_MM_INVALID_PARAMETER -2
#define SPM_MM_DENIED -3
#define SPM_MM_NO_MEMORY -5
#ifndef __ASSEMBLER__
#include <stdint.h>
int32_t spm_mm_setup(void);
uint64_t spm_mm_smc_handler(uint32_t smc_fid,
uint64_t x1,
uint64_t x2,
uint64_t x3,
uint64_t x4,
void *cookie,
void *handle,
uint64_t flags);
/* Helper to enter a secure partition */
uint64_t spm_mm_sp_call(uint32_t smc_fid,
uint64_t x1,
uint64_t x2,
uint64_t x3);
#endif /* __ASSEMBLER__ */
#endif /* SPM_MM_SVC_H */
/*
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SPM_SVC_H
#define SPM_SVC_H
#if SPM_MM
#include <lib/utils_def.h>
#define SPM_VERSION_MAJOR U(0)
#define SPM_VERSION_MAJOR_SHIFT 16
#define SPM_VERSION_MAJOR_MASK U(0x7FFF)
#define SPM_VERSION_MINOR U(1)
#define SPM_VERSION_MINOR_SHIFT 0
#define SPM_VERSION_MINOR_MASK U(0xFFFF)
#define SPM_VERSION_FORM(major, minor) ((major << SPM_VERSION_MAJOR_SHIFT) | (minor))
#define SPM_VERSION_COMPILED SPM_VERSION_FORM(SPM_VERSION_MAJOR, SPM_VERSION_MINOR)
/* The macros below are used to identify SPM calls from the SMC function ID */
#define SPM_FID_MASK U(0xffff)
#define SPM_FID_MIN_VALUE U(0x40)
#define SPM_FID_MAX_VALUE U(0x7f)
#define is_spm_fid(_fid) \
((((_fid) & SPM_FID_MASK) >= SPM_FID_MIN_VALUE) && \
(((_fid) & SPM_FID_MASK) <= SPM_FID_MAX_VALUE))
/*
* SMC IDs defined for accessing services implemented by the Secure Partition
* Manager from the Secure Partition(s). These services enable a partition to
* handle delegated events and request privileged operations from the manager.
* They occupy the range 0x60-0x7f.
*/
#define SPM_VERSION_AARCH32 U(0x84000060)
#define SP_EVENT_COMPLETE_AARCH64 U(0xC4000061)
#define SP_MEMORY_ATTRIBUTES_GET_AARCH64 U(0xC4000064)
#define SP_MEMORY_ATTRIBUTES_SET_AARCH64 U(0xC4000065)
/*
* Macros used by SP_MEMORY_ATTRIBUTES_SET_AARCH64.
*/
#define SP_MEMORY_ATTRIBUTES_ACCESS_NOACCESS U(0)
#define SP_MEMORY_ATTRIBUTES_ACCESS_RW U(1)
/* Value U(2) is reserved. */
#define SP_MEMORY_ATTRIBUTES_ACCESS_RO U(3)
#define SP_MEMORY_ATTRIBUTES_ACCESS_MASK U(3)
#define SP_MEMORY_ATTRIBUTES_ACCESS_SHIFT 0
#define SP_MEMORY_ATTRIBUTES_EXEC (U(0) << 2)
#define SP_MEMORY_ATTRIBUTES_NON_EXEC (U(1) << 2)
/* SPM error codes. */
#define SPM_SUCCESS 0
#define SPM_NOT_SUPPORTED -1
#define SPM_INVALID_PARAMETER -2
#define SPM_DENIED -3
#define SPM_NO_MEMORY -5
#endif /* SPM_MM */
#ifndef __ASSEMBLER__
#include <stdint.h>
int32_t spm_setup(void);
#if SPM_MM
uint64_t spm_smc_handler(uint32_t smc_fid,
uint64_t x1,
uint64_t x2,
uint64_t x3,
uint64_t x4,
void *cookie,
void *handle,
uint64_t flags);
/* Helper to enter a Secure Partition */
uint64_t spm_sp_call(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3);
#endif /* SPM_MM */
#endif /* __ASSEMBLER__ */
#endif /* SPM_SVC_H */
/*
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SPRT_SVC_H
#define SPRT_SVC_H
#include <lib/smccc.h>
#include <lib/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 */
/*
* Copyright (c) 2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include "sprt_common.h"
#include "sprt_queue.h"
void sprt_initialize_queues(void *buffer_base, size_t buffer_size)
{
/* Initialize queue for blocking messages */
void *blocking_base = buffer_base;
uint32_t blocking_num = 4U;
size_t blocking_size = SPRT_QUEUE_HEADER_SIZE +
SPRT_QUEUE_ENTRY_MSG_SIZE * blocking_num;
sprt_queue_init(blocking_base, blocking_num, SPRT_QUEUE_ENTRY_MSG_SIZE);
/* Initialize queue for non-blocking messages */
void *non_blocking_base = (void *)((uintptr_t)blocking_base + blocking_size);
size_t non_blocking_size = buffer_size - blocking_size;
uint32_t non_blocking_num = (non_blocking_size - SPRT_QUEUE_HEADER_SIZE) /
SPRT_QUEUE_ENTRY_MSG_SIZE;
sprt_queue_init(non_blocking_base, non_blocking_num, SPRT_QUEUE_ENTRY_MSG_SIZE);
}
int sprt_push_message(void *buffer_base,
const struct sprt_queue_entry_message *message,
int queue_num)
{
struct sprt_queue *q = buffer_base;
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_push(q, message);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment