[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH v10 16/24] xen/arm: ffa: add defines for sharing memory


  • To: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 18 Jul 2023 14:36:36 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KIQN5VR6al95yX44zbALQFxPbHH+rmQdO5Pf8w3Ege8=; b=PL4bnDHobUNP7uN5KhLfn6w0TDiVMSqyvwxzSBxlYtqQ18neEBRdbx6P2ZhmwYv1wWeo4vzz2WStxJBz5uu6fB6BNYXgvLkcRtsC78onVsjEfmWDzOJ+JZHsOwLhI47YqTYi2J+Y2USZh2BhGMYwX/8zrzXpw+Hu2ApG6yLuj4W2FOzpyxunT0g4nqOmePSQaR4MEe5PPlit/VA/b8eY8vCTiRV3FgbbqdykI6GiXAzDCIyrh7GiglgHk0Aycr65jx/MhNR50mYVxaVkRLm1URVcSV4UnaWuGuLUqW/PLRIUtEzZkAwAqRVqtzxYWXdFYMqoWwlM6vOxzVf4XnegiA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLscYympgY+IK3UBdW1OUh/SkZgsPt94xdK4p1QbIBmYglJ5vRFBrnfOcBpJKyjsAiUXEF8OAdsJBp6oF3UamuA9XVgIecMHRAbiEjlvJOASOLH4QELO8tW8hld4uKbnlaO9cbnUB3mEUrddqcuzmKmoBE0GDEyouQcGnY5MBvpYAqgAXn2dN2d7LF8WgFRLBTpLhNDh+tMGHosVxDBTxTEC7EaWP5/FMNghC1gFyCrYGS/GXbaK2/zIXgX2BDH9HmD+1/Ie6MzEfn8ZWd1ocsYsl+TM83jMoz71cG2TnAAVznwRvS3E7Rl+8WYnLp0ges3Ls5t/GT4sUxruipEZpg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Marc Bonnici <Marc.Bonnici@xxxxxxx>, Achin Gupta <Achin.Gupta@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Tue, 18 Jul 2023 14:37:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZuH9Y/E5eTczWgkKkQ5tsd+GUtq+/mXcA
  • Thread-topic: [XEN PATCH v10 16/24] xen/arm: ffa: add defines for sharing memory

Hi Jens,

> On 17 Jul 2023, at 09:20, Jens Wiklander <jens.wiklander@xxxxxxxxxx> wrote:
> 
> According to DEN0077A version 1.1 REL0
> - Section 10.9.2 Memory region handle, page 167
> - Table 10.18 at page 175
> - Table 10.15 at page 168
> - Section 10.11.4 Flags usage, page 184-187
> add defines needed for sharing using the function FFA_MEM_SHARE and
> friends.
> 
> Also add limits for how many shared buffers that a guest can have at
> once and how large a shared buffer can be at most.
> 
> Signed-off-by: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
> Reviewed-by: Henry Wang <Henry.Wang@xxxxxxx>

Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> xen/arch/arm/tee/ffa.c | 58 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
> 
> diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
> index d5748b9ce88c..e895e355e620 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,56 @@
>  */
> #define FFA_MAX_RXTX_PAGE_COUNT         1
> 
> +/*
> + * Limit for shared buffer size. Please note that this define limits
> + * number of pages.
> + *
> + * FF-A doesn't have any direct requirements 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 overhead which can be hard to predict exactly, double this number
> + * to give a safe margin.
> + */
> +#define FFA_MAX_SHM_PAGE_COUNT          (2 * SZ_512K / FFA_PAGE_SIZE)
> +
> +/*
> + * Limits the number of shared buffers that guest can have at once. This
> + * is to prevent case, when guests trick XEN into exhausting its own
> + * memory by allocating many small buffers. This value has been chosen
> + * 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)
> +
> /*
>  * Flags and field values used for the MSG_SEND_DIRECT_REQ/RESP:
>  * BIT(31): Framework or partition message
> -- 
> 2.34.1
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.