Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2744702pxb; Tue, 21 Sep 2021 06:49:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrIu7esjjtuvoVKraJv/O18vPfK9xK1t0+MvSSEBSdEgEZNh1yPmBvZ07t+bH9MBncbUB9 X-Received: by 2002:a17:906:6547:: with SMTP id u7mr34534738ejn.544.1632232151434; Tue, 21 Sep 2021 06:49:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632232151; cv=pass; d=google.com; s=arc-20160816; b=zO/9TKyeyB8EP7Y9WWpZ9gixPAiU2J8lno8UxF+hdaUaYyMcOSCAn1ImhMBtpr4B2r o+k8xDfwkfTByRQs2Qbicz8/YmmYqZbOER3vJr38f9BBkm3T484jnak+MhgG8H1adqPc Lusgc0RnFmFoU+zAhvbRXtCIisMsuRe2Y1PBbFOL3lKL9G6kSTFNKrsXmCsBCzu7N6P7 wgQjgdivu9KX1HjZHz0BSnA0tXi8ov4ErLdd2+O2IkLO+NNslKgQ8TCWo8PRbr3ECEwt zipVS8f0iXUTZJ6bDESuKbV1CyQvBEh8eHzClkQWVe8a+Byb2QzJOA/MGjPXTZ45LBaI pfOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Nc+1R6n9uacoJl6dRDPvcVxljHhtW21u21zWiNRIc78=; b=oB+VPxUEK7qdKhpt+3RYmHnoytX/AGpAWJUHgoibqAPjG6c0H3cK5yG23FCX+EJdeN 7N1w6ZwU6f5NvP7h8UjJOdqwETK3K4gZy5YWeE4jOs9PtxEvgOqmRO8lnP/JQrcU+qUR 4ik+rJqQLfV3oX3ZOJylroxSr7qL0wQMaKz27nmo2dEOqFJSlZNRMxLc+wlsQPzsDTHw 7jIOQIGBM8IE5nqfUt7XOgkhqCbKFPmnwaDRLijKyqXB1BiJo1GWJ3T0QHR7KHry0cd2 EpA3LChuyIVdqJNniALYvY3vTAdNZwYdqeN9r89MjVJR791+sZd0l3Thp14qO3jKHpu5 p/Hg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=YznDBPPM; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si18606630edj.607.2021.09.21.06.48.43; Tue, 21 Sep 2021 06:49:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=YznDBPPM; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233313AbhIUNqk (ORCPT + 99 others); Tue, 21 Sep 2021 09:46:40 -0400 Received: from mail-bn1nam07on2078.outbound.protection.outlook.com ([40.107.212.78]:60294 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233289AbhIUNqk (ORCPT ); Tue, 21 Sep 2021 09:46:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R75jtLS1xM5yJxXr+PE8H+2Ec/+IN5lW+HuuXEaprKAbReg7bpg/77fd+F4/qG4atPHRX5P5dn1RByW2s/o0iU6QklGpmAgO9fE8gJhzyMCnocQz7pd2F0bH4mQfvW4KsKYkgAwpfvfHylwszTumTnzq59icZ4lpiCzUisSmw+E/iBMVDU3g4d/8++AnmyrbInge7m9Oi/jSt1yIUGS6fCX265vPrqwAzDy+na7sT/hrtXlvjCl4DEZZktlI+tXh6DA1mPhY+hIO77G2gagasyS266g+0n6c2YmUIUV76H9t+Q+G2k7JiqC0cK1DJ3ljXExm8EyiFF+BSw2uz4BPEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Nc+1R6n9uacoJl6dRDPvcVxljHhtW21u21zWiNRIc78=; b=X8fbqMs0Q1T6PlgE6OTrgaWr2Fvo0ZPuyo9RxF0lPwdxVLaVGepwjkLUL7Kev69EZnJfeS5rk6pP+kfe9RzHTfjhU0D14A+RCH+5QSxv6841eYf/nvM69iDYoLps+NicE+ht+eqaap3xnfnrDSA9rLmNxA6oClbmO0pnNxQORDl40SSbIT7Du0dCr8rAcOwC/5AE4bzO5kw0L4YN5uz/gpxyz6eIfiwCP7kaDaqj+yi5mrwz475Qcx6ALNNE2RSVr1EG6iw+VaC/yRlyf8VoLIJ+gIdeO9VY2kYRsuGz/sQ0PEiiozOpZDIXq1nceAITkLOYxz0SgCOd8R8XLFPHSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nc+1R6n9uacoJl6dRDPvcVxljHhtW21u21zWiNRIc78=; b=YznDBPPMOY0/eE58uGOFreNm69+PS4NZNJSc5Po5wYBhUqQzCcoJ+t7VzBD8n50oBKmxRZG3dX/jPh9YZ83LYW4LV5lpsKMmUMcD4H/c07g9U+B6ohmj7WD6kMFfcqzKH9NQqgUnxGgrrAKNN60RzhSKvTXisZptp3n8+ixW33JOcVI0vuu6cmr5tHmbGtTx9ldfO6rkjoMHxgpiXgn5MqJgenxZDe1ISWIDNy+c0pBUne5l1Lotv2E6cRf8uIwHYTwAC4xSvOaRpsAKPRxiz+oPeKsPm6SiJ4+qN1Snaaq9BoeEIPvPjeCR3zlfS+cFtHD6jai8hfST1arqQ9mJaQ== Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5221.namprd12.prod.outlook.com (2603:10b6:208:30b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 13:45:10 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::e8af:232:915e:2f95]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::e8af:232:915e:2f95%8]) with mapi id 15.20.4544.013; Tue, 21 Sep 2021 13:45:10 +0000 Date: Tue, 21 Sep 2021 10:45:08 -0300 From: Jason Gunthorpe To: Liu Yi L Cc: alex.williamson@redhat.com, hch@lst.de, jasowang@redhat.com, joro@8bytes.org, jean-philippe@linaro.org, kevin.tian@intel.com, parav@mellanox.com, lkml@metux.net, pbonzini@redhat.com, lushenming@huawei.com, eric.auger@redhat.com, corbet@lwn.net, ashok.raj@intel.com, yi.l.liu@linux.intel.com, jun.j.tian@intel.com, hao.wu@intel.com, dave.jiang@intel.com, jacob.jun.pan@linux.intel.com, kwankhede@nvidia.com, robin.murphy@arm.com, kvm@vger.kernel.org, iommu@lists.linux-foundation.org, dwmw2@infradead.org, linux-kernel@vger.kernel.org, baolu.lu@linux.intel.com, david@gibson.dropbear.id.au, nicolinc@nvidia.com Subject: Re: [RFC 00/20] Introduce /dev/iommu for userspace I/O address space management Message-ID: <20210921134508.GL327412@nvidia.com> References: <20210919063848.1476776-1-yi.l.liu@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210919063848.1476776-1-yi.l.liu@intel.com> X-ClientProxiedBy: MN2PR10CA0018.namprd10.prod.outlook.com (2603:10b6:208:120::31) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 Received: from mlx.ziepe.ca (142.162.113.129) by MN2PR10CA0018.namprd10.prod.outlook.com (2603:10b6:208:120::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Tue, 21 Sep 2021 13:45:09 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mSg56-003Shl-Vn; Tue, 21 Sep 2021 10:45:09 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d615b4d4-890f-4ce0-29f8-08d97d06077a X-MS-TrafficTypeDiagnostic: BL1PR12MB5221: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:480; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pPD36VXbO9At6kr/wWl+CaHqx3W1u9u0tjqhKiSaE/TXQRTMpczesMA3ZfF+9IzddYwbVNKAQJ6EPfDx6Nsrq5wXg1BneqmbfLFvZtGnN8wdQ2RtbgWVhY6o7cA+q8zWBjzPilQTHGWlkDt3Kp+QmmSjmV/eNv7ilMLo5LsWrms1Ho9YVFBdkGJPbIDYzybIF8kzWw1WfGtqtXrOQiMWDhQDC+8fmtyRFLVI9NHsC66PxZKDqebYaTguSDyfvLwOdYua2Lgr+sxrU4AsZQDNJgDwYwq4MtoOyVqzeg2JOHyjo2RUrgrxjOs0OfABa2O1he7TsYUwZwyADuSC3eH/n88hqFqrSUon9eVAzbbVUBC68saeuwvv8d5AqQ3nOQBJUs5ZhNtmTCNla30avfWEIzNwujq9b6f/GMJdPoyBkZNpMr6ApMVXUfA4QPYYGlarvASXKyU8/kvEQZaGQFBhgyUJ67KFzFAkgTVWlD00QH2WOtI/2BHPpX8E0HoulHFRzcR6quM3b0Ozzi0vEFwL7hppqiGJavcGQw6AhLc8Rfapq0q6yKqS0vdBA6EETw3mKXYuGGOhSpXHWl11w6n8cLkobahRyj+Z0FM3PVZW48LrU3ChmCua+CnQj3Zq5jpuu8b4ZThs/xV9npWiY9Suht4r/lfh38Q9S26HKq4t3S13eujbouPp2n5wQKrW3l4d X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(186003)(86362001)(26005)(426003)(1076003)(8676002)(2616005)(8936002)(2906002)(66946007)(66476007)(107886003)(36756003)(38100700002)(4326008)(83380400001)(33656002)(9746002)(508600001)(316002)(5660300002)(7416002)(9786002)(66556008)(6916009)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kNlgUgIKJuwgssXD/cYJ6xuD64uoug/UV0bEXfN6WmVUtb381FpRPvgtqGwZ?= =?us-ascii?Q?eMmCJT2sO9oZrrp5s01Osnudj9AiQU7we5xtbZSDZ0oHXgWVllI4WH6eH+Vq?= =?us-ascii?Q?GV1u4mpPMA6r9LnssxReahgqZgrDy6dPYNl3tOWLckPibWNLz93/818fqc/x?= =?us-ascii?Q?8t9IYkiqMgsDlTLS5w2Jvy2mo651a747pcblLfGERJHrDvA+OHQSE4cfo9TG?=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xJsr3tY4JLUVDtPl28oUUok2Ih0t?= =?us-ascii?Q?DWg/FPr89uWDcOEpGn7Hx3f+UbcNKdFZIe22Mz1kY8Isvs3ecvruGY54riev?= =?us-ascii?Q?eQ2n7CdNfU7OmoPaGQhlxDJ1P3aajhazzryWUkAdyZ7t9hcDtEHg+x6/Kklw?= =?us-ascii?Q?GXlRI8dAzC8itf9n+uGOnBdR+eV7EZxLXsQwtt4mdFU0ta3bY84tgLcJeiNu?= =?us-ascii?Q?i2xdwMoqOg8opHiDctpf9znz?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d615b4d4-890f-4ce0-29f8-08d97d06077a X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 13:45:10.1126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: phWVkSgZ6pg1QXj0j41IVwWqGBcQHApB4o833pkXQnur2ztxA5Vly4PPti0im5oo X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5221 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 19, 2021 at 02:38:28PM +0800, Liu Yi L wrote: > Linux now includes multiple device-passthrough frameworks (e.g. VFIO and > vDPA) to manage secure device access from the userspace. One critical task > of those frameworks is to put the assigned device in a secure, IOMMU- > protected context so user-initiated DMAs are prevented from doing harm to > the rest of the system. Some bot will probably send this too, but it has compile warnings and needs to be rebased to 5.15-rc1 drivers/iommu/iommufd/iommufd.c:269:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (refcount_read(&ioas->refs) > 1) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iommu/iommufd/iommufd.c:277:9: note: uninitialized use occurs here return ret; ^~~ drivers/iommu/iommufd/iommufd.c:269:2: note: remove the 'if' if its condition is always true if (refcount_read(&ioas->refs) > 1) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iommu/iommufd/iommufd.c:253:17: note: initialize the variable 'ret' to silence this warning int ioasid, ret; ^ = 0 drivers/iommu/iommufd/iommufd.c:727:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (idev->dev == dev || idev->dev_cookie == dev_cookie) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iommu/iommufd/iommufd.c:767:17: note: uninitialized use occurs here return ERR_PTR(ret); ^~~ drivers/iommu/iommufd/iommufd.c:727:3: note: remove the 'if' if its condition is always false if (idev->dev == dev || idev->dev_cookie == dev_cookie) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iommu/iommufd/iommufd.c:727:7: warning: variable 'ret' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized] if (idev->dev == dev || idev->dev_cookie == dev_cookie) { ^~~~~~~~~~~~~~~~ drivers/iommu/iommufd/iommufd.c:767:17: note: uninitialized use occurs here return ERR_PTR(ret); ^~~ drivers/iommu/iommufd/iommufd.c:727:7: note: remove the '||' if its condition is always false if (idev->dev == dev || idev->dev_cookie == dev_cookie) { ^~~~~~~~~~~~~~~~~~~ drivers/iommu/iommufd/iommufd.c:717:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 0 Jason