[PATCH 3/4] firmware: arm_ffa: Check if receiving notifications are supported before sending

Jens Wiklander jens.wiklander at linaro.org
Tue Apr 16 00:31:41 PDT 2024


On Mon, Apr 15, 2024 at 6:05 PM Sudeep Holla <sudeep.holla at arm.com> wrote:
>
> Add check to see if the target partition can receive the notifications
> before sending any notifications to the partition.
>
> Signed-off-by: Sudeep Holla <sudeep.holla at arm.com>
> ---
>  drivers/firmware/arm_ffa/driver.c | 6 +++++-
>  include/linux/arm_ffa.h           | 2 ++
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index 52379885a403..d5087e4f6d35 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -1092,12 +1092,16 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu,
>         return rc;
>  }
>
> +#define ffa_partition_supports_notify_recv(dev)        \
> +       ffa_partition_check_property(dev, FFA_PARTITION_NOTIFICATION_RECV)
> +
>  static int ffa_notify_send(struct ffa_device *dev, int notify_id,
>                            bool is_per_vcpu, u16 vcpu)
>  {
>         u32 flags = 0;
>
> -       if (ffa_notifications_disabled())
> +       if (ffa_notifications_disabled() ||
> +           !ffa_partition_supports_notify_recv(dev))
>                 return -EOPNOTSUPP;

A client shouldn't send random notifications. First, it communicates
with the partition to establish which notification ID it should use.
If that fails we should never reach this stage. Unexpected
notifications are caught in other layers.

Cheers,
Jens

>
>         if (is_per_vcpu)
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index c906f666ff5d..13830be5851d 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -221,6 +221,8 @@ struct ffa_partition_info {
>  #define FFA_PARTITION_DIRECT_SEND      BIT(1)
>  /* partition can send and receive indirect messages. */
>  #define FFA_PARTITION_INDIRECT_MSG     BIT(2)
> +/* partition can receive notifications */
> +#define FFA_PARTITION_NOTIFICATION_RECV        BIT(3)
>  /* partition runs in the AArch64 execution state. */
>  #define FFA_PARTITION_AARCH64_EXEC     BIT(8)
>         u32 properties;
>
> --
> 2.43.2
>



More information about the linux-arm-kernel mailing list