[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN PATCH v1 3/5] xen/arm: ffa: simplify ffa_handle_mem_share()
- To: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
- From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
- Date: Wed, 10 Apr 2024 07:07:17 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- 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=2; 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=j7VzH6NTtehvGbJ/7QpdOn/OZApWx2FdsX+6WHygoSw=; b=C0k3JYo+U/A2ErmQr8ibvyXYhlO1nrZYQPF4r7ZZzUqgVekjVpyDHkMBO6tiqDsJZaL4zAGpChc7HDsDvZRiGgyZJfbMghEfAqq92boWO7Dfgtd/QD4tox9SXdwjzMIxcxGChZxFgpvba/7uSu5Cftmva8gzZcRhi3Z2tIOxGvFGmU3EjUQYxgb3bZjtTje8sGOxa5VsGDJ1Un6Rk0+XAv93KwKmmA+AsVWEjAONOb7m3UsGOGE6FwQ7M4Be1db4isyoqgWJWQCZShr9FSDcrCc+khmrJyds8Oz+EL6ETKYbFqbd4f0S+1paa30/HiHs2V+P90MWlhxduqlZsSbL1g==
- 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=j7VzH6NTtehvGbJ/7QpdOn/OZApWx2FdsX+6WHygoSw=; b=e9JUByv/HNs73Uj28i05PWw4T1hIaKF8Wyl3PZdfKxIlwPHEJwoa3wk+MC1eqHQK9Btm8Zj6PCWL6rd6fJB1+DKdf2K77BerZx9A9uK25Bnw5fITVZ8NvhSnIEnJZCzcpD9OPQkgD3QvbnfvQ+YhhphQmNdr6EOr+1V5RVJ+sZw33P+o7l4gdGN6j8QqXf+4YaC8O21eq5byjqE9D19xgG7fnIkSVkJjGEAT1v9BRAPuRvOTELdqmavywqe7GHycRAoOZXS2w1FKP2pvNZACESICyggHkXv05r4bffF/6ON6HFANQ6pbriYp+T2EGRcIfFTqtg2+1hBi+HR3z1co7w==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=VrV/qPy6ON2VpzqqDZTKV5Hq58yACdG0SD0cKS6/RTV6zBXKEkclnY5yntcFbZue0ghqXIhWHKiPyyIUGgOuAwNHBRVPsx1QtNl0B527V1V5+CsjLSBVvUFlHc3xMIdVw4mv+myBpOlQUkNGWEdCJ0ddRtLzkzkDkJGxN/6WhZCEAlDqZfffXgKd1yXLbaD2HbZFbi/2dHh5r3coY3/GzXgSGlzWvH9ZT3g6fBzvj7IL8M83yC3cXJOJv3iyqUmXS0OlvDxzBCI3n0PnTUZMYTOvfABjPB5B5StkBwHo3/gtrunFrASJAXJaUucf5PlXIb/MNxUg3qCJz5cABslf6g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZH58vkr63O065nnb+V4k9/6un7EbuR+OrxhsKRr+2Pgbkjh1HuaUwIGCkkpllw2x/Heho12kIXwFgQrwUBr7j5P4K5rL2QciHnVxJk47Dhjl2Jj2JJ3xfc9qooaSm1icSULKghBCblqKi0mYugwWYC1mocIwaPJPt/8/yBCtK1mkwcRtKE9MxZcGvCZo+ucbuRbyEDaqYHRU948Fyu75FXZz6J5dIiMEOA+Vx0iBD7ZqNIJPC8qylyiZu5ky7JfoYnnswquSfBuHZJkFx8DPD49XPamV023MVXtEwxbkZ9qJvfsoS1BnpfUJSjeZkStl4XljF+UykV/v+plcOSNojA==
- Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "patches@xxxxxxxxxx" <patches@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
- Delivery-date: Wed, 10 Apr 2024 07:07:34 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Thread-index: AQHaipO7JiFTQp6ixkmJ3l2NEqDHxrFhFj2A
- Thread-topic: [XEN PATCH v1 3/5] xen/arm: ffa: simplify ffa_handle_mem_share()
Hi Jens,
> On 9 Apr 2024, at 17:36, Jens Wiklander <jens.wiklander@xxxxxxxxxx> wrote:
>
> Simplify ffa_handle_mem_share() by removing the start_page_idx and
> last_page_idx parameters from get_shm_pages() and check that the number
> of pages matches expectations at the end of get_shm_pages().
>
> Signed-off-by: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
Cheers
Bertrand
> ---
> xen/arch/arm/tee/ffa_shm.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/xen/arch/arm/tee/ffa_shm.c b/xen/arch/arm/tee/ffa_shm.c
> index 75a5b66aeb4c..370d83ec5cf8 100644
> --- a/xen/arch/arm/tee/ffa_shm.c
> +++ b/xen/arch/arm/tee/ffa_shm.c
> @@ -159,10 +159,9 @@ static int32_t ffa_mem_reclaim(uint32_t handle_lo,
> uint32_t handle_hi,
> */
> static int get_shm_pages(struct domain *d, struct ffa_shm_mem *shm,
> const struct ffa_address_range *range,
> - uint32_t range_count, unsigned int start_page_idx,
> - unsigned int *last_page_idx)
> + uint32_t range_count)
> {
> - unsigned int pg_idx = start_page_idx;
> + unsigned int pg_idx = 0;
> gfn_t gfn;
> unsigned int n;
> unsigned int m;
> @@ -191,7 +190,9 @@ static int get_shm_pages(struct domain *d, struct
> ffa_shm_mem *shm,
> }
> }
>
> - *last_page_idx = pg_idx;
> + /* The ranges must add up */
> + if ( pg_idx < shm->page_count )
> + return FFA_RET_INVALID_PARAMETERS;
>
> return FFA_RET_OK;
> }
> @@ -460,7 +461,6 @@ void ffa_handle_mem_share(struct cpu_user_regs *regs)
> struct domain *d = current->domain;
> struct ffa_ctx *ctx = d->arch.tee;
> struct ffa_shm_mem *shm = NULL;
> - unsigned int last_page_idx = 0;
> register_t handle_hi = 0;
> register_t handle_lo = 0;
> int ret = FFA_RET_DENIED;
> @@ -570,15 +570,9 @@ void ffa_handle_mem_share(struct cpu_user_regs *regs)
> goto out;
> }
>
> - ret = get_shm_pages(d, shm, region_descr->address_range_array,
> range_count,
> - 0, &last_page_idx);
> + ret = get_shm_pages(d, shm, region_descr->address_range_array,
> range_count);
> if ( ret )
> goto out;
> - if ( last_page_idx != shm->page_count )
> - {
> - ret = FFA_RET_INVALID_PARAMETERS;
> - goto out;
> - }
>
> /* Note that share_shm() uses our tx buffer */
> spin_lock(&ffa_tx_buffer_lock);
> --
> 2.34.1
>
|