Procházet zdrojové kódy

video: driver: reject invalid buffer mapping request

Reject non-secure mapping request for a secure buffer(or vice versa).
These combinations will lead to transaction fault later. So it is
better to reject this buffer mappings upfront.

Change-Id: Iaac851b235707dde8d303fb581ba0ae7c8768b85
Signed-off-by: Govindaraj Rajagopal <[email protected]>
Govindaraj Rajagopal před 3 roky
rodič
revize
33f263995d
1 změnil soubory, kde provedl 20 přidání a 0 odebrání
  1. 20 0
      driver/vidc/src/msm_vidc_memory.c

+ 20 - 0
driver/vidc/src/msm_vidc_memory.c

@@ -172,6 +172,11 @@ void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
 	}
 }
 
+static bool is_non_secure_buffer(struct dma_buf *dmabuf)
+{
+	return mem_buf_dma_buf_exclusive_owner(dmabuf);
+}
+
 int msm_vidc_memory_map(struct msm_vidc_core *core, struct msm_vidc_map *map)
 {
 	int rc = 0;
@@ -189,6 +194,21 @@ int msm_vidc_memory_map(struct msm_vidc_core *core, struct msm_vidc_map *map)
 		goto exit;
 	}
 
+	/* reject non-secure mapping request for a secure buffer(or vice versa) */
+	if (map->region == MSM_VIDC_NON_SECURE || map->region == MSM_VIDC_NON_SECURE_PIXEL) {
+		if (!is_non_secure_buffer(map->dmabuf)) {
+			d_vpr_e("%s: secure buffer mapping to non-secure region %d not allowed\n",
+				__func__, map->region);
+			return -EINVAL;
+		}
+	} else {
+		if (is_non_secure_buffer(map->dmabuf)) {
+			d_vpr_e("%s: non-secure buffer mapping to secure region %d not allowed\n",
+				__func__, map->region);
+			return -EINVAL;
+		}
+	}
+
 	cb = get_context_bank(core, map->region);
 	if (!cb) {
 		d_vpr_e("%s: Failed to get context bank device\n",