Message ID | 20240129063025.29251-4-yunfei.dong@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-42238-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp391978dyb; Sun, 28 Jan 2024 22:32:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEleoo9fQ1hS6o7RZA7Fuq5YMQBjUYZWLiqS0cQPnqh6y8td2eCpTg3eu3cNyJ5ey4rf33e X-Received: by 2002:a17:906:a119:b0:a35:cb41:33e0 with SMTP id t25-20020a170906a11900b00a35cb4133e0mr703234ejy.27.1706509946961; Sun, 28 Jan 2024 22:32:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706509946; cv=pass; d=google.com; s=arc-20160816; b=MdOCW1Wi8hkrhDubHKpKQ/Lv60VLCIaOt4yvOk/XW3nWXBoVAbNb2bu+FWmW7yXtjm jruagqIrKG51OyfVeyEPjlKeAxFkIaPOG/5+qIwO0l3Xn34GWLeXgyMXpJMhQML2pPo9 Bx7wZ80elXzUueF/0QvqNKUM//8qjFH8DhlIxRxlyLSVwDpJpka1Dpgv31tKt1r7uftL ovBRaSoo7GA611sw6Ee2bu0VxKa6kVKZC0VM7WTtqrWS7Z+OAU/pPLBz9hlyl4hR9O7n iehKL7YQPreBYdvQNM/DhHiKKTUVf+xJ31hekiKkXXLhGjSPozA3OzNAe2H+Tk5wWLaJ jtOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iRfjJ9YWROks75IUMtZC2wrUKi1suXGk03fbJUFbyt0=; fh=wcqrfUTA4c9nkJHA4kqbuH5WL/x/W2/AFDhttE+DJkw=; b=ol5g2iP7JiPv/sVsKl9tVDzGFShPzU4YWTFS3O59FrHqLGhixhaU1jO339SUXa0nhH Km0Ng28ljtxEWzhudLNfRHZqJD+TCBbkbZb8AuD0/9m+pcAIAoi4+Bi2ICSL0I3l/i7b FLGpIrkMxtBEccNo+cBNWE0A2W0JXgJa/0R8tKoraozJn0iXyro6dHpsNLmROtC17GXi Brr/rTHfG/r3PXyfhXmM8Z+9pXzMZYjl3c914Zbj+6BhRXp4X0G1nqWAgBxEmOK2YXkj QcgzOQCb3qpJPCJtF8mv3cSUh1cf4As1ITLpMgEln4EHnLPyjbUJ874gucB4UfSH5JfG STtw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=jhkTa5bB; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-42238-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42238-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s14-20020a1709066c8e00b00a35a2453d0dsi908099ejr.169.2024.01.28.22.32.26 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 22:32:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42238-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=jhkTa5bB; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-42238-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42238-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 956BA1F2303C for <ouuuleilei@gmail.com>; Mon, 29 Jan 2024 06:32:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 367A0537F1; Mon, 29 Jan 2024 06:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="jhkTa5bB" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0E3D4CE02; Mon, 29 Jan 2024 06:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706509851; cv=none; b=XF6omy+l7RbNq2vZ9g+LsiwzadBX82KJW0SbFOsBDa10LWKYd1wgujZt+CrlipkRKTGVfutEQA3X5xR3dSifJQV7r9p4WWX7ycGjFw5L/RSAz54m0MTcQpyFpg4dCeh5w8FyMrV2bTsaa3Aosw1IdieVQaG7GecGv/uXNO5q17c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706509851; c=relaxed/simple; bh=9w2g6Gq7+Vgz14KR9HnQQihLeCCf4NtwnAbBqhhkmRM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HXawG8Ii/ZQ/qmHXI/oLkksNIrERm5q2A9x6YciBvtW02CY+R0R+KtmY9QyXXtY/gHJtz6feEv0pCXI/33diTa7hWa5jv5ybsw7roQguATpoCWfO5BF1bYof7SepaV+y9P/2daiW6MHCCK+exKcqEQd8+yckR1kQmWCY63JpuxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=jhkTa5bB; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: edf4142cbe6f11eea2298b7352fd921d-20240129 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=iRfjJ9YWROks75IUMtZC2wrUKi1suXGk03fbJUFbyt0=; b=jhkTa5bBLiYUT3wpEltBxfzcWPuTQQZYVqddzaf9asJdWmMcexNnkzGzCmHJqKWIzWSQxBOVUfhdMicHCknFw6ecI1RAoTomn2is7LHQtJgekjkE1ZtA2Lo6HW2V877F/BsOqusz6vAkJ+Cfu6vXriNcO0HJT9lNCgFAU1VnBUE=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.36,REQID:fb4fdc5f-960c-4c64-89c6-9a1053dcc4b8,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:6e16cf4,CLOUDID:7ed4dc7f-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT: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: edf4142cbe6f11eea2298b7352fd921d-20240129 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] 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 902818360; Mon, 29 Jan 2024 14:30:43 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 29 Jan 2024 14:30:40 +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; Mon, 29 Jan 2024 14:30:38 +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 v4,03/22] v4l2: verify restricted dmabufs are used in restricted queue Date: Mon, 29 Jan 2024 14:30:06 +0800 Message-ID: <20240129063025.29251-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240129063025.29251-1-yunfei.dong@mediatek.com> References: <20240129063025.29251-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--8.360000-8.000000 X-TMASE-MatchedRID: vT/skvKLwFh/+iNkyaz33x+WEMjoO9WWTJDl9FKHbrn8dcjERAe6XpPD bikkMnICYUA4QKGgNJ2/QAgXHCg/RXdWNVeH9NKPSEQN/D/3cG4k9Lf/qe8xx9VU7IWeAUCLMCm LSFOvZt1yylwV7Bc73YAy6p60ZV62fJ5/bZ6npdiyO81X3yak88kZdO1mPd6HHujJdWgMIOuuBc q5ylGQImmWoby5Y3Os7MRn2aF6FKR+3BndfXUhXQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.360000-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: DF28679987472B888EA7E9A1D6228B4E0BCD01647BD0B2DD86B95E8C06EC4EB42000:8 X-MTK: N X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789405374251193503 X-GMAIL-MSGID: 1789405374251193503 |
Series |
media: add driver to support secure video decoder
|
|
Commit Message
Yunfei Dong (董云飞)
Jan. 29, 2024, 6:30 a.m. UTC
From: Jeffrey Kardatzke <jkardatzke@google.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@google.com> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.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;