[PATCH v9 12/27] gunyah: rsc_mgr: Add RPC for sharing memory
Elliot Berman
quic_eberman at quicinc.com
Mon Jan 30 13:45:38 PST 2023
On 1/30/2023 2:14 AM, Srivatsa Vaddagiri wrote:
> * Elliot Berman <quic_eberman at quicinc.com> [2023-01-20 14:46:11]:
>
>> +static int gh_rm_mem_lend_common(struct gh_rm *rm, u32 message_id, struct gh_rm_mem_parcel *p)
>> +{
>> + size_t msg_size = 0, initial_n_mem_entries = p->n_mem_entries;
>> + void *msg;
>> + __le32 *resp;
>> + struct gh_mem_share_req_header *req_header;
>> + struct gh_mem_share_req_acl_section *acl_section;
>> + struct gh_mem_share_req_mem_section *mem_section;
>> + u32 *mem_attr_section;
>> + size_t resp_size;
>> + int ret;
>> +
>> + if (!p->acl_entries || !p->n_acl_entries || !p->mem_entries || !p->n_mem_entries ||
>> + p->n_acl_entries > U8_MAX || p->mem_handle != GH_MEM_HANDLE_INVAL)
>> + return -EINVAL;
>> +
>> + if (initial_n_mem_entries > GH_RM_MAX_MEM_ENTRIES)
>> + initial_n_mem_entries = GH_RM_MAX_MEM_ENTRIES;
>> +
>> + /* The format of the message goes:
>> + * request header
>> + * ACL entries (which VMs get what kind of access to this memory parcel)
>> + * Memory entries (list of memory regions to share)
>> + * Memory attributes (currently unused, we'll hard-code the size to 0)
>> + */
>> + msg_size += sizeof(struct gh_mem_share_req_header);
>> + msg_size += offsetof(struct gh_mem_share_req_acl_section, entries[p->n_acl_entries]);
>> + msg_size += offsetof(struct gh_mem_share_req_mem_section, entries[initial_n_mem_entries]);
>> + msg_size += sizeof(u32); /* for memory attributes, currently unused */
>> +
>> + msg = kzalloc(msg_size, GFP_KERNEL);
>> + if (!msg)
>> + return -ENOMEM;
>> +
>> + ret = gh_rm_platform_pre_mem_share(rm, p);
>
> Hmm ..I think gh_rm_platform_pre_mem_share() is not yet defined as of this
> patch, so you probably want this in a later patch.
>
Seems I fell victim to trusting automatic fixup tools. Fixed.
>> + if (ret) {
>> + kfree(msg);
>> + return ret;
>> + }
>> +
More information about the linux-arm-kernel
mailing list