Message ID | 20231206081538.17056-4-yunfei.dong@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3957203vqy; Wed, 6 Dec 2023 00:16:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZhG5jZeLElKFpFsdqwb8zM7yyEqrqE2k/e1FipPC8jgdFt3XNAVjx2kXUlqoceQ75x9os X-Received: by 2002:a17:902:684c:b0:1d0:6ffd:837d with SMTP id f12-20020a170902684c00b001d06ffd837dmr169810pln.136.1701850592006; Wed, 06 Dec 2023 00:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701850591; cv=none; d=google.com; s=arc-20160816; b=cQFxVPIML3L7JyJNMNS5TqfnUzAvj+Sm81BEmIJLzTZkk8+5XmmQyZ7jA72hVlIntd oo0IFNodoFvG0VNKgPI66xZqu1amldP3Mb7Icmm+vHdmzmzqR0nohzCfoLn2af3KFzEg Zn9/HbSOq5rJiJEOonCk1GzuOqiDf0LYijhres+NGt1wg1x4o+eswHHRkJqiYf7rQOBN 44ftNm+CJmvLEQ8GANvIYlbFiLin6GCpDVzjj9EChaESDphqtt+XCQk85JqSCFPjPEhF tLSZceojYHsXd4qjN8h4qFk5BsgI1HruigEc38PT+iETSsemZ06XDmlaz5geRR81m1oJ QnMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xbClLI66nLXR6+DrvXNRdDsoO2AywNyP9UvNF0j25Es=; fh=Jm1zUP85NkLhaS8mFbLRiIHu8uZd7NKlphUk8mYvM1c=; b=JHH3uGN4KseWXDlw4qvPHKJn02WBWQX0Q5qpDZiO3D1anrSp4JxBtxQDbLxSI8/WgL oFoDC0I0TqXyo37dZL8tOwWC8Nhw44LoQgKO70fzN7alBEzewXQkDmGrBsZ+4DVkqlcj tIY3WtcICt/YGB5VW2cpF3tGfvSO8hxob34vqxWeNLFQk63dkEH8t2e/7Zqf3QyzlYvp HvlyUTWDcYEJlm6CBWeX8GwUmm3mVYBQFqF1EJYedNuFya4BWf2y/3tODxc9yYdefA45 s5rDujojnUbVlyj0/JY1tSEinziEX3NRXecugbUJIKoVUqAv78YFMiGVn1OrjLcZL/3A MX2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cRW6mP1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id k8-20020a170902694800b001cfcf3dd310si10758750plt.505.2023.12.06.00.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:16:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cRW6mP1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6EED3802FA3C; Wed, 6 Dec 2023 00:16:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377195AbjLFIQB (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 03:16:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377151AbjLFIPu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 6 Dec 2023 03:15:50 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46601B5; Wed, 6 Dec 2023 00:15:56 -0800 (PST) X-UUID: a7c3619a940f11ee8051498923ad61e6-20231206 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=xbClLI66nLXR6+DrvXNRdDsoO2AywNyP9UvNF0j25Es=; b=cRW6mP1pz65/Eq+nfYOerOJHYeI/9JkAmywuPWYpfUabXpatevW8XDcBcQgNqsBjATJ+O4ZuMBSCID4LkVllPe92zWIwhucgPeFKsAvOoVcAt1UI0hABGHBZDSRq85feMiBYlF8D0dh+6CZQEEOGgJaxKDr6h7/0GaUIr7JUMMA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.34,REQID:2fb79652-11d7-43fc-9a4f-6b44832471ca,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:abefa75,CLOUDID:20e87773-1bd3-4f48-b671-ada88705968c,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: a7c3619a940f11ee8051498923ad61e6-20231206 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from <yunfei.dong@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1903711512; Wed, 06 Dec 2023 16:15:45 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 6 Dec 2023 16:15:44 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 6 Dec 2023 16:15:42 +0800 From: Yunfei Dong <yunfei.dong@mediatek.com> To: Jeffrey Kardatzke <jkardatzke@google.com>, =?utf-8?q?N=C3=ADcolas_F_=2E_?= =?utf-8?q?R_=2E_A_=2E_Prado?= <nfraprado@collabora.com>, Nicolas Dufresne <nicolas.dufresne@collabora.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Nathan Hebert <nhebert@chromium.org> CC: Chen-Yu Tsai <wenst@chromium.org>, Yong Wu <yong.wu@mediatek.com>, Hsin-Yi Wang <hsinyi@chromium.org>, Fritz Koenig <frkoenig@chromium.org>, Daniel Vetter <daniel@ffwll.ch>, Steve Cho <stevecho@chromium.org>, Yunfei Dong <yunfei.dong@mediatek.com>, Sumit Semwal <sumit.semwal@linaro.org>, Brian Starkey <Brian.Starkey@arm.com>, John Stultz <jstultz@google.com>, "T . J . Mercier" <tjmercier@google.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, Matthias Brugger <matthias.bgg@gmail.com>, <dri-devel@lists.freedesktop.org>, <linaro-mm-sig@lists.linaro.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org>, <Project_Global_Chrome_Upstream_Group@mediatek.com> Subject: [PATCH v3,03/21] v4l2: verify secure dmabufs are used in secure queue Date: Wed, 6 Dec 2023 16:15:20 +0800 Message-ID: <20231206081538.17056-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206081538.17056-1-yunfei.dong@mediatek.com> References: <20231206081538.17056-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 00:16:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784519686509193285 X-GMAIL-MSGID: 1784519686509193285 |
Series |
add driver to support secure video decoder
|
|
Commit Message
Yunfei Dong (董云飞)
Dec. 6, 2023, 8:15 a.m. UTC
From: Jeffrey Kardatzke <jkardatzke@google.com> Verfies in the dmabuf implementations that if the secure memory flag is set for a queue that the dmabuf submitted to the queue is unmappable. Signed-off-by: Jeffrey Kardatzke <jkardatzke@google.com> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> --- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 ++++++ drivers/media/common/videobuf2/videobuf2-dma-sg.c | 6 ++++++ 2 files changed, 12 insertions(+)
Comments
On 06/12/2023 09:15, Yunfei Dong wrote: > From: Jeffrey Kardatzke <jkardatzke@google.com> > > Verfies in the dmabuf implementations that if the secure memory flag is Verfies -> Verifies > set for a queue that the dmabuf submitted to the queue is unmappable. > > Signed-off-by: Jeffrey Kardatzke <jkardatzke@google.com> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > --- > drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 ++++++ > drivers/media/common/videobuf2/videobuf2-dma-sg.c | 6 ++++++ > 2 files changed, 12 insertions(+) > > diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c > index 3d4fd4ef5310..ad58ef8dc231 100644 > --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c > +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c > @@ -710,6 +710,12 @@ static int vb2_dc_map_dmabuf(void *mem_priv) > return -EINVAL; > } > > + /* verify the dmabuf is secure if we are in secure mode */ > + if (buf->vb->vb2_queue->secure_mem && sg_page(sgt->sgl)) { This needs a bit more explanation. I guess that for secure memory sg_page returns NULL? > + pr_err("secure queue requires secure 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 28f3fdfe23a2..55428c73c380 100644 > --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c > +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c > @@ -564,6 +564,12 @@ static int vb2_dma_sg_map_dmabuf(void *mem_priv) > return -EINVAL; > } > > + /* verify the dmabuf is secure if we are in secure mode */ > + if (buf->vb->vb2_queue->secure_mem && !sg_dma_secure(sgt->sgl)) { I can't find the sg_dma_secure function. I suspect this patch series depends on another series? > + pr_err("secure queue requires secure dma_buf"); > + return -EINVAL; > + } > + > buf->dma_sgt = sgt; > buf->vaddr = NULL; > Regards, Hans
On Mon, Dec 11, 2023 at 2:58 AM Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote: > > On 06/12/2023 09:15, Yunfei Dong wrote: > > From: Jeffrey Kardatzke <jkardatzke@google.com> > > > > Verfies in the dmabuf implementations that if the secure memory flag is > > Verfies -> Verifies Thanks. Yunfei, change that please. > > > set for a queue that the dmabuf submitted to the queue is unmappable. > > > > Signed-off-by: Jeffrey Kardatzke <jkardatzke@google.com> > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > > --- > > drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 ++++++ > > drivers/media/common/videobuf2/videobuf2-dma-sg.c | 6 ++++++ > > 2 files changed, 12 insertions(+) > > > > diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c > > index 3d4fd4ef5310..ad58ef8dc231 100644 > > --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c > > +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c > > @@ -710,6 +710,12 @@ static int vb2_dc_map_dmabuf(void *mem_priv) > > return -EINVAL; > > } > > > > + /* verify the dmabuf is secure if we are in secure mode */ > > + if (buf->vb->vb2_queue->secure_mem && sg_page(sgt->sgl)) { > > This needs a bit more explanation. I guess that for secure memory > sg_page returns NULL? How about if we change it to: /* verify the dmabuf is secure if we are in secure mode, this is done by validating there is no page entry for the dmabuf */ > > > + pr_err("secure queue requires secure 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 28f3fdfe23a2..55428c73c380 100644 > > --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c > > +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c > > @@ -564,6 +564,12 @@ static int vb2_dma_sg_map_dmabuf(void *mem_priv) > > return -EINVAL; > > } > > > > + /* verify the dmabuf is secure if we are in secure mode */ > > + if (buf->vb->vb2_queue->secure_mem && !sg_dma_secure(sgt->sgl)) { > > I can't find the sg_dma_secure function. I suspect this patch series > depends on another series? That was an oversight, it should be the same as in videobuf2-dma-contig.c. Yunfei, can you change this to match what's in videobuf2-dma-contig.c after the comment is reworded? > > > + pr_err("secure queue requires secure dma_buf"); > > + return -EINVAL; > > + } > > + > > buf->dma_sgt = sgt; > > buf->vaddr = NULL; > > > > Regards, > > Hans
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c index 3d4fd4ef5310..ad58ef8dc231 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c @@ -710,6 +710,12 @@ static int vb2_dc_map_dmabuf(void *mem_priv) return -EINVAL; } + /* verify the dmabuf is secure if we are in secure mode */ + if (buf->vb->vb2_queue->secure_mem && sg_page(sgt->sgl)) { + pr_err("secure queue requires secure 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 28f3fdfe23a2..55428c73c380 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -564,6 +564,12 @@ static int vb2_dma_sg_map_dmabuf(void *mem_priv) return -EINVAL; } + /* verify the dmabuf is secure if we are in secure mode */ + if (buf->vb->vb2_queue->secure_mem && !sg_dma_secure(sgt->sgl)) { + pr_err("secure queue requires secure dma_buf"); + return -EINVAL; + } + buf->dma_sgt = sgt; buf->vaddr = NULL;