Skip to content

Commit abf5422

Browse files
committed
Merge tag 'ffa-fixes-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/fixes
Arm FF-A fixes for v6.4 Quite a few fixes to address set of assorted issues: 1. NULL pointer dereference if the ffa driver doesn't provide remove() callback as it is currently executed unconditionally 2. FF-A core probe failure on systems with v1.0 firmware as the new partition info get count flag is used unconditionally 3. Failure to register more than one logical partition or service within the same physical partition as the device name contains only VM ID which will be same for all but each will have unique UUID. 4. Rejection of certain memory interface transmissions by the receivers (secure partitions) as few MBZ fields are non-zero due to lack of explicit re-initialization of those fields * tag 'ffa-fixes-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_ffa: Set reserved/MBZ fields to zero in the memory descriptors firmware: arm_ffa: Fix FFA device names for logical partitions firmware: arm_ffa: Fix usage of partition info get count flag firmware: arm_ffa: Check if ffa_driver remove is present before executing Link: https://lore.kernel.org/r/20230509143453.1188753-1-sudeep.holla@arm.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 51bba25 + 111a833 commit abf5422

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

drivers/firmware/arm_ffa/bus.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "common.h"
1717

18+
static DEFINE_IDA(ffa_bus_id);
19+
1820
static int ffa_device_match(struct device *dev, struct device_driver *drv)
1921
{
2022
const struct ffa_device_id *id_table;
@@ -53,7 +55,8 @@ static void ffa_device_remove(struct device *dev)
5355
{
5456
struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
5557

56-
ffa_drv->remove(to_ffa_dev(dev));
58+
if (ffa_drv->remove)
59+
ffa_drv->remove(to_ffa_dev(dev));
5760
}
5861

5962
static int ffa_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
@@ -130,6 +133,7 @@ static void ffa_release_device(struct device *dev)
130133
{
131134
struct ffa_device *ffa_dev = to_ffa_dev(dev);
132135

136+
ida_free(&ffa_bus_id, ffa_dev->id);
133137
kfree(ffa_dev);
134138
}
135139

@@ -170,18 +174,24 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
170174
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
171175
const struct ffa_ops *ops)
172176
{
173-
int ret;
177+
int id, ret;
174178
struct device *dev;
175179
struct ffa_device *ffa_dev;
176180

181+
id = ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL);
182+
if (id < 0)
183+
return NULL;
184+
177185
ffa_dev = kzalloc(sizeof(*ffa_dev), GFP_KERNEL);
178-
if (!ffa_dev)
186+
if (!ffa_dev) {
187+
ida_free(&ffa_bus_id, id);
179188
return NULL;
189+
}
180190

181191
dev = &ffa_dev->dev;
182192
dev->bus = &ffa_bus_type;
183193
dev->release = ffa_release_device;
184-
dev_set_name(&ffa_dev->dev, "arm-ffa-%04x", vm_id);
194+
dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id);
185195

186196
ffa_dev->vm_id = vm_id;
187197
ffa_dev->ops = ops;
@@ -217,4 +227,5 @@ void arm_ffa_bus_exit(void)
217227
{
218228
ffa_devices_unregister();
219229
bus_unregister(&ffa_bus_type);
230+
ida_destroy(&ffa_bus_id);
220231
}

drivers/firmware/arm_ffa/driver.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
193193
int idx, count, flags = 0, sz, buf_sz;
194194
ffa_value_t partition_info;
195195

196-
if (!buffer || !num_partitions) /* Just get the count for now */
196+
if (drv_info->version > FFA_VERSION_1_0 &&
197+
(!buffer || !num_partitions)) /* Just get the count for now */
197198
flags = PARTITION_INFO_GET_RETURN_COUNT_ONLY;
198199

199200
mutex_lock(&drv_info->rx_lock);
@@ -420,12 +421,17 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize,
420421
ep_mem_access->receiver = args->attrs[idx].receiver;
421422
ep_mem_access->attrs = args->attrs[idx].attrs;
422423
ep_mem_access->composite_off = COMPOSITE_OFFSET(args->nattrs);
424+
ep_mem_access->flag = 0;
425+
ep_mem_access->reserved = 0;
423426
}
427+
mem_region->reserved_0 = 0;
428+
mem_region->reserved_1 = 0;
424429
mem_region->ep_count = args->nattrs;
425430

426431
composite = buffer + COMPOSITE_OFFSET(args->nattrs);
427432
composite->total_pg_cnt = ffa_get_num_pages_sg(args->sg);
428433
composite->addr_range_cnt = num_entries;
434+
composite->reserved = 0;
429435

430436
length = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, num_entries);
431437
frag_len = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, 0);
@@ -460,6 +466,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize,
460466

461467
constituents->address = sg_phys(args->sg);
462468
constituents->pg_cnt = args->sg->length / FFA_PAGE_SIZE;
469+
constituents->reserved = 0;
463470
constituents++;
464471
frag_len += sizeof(struct ffa_mem_region_addr_range);
465472
} while ((args->sg = sg_next(args->sg)));

include/linux/arm_ffa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696

9797
/* FFA Bus/Device/Driver related */
9898
struct ffa_device {
99+
u32 id;
99100
int vm_id;
100101
bool mode_32bit;
101102
uuid_t uuid;

0 commit comments

Comments
 (0)