Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2069959rdf; Mon, 6 Nov 2023 04:05:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzJSrC1oAfgThh1r64GfCxG/72cboxsvIDBtyfh0Xm72jrEoXp2kfLsH50mERjwKZA8G+e X-Received: by 2002:a05:6e02:1051:b0:359:4b3b:531a with SMTP id p17-20020a056e02105100b003594b3b531amr11920970ilj.30.1699272341017; Mon, 06 Nov 2023 04:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699272340; cv=none; d=google.com; s=arc-20160816; b=cdlYOsE5yPPlg/UwMO4P0HCcTL2e9pHZSgByE7cGVfTYiUi0sbjO2P39EBeGV1ySQx VT8xPFO90xZ/SRNnqCEUM76KNWEjHEb4Kf3feh2TZyzLZ/ClLpWm2yd1mDc6r7PSh706 DDJYWBmY4biKo8yna7FR5i6ezA6SDVx8gNUXKb3L32AzyLMgmLEbaLOnbr3KwNKz+HKU 1qq3jM7tXneHkk8wbe77p3QyAaH6iGxAN4vva61Y2F9ff4puwpClbiOsRbT8snrFPmGg LyJSk1nhlUJ9ZeNZYUgRWrURVH79Lp9lb52nTQOTxOE1w1nTyPTx6OHcTb7TfEdDSLUb FpzA== 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=xaXSYYp/R/Yb59Wdv7tahHP4Ng033IFyHb7NA8pgCLk=; fh=HMoU6Z0fAVEi/36PnBTb4UQLM/fqzPQmIZjxf5hFbO0=; b=YKFgvntrXjgYUBNTmgoqwWIeDLRoMieHdQQTzhn1U5rdO0jk6vARY/Zc+GMGcJaCcd XcbNq8o9vTQe0nXL9cVHG6AGzfdhbXaxDRK1JTxn9hEc95o67osYhSU/s4xojY9rR9ys oRLEJdP56on8kFz2YEh9BjyXZcwmGAehDoYZKdaRbeymiZacPOFNtZC19HPRBaosVpTv 2zRzP9RUaFHt4EJWPfLkAXbq+8kAhLOoJvzz61FxW2c3smDqoGYZQ6FNEZZZMjCWj4KQ /Z+jrGeLG7phFlihALzvXBcEpTXihZ04a4mJWsgW/1gV95ord3oG6zf859dIWaDiP6yW QUcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=WaoOShaH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h64-20020a638343000000b005bd3cf5fd1esi7878907pge.389.2023.11.06.04.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 04:05:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=WaoOShaH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id C80B88075ED0; Mon, 6 Nov 2023 04:05:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231549AbjKFMEi (ORCPT + 99 others); Mon, 6 Nov 2023 07:04:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjKFMEh (ORCPT ); Mon, 6 Nov 2023 07:04:37 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39950DB; Mon, 6 Nov 2023 04:04:32 -0800 (PST) X-UUID: a2ecaa9e7c9c11ee8051498923ad61e6-20231106 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=xaXSYYp/R/Yb59Wdv7tahHP4Ng033IFyHb7NA8pgCLk=; b=WaoOShaHmylv9HtgnJK2dNAjzZtYqMfQjiwIhDO9jumxvmvjD6jTfY2Ij9Z0S1BeYTk8Abw/KoLFacsJZPIDdvKiwo1/1sNKRIpy/mspQ8hQ5RbSnTgnnQq8CrEUT7XlAvfvdp6q5IQsgpQOe2qo/wzOrhsfNUyaAqPS5CAwyoY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:7c558346-52ca-4f99-8584-01740e761014,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:364b77b,CLOUDID:d3475472-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 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: a2ecaa9e7c9c11ee8051498923ad61e6-20231106 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1694378906; Mon, 06 Nov 2023 20:04:28 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 6 Nov 2023 20:04:26 +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, 6 Nov 2023 20:04:25 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , "T . J . Mercier" , John Stultz , Yong Wu , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert CC: Chen-Yu Tsai , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , "Steve Cho" , Yunfei Dong , , , , , , Subject: [PATCH v2,01/21] v4l2: add secure memory flags Date: Mon, 6 Nov 2023 20:04:03 +0800 Message-ID: <20231106120423.23364-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231106120423.23364-1-yunfei.dong@mediatek.com> References: <20231106120423.23364-1-yunfei.dong@mediatek.com> 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--3.729000-8.000000 X-TMASE-MatchedRID: 1EkN8wfBE2kXSulpnju2H4SvKOGqLLPKK2i9pofGVStcU0dNErOD+mlF 7OhYLlctcYKRVYWgduVAw/iJrysrSm+IsUfG75P2joyKzEmtrEeQoBr+SFneJJj9R7obtcgyH5L 2GhBQtff4ei4a6fEfjpynPbWEKM6u8xjBEybW2by3HA8h5a0MOXnL427v8Q461gisw2JKo8k86a y9NNiI8eLzNWBegCW2wgn7iDBesS0nRE+fI6etksezPriNOMMa5evK5QqVTFyJjYpg0md7nwGuY jlJhX2RTAsYtPFcm2AFxhhkRSbhgvVEcnBy2ijPFj2h5F4GY+ndddgV66Y3YYSVUZZHNLr+RgV6 Hsqyx11QaONuZ6Jr4g9k3l8EaYIcDiKmdrlEg1g= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.729000-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 9864FE8686BDE13139414B2CB77751A0FE1C12DDB68367C23E2FAB1D8E76EF7F2000: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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 04:05:07 -0800 (PST) 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 4b6a9d2ea372..f6333d8fa617 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 @@ -598,6 +601,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; @@ -766,7 +771,8 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, 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 c3d4e490ce7c..4bf8d392d5a5 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) @@ -1035,6 +1036,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) #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_SECURE_MEM (1 << 7) /** * struct v4l2_plane - plane info for multi-planar buffers -- 2.18.0