From patchwork Wed Dec 6 08:15:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 174408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3957066vqy; Wed, 6 Dec 2023 00:16:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9DOnRZJH0An3s11ji3qCdmcTClVpIoK0Hwo7pj+FhOPyQcTWiAeA9Z0NPcdoWtSXANfFb X-Received: by 2002:a17:90b:4cc2:b0:286:6cc0:caea with SMTP id nd2-20020a17090b4cc200b002866cc0caeamr521487pjb.97.1701850570296; Wed, 06 Dec 2023 00:16:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701850570; cv=none; d=google.com; s=arc-20160816; b=Y3qqa1ThwrP/avu2P2VyGJLu5TCnPmLjKygzJ81dFH5b/52vqnhry5eBbzRSYKbiSB +LsuRGSer7QVarNj0pQbugP+Gi3YwZ8toJL1/sHPZRqB6US2oMYw/RsGOJ1aEZjNWSgx xY1zGbiNQOaVGSG3c6Yn6Mp/Ovs4Yw9g2C8oYIQcXz+P18gwp8yGLqODgTKkPMZwzihy jdUoBCDoK6LI9I4Jyr8Ml1uLhPRduysSlDuCmUyKetv1t1K0FZoVoLIA6udtww4EmI0s yPRiK1SJhsEscNPJwTbHEzc2pd8pkebeMzlIu8zCkzAbQumgP4cof34mHg2KfR8BDy8G fwPg== 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=Gtxt/C4CIwXGjWvyCwDlPRCsxH6BQ3m1lajwI0U2H/U=; fh=wcqrfUTA4c9nkJHA4kqbuH5WL/x/W2/AFDhttE+DJkw=; b=KmHDm7VKX0n9gjP1tDoayyoAj9sSXxfPgIFqBLo2NwvVKgAKMzkPZL/X+IbYRZbzf4 QmvVTRux4eAr7i4ASk0OAw9S5qxwtwbAk8FjEsyhG/ocDyk/0Lztm9ZnlLDoUCF8id1k WcIjiTOFdDCiSNO5kWD6YIHGgAMS/tQ35D9sfQLuZUeGhONvl5nt2VX4AakboVJ1jesP voF1D8eLThiHTsXvX6P5iiMP9ANdOD3wI+tSx4pC/uI6YaEcySI65NiKopQlDxXhKpsu OHpEmVGsmCQYdK/iwh2B0MP6840W8jecMvKbxJw3Qo+lO2iRaMQCU4aWarzeh07dp7aF 7TNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=IKdLnIG7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id gg16-20020a17090b0a1000b002866c405e01si7380324pjb.17.2023.12.06.00.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:16:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=IKdLnIG7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 76CA982DC602; Wed, 6 Dec 2023 00:16:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377149AbjLFIPu (ORCPT + 99 others); Wed, 6 Dec 2023 03:15:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376876AbjLFIPr (ORCPT ); Wed, 6 Dec 2023 03:15:47 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3C0D3; Wed, 6 Dec 2023 00:15:50 -0800 (PST) X-UUID: a6618ab6940f11eea33bb35ae8d461a2-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=Gtxt/C4CIwXGjWvyCwDlPRCsxH6BQ3m1lajwI0U2H/U=; b=IKdLnIG7QRgMwItgumiEt9xwdq5SbopCgrJ6f5g1Kl4amHuhPrhxwKeQuinsmjgLx/MCc1trvmB/uYJBWFbuCgKGDGGgwSZNLiIivCoR5k7psPnkTVW7LnNbdvl3czKNukupwytsRBTVLDPfLyCWMG9n5aSpD0rhKUc6SGILyPc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.34,REQID:84038762-c0ff-40f4-b327-d31c9d9da937,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:abefa75,CLOUDID:182c59fd-4a48-46e2-b946-12f04f20af8c,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 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: a6618ab6940f11eea33bb35ae8d461a2-20231206 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1042332511; Wed, 06 Dec 2023 16:15: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; Wed, 6 Dec 2023 16:15:41 +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:40 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , =?utf-8?q?N=C3=ADcolas_F_=2E_?= =?utf-8?q?R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Chen-Yu Tsai , Yong Wu , "Hsin-Yi Wang" , Fritz Koenig , "Daniel Vetter" , Steve Cho , Yunfei Dong , Sumit Semwal , "Brian Starkey" , John Stultz , "T . J . Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= , Matthias Brugger , , , , , , , Subject: [PATCH v3,01/21] v4l2: add secure memory flags Date: Wed, 6 Dec 2023 16:15:18 +0800 Message-ID: <20231206081538.17056-2-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 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.791700-8.000000 X-TMASE-MatchedRID: jAP7Z+txIHYXSulpnju2H4SvKOGqLLPKK2i9pofGVStcU0dNErOD+mlF 7OhYLlctcYKRVYWgduVAw/iJrysrSm+IsUfG75P2joyKzEmtrEeQoBr+SFneJJj9R7obtcgyH5L 2GhBQtff4ei4a6fEfjpynPbWEKM6u8xjBEybW2by3HA8h5a0MOXnL427v8Q461gisw2JKo8lYua /kyrSLKzqKm/4qdbn8gDLqnrRlXrZ8nn9tnqel2MprJP8FBOIa2ntLqnPa1U32O6TmKuehrIU0+ TfNuMYBg5SfNRWImmHKWqep8B//Hg6qbFFxcFTguN8K5GvhTbfHIhLbWKGpxiA2fMrPTSd/T07L PKPPWmXzYaPZALfIbSyZdUr8fx4fMbuyvvGhtIDNwMS8lpRKBQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.791700-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 97FF8B845C51ADA254BD35568E7F9B4AB38BDE9BF69A393FCA1FA0275D045FFC2000:8 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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 00:16:02 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784519663896570901 X-GMAIL-MSGID: 1784519663896570901 From: Jeffrey Kardatzke Adds a V4L2 flag which indicates that a queue is using secure dmabufs and the corresponding capability flag. Signed-off-by: Jeffrey Kardatzke Signed-off-by: Yunfei Dong --- include/media/videobuf2-core.h | 8 +++++++- include/uapi/linux/videodev2.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 5557d78b6f20..98eba43661c1 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -518,6 +518,9 @@ struct vb2_buf_ops { * ->finish(). * @non_coherent_mem: when set queue will attempt to allocate buffers using * non-coherent memory. + * @allow_secure_mem: when set user-space can pass the %V4L2_MEMORY_FLAG_SECURE + * flag to indicate the dma bufs are secure. + * @secure_mem: when set queue will verify that the dma bufs are secure. * @lock: pointer to a mutex that protects the &struct vb2_queue. The * driver can set this to a mutex to let the v4l2 core serialize * the queuing ioctls. If the driver wants to handle locking @@ -601,6 +604,8 @@ struct vb2_queue { unsigned int uses_requests:1; unsigned int allow_cache_hints:1; unsigned int non_coherent_mem:1; + unsigned int allow_secure_mem:1; + unsigned int secure_mem:1; struct mutex *lock; void *owner; @@ -770,7 +775,8 @@ void vb2_core_querybuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); * @q: pointer to &struct vb2_queue with videobuf2 queue. * @memory: memory type, as defined by &enum vb2_memory. * @flags: auxiliary queue/buffer management flags. Currently, the only - * used flag is %V4L2_MEMORY_FLAG_NON_COHERENT. + * used flags are %V4L2_MEMORY_FLAG_NON_COHERENT and + * %V4L2_MEMORY_FLAG_SECURE. * @count: requested buffer count. * * Videobuf2 core helper to implement VIDIOC_REQBUF() operation. It is called diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 68e7ac178cc2..570b11552818 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1026,6 +1026,7 @@ struct v4l2_requestbuffers { }; #define V4L2_MEMORY_FLAG_NON_COHERENT (1 << 0) +#define V4L2_MEMORY_FLAG_SECURE (1 << 1) /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */ #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) @@ -1036,6 +1037,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) #define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS (1 << 7) +#define V4L2_BUF_CAP_SUPPORTS_SECURE_MEM (1 << 8) /** * struct v4l2_plane - plane info for multi-planar buffers