Skip to content

Commit aaca766

Browse files
eberman-quicgregkh
authored andcommitted
misc: fastrpc: Pass bitfield into qcom_scm_assign_mem
The srcvm parameter of qcom_scm_assign_mem is a pointer to a bitfield of VMIDs. The bitfield is updated with which VMIDs have permissions after the qcom_scm_assign_mem call. This makes it simpler for clients to make qcom_scm_assign_mem calls later, they always pass in same srcvm bitfield and do not need to closely track whether memory was originally shared. When restoring permissions to HLOS, fastrpc is incorrectly using the first VMID directly -- neither the BIT nor the other possible VMIDs the memory was already assigned to. We already have a field intended for this purpose: "perms" in the struct fastrpc_channel_ctx, but it was never used. Start using the perms field. Cc: Abel Vesa <abel.vesa@linaro.org> Cc: Vamsi Krishna Gattupalli <quic_vgattupa@quicinc.com> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Fixes: e90d911 ("misc: fastrpc: Add support to secure memory map") Fixes: 0871561 ("misc: fastrpc: Add support for audiopd") Fixes: 532ad70 ("misc: fastrpc: Add mmap request assigning for static PD pool") Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> drivers/misc/fastrpc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) Link: https://lore.kernel.org/r/20230112182313.521467-1-quic_eberman@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a769b05 commit aaca766

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

drivers/misc/fastrpc.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static void fastrpc_free_map(struct kref *ref)
321321
perm.vmid = QCOM_SCM_VMID_HLOS;
322322
perm.perm = QCOM_SCM_PERM_RWX;
323323
err = qcom_scm_assign_mem(map->phys, map->size,
324-
&(map->fl->cctx->vmperms[0].vmid), &perm, 1);
324+
&map->fl->cctx->perms, &perm, 1);
325325
if (err) {
326326
dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
327327
map->phys, map->size, err);
@@ -798,10 +798,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
798798
* If subsystem VMIDs are defined in DTSI, then do
799799
* hyp_assign from HLOS to those VM(s)
800800
*/
801-
unsigned int perms = BIT(QCOM_SCM_VMID_HLOS);
802-
803801
map->attr = attr;
804-
err = qcom_scm_assign_mem(map->phys, (u64)map->size, &perms,
802+
err = qcom_scm_assign_mem(map->phys, (u64)map->size, &fl->cctx->perms,
805803
fl->cctx->vmperms, fl->cctx->vmcount);
806804
if (err) {
807805
dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d",
@@ -1268,10 +1266,9 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
12681266

12691267
/* Map if we have any heap VMIDs associated with this ADSP Static Process. */
12701268
if (fl->cctx->vmcount) {
1271-
unsigned int perms = BIT(QCOM_SCM_VMID_HLOS);
1272-
12731269
err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys,
1274-
(u64)fl->cctx->remote_heap->size, &perms,
1270+
(u64)fl->cctx->remote_heap->size,
1271+
&fl->cctx->perms,
12751272
fl->cctx->vmperms, fl->cctx->vmcount);
12761273
if (err) {
12771274
dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d",
@@ -1319,7 +1316,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
13191316
perm.perm = QCOM_SCM_PERM_RWX;
13201317
err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys,
13211318
(u64)fl->cctx->remote_heap->size,
1322-
&(fl->cctx->vmperms[0].vmid), &perm, 1);
1319+
&fl->cctx->perms, &perm, 1);
13231320
if (err)
13241321
dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
13251322
fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err);
@@ -1901,7 +1898,7 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
19011898
perm.vmid = QCOM_SCM_VMID_HLOS;
19021899
perm.perm = QCOM_SCM_PERM_RWX;
19031900
err = qcom_scm_assign_mem(buf->phys, buf->size,
1904-
&(fl->cctx->vmperms[0].vmid), &perm, 1);
1901+
&fl->cctx->perms, &perm, 1);
19051902
if (err) {
19061903
dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
19071904
buf->phys, buf->size, err);

0 commit comments

Comments
 (0)