mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
Merge changes from topic "ffa_el3_spmc" into integration
* changes: feat(fvp): add plat hook for memory transactions feat(spmc): enable handling of the NS bit feat(spmc): add support for v1.1 FF-A memory data structures feat(spmc/mem): prevent duplicated sharing of memory regions feat(spmc/mem): support multiple endpoints in memory transactions feat(spmc): add support for v1.1 FF-A boot protocol feat(plat/fvp): introduce accessor function to obtain datastore feat(spmc/mem): add FF-A memory management code
This commit is contained in:
commit
70313d363b
12 changed files with 2652 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
|
@ -104,6 +104,13 @@
|
|||
#define round_down(value, boundary) \
|
||||
((value) & ~round_boundary(value, boundary))
|
||||
|
||||
/**
|
||||
* Helper macro to ensure a value lies on a given boundary.
|
||||
*/
|
||||
#define is_aligned(value, boundary) \
|
||||
(round_up((uintptr_t) value, boundary) == \
|
||||
round_down((uintptr_t) value, boundary))
|
||||
|
||||
/*
|
||||
* Evaluates to 1 if (ptr + inc) overflows, 0 otherwise.
|
||||
* Both arguments must be unsigned pointer values (i.e. uintptr_t).
|
||||
|
|
|
@ -347,6 +347,10 @@ int plat_spm_sp_get_next_address(void **sp_base, size_t *sp_size,
|
|||
int plat_spm_core_manifest_load(spmc_manifest_attribute_t *manifest,
|
||||
const void *pm_addr);
|
||||
#endif
|
||||
#if defined(SPMC_AT_EL3)
|
||||
int plat_spmc_shmem_datastore_get(uint8_t **datastore, size_t *size);
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Mandatory BL image load functions(may be overridden).
|
||||
******************************************************************************/
|
||||
|
|
258
include/services/el3_spmc_ffa_memory.h
Normal file
258
include/services/el3_spmc_ffa_memory.h
Normal file
|
@ -0,0 +1,258 @@
|
|||
/*
|
||||
* Copyright (c) 2022, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef EL3_SPMC_FFA_MEM_H
|
||||
#define EL3_SPMC_FFA_MEM_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* Subset of Arm Firmware Framework for Armv8-A
|
||||
* (https://developer.arm.com/docs/den0077/a) needed for shared memory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* typedef ffa_endpoint_id16_t - Endpoint ID
|
||||
*
|
||||
* Current implementation only supports VM IDs. FF-A spec also support stream
|
||||
* endpoint ids.
|
||||
*/
|
||||
typedef uint16_t ffa_endpoint_id16_t;
|
||||
|
||||
/**
|
||||
* struct ffa_cons_mrd - Constituent memory region descriptor
|
||||
* @address:
|
||||
* Start address of contiguous memory region. Must be 4K page aligned.
|
||||
* @page_count:
|
||||
* Number of 4K pages in region.
|
||||
* @reserved_12_15:
|
||||
* Reserve bytes 12-15 to pad struct size to 16 bytes.
|
||||
*/
|
||||
struct ffa_cons_mrd {
|
||||
uint64_t address;
|
||||
uint32_t page_count;
|
||||
uint32_t reserved_12_15;
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_cons_mrd) == 16, assert_ffa_cons_mrd_size_mismatch);
|
||||
|
||||
/**
|
||||
* struct ffa_comp_mrd - Composite memory region descriptor
|
||||
* @total_page_count:
|
||||
* Number of 4k pages in memory region. Must match sum of
|
||||
* @address_range_array[].page_count.
|
||||
* @address_range_count:
|
||||
* Number of entries in @address_range_array.
|
||||
* @reserved_8_15:
|
||||
* Reserve bytes 8-15 to pad struct size to 16 byte alignment and
|
||||
* make @address_range_array 16 byte aligned.
|
||||
* @address_range_array:
|
||||
* Array of &struct ffa_cons_mrd entries.
|
||||
*/
|
||||
struct ffa_comp_mrd {
|
||||
uint32_t total_page_count;
|
||||
uint32_t address_range_count;
|
||||
uint64_t reserved_8_15;
|
||||
struct ffa_cons_mrd address_range_array[];
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_comp_mrd) == 16, assert_ffa_comp_mrd_size_mismatch);
|
||||
|
||||
/**
|
||||
* typedef ffa_mem_attr8_t - Memory region attributes v1.0.
|
||||
* typedef ffa_mem_attr16_t - Memory region attributes v1.1.
|
||||
*
|
||||
* * @FFA_MEM_ATTR_NS_BIT:
|
||||
* Memory security state.
|
||||
* * @FFA_MEM_ATTR_DEVICE_NGNRNE:
|
||||
* Device-nGnRnE.
|
||||
* * @FFA_MEM_ATTR_DEVICE_NGNRE:
|
||||
* Device-nGnRE.
|
||||
* * @FFA_MEM_ATTR_DEVICE_NGRE:
|
||||
* Device-nGRE.
|
||||
* * @FFA_MEM_ATTR_DEVICE_GRE:
|
||||
* Device-GRE.
|
||||
* * @FFA_MEM_ATTR_NORMAL_MEMORY_UNCACHED
|
||||
* Normal memory. Non-cacheable.
|
||||
* * @FFA_MEM_ATTR_NORMAL_MEMORY_CACHED_WB
|
||||
* Normal memory. Write-back cached.
|
||||
* * @FFA_MEM_ATTR_NON_SHAREABLE
|
||||
* Non-shareable. Combine with FFA_MEM_ATTR_NORMAL_MEMORY_*.
|
||||
* * @FFA_MEM_ATTR_OUTER_SHAREABLE
|
||||
* Outer Shareable. Combine with FFA_MEM_ATTR_NORMAL_MEMORY_*.
|
||||
* * @FFA_MEM_ATTR_INNER_SHAREABLE
|
||||
* Inner Shareable. Combine with FFA_MEM_ATTR_NORMAL_MEMORY_*.
|
||||
*/
|
||||
typedef uint8_t ffa_mem_attr8_t;
|
||||
typedef uint16_t ffa_mem_attr16_t;
|
||||
#define FFA_MEM_ATTR_NS_BIT (0x1U << 6)
|
||||
#define FFA_MEM_ATTR_DEVICE_NGNRNE ((1U << 4) | (0x0U << 2))
|
||||
#define FFA_MEM_ATTR_DEVICE_NGNRE ((1U << 4) | (0x1U << 2))
|
||||
#define FFA_MEM_ATTR_DEVICE_NGRE ((1U << 4) | (0x2U << 2))
|
||||
#define FFA_MEM_ATTR_DEVICE_GRE ((1U << 4) | (0x3U << 2))
|
||||
#define FFA_MEM_ATTR_NORMAL_MEMORY_UNCACHED ((2U << 4) | (0x1U << 2))
|
||||
#define FFA_MEM_ATTR_NORMAL_MEMORY_CACHED_WB ((2U << 4) | (0x3U << 2))
|
||||
#define FFA_MEM_ATTR_NON_SHAREABLE (0x0U << 0)
|
||||
#define FFA_MEM_ATTR_OUTER_SHAREABLE (0x2U << 0)
|
||||
#define FFA_MEM_ATTR_INNER_SHAREABLE (0x3U << 0)
|
||||
|
||||
/**
|
||||
* typedef ffa_mem_perm8_t - Memory access permissions
|
||||
*
|
||||
* * @FFA_MEM_ATTR_RO
|
||||
* Request or specify read-only mapping.
|
||||
* * @FFA_MEM_ATTR_RW
|
||||
* Request or allow read-write mapping.
|
||||
* * @FFA_MEM_PERM_NX
|
||||
* Deny executable mapping.
|
||||
* * @FFA_MEM_PERM_X
|
||||
* Request executable mapping.
|
||||
*/
|
||||
typedef uint8_t ffa_mem_perm8_t;
|
||||
#define FFA_MEM_PERM_RO (1U << 0)
|
||||
#define FFA_MEM_PERM_RW (1U << 1)
|
||||
#define FFA_MEM_PERM_NX (1U << 2)
|
||||
#define FFA_MEM_PERM_X (1U << 3)
|
||||
|
||||
/**
|
||||
* typedef ffa_mem_flag8_t - Endpoint memory flags
|
||||
*
|
||||
* * @FFA_MEM_FLAG_NON_RETRIEVAL_BORROWER
|
||||
* Non-retrieval Borrower. Memory region must not be or was not retrieved on
|
||||
* behalf of this endpoint.
|
||||
*/
|
||||
typedef uint8_t ffa_mem_flag8_t;
|
||||
#define FFA_MEM_FLAG_NON_RETRIEVAL_BORROWER (1U << 0)
|
||||
|
||||
/**
|
||||
* typedef ffa_mtd_flag32_t - Memory transaction descriptor flags
|
||||
*
|
||||
* * @FFA_MTD_FLAG_ZERO_MEMORY
|
||||
* Zero memory after unmapping from sender (must be 0 for share).
|
||||
* * @FFA_MTD_FLAG_TIME_SLICING
|
||||
* Not supported by this implementation.
|
||||
* * @FFA_MTD_FLAG_ZERO_MEMORY_AFTER_RELINQUISH
|
||||
* Zero memory after unmapping from borrowers (must be 0 for share).
|
||||
* * @FFA_MTD_FLAG_TYPE_MASK
|
||||
* Bit-mask to extract memory management transaction type from flags.
|
||||
* * @FFA_MTD_FLAG_TYPE_SHARE_MEMORY
|
||||
* Share memory transaction flag.
|
||||
* Used by @SMC_FC_FFA_MEM_RETRIEVE_RESP to indicate that memory came from
|
||||
* @SMC_FC_FFA_MEM_SHARE and by @SMC_FC_FFA_MEM_RETRIEVE_REQ to specify that
|
||||
* it must have.
|
||||
* * @FFA_MTD_FLAG_ADDRESS_RANGE_ALIGNMENT_HINT_MASK
|
||||
* Not supported by this implementation.
|
||||
*/
|
||||
typedef uint32_t ffa_mtd_flag32_t;
|
||||
#define FFA_MTD_FLAG_ZERO_MEMORY (1U << 0)
|
||||
#define FFA_MTD_FLAG_TIME_SLICING (1U << 1)
|
||||
#define FFA_MTD_FLAG_ZERO_MEMORY_AFTER_RELINQUISH (1U << 2)
|
||||
#define FFA_MTD_FLAG_TYPE_MASK (3U << 3)
|
||||
#define FFA_MTD_FLAG_TYPE_SHARE_MEMORY (1U << 3)
|
||||
#define FFA_MTD_FLAG_TYPE_LEND_MEMORY (1U << 4)
|
||||
#define FFA_MTD_FLAG_ADDRESS_RANGE_ALIGNMENT_HINT_MASK (0x1FU << 5)
|
||||
|
||||
/**
|
||||
* struct ffa_mapd - Memory access permissions descriptor
|
||||
* @endpoint_id:
|
||||
* Endpoint id that @memory_access_permissions and @flags apply to.
|
||||
* (&typedef ffa_endpoint_id16_t).
|
||||
* @memory_access_permissions:
|
||||
* FFA_MEM_PERM_* values or'ed together (&typedef ffa_mem_perm8_t).
|
||||
* @flags:
|
||||
* FFA_MEM_FLAG_* values or'ed together (&typedef ffa_mem_flag8_t).
|
||||
*/
|
||||
struct ffa_mapd {
|
||||
ffa_endpoint_id16_t endpoint_id;
|
||||
ffa_mem_perm8_t memory_access_permissions;
|
||||
ffa_mem_flag8_t flags;
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_mapd) == 4, assert_ffa_mapd_size_mismatch);
|
||||
|
||||
/**
|
||||
* struct ffa_emad_v1_0 - Endpoint memory access descriptor.
|
||||
* @mapd: &struct ffa_mapd.
|
||||
* @comp_mrd_offset:
|
||||
* Offset of &struct ffa_comp_mrd from start of &struct ffa_mtd_v1_0.
|
||||
* @reserved_8_15:
|
||||
* Reserved bytes 8-15. Must be 0.
|
||||
*/
|
||||
struct ffa_emad_v1_0 {
|
||||
struct ffa_mapd mapd;
|
||||
uint32_t comp_mrd_offset;
|
||||
uint64_t reserved_8_15;
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_emad_v1_0) == 16, assert_ffa_emad_v1_0_size_mismatch);
|
||||
|
||||
/**
|
||||
* struct ffa_mtd_v1_0 - Memory transaction descriptor.
|
||||
* @sender_id:
|
||||
* Sender endpoint id.
|
||||
* @memory_region_attributes:
|
||||
* FFA_MEM_ATTR_* values or'ed together (&typedef ffa_mem_attr8_t).
|
||||
* @reserved_3:
|
||||
* Reserved bytes 3. Must be 0.
|
||||
* @flags:
|
||||
* FFA_MTD_FLAG_* values or'ed together (&typedef ffa_mtd_flag32_t).
|
||||
* @handle:
|
||||
* Id of shared memory object. Must be 0 for MEM_SHARE or MEM_LEND.
|
||||
* @tag: Client allocated tag. Must match original value.
|
||||
* @reserved_24_27:
|
||||
* Reserved bytes 24-27. Must be 0.
|
||||
* @emad_count:
|
||||
* Number of entries in @emad.
|
||||
* @emad:
|
||||
* Endpoint memory access descriptor array (see @struct ffa_emad_v1_0).
|
||||
*/
|
||||
struct ffa_mtd_v1_0 {
|
||||
ffa_endpoint_id16_t sender_id;
|
||||
ffa_mem_attr8_t memory_region_attributes;
|
||||
uint8_t reserved_3;
|
||||
ffa_mtd_flag32_t flags;
|
||||
uint64_t handle;
|
||||
uint64_t tag;
|
||||
uint32_t reserved_24_27;
|
||||
uint32_t emad_count;
|
||||
struct ffa_emad_v1_0 emad[];
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_mtd_v1_0) == 32, assert_ffa_mtd_size_v1_0_mismatch);
|
||||
|
||||
/**
|
||||
* struct ffa_mtd - Memory transaction descriptor for FF-A v1.1.
|
||||
* @sender_id:
|
||||
* Sender endpoint id.
|
||||
* @memory_region_attributes:
|
||||
* FFA_MEM_ATTR_* values or'ed together (&typedef ffa_mem_attr16_t).
|
||||
* @flags:
|
||||
* FFA_MTD_FLAG_* values or'ed together (&typedef ffa_mtd_flag32_t).
|
||||
* @handle:
|
||||
* Id of shared memory object. Must be 0 for MEM_SHARE or MEM_LEND.
|
||||
* @tag: Client allocated tag. Must match original value.
|
||||
* @emad_size:
|
||||
* Size of the emad descriptor.
|
||||
* @emad_count:
|
||||
* Number of entries in the emad array.
|
||||
* @emad_offset:
|
||||
* Offset from the beginning of the descriptor to the location of the
|
||||
* memory access descriptor array (see @struct ffa_emad_v1_0).
|
||||
* @reserved_36_39:
|
||||
* Reserved bytes 36-39. Must be 0.
|
||||
* @reserved_40_47:
|
||||
* Reserved bytes 44-47. Must be 0.
|
||||
*/
|
||||
struct ffa_mtd {
|
||||
ffa_endpoint_id16_t sender_id;
|
||||
ffa_mem_attr16_t memory_region_attributes;
|
||||
ffa_mtd_flag32_t flags;
|
||||
uint64_t handle;
|
||||
uint64_t tag;
|
||||
uint32_t emad_size;
|
||||
uint32_t emad_count;
|
||||
uint32_t emad_offset;
|
||||
uint32_t reserved_36_39;
|
||||
uint64_t reserved_40_47;
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_mtd) == 48, assert_ffa_mtd_size_mismatch);
|
||||
|
||||
#endif /* EL3_SPMC_FFA_MEM_H */
|
|
@ -271,4 +271,71 @@ static inline bool ffa_is_normal_world_id(uint16_t id)
|
|||
return !ffa_is_secure_world_id(id);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Boot information protocol as per the FF-A v1.1 spec.
|
||||
*****************************************************************************/
|
||||
#define FFA_INIT_DESC_SIGNATURE 0x00000FFA
|
||||
|
||||
/* Boot information type. */
|
||||
#define FFA_BOOT_INFO_TYPE_STD U(0x0)
|
||||
#define FFA_BOOT_INFO_TYPE_IMPL U(0x1)
|
||||
|
||||
#define FFA_BOOT_INFO_TYPE_MASK U(0x1)
|
||||
#define FFA_BOOT_INFO_TYPE_SHIFT U(0x7)
|
||||
#define FFA_BOOT_INFO_TYPE(type) \
|
||||
(((type) & FFA_BOOT_INFO_TYPE_MASK) \
|
||||
<< FFA_BOOT_INFO_TYPE_SHIFT)
|
||||
|
||||
/* Boot information identifier. */
|
||||
#define FFA_BOOT_INFO_TYPE_ID_FDT U(0x0)
|
||||
#define FFA_BOOT_INFO_TYPE_ID_HOB U(0x1)
|
||||
|
||||
#define FFA_BOOT_INFO_TYPE_ID_MASK U(0x3F)
|
||||
#define FFA_BOOT_INFO_TYPE_ID_SHIFT U(0x0)
|
||||
#define FFA_BOOT_INFO_TYPE_ID(type) \
|
||||
(((type) & FFA_BOOT_INFO_TYPE_ID_MASK) \
|
||||
<< FFA_BOOT_INFO_TYPE_ID_SHIFT)
|
||||
|
||||
/* Format of Flags Name field. */
|
||||
#define FFA_BOOT_INFO_FLAG_NAME_STRING U(0x0)
|
||||
#define FFA_BOOT_INFO_FLAG_NAME_UUID U(0x1)
|
||||
|
||||
#define FFA_BOOT_INFO_FLAG_NAME_MASK U(0x3)
|
||||
#define FFA_BOOT_INFO_FLAG_NAME_SHIFT U(0x0)
|
||||
#define FFA_BOOT_INFO_FLAG_NAME(type) \
|
||||
(((type) & FFA_BOOT_INFO_FLAG_NAME_MASK)\
|
||||
<< FFA_BOOT_INFO_FLAG_NAME_SHIFT)
|
||||
|
||||
/* Format of Flags Contents field. */
|
||||
#define FFA_BOOT_INFO_FLAG_CONTENT_ADR U(0x0)
|
||||
#define FFA_BOOT_INFO_FLAG_CONTENT_VAL U(0x1)
|
||||
|
||||
#define FFA_BOOT_INFO_FLAG_CONTENT_MASK U(0x1)
|
||||
#define FFA_BOOT_INFO_FLAG_CONTENT_SHIFT U(0x2)
|
||||
#define FFA_BOOT_INFO_FLAG_CONTENT(content) \
|
||||
(((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \
|
||||
<< FFA_BOOT_INFO_FLAG_CONTENT_SHIFT)
|
||||
|
||||
/* Boot information descriptor. */
|
||||
struct ffa_boot_info_desc {
|
||||
uint8_t name[16];
|
||||
uint8_t type;
|
||||
uint8_t reserved;
|
||||
uint16_t flags;
|
||||
uint32_t size_boot_info;
|
||||
uint64_t content;
|
||||
};
|
||||
|
||||
/* Boot information header. */
|
||||
struct ffa_boot_info_header {
|
||||
uint32_t signature; /* 0xFFA */
|
||||
uint32_t version;
|
||||
uint32_t size_boot_info_blob;
|
||||
uint32_t size_boot_info_desc;
|
||||
uint32_t count_boot_info_desc;
|
||||
uint32_t offset_boot_info_desc;
|
||||
uint64_t reserved;
|
||||
};
|
||||
|
||||
#endif /* FFA_SVC_H */
|
||||
|
|
47
plat/arm/board/fvp/fvp_el3_spmc.c
Normal file
47
plat/arm/board/fvp/fvp_el3_spmc.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#include <services/el3_spmc_ffa_memory.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
/*
|
||||
* On the FVP platform when using the EL3 SPMC implementation allocate the
|
||||
* datastore for tracking shared memory descriptors in the TZC DRAM section
|
||||
* to ensure sufficient storage can be allocated.
|
||||
* Provide an implementation of the accessor method to allow the datastore
|
||||
* details to be retrieved by the SPMC.
|
||||
* The SPMC will take care of initializing the memory region.
|
||||
*/
|
||||
|
||||
#define PLAT_SPMC_SHMEM_DATASTORE_SIZE 512 * 1024
|
||||
|
||||
__section("arm_el3_tzc_dram") static uint8_t
|
||||
plat_spmc_shmem_datastore[PLAT_SPMC_SHMEM_DATASTORE_SIZE];
|
||||
|
||||
int plat_spmc_shmem_datastore_get(uint8_t **datastore, size_t *size)
|
||||
{
|
||||
*datastore = plat_spmc_shmem_datastore;
|
||||
*size = PLAT_SPMC_SHMEM_DATASTORE_SIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add dummy implementations of memory management related platform hooks.
|
||||
* These can be used to implement platform specific functionality to support
|
||||
* a memory sharing/lending operation.
|
||||
*
|
||||
* Note: The hooks must be located as part of the initial share request and
|
||||
* final reclaim to prevent order dependencies with operations that may take
|
||||
* place in the normal world without visibility of the SPMC.
|
||||
*/
|
||||
int plat_spmc_shmem_begin(struct ffa_mtd *desc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int plat_spmc_shmem_reclaim(struct ffa_mtd *desc)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -425,3 +425,7 @@ ENABLE_SYS_REG_TRACE_FOR_NS := 1
|
|||
|
||||
# enable trace filter control registers access to NS by default
|
||||
ENABLE_TRF_FOR_NS := 1
|
||||
|
||||
ifeq (${SPMC_AT_EL3}, 1)
|
||||
PLAT_BL_COMMON_SOURCES += plat/arm/board/fvp/fvp_el3_spmc.c
|
||||
endif
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#define FFA_ID_MASK U(0xFFFF)
|
||||
#define FFA_PARTITION_ID_SHIFT U(16)
|
||||
#define FFA_FEATURES_BIT31_MASK U(0x1u << 31)
|
||||
#define FFA_FEATURES_RET_REQ_NS_BIT U(0x1 << 1)
|
||||
|
||||
#define FFA_RUN_EP_ID(ep_vcpu_ids) \
|
||||
((ep_vcpu_ids >> FFA_PARTITION_ID_SHIFT) & FFA_ID_MASK)
|
||||
|
@ -170,6 +171,12 @@ struct secure_partition_desc {
|
|||
* Store whether the SP has subscribed to any power management messages.
|
||||
*/
|
||||
uint16_t pwr_mgmt_msgs;
|
||||
|
||||
/*
|
||||
* Store whether the SP has requested the use of the NS bit for memory
|
||||
* management transactions if it is using FF-A v1.0.
|
||||
*/
|
||||
bool ns_bit_requested;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -225,7 +232,8 @@ extern const spd_pm_ops_t spmc_pm;
|
|||
|
||||
/* Setup Function for different SP types. */
|
||||
void spmc_sp_common_setup(struct secure_partition_desc *sp,
|
||||
entry_point_info_t *ep_info);
|
||||
entry_point_info_t *ep_info,
|
||||
int32_t boot_info_reg);
|
||||
void spmc_el1_sp_setup(struct secure_partition_desc *sp,
|
||||
entry_point_info_t *ep_info);
|
||||
void spmc_sp_common_ep_commit(struct secure_partition_desc *sp,
|
||||
|
@ -272,4 +280,16 @@ struct el3_lp_desc *get_el3_lp_array(void);
|
|||
*/
|
||||
struct mailbox *spmc_get_mbox_desc(bool secure_origin);
|
||||
|
||||
/*
|
||||
* Helper function to obtain the context of an SP with a given partition ID.
|
||||
*/
|
||||
struct secure_partition_desc *spmc_get_sp_ctx(uint16_t id);
|
||||
|
||||
/*
|
||||
* Add helper function to obtain the FF-A version of the calling
|
||||
* partition.
|
||||
*/
|
||||
uint32_t get_partition_ffa_version(bool secure_origin);
|
||||
|
||||
|
||||
#endif /* SPMC_H */
|
||||
|
|
|
@ -12,7 +12,8 @@ SPMC_SOURCES := $(addprefix services/std_svc/spm/el3_spmc/, \
|
|||
spmc_main.c \
|
||||
spmc_setup.c \
|
||||
logical_sp.c \
|
||||
spmc_pm.c)
|
||||
spmc_pm.c \
|
||||
spmc_shared_mem.c)
|
||||
|
||||
# Specify platform specific logical partition implementation.
|
||||
SPMC_LP_SOURCES := $(addprefix ${PLAT_DIR}/, \
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <services/spmc_svc.h>
|
||||
#include <services/spmd_svc.h>
|
||||
#include "spmc.h"
|
||||
#include "spmc_shared_mem.h"
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
|
@ -989,6 +990,53 @@ err:
|
|||
return spmc_ffa_error_return(handle, ret);
|
||||
}
|
||||
|
||||
static uint64_t ffa_feature_success(void *handle, uint32_t arg2)
|
||||
{
|
||||
SMC_RET3(handle, FFA_SUCCESS_SMC32, 0, arg2);
|
||||
}
|
||||
|
||||
static uint64_t ffa_features_retrieve_request(bool secure_origin,
|
||||
uint32_t input_properties,
|
||||
void *handle)
|
||||
{
|
||||
/*
|
||||
* If we're called by the normal world we don't support any
|
||||
* additional features.
|
||||
*/
|
||||
if (!secure_origin) {
|
||||
if ((input_properties & FFA_FEATURES_RET_REQ_NS_BIT) != 0U) {
|
||||
return spmc_ffa_error_return(handle,
|
||||
FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
} else {
|
||||
struct secure_partition_desc *sp = spmc_get_current_sp_ctx();
|
||||
/*
|
||||
* If v1.1 the NS bit must be set otherwise it is an invalid
|
||||
* call. If v1.0 check and store whether the SP has requested
|
||||
* the use of the NS bit.
|
||||
*/
|
||||
if (sp->ffa_version == MAKE_FFA_VERSION(1, 1)) {
|
||||
if ((input_properties &
|
||||
FFA_FEATURES_RET_REQ_NS_BIT) == 0U) {
|
||||
return spmc_ffa_error_return(handle,
|
||||
FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
return ffa_feature_success(handle,
|
||||
FFA_FEATURES_RET_REQ_NS_BIT);
|
||||
} else {
|
||||
sp->ns_bit_requested = (input_properties &
|
||||
FFA_FEATURES_RET_REQ_NS_BIT) !=
|
||||
0U;
|
||||
}
|
||||
if (sp->ns_bit_requested) {
|
||||
return ffa_feature_success(handle,
|
||||
FFA_FEATURES_RET_REQ_NS_BIT);
|
||||
}
|
||||
}
|
||||
SMC_RET1(handle, FFA_SUCCESS_SMC32);
|
||||
}
|
||||
|
||||
static uint64_t ffa_features_handler(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint64_t x1,
|
||||
|
@ -1002,21 +1050,34 @@ static uint64_t ffa_features_handler(uint32_t smc_fid,
|
|||
uint32_t function_id = (uint32_t) x1;
|
||||
uint32_t input_properties = (uint32_t) x2;
|
||||
|
||||
/*
|
||||
* We don't currently support any additional input properties
|
||||
* for any ABI therefore ensure this value is always set to 0.
|
||||
*/
|
||||
if (input_properties != 0) {
|
||||
return spmc_ffa_error_return(handle, FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/* Check if a Feature ID was requested. */
|
||||
if ((function_id & FFA_FEATURES_BIT31_MASK) == 0U) {
|
||||
/* We currently don't support any additional features. */
|
||||
return spmc_ffa_error_return(handle, FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/* Report if an FF-A ABI is supported. */
|
||||
/*
|
||||
* Handle the cases where we have separate handlers due to additional
|
||||
* properties.
|
||||
*/
|
||||
switch (function_id) {
|
||||
case FFA_MEM_RETRIEVE_REQ_SMC32:
|
||||
case FFA_MEM_RETRIEVE_REQ_SMC64:
|
||||
return ffa_features_retrieve_request(secure_origin,
|
||||
input_properties,
|
||||
handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't currently support additional input properties for these
|
||||
* other ABIs therefore ensure this value is set to 0.
|
||||
*/
|
||||
if (input_properties != 0U) {
|
||||
return spmc_ffa_error_return(handle,
|
||||
FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/* Report if any other FF-A ABI is supported. */
|
||||
switch (function_id) {
|
||||
/* Supported features from both worlds. */
|
||||
case FFA_ERROR:
|
||||
|
@ -1033,6 +1094,7 @@ static uint64_t ffa_features_handler(uint32_t smc_fid,
|
|||
case FFA_RXTX_MAP_SMC32:
|
||||
case FFA_RXTX_MAP_SMC64:
|
||||
case FFA_RXTX_UNMAP:
|
||||
case FFA_MEM_FRAG_TX:
|
||||
case FFA_MSG_RUN:
|
||||
|
||||
/*
|
||||
|
@ -1050,9 +1112,25 @@ static uint64_t ffa_features_handler(uint32_t smc_fid,
|
|||
case FFA_SECONDARY_EP_REGISTER_SMC64:
|
||||
case FFA_MSG_SEND_DIRECT_RESP_SMC32:
|
||||
case FFA_MSG_SEND_DIRECT_RESP_SMC64:
|
||||
case FFA_MEM_RELINQUISH:
|
||||
case FFA_MSG_WAIT:
|
||||
|
||||
if (!secure_origin) {
|
||||
return spmc_ffa_error_return(handle,
|
||||
FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
SMC_RET1(handle, FFA_SUCCESS_SMC32);
|
||||
/* Execution stops here. */
|
||||
|
||||
/* Supported features only from the normal world. */
|
||||
case FFA_MEM_SHARE_SMC32:
|
||||
case FFA_MEM_SHARE_SMC64:
|
||||
case FFA_MEM_LEND_SMC32:
|
||||
case FFA_MEM_LEND_SMC64:
|
||||
case FFA_MEM_RECLAIM:
|
||||
case FFA_MEM_FRAG_RX:
|
||||
|
||||
if (secure_origin) {
|
||||
return spmc_ffa_error_return(handle,
|
||||
FFA_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
@ -1316,7 +1394,8 @@ static uint64_t ffa_sec_ep_register_handler(uint32_t smc_fid,
|
|||
******************************************************************************/
|
||||
static int sp_manifest_parse(void *sp_manifest, int offset,
|
||||
struct secure_partition_desc *sp,
|
||||
entry_point_info_t *ep_info)
|
||||
entry_point_info_t *ep_info,
|
||||
int32_t *boot_info_reg)
|
||||
{
|
||||
int32_t ret, node;
|
||||
uint32_t config_32;
|
||||
|
@ -1433,6 +1512,20 @@ static int sp_manifest_parse(void *sp_manifest, int offset,
|
|||
sp->pwr_mgmt_msgs = config_32;
|
||||
}
|
||||
|
||||
ret = fdt_read_uint32(sp_manifest, node,
|
||||
"gp-register-num", &config_32);
|
||||
if (ret != 0) {
|
||||
WARN("Missing boot information register.\n");
|
||||
} else {
|
||||
/* Check if a register number between 0-3 is specified. */
|
||||
if (config_32 < 4) {
|
||||
*boot_info_reg = config_32;
|
||||
} else {
|
||||
WARN("Incorrect boot information register (%u).\n",
|
||||
config_32);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1448,7 +1541,7 @@ static int find_and_prepare_sp_context(void)
|
|||
uintptr_t manifest_base;
|
||||
uintptr_t manifest_base_align;
|
||||
entry_point_info_t *next_image_ep_info;
|
||||
int32_t ret;
|
||||
int32_t ret, boot_info_reg = -1;
|
||||
struct secure_partition_desc *sp;
|
||||
|
||||
next_image_ep_info = bl31_plat_get_next_image_ep_info(SECURE);
|
||||
|
@ -1507,7 +1600,8 @@ static int find_and_prepare_sp_context(void)
|
|||
SECURE | EP_ST_ENABLE);
|
||||
|
||||
/* Parse the SP manifest. */
|
||||
ret = sp_manifest_parse(sp_manifest, ret, sp, next_image_ep_info);
|
||||
ret = sp_manifest_parse(sp_manifest, ret, sp, next_image_ep_info,
|
||||
&boot_info_reg);
|
||||
if (ret != 0) {
|
||||
ERROR("Error in Secure Partition manifest parsing.\n");
|
||||
return ret;
|
||||
|
@ -1520,7 +1614,7 @@ static int find_and_prepare_sp_context(void)
|
|||
}
|
||||
|
||||
/* Perform any common initialisation. */
|
||||
spmc_sp_common_setup(sp, next_image_ep_info);
|
||||
spmc_sp_common_setup(sp, next_image_ep_info, boot_info_reg);
|
||||
|
||||
/* Perform any initialisation specific to S-EL1 SPs. */
|
||||
spmc_el1_sp_setup(sp, next_image_ep_info);
|
||||
|
@ -1677,6 +1771,18 @@ int32_t spmc_setup(void)
|
|||
initalize_sp_descs();
|
||||
initalize_ns_ep_descs();
|
||||
|
||||
/*
|
||||
* Retrieve the information of the datastore for tracking shared memory
|
||||
* requests allocated by platform code and zero the region if available.
|
||||
*/
|
||||
ret = plat_spmc_shmem_datastore_get(&spmc_shmem_obj_state.data,
|
||||
&spmc_shmem_obj_state.data_size);
|
||||
if (ret != 0) {
|
||||
ERROR("Failed to obtain memory descriptor backing store!\n");
|
||||
return ret;
|
||||
}
|
||||
memset(spmc_shmem_obj_state.data, 0, spmc_shmem_obj_state.data_size);
|
||||
|
||||
/* Setup logical SPs. */
|
||||
ret = logical_sp_init();
|
||||
if (ret != 0) {
|
||||
|
@ -1799,6 +1905,35 @@ uint64_t spmc_smc_handler(uint32_t smc_fid,
|
|||
case FFA_MSG_RUN:
|
||||
return ffa_run_handler(smc_fid, secure_origin, x1, x2, x3, x4,
|
||||
cookie, handle, flags);
|
||||
|
||||
case FFA_MEM_SHARE_SMC32:
|
||||
case FFA_MEM_SHARE_SMC64:
|
||||
case FFA_MEM_LEND_SMC32:
|
||||
case FFA_MEM_LEND_SMC64:
|
||||
return spmc_ffa_mem_send(smc_fid, secure_origin, x1, x2, x3, x4,
|
||||
cookie, handle, flags);
|
||||
|
||||
case FFA_MEM_FRAG_TX:
|
||||
return spmc_ffa_mem_frag_tx(smc_fid, secure_origin, x1, x2, x3,
|
||||
x4, cookie, handle, flags);
|
||||
|
||||
case FFA_MEM_FRAG_RX:
|
||||
return spmc_ffa_mem_frag_rx(smc_fid, secure_origin, x1, x2, x3,
|
||||
x4, cookie, handle, flags);
|
||||
|
||||
case FFA_MEM_RETRIEVE_REQ_SMC32:
|
||||
case FFA_MEM_RETRIEVE_REQ_SMC64:
|
||||
return spmc_ffa_mem_retrieve_req(smc_fid, secure_origin, x1, x2,
|
||||
x3, x4, cookie, handle, flags);
|
||||
|
||||
case FFA_MEM_RELINQUISH:
|
||||
return spmc_ffa_mem_relinquish(smc_fid, secure_origin, x1, x2,
|
||||
x3, x4, cookie, handle, flags);
|
||||
|
||||
case FFA_MEM_RECLAIM:
|
||||
return spmc_ffa_mem_reclaim(smc_fid, secure_origin, x1, x2, x3,
|
||||
x4, cookie, handle, flags);
|
||||
|
||||
default:
|
||||
WARN("Unsupported FF-A call 0x%08x.\n", smc_fid);
|
||||
break;
|
||||
|
|
|
@ -10,18 +10,138 @@
|
|||
#include <arch.h>
|
||||
#include <arch_helpers.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/fdt_wrappers.h>
|
||||
#include <context.h>
|
||||
#include <lib/el3_runtime/context_mgmt.h>
|
||||
#include <lib/utils.h>
|
||||
#include <lib/xlat_tables/xlat_tables_v2.h>
|
||||
#include <libfdt.h>
|
||||
#include <plat/common/common_def.h>
|
||||
#include <plat/common/platform.h>
|
||||
#include <services/ffa_svc.h>
|
||||
#include "spm_common.h"
|
||||
#include "spmc.h"
|
||||
#include <tools_share/firmware_image_package.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
/*
|
||||
* Statically allocate a page of memory for passing boot information to an SP.
|
||||
*/
|
||||
static uint8_t ffa_boot_info_mem[PAGE_SIZE] __aligned(PAGE_SIZE);
|
||||
|
||||
/*
|
||||
* This function creates a initialization descriptor in the memory reserved
|
||||
* for passing boot information to an SP. It then copies the partition manifest
|
||||
* into this region and ensures that its reference in the initialization
|
||||
* descriptor is updated.
|
||||
*/
|
||||
static void spmc_create_boot_info(entry_point_info_t *ep_info,
|
||||
struct secure_partition_desc *sp)
|
||||
{
|
||||
struct ffa_boot_info_header *boot_header;
|
||||
struct ffa_boot_info_desc *boot_descriptor;
|
||||
uintptr_t manifest_addr;
|
||||
|
||||
/*
|
||||
* Calculate the maximum size of the manifest that can be accommodated
|
||||
* in the boot information memory region.
|
||||
*/
|
||||
const unsigned int
|
||||
max_manifest_sz = sizeof(ffa_boot_info_mem) -
|
||||
(sizeof(struct ffa_boot_info_header) +
|
||||
sizeof(struct ffa_boot_info_desc));
|
||||
|
||||
/*
|
||||
* The current implementation only supports the FF-A v1.1
|
||||
* implementation of the boot protocol, therefore check
|
||||
* that a v1.0 SP has not requested use of the protocol.
|
||||
*/
|
||||
if (sp->ffa_version == MAKE_FFA_VERSION(1, 0)) {
|
||||
ERROR("FF-A boot protocol not supported for v1.0 clients\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the manifest will fit into the boot info memory region else
|
||||
* bail.
|
||||
*/
|
||||
if (ep_info->args.arg1 > max_manifest_sz) {
|
||||
WARN("Unable to copy manifest into boot information. ");
|
||||
WARN("Max sz = %u bytes. Manifest sz = %lu bytes\n",
|
||||
max_manifest_sz, ep_info->args.arg1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Zero the memory region before populating. */
|
||||
memset(ffa_boot_info_mem, 0, PAGE_SIZE);
|
||||
|
||||
/*
|
||||
* Populate the ffa_boot_info_header at the start of the boot info
|
||||
* region.
|
||||
*/
|
||||
boot_header = (struct ffa_boot_info_header *) ffa_boot_info_mem;
|
||||
|
||||
/* Position the ffa_boot_info_desc after the ffa_boot_info_header. */
|
||||
boot_header->offset_boot_info_desc =
|
||||
sizeof(struct ffa_boot_info_header);
|
||||
boot_descriptor = (struct ffa_boot_info_desc *)
|
||||
(ffa_boot_info_mem +
|
||||
boot_header->offset_boot_info_desc);
|
||||
|
||||
/*
|
||||
* We must use the FF-A version coresponding to the version implemented
|
||||
* by the SP. Currently this can only be v1.1.
|
||||
*/
|
||||
boot_header->version = sp->ffa_version;
|
||||
|
||||
/* Populate the boot information header. */
|
||||
boot_header->size_boot_info_desc = sizeof(struct ffa_boot_info_desc);
|
||||
|
||||
/* Set the signature "0xFFA". */
|
||||
boot_header->signature = FFA_INIT_DESC_SIGNATURE;
|
||||
|
||||
/* Set the count. Currently 1 since only the manifest is specified. */
|
||||
boot_header->count_boot_info_desc = 1;
|
||||
|
||||
/* Populate the boot information descriptor for the manifest. */
|
||||
boot_descriptor->type =
|
||||
FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) |
|
||||
FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT);
|
||||
|
||||
boot_descriptor->flags =
|
||||
FFA_BOOT_INFO_FLAG_NAME(FFA_BOOT_INFO_FLAG_NAME_UUID) |
|
||||
FFA_BOOT_INFO_FLAG_CONTENT(FFA_BOOT_INFO_FLAG_CONTENT_ADR);
|
||||
|
||||
/*
|
||||
* Copy the manifest into boot info region after the boot information
|
||||
* descriptor.
|
||||
*/
|
||||
boot_descriptor->size_boot_info = (uint32_t) ep_info->args.arg1;
|
||||
|
||||
manifest_addr = (uintptr_t) (ffa_boot_info_mem +
|
||||
boot_header->offset_boot_info_desc +
|
||||
boot_header->size_boot_info_desc);
|
||||
|
||||
memcpy((void *) manifest_addr, (void *) ep_info->args.arg0,
|
||||
boot_descriptor->size_boot_info);
|
||||
|
||||
boot_descriptor->content = manifest_addr;
|
||||
|
||||
/* Calculate the size of the total boot info blob. */
|
||||
boot_header->size_boot_info_blob = boot_header->offset_boot_info_desc +
|
||||
boot_descriptor->size_boot_info +
|
||||
(boot_header->count_boot_info_desc *
|
||||
boot_header->size_boot_info_desc);
|
||||
|
||||
INFO("SP boot info @ 0x%lx, size: %u bytes.\n",
|
||||
(uintptr_t) ffa_boot_info_mem,
|
||||
boot_header->size_boot_info_blob);
|
||||
INFO("SP manifest @ 0x%lx, size: %u bytes.\n",
|
||||
boot_descriptor->content,
|
||||
boot_descriptor->size_boot_info);
|
||||
}
|
||||
|
||||
/*
|
||||
* We are assuming that the index of the execution
|
||||
* context used is the linear index of the current physical cpu.
|
||||
|
@ -68,7 +188,8 @@ void spmc_el1_sp_setup(struct secure_partition_desc *sp,
|
|||
|
||||
/* Common initialisation for all SPs. */
|
||||
void spmc_sp_common_setup(struct secure_partition_desc *sp,
|
||||
entry_point_info_t *ep_info)
|
||||
entry_point_info_t *ep_info,
|
||||
int32_t boot_info_reg)
|
||||
{
|
||||
uint16_t sp_id;
|
||||
|
||||
|
@ -96,11 +217,50 @@ void spmc_sp_common_setup(struct secure_partition_desc *sp,
|
|||
*/
|
||||
assert(sp->runtime_el == S_EL1);
|
||||
|
||||
/*
|
||||
* Clear the general purpose registers. These should be populated as
|
||||
* required.
|
||||
*/
|
||||
zeromem(&ep_info->args, sizeof(ep_info->args));
|
||||
/* Check if the SP wants to use the FF-A boot protocol. */
|
||||
if (boot_info_reg >= 0) {
|
||||
/*
|
||||
* Create a boot information descriptor and copy the partition
|
||||
* manifest into the reserved memory region for consumption by
|
||||
* the SP.
|
||||
*/
|
||||
spmc_create_boot_info(ep_info, sp);
|
||||
|
||||
/*
|
||||
* We have consumed what we need from ep args so we can now
|
||||
* zero them before we start populating with new information
|
||||
* specifically for the SP.
|
||||
*/
|
||||
zeromem(&ep_info->args, sizeof(ep_info->args));
|
||||
|
||||
/*
|
||||
* Pass the address of the boot information in the
|
||||
* boot_info_reg.
|
||||
*/
|
||||
switch (boot_info_reg) {
|
||||
case 0:
|
||||
ep_info->args.arg0 = (uintptr_t) ffa_boot_info_mem;
|
||||
break;
|
||||
case 1:
|
||||
ep_info->args.arg1 = (uintptr_t) ffa_boot_info_mem;
|
||||
break;
|
||||
case 2:
|
||||
ep_info->args.arg2 = (uintptr_t) ffa_boot_info_mem;
|
||||
break;
|
||||
case 3:
|
||||
ep_info->args.arg3 = (uintptr_t) ffa_boot_info_mem;
|
||||
break;
|
||||
default:
|
||||
ERROR("Invalid value for \"gp-register-num\" %d.\n",
|
||||
boot_info_reg);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* We don't need any of the information that was populated
|
||||
* in ep_args so we can clear them.
|
||||
*/
|
||||
zeromem(&ep_info->args, sizeof(ep_info->args));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
1812
services/std_svc/spm/el3_spmc/spmc_shared_mem.c
Normal file
1812
services/std_svc/spm/el3_spmc/spmc_shared_mem.c
Normal file
File diff suppressed because it is too large
Load diff
115
services/std_svc/spm/el3_spmc/spmc_shared_mem.h
Normal file
115
services/std_svc/spm/el3_spmc/spmc_shared_mem.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) 2022, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef SPMC_SHARED_MEM_H
|
||||
#define SPMC_SHARED_MEM_H
|
||||
|
||||
#include <services/el3_spmc_ffa_memory.h>
|
||||
|
||||
/**
|
||||
* struct ffa_mem_relinquish_descriptor - Relinquish request descriptor.
|
||||
* @handle:
|
||||
* Id of shared memory object to relinquish.
|
||||
* @flags:
|
||||
* If bit 0 is set clear memory after unmapping from borrower. Must be 0
|
||||
* for share. Bit[1]: Time slicing. Not supported, must be 0. All other
|
||||
* bits are reserved 0.
|
||||
* @endpoint_count:
|
||||
* Number of entries in @endpoint_array.
|
||||
* @endpoint_array:
|
||||
* Array of endpoint ids.
|
||||
*/
|
||||
struct ffa_mem_relinquish_descriptor {
|
||||
uint64_t handle;
|
||||
uint32_t flags;
|
||||
uint32_t endpoint_count;
|
||||
ffa_endpoint_id16_t endpoint_array[];
|
||||
};
|
||||
CASSERT(sizeof(struct ffa_mem_relinquish_descriptor) == 16,
|
||||
assert_ffa_mem_relinquish_descriptor_size_mismatch);
|
||||
|
||||
/**
|
||||
* struct spmc_shmem_obj_state - Global state.
|
||||
* @data: Backing store for spmc_shmem_obj objects.
|
||||
* @data_size: The size allocated for the backing store.
|
||||
* @allocated: Number of bytes allocated in @data.
|
||||
* @next_handle: Handle used for next allocated object.
|
||||
* @lock: Lock protecting all state in this file.
|
||||
*/
|
||||
struct spmc_shmem_obj_state {
|
||||
uint8_t *data;
|
||||
size_t data_size;
|
||||
size_t allocated;
|
||||
uint64_t next_handle;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
extern struct spmc_shmem_obj_state spmc_shmem_obj_state;
|
||||
extern int plat_spmc_shmem_begin(struct ffa_mtd *desc);
|
||||
extern int plat_spmc_shmem_reclaim(struct ffa_mtd *desc);
|
||||
|
||||
long spmc_ffa_mem_send(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint64_t total_length,
|
||||
uint32_t fragment_length,
|
||||
uint64_t address,
|
||||
uint32_t page_count,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
long spmc_ffa_mem_frag_tx(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint64_t handle_low,
|
||||
uint64_t handle_high,
|
||||
uint32_t fragment_length,
|
||||
uint32_t sender_id,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
long spmc_ffa_mem_retrieve_req(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint32_t total_length,
|
||||
uint32_t fragment_length,
|
||||
uint64_t address,
|
||||
uint32_t page_count,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
long spmc_ffa_mem_frag_rx(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint32_t handle_low,
|
||||
uint32_t handle_high,
|
||||
uint32_t fragment_offset,
|
||||
uint32_t sender_id,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
|
||||
int spmc_ffa_mem_relinquish(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint32_t handle_low,
|
||||
uint32_t handle_high,
|
||||
uint32_t fragment_offset,
|
||||
uint32_t sender_id,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
int spmc_ffa_mem_reclaim(uint32_t smc_fid,
|
||||
bool secure_origin,
|
||||
uint32_t handle_low,
|
||||
uint32_t handle_high,
|
||||
uint32_t mem_flags,
|
||||
uint64_t x4,
|
||||
void *cookie,
|
||||
void *handle,
|
||||
uint64_t flags);
|
||||
|
||||
#endif /* SPMC_SHARED_MEM_H */
|
Loading…
Add table
Reference in a new issue