fix(notifications): return error if MBZ set in bind
Return FFA_INVALID_PARAMETERS if any of the flag bits that MBZ is set
when invoking FFA_NOTIFICATION_BIND.
Change-Id: Ie6dc37e0fff26a2ad10119b61e9c782fde711a9b
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/src/api.c b/src/api.c
index 7a3257d..8ae4e4a 100644
--- a/src/api.c
+++ b/src/api.c
@@ -3280,6 +3280,12 @@
is_bind ? sender_vm_id : HF_INVALID_VM_ID;
const ffa_vm_id_t id_to_validate =
is_bind ? HF_INVALID_VM_ID : sender_vm_id;
+ const uint32_t flags_mbz =
+ is_bind ? ~FFA_NOTIFICATIONS_FLAG_PER_VCPU : ~0U;
+
+ if ((flags_mbz & flags) != 0U) {
+ return ffa_error(FFA_INVALID_PARAMETERS);
+ }
if (!plat_ffa_is_notifications_bind_valid(current, sender_vm_id,
receiver_vm_id)) {
diff --git a/test/vmapi/ffa_secure_partitions/notifications.c b/test/vmapi/ffa_secure_partitions/notifications.c
index bd72dde..e35bb12 100644
--- a/test/vmapi/ffa_secure_partitions/notifications.c
+++ b/test/vmapi/ffa_secure_partitions/notifications.c
@@ -249,3 +249,15 @@
res = ffa_notification_get(own_id, 0, 0xFF00U);
EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
}
+
+TEST(ffa_notifications, fail_if_mbz_set_in_notifications_bind)
+{
+ struct ffa_value res;
+ const ffa_vm_id_t sender = SP_ID(1);
+ ffa_vm_id_t own_id = hf_vm_get_id();
+
+ res = ffa_notification_bind(sender, own_id,
+ ~FFA_NOTIFICATION_FLAG_PER_VCPU,
+ FFA_NOTIFICATION_MASK(1));
+ EXPECT_FFA_ERROR(res, FFA_INVALID_PARAMETERS);
+}