[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240129063025.29251-4-yunfei.dong@mediatek.com>
Date: Mon, 29 Jan 2024 14:30:06 +0800
From: Yunfei Dong <yunfei.dong@...iatek.com>
To: Jeffrey Kardatzke <jkardatzke@...gle.com>,
Nícolas F . R . A . Prado
<nfraprado@...labora.com>, Nicolas Dufresne <nicolas.dufresne@...labora.com>,
Hans Verkuil <hverkuil-cisco@...all.nl>, AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>, Benjamin Gaignard
<benjamin.gaignard@...labora.com>, Nathan Hebert <nhebert@...omium.org>
CC: Chen-Yu Tsai <wenst@...omium.org>, Yong Wu <yong.wu@...iatek.com>,
"Hsin-Yi Wang" <hsinyi@...omium.org>, Fritz Koenig <frkoenig@...omium.org>,
"Daniel Vetter" <daniel@...ll.ch>, Steve Cho <stevecho@...omium.org>, Yunfei
Dong <yunfei.dong@...iatek.com>, Sumit Semwal <sumit.semwal@...aro.org>,
"Brian Starkey" <Brian.Starkey@....com>, John Stultz <jstultz@...gle.com>, "T
. J . Mercier" <tjmercier@...gle.com>, Christian König
<christian.koenig@....com>, Matthias Brugger <matthias.bgg@...il.com>,
<dri-devel@...ts.freedesktop.org>, <linaro-mm-sig@...ts.linaro.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-mediatek@...ts.infradead.org>,
<Project_Global_Chrome_Upstream_Group@...iatek.com>
Subject: [PATCH v4,03/22] v4l2: verify restricted dmabufs are used in restricted queue
From: Jeffrey Kardatzke <jkardatzke@...gle.com>
Verfies in the dmabuf implementations that if the restricted memory
flag is set for a queue that the dmabuf submitted to the queue is
unmappable.
Signed-off-by: Jeffrey Kardatzke <jkardatzke@...gle.com>
Signed-off-by: Yunfei Dong <yunfei.dong@...iatek.com>
---
drivers/media/common/videobuf2/videobuf2-dma-contig.c | 8 ++++++++
drivers/media/common/videobuf2/videobuf2-dma-sg.c | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index 3d4fd4ef5310..f953570fef27 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -710,6 +710,14 @@ static int vb2_dc_map_dmabuf(void *mem_priv)
return -EINVAL;
}
+ /* Verify the dmabuf is restricted if we are in restricted mode, this is done
+ * by validating there is no page entry for the dmabuf.
+ */
+ if (buf->vb->vb2_queue->restricted_mem && sg_page(sgt->sgl)) {
+ pr_err("restricted queue requires restricted dma_buf");
+ return -EINVAL;
+ }
+
/* checking if dmabuf is big enough to store contiguous chunk */
contig_size = vb2_dc_get_contiguous_size(sgt);
if (contig_size < buf->size) {
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index 6975a71d740f..f87bd3f40b9b 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -570,6 +570,14 @@ static int vb2_dma_sg_map_dmabuf(void *mem_priv)
return -EINVAL;
}
+ /* Verify the dmabuf is restricted if we are in restricted mode, this is done
+ * by validating there is no page entry for the dmabuf.
+ */
+ if (buf->vb->vb2_queue->restricted_mem && !sg_page(sgt->sgl)) {
+ pr_err("restricted queue requires restricted dma_buf");
+ return -EINVAL;
+ }
+
buf->dma_sgt = sgt;
buf->vaddr = NULL;
--
2.18.0
Powered by blists - more mailing lists