Skip to content

Commit 763bb7f

Browse files
sudeep-hollasmb49
authored andcommitted
firmware: arm_ffa: Set reserved/MBZ fields to zero in the memory descriptors
BugLink: https://bugs.launchpad.net/bugs/2028979 commit 111a833 upstream. The transmit buffers allocated by the driver can be used to transmit data by any messages/commands needing the buffer. However, it is not guaranteed to have been zero-ed before every new transmission and hence it will just contain residual value from the previous transmission. There are several reserved fields in the memory descriptors that must be zero(MBZ). The receiver can reject the transmission if any such MBZ fields are non-zero. While we can set the whole page to zero, it is not optimal as most of the fields get initialised to the value required for the current transmission. So, just set the reserved/MBZ fields to zero in the memory descriptors explicitly to honour the requirement and keep the receiver happy. Fixes: cc2195f ("firmware: arm_ffa: Add support for MEM_* interfaces") Reported-by: Marc Bonnici <marc.bonnici@arm.com> Link: https://lore.kernel.org/r/20230503131252.12585-1-sudeep.holla@arm.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 7f93657 commit 763bb7f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/firmware/arm_ffa/driver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,17 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize,
420420
ep_mem_access->receiver = args->attrs[idx].receiver;
421421
ep_mem_access->attrs = args->attrs[idx].attrs;
422422
ep_mem_access->composite_off = COMPOSITE_OFFSET(args->nattrs);
423+
ep_mem_access->flag = 0;
424+
ep_mem_access->reserved = 0;
423425
}
426+
mem_region->reserved_0 = 0;
427+
mem_region->reserved_1 = 0;
424428
mem_region->ep_count = args->nattrs;
425429

426430
composite = buffer + COMPOSITE_OFFSET(args->nattrs);
427431
composite->total_pg_cnt = ffa_get_num_pages_sg(args->sg);
428432
composite->addr_range_cnt = num_entries;
433+
composite->reserved = 0;
429434

430435
length = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, num_entries);
431436
frag_len = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, 0);
@@ -460,6 +465,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize,
460465

461466
constituents->address = sg_phys(args->sg);
462467
constituents->pg_cnt = args->sg->length / FFA_PAGE_SIZE;
468+
constituents->reserved = 0;
463469
constituents++;
464470
frag_len += sizeof(struct ffa_mem_region_addr_range);
465471
} while ((args->sg = sg_next(args->sg)));

0 commit comments

Comments
 (0)