Message ID | 20230413071424.3273490-16-jens.wiklander@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Xen FF-A mediator | expand |
Hi Jens, > -----Original Message----- > Subject: [XEN PATCH v8 15/22] xen/arm: ffa: add defines for sharing memory > > Adds defines needed for sharing using the function FFA_MEM_SHARE and > friends. Same as my comments in previous patches, I would suggest to also mention the references in commit message. > > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> > --- > xen/arch/arm/tee/ffa.c | 60 > ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > + * FF-A doesn't have any direct requirments on GlobalPlatform or vice Typo: s/requirements/requirements/ > + * versa, but an implementation can very well use FF-A in order to provide > + * a GlobalPlatform interface on top. > + * > + * Global Platform specification for TEE requires that any TEE > + * implementation should allow to share buffers with size of at least > + * 512KB, defined in TEEC-1.0C page 24, Table 4-1, > + * TEEC_CONFIG_SHAREDMEM_MAX_SIZE. > + * Due to align issue mentioned above, we need to increase this s/align issue/alignment issue/ ? > + * value with one. > + */ > +#define FFA_MAX_SHM_PAGE_COUNT (SZ_512K / FFA_PAGE_SIZE + 1) > + > +/* > + * Limits the number of shared buffers that guest can have at once. This > + * is to prevent case, when guests tricks XEN into exhausting its own Typo: s/tricks/trick/ > + * memory by allocating many small buffers. This value has been chosen > + * arbitrary. Typo: s/ arbitrary/arbitrarily/ > + */ > +#define FFA_MAX_SHM_COUNT 32 > + > +/* FF-A-1.1-REL0 section 10.9.2 Memory region handle, page 167 */ > +#define FFA_HANDLE_HYP_FLAG BIT(63, ULL) > +#define FFA_HANDLE_INVALID 0xffffffffffffffffULL > + > +/* > + * Memory attributes: Normal memory, Write-Back cacheable, Inner > shareable > + * Defined in FF-A-1.1-REL0 Table 10.18 at page 175. > + */ > +#define FFA_NORMAL_MEM_REG_ATTR 0x2fU > +/* > + * Memory access permissions: Read-write > + * Defined in FF-A-1.1-REL0 Table 10.15 at page 168. > + */ > +#define FFA_MEM_ACC_RW 0x2U > + > +/* FF-A-1.1-REL0 section 10.11.4 Flags usage, page 184-187 */ > +/* Clear memory before mapping in receiver */ > +#define FFA_MEMORY_REGION_FLAG_CLEAR BIT(0, U) > +/* Relayer may time slice this operation */ > +#define FFA_MEMORY_REGION_FLAG_TIME_SLICE BIT(1, U) > +/* Clear memory after receiver relinquishes it */ > +#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH BIT(2, U) > +/* Share memory transaction */ > +#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE (1U << 3) > + I confirm the values introduced in this patch are consistent with in-code comments on top of them. Thanks for the pointer :) With the typos corrected: Reviewed-by: Henry Wang <Henry.Wang@arm.com> Kind regards, Henry > /* > * Flags and field values used for the MSG_SEND_DIRECT_REQ/RESP: > * BIT(31): Framework or partition message > -- > 2.34.1 >
Hi Henry, On Thu, Apr 13, 2023 at 1:47 PM Henry Wang <Henry.Wang@arm.com> wrote: > > Hi Jens, > > > -----Original Message----- > > Subject: [XEN PATCH v8 15/22] xen/arm: ffa: add defines for sharing memory > > > > Adds defines needed for sharing using the function FFA_MEM_SHARE and > > friends. > > Same as my comments in previous patches, I would suggest to also mention > the references in commit message. OK, I'll add something. > > > > > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> > > --- > > xen/arch/arm/tee/ffa.c | 60 > > ++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 60 insertions(+) > > > > + * FF-A doesn't have any direct requirments on GlobalPlatform or vice > > Typo: s/requirements/requirements/ OK > > > + * versa, but an implementation can very well use FF-A in order to provide > > + * a GlobalPlatform interface on top. > > + * > > + * Global Platform specification for TEE requires that any TEE > > + * implementation should allow to share buffers with size of at least > > + * 512KB, defined in TEEC-1.0C page 24, Table 4-1, > > + * TEEC_CONFIG_SHAREDMEM_MAX_SIZE. > > + * Due to align issue mentioned above, we need to increase this > > s/align issue/alignment issue/ ? Yes, I'll make it "the alignment issue". > > > + * value with one. > > + */ > > +#define FFA_MAX_SHM_PAGE_COUNT (SZ_512K / FFA_PAGE_SIZE + 1) > > + > > +/* > > + * Limits the number of shared buffers that guest can have at once. This > > + * is to prevent case, when guests tricks XEN into exhausting its own > > Typo: s/tricks/trick/ OK > > > + * memory by allocating many small buffers. This value has been chosen > > + * arbitrary. > > Typo: s/ arbitrary/arbitrarily/ OK > > > + */ > > +#define FFA_MAX_SHM_COUNT 32 > > + > > +/* FF-A-1.1-REL0 section 10.9.2 Memory region handle, page 167 */ > > +#define FFA_HANDLE_HYP_FLAG BIT(63, ULL) > > +#define FFA_HANDLE_INVALID 0xffffffffffffffffULL > > + > > +/* > > + * Memory attributes: Normal memory, Write-Back cacheable, Inner > > shareable > > + * Defined in FF-A-1.1-REL0 Table 10.18 at page 175. > > + */ > > +#define FFA_NORMAL_MEM_REG_ATTR 0x2fU > > +/* > > + * Memory access permissions: Read-write > > + * Defined in FF-A-1.1-REL0 Table 10.15 at page 168. > > + */ > > +#define FFA_MEM_ACC_RW 0x2U > > + > > +/* FF-A-1.1-REL0 section 10.11.4 Flags usage, page 184-187 */ > > +/* Clear memory before mapping in receiver */ > > +#define FFA_MEMORY_REGION_FLAG_CLEAR BIT(0, U) > > +/* Relayer may time slice this operation */ > > +#define FFA_MEMORY_REGION_FLAG_TIME_SLICE BIT(1, U) > > +/* Clear memory after receiver relinquishes it */ > > +#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH BIT(2, U) > > +/* Share memory transaction */ > > +#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE (1U << 3) > > + > > I confirm the values introduced in this patch are consistent with in-code > comments on top of them. Thanks for the pointer :) :-) > > With the typos corrected: > Reviewed-by: Henry Wang <Henry.Wang@arm.com> Great. Thanks, Jens > > Kind regards, > Henry > > > > /* > > * Flags and field values used for the MSG_SEND_DIRECT_REQ/RESP: > > * BIT(31): Framework or partition message > > -- > > 2.34.1 > > >
diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c index 74b8c517afb8..58c581c8ffc7 100644 --- a/xen/arch/arm/tee/ffa.c +++ b/xen/arch/arm/tee/ffa.c @@ -5,6 +5,14 @@ * Arm Firmware Framework for ARMv8-A (FF-A) mediator * * Copyright (C) 2023 Linaro Limited + * + * References: + * FF-A-1.0-REL: FF-A specification version 1.0 available at + * https://developer.arm.com/documentation/den0077/a + * FF-A-1.1-REL0: FF-A specification version 1.1 available at + * https://developer.arm.com/documentation/den0077/e + * TEEC-1.0C: TEE Client API Specification version 1.0c available at + * https://globalplatform.org/specs-library/tee-client-api-specification/ */ #include <xen/bitops.h> @@ -80,6 +88,58 @@ */ #define FFA_MAX_RXTX_PAGE_COUNT 32 +/* + * Limit for shared buffer size. Please note that this define limits + * number of pages. But user buffer can be not aligned to a page + * boundary. So it is possible that user would not be able to share + * exactly FFA_MAX_SHM_BUFFER_PG * FFA_PAGE_SIZE bytes. + * + * FF-A doesn't have any direct requirments on GlobalPlatform or vice + * versa, but an implementation can very well use FF-A in order to provide + * a GlobalPlatform interface on top. + * + * Global Platform specification for TEE requires that any TEE + * implementation should allow to share buffers with size of at least + * 512KB, defined in TEEC-1.0C page 24, Table 4-1, + * TEEC_CONFIG_SHAREDMEM_MAX_SIZE. + * Due to align issue mentioned above, we need to increase this + * value with one. + */ +#define FFA_MAX_SHM_PAGE_COUNT (SZ_512K / FFA_PAGE_SIZE + 1) + +/* + * Limits the number of shared buffers that guest can have at once. This + * is to prevent case, when guests tricks XEN into exhausting its own + * memory by allocating many small buffers. This value has been chosen + * arbitrary. + */ +#define FFA_MAX_SHM_COUNT 32 + +/* FF-A-1.1-REL0 section 10.9.2 Memory region handle, page 167 */ +#define FFA_HANDLE_HYP_FLAG BIT(63, ULL) +#define FFA_HANDLE_INVALID 0xffffffffffffffffULL + +/* + * Memory attributes: Normal memory, Write-Back cacheable, Inner shareable + * Defined in FF-A-1.1-REL0 Table 10.18 at page 175. + */ +#define FFA_NORMAL_MEM_REG_ATTR 0x2fU +/* + * Memory access permissions: Read-write + * Defined in FF-A-1.1-REL0 Table 10.15 at page 168. + */ +#define FFA_MEM_ACC_RW 0x2U + +/* FF-A-1.1-REL0 section 10.11.4 Flags usage, page 184-187 */ +/* Clear memory before mapping in receiver */ +#define FFA_MEMORY_REGION_FLAG_CLEAR BIT(0, U) +/* Relayer may time slice this operation */ +#define FFA_MEMORY_REGION_FLAG_TIME_SLICE BIT(1, U) +/* Clear memory after receiver relinquishes it */ +#define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH BIT(2, U) +/* Share memory transaction */ +#define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE (1U << 3) + /* * Flags and field values used for the MSG_SEND_DIRECT_REQ/RESP: * BIT(31): Framework or partition message
Adds defines needed for sharing using the function FFA_MEM_SHARE and friends. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> --- xen/arch/arm/tee/ffa.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)