Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

misc: fastrpc: Pass proper scm arguments for secure map request

If a map request is made with securemap attribute, the memory
ownership needs to be reassigned to new VMID to allow access
from protection domain. Currently only DSP VMID is passed to
the reassign call which is incorrect as only a combination of
HLOS and DSP VMID is allowed for memory ownership reassignment
and passing only DSP VMID will cause assign call failure.

Also pass proper restoring permissions to HLOS as the source
permission will now carry both HLOS and DSP VMID permission.

Change is also made to get valid physical address from
scatter/gather for this allocation request.

Fixes: e90d91190619 ("misc: fastrpc: Add support to secure memory map")
Cc: stable <stable@kernel.org>
Tested-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230523152550.438363-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ekansh Gupta and committed by
Greg Kroah-Hartman
a6e766de bca7a463

+17 -5
+17 -5
drivers/misc/fastrpc.c
··· 316 316 if (map->table) { 317 317 if (map->attr & FASTRPC_ATTR_SECUREMAP) { 318 318 struct qcom_scm_vmperm perm; 319 + int vmid = map->fl->cctx->vmperms[0].vmid; 320 + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS) | BIT(vmid); 319 321 int err = 0; 320 322 321 323 perm.vmid = QCOM_SCM_VMID_HLOS; 322 324 perm.perm = QCOM_SCM_PERM_RWX; 323 325 err = qcom_scm_assign_mem(map->phys, map->size, 324 - &map->fl->cctx->perms, &perm, 1); 326 + &src_perms, &perm, 1); 325 327 if (err) { 326 328 dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", 327 329 map->phys, map->size, err); ··· 789 787 goto map_err; 790 788 } 791 789 792 - map->phys = sg_dma_address(map->table->sgl); 793 - map->phys += ((u64)fl->sctx->sid << 32); 790 + if (attr & FASTRPC_ATTR_SECUREMAP) { 791 + map->phys = sg_phys(map->table->sgl); 792 + } else { 793 + map->phys = sg_dma_address(map->table->sgl); 794 + map->phys += ((u64)fl->sctx->sid << 32); 795 + } 794 796 map->size = len; 795 797 map->va = sg_virt(map->table->sgl); 796 798 map->len = len; ··· 804 798 * If subsystem VMIDs are defined in DTSI, then do 805 799 * hyp_assign from HLOS to those VM(s) 806 800 */ 801 + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); 802 + struct qcom_scm_vmperm dst_perms[2] = {0}; 803 + 804 + dst_perms[0].vmid = QCOM_SCM_VMID_HLOS; 805 + dst_perms[0].perm = QCOM_SCM_PERM_RW; 806 + dst_perms[1].vmid = fl->cctx->vmperms[0].vmid; 807 + dst_perms[1].perm = QCOM_SCM_PERM_RWX; 807 808 map->attr = attr; 808 - err = qcom_scm_assign_mem(map->phys, (u64)map->size, &fl->cctx->perms, 809 - fl->cctx->vmperms, fl->cctx->vmcount); 809 + err = qcom_scm_assign_mem(map->phys, (u64)map->size, &src_perms, dst_perms, 2); 810 810 if (err) { 811 811 dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", 812 812 map->phys, map->size, err);