Skip to content

Commit

Permalink
core: sp: fix FFA_MEM_RECLAIM checks
Browse files Browse the repository at this point in the history
Currently it is assumed that a NS endpoint's ID is always 0. This is not
true if multiple VMs are present in the NWd, so the check will fail when
reclaiming shared memory from an SP. Fix this by removing the owner ID
check if the reclaim call comes from NWd, in this case the necessary
checks are done by the hypervisor.

Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
  • Loading branch information
balint-dobszay-arm authored and jforissier committed Oct 13, 2023
1 parent 32b3180 commit 5f979c1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/arch/arm/kernel/spmc_sp_handler.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2021-2022, Arm Limited
* Copyright (c) 2021-2023, Arm Limited
*/
#include <assert.h>
#include <bench.h>
Expand Down Expand Up @@ -768,7 +768,6 @@ bool ffa_mem_reclaim(struct thread_smc_args *args,
{
uint64_t handle = reg_pair_to_64(args->a2, args->a1);
uint32_t flags = args->a3;
uint32_t endpoint = 0;
struct sp_mem *smem = NULL;
struct sp_mem_receiver *receiver = NULL;
uint32_t exceptions = 0;
Expand All @@ -777,12 +776,12 @@ bool ffa_mem_reclaim(struct thread_smc_args *args,
if (!smem)
return false;

if (caller_sp)
endpoint = caller_sp->endpoint_id;

/* Make sure that the caller is the owner of the share */
if (smem->sender_id != endpoint) {
ffa_set_error(args, FFA_DENIED);
/*
* If the caller is an SP, make sure that it is the owner of the share.
* If the call comes from NWd this is ensured by the hypervisor.
*/
if (caller_sp && caller_sp->endpoint_id != smem->sender_id) {
ffa_set_error(args, FFA_INVALID_PARAMETERS);
return true;
}

Expand Down

0 comments on commit 5f979c1

Please sign in to comment.