Skip to content

Commit eed396b

Browse files
committed
firmware: arm_ffa: Handle ffa_notification_get correctly at virtual FF-A instance
JIRA: https://issues.redhat.com/browse/RHEL-102691 commit 9472fe2 Author: Sudeep Holla <sudeep.holla@arm.com> Date: Mon, 17 Feb 2025 15:39:00 +0000 Currently it is assumed that the driver always calls ffa_notification_get() at the NS physical FF-A instance to request the SPMC to return pending SP or SPM Framework notifications. However, in order to support the driver invoking ffa_notification_get() at virtual FF-A instance, we need to make sure correct bits are enabled in the bitmaps enable flag. It is expected to have hypervisor framework and VM notifications bitmap to be zero at the non-secure physical FF-A instance. Message-Id: <20250217-ffa_updates-v3-19-bd1d9de615e7@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
1 parent 0b6f609 commit eed396b

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,12 @@ enum notify_type {
841841
#define NON_SECURE_VM_BITMAP_ENABLE BIT(NON_SECURE_VM)
842842
#define SPM_FRAMEWORK_BITMAP_ENABLE BIT(SPM_FRAMEWORK)
843843
#define NS_HYP_FRAMEWORK_BITMAP_ENABLE BIT(NS_HYP_FRAMEWORK)
844-
#define FFA_BITMAP_ENABLE_MASK \
844+
#define FFA_BITMAP_SECURE_ENABLE_MASK \
845845
(SECURE_PARTITION_BITMAP_ENABLE | SPM_FRAMEWORK_BITMAP_ENABLE)
846+
#define FFA_BITMAP_NS_ENABLE_MASK \
847+
(NON_SECURE_VM_BITMAP_ENABLE | NS_HYP_FRAMEWORK_BITMAP_ENABLE)
848+
#define FFA_BITMAP_ALL_ENABLE_MASK \
849+
(FFA_BITMAP_SECURE_ENABLE_MASK | FFA_BITMAP_NS_ENABLE_MASK)
846850

847851
#define FFA_SECURE_PARTITION_ID_FLAG BIT(15)
848852

@@ -914,9 +918,15 @@ static int ffa_notification_get(u32 flags, struct ffa_notify_bitmaps *notify)
914918
else if (ret.a0 != FFA_SUCCESS)
915919
return -EINVAL; /* Something else went wrong. */
916920

917-
notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3);
918-
notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5);
919-
notify->arch_map = PACK_NOTIFICATION_BITMAP(ret.a6, ret.a7);
921+
if (flags & SECURE_PARTITION_BITMAP_ENABLE)
922+
notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3);
923+
if (flags & NON_SECURE_VM_BITMAP_ENABLE)
924+
notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5);
925+
if (flags & SPM_FRAMEWORK_BITMAP_ENABLE)
926+
notify->arch_map = SPM_FRAMEWORK_BITMAP(ret.a6);
927+
if (flags & NS_HYP_FRAMEWORK_BITMAP_ENABLE)
928+
notify->arch_map = PACK_NOTIFICATION_BITMAP(notify->arch_map,
929+
ret.a7);
920930

921931
return 0;
922932
}
@@ -1444,12 +1454,19 @@ static void handle_fwk_notif_callbacks(u32 bitmap)
14441454
kfree(buf);
14451455
}
14461456

1447-
static void notif_get_and_handle(void *unused)
1457+
static void notif_get_and_handle(void *cb_data)
14481458
{
14491459
int rc;
1450-
struct ffa_notify_bitmaps bitmaps;
1460+
u32 flags;
1461+
struct ffa_drv_info *info = cb_data;
1462+
struct ffa_notify_bitmaps bitmaps = { 0 };
1463+
1464+
if (info->vm_id == 0) /* Non secure physical instance */
1465+
flags = FFA_BITMAP_SECURE_ENABLE_MASK;
1466+
else
1467+
flags = FFA_BITMAP_ALL_ENABLE_MASK;
14511468

1452-
rc = ffa_notification_get(FFA_BITMAP_ENABLE_MASK, &bitmaps);
1469+
rc = ffa_notification_get(flags, &bitmaps);
14531470
if (rc) {
14541471
pr_err("Failed to retrieve notifications with %d!\n", rc);
14551472
return;

0 commit comments

Comments
 (0)