Message ID | 20240415-ffa_msg2_support-v1-3-a28c964b1b3f@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | firmware: arm_ffa: Support for MSG_SEND2 and minor harderning checks | expand |
On Mon, Apr 15, 2024 at 6:05 PM Sudeep Holla <sudeep.holla@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@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 >
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; 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;
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@arm.com> --- drivers/firmware/arm_ffa/driver.c | 6 +++++- include/linux/arm_ffa.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-)