浏览代码

msm: adsprpc: Set buffer type in TVM to non-secure

Customer is seeing issue when sharing buffer to secure PD.
Buffer is being set to 'secure buffer type' by trusted driver which
is invalid in TVM.
There are no 'secure' buffers on TVM. All buffers in TVM need to be
marked as 'non-secure'.

Fix is to explicitly mark buffers as 'non-secure' for TVM only.

Change-Id: I80c70bc59dcbd78be4119c1855fd4e5fa2e7d5cb
Edgar Flores 1 年之前
父节点
当前提交
698dfba608
共有 1 个文件被更改,包括 11 次插入8 次删除
  1. 11 8
      dsp/adsprpc.c

+ 11 - 8
dsp/adsprpc.c

@@ -1178,13 +1178,6 @@ static int get_buffer_attr(struct dma_buf *buf, bool *exclusive_access, bool *hl
 		*exclusive_access = true;
 
 #if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
-	/*
-	 * PVM (HLOS) can share buffers with TVM. In that case,
-	 * it is expected to relinquish its ownership to those buffers
-	 * before sharing. But if the PVM still retains access, then
-	 * these buffers cannot be used by TVM.
-	 */
-
 	for (int ii = 0; ii < vmids_list_len; ii++) {
 		if (vmids_list[ii] == VMID_HLOS) {
 			*hlos_access = true;
@@ -1209,8 +1202,13 @@ static int set_buffer_secure_type(struct fastrpc_mmap *map)
 		goto bail;
 	}
 #if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
+        /*
+         * PVM (HLOS) can share buffers with TVM, in case buffers are to be shared to secure PD,
+         * PVM is expected to relinquish its ownership to those buffers before sharing.
+         * If PVM still retains access, then those buffers cannot be shared to secure PD.
+         */
 	if (hlos_access) {
-		ADSPRPC_ERR("Sharing HLOS buffer (fd %d) not allowed on TVM\n", map->fd);
+		ADSPRPC_ERR("Buffers with HLOS access (fd %d) are not allowed on TVM\n", map->fd);
 		err = -EACCES;
 		goto bail;
 	}
@@ -1225,7 +1223,12 @@ static int set_buffer_secure_type(struct fastrpc_mmap *map)
 	 *	- Since it is a secure environment by default, there are no explicit "secure" buffers
 	 *	- All buffers are marked "non-secure"
 	 */
+#if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
+	map->secure = 0;
+#else
 	map->secure = (exclusive_access) ? 0 : 1;
+#endif
+
 bail:
 	return err;
 }