Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp488170pxb; Thu, 23 Sep 2021 04:43:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlIi5G07XltWMrYCMYtJ+EMVlE0fLkBN2RgBdHAXBuYRX7fJXwNbL86KYlwX/5UC5537D7 X-Received: by 2002:a5e:a609:: with SMTP id q9mr3410834ioi.23.1632397424496; Thu, 23 Sep 2021 04:43:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632397424; cv=pass; d=google.com; s=arc-20160816; b=Wbk48T204HiHDGLdfJ/jbi7QZjINz1Y1dOshDODP+ShbpyDnqUpDui6elc+R53BVmH N0u8oA1ryCXOxe0xQ4od/HJyKtMtGF8PuFGVr47jwfukUn83YOU0EVMg3fKKWkgobsoB TjT9ErI88o8y2t0rIc0J/FanWWQ/n+7s1A3YevDTvZBlMCs9joV4IK/oFKG/zfZvQZsL PkivP+vkLkxjBByLUo41ZehQAIJdcUrohzV5HE9s6t+hhC7lkS9AMmAq4eFF6inMD5BY QAG2YQuopEoCoG3qVBXK/FGxxPM+fbIpg/2GdluxkIFfVVjK3kmLofq1p5l/tthLENzR 2RbQ== 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=vBJYojau7hiTKVLiT+3OLvavyVqVp/BBeBKyx7I+ORA=; b=ha/kuM+C8cxYw5G/rQJ3GTamgudjKa+Ftcf1Le+iX5OxtXblB0tXnd4Q0cvqCSKd5C cxEo5I5plrxgDptxhTP88NK9PgSLWk07rRPhz2/rBpIzEAUOFdnmh17/EiUIPHK5Xv8x zehqhHUIsMM4l7wRK2MJCSgq2+ibCsOnrOOHoXmirY5tAClryWnqpD5QJzWcfOBLi5tv tgevDg5EbPboicnbT6kq7vs/AN4l9oM/it/tOLOThcfKKwOz8AHVxRcsK/I4SRtvU/6w J6VZo+OJdhLp1NZ1EHQgcfb+y9UjMy4j2csp3ZPGhyfyru5cLK+0OIJg66iOvkVNaqR/ AAjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=iWDP2snV; 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 138si5187357iob.37.2021.09.23.04.43.09; Thu, 23 Sep 2021 04:43:44 -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=iWDP2snV; 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 S240665AbhIWLny (ORCPT + 99 others); Thu, 23 Sep 2021 07:43:54 -0400 Received: from mail-mw2nam08on2085.outbound.protection.outlook.com ([40.107.101.85]:52961 "EHLO NAM04-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238930AbhIWLnx (ORCPT ); Thu, 23 Sep 2021 07:43:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XcDrhcZ5LVczmyEDTe/CHt61IvlMFZbdHn6D75nhVTtfZw2vav5tBgP9mxzjPLWsfiYLt6ixGx1Dz5t7+BPkA+kIrt2AUdyL6gryj4h1lZ+NQpSTstUTjqftR6PflphfO8hFy0HFjFh8vDzDrrt1VNdRIKhp3ipT3tYapQUKbIXbK3xYIz6D7PaicMAMYUD7KuDd0pB7QA8JuVwjLoNAPNWt1eZzLIcslzlEIteq5uzfVQvKRTiQ+CSLXo6cH22hPr/y3Z6zOPOidLQ0pbd6X81lyN09moX/L/n8wOefs3vdz15VdIX47k2uC2ysjaw/SB425kJYxfMdusA2QhLGwQ== 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=vBJYojau7hiTKVLiT+3OLvavyVqVp/BBeBKyx7I+ORA=; b=AAwsG8almCUCZfhdd1/tVUwrI+wFD7jaT8ceWjzHhKpC6P150ZyUMSahYnp27ntyoFiE4/k0ncEVX22IisoZ7GfoaxZDaC8uxBxCd2LQmV7u9hQ7Afk4oQYXkI66lktmX5CzqT4clKhElClgWPnvx4+mGYpxzYVsUBNFSf042g+UkqBBUFtm9DKSezSKss3iuNk9LRP1YNkuZIC0kwSMWfLPdDFpq3FprQkrCeVFYq3HLsdeJoxhTtsT4/c9V3QulO2V/XxXxiwdYKvlhmJRXJZw7xh/Dm/VPKoZG/6BHdNHUJ4brqX2mg5r32TUzLjVT0dL6ziLQ10QBe2kZ3uPkA== 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=vBJYojau7hiTKVLiT+3OLvavyVqVp/BBeBKyx7I+ORA=; b=iWDP2snV5pzbdguAKMB3ioMq5mSDMrFY/IwkCFrlM5vH7DDtYGpSvQJKeuoi4vVT62RZGf26ZfUFa75wBz6I3xwfZMplful0oX2aXM+cFUc6vMOHTiJAswZZp7yw/N0qGujhqis2AZHyrD2er9oANw/cOdXhxm+7UK0UvpfTEc0g5tzRiH7KOTGLZsw5NOX4NLKoozLTGHMuwgXLzJe8dtERj4fCcS9i33Cu9w7YzRzwh2mdxmBLGsrsQdGlUdBLDwTCaBm96pdXrtDWvr8xKV4piXOCIrxJGfgkkw0okpNW+6kJfzUG9vUPSNB3Oh+aDFI2iSyYjUvWMhnoMvEXPQ== 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 BL1PR12MB5379.namprd12.prod.outlook.com (2603:10b6:208:317::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 11:42:20 +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.015; Thu, 23 Sep 2021 11:42:20 +0000 Date: Thu, 23 Sep 2021 08:42:19 -0300 From: Jason Gunthorpe To: "Tian, Kevin" Cc: Alex Williamson , "Liu, Yi L" , "hch@lst.de" , "jasowang@redhat.com" , "joro@8bytes.org" , "jean-philippe@linaro.org" , "parav@mellanox.com" , "lkml@metux.net" , "pbonzini@redhat.com" , "lushenming@huawei.com" , "eric.auger@redhat.com" , "corbet@lwn.net" , "Raj, Ashok" , "yi.l.liu@linux.intel.com" , "Tian, Jun J" , "Wu, Hao" , "Jiang, Dave" , "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 10/20] iommu/iommufd: Add IOMMU_DEVICE_GET_INFO Message-ID: <20210923114219.GG964074@nvidia.com> References: <20210919063848.1476776-1-yi.l.liu@intel.com> <20210919063848.1476776-11-yi.l.liu@intel.com> <20210922152407.1bfa6ff7.alex.williamson@redhat.com> <20210922234954.GB964074@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0439.namprd13.prod.outlook.com (2603:10b6:208:2c3::24) 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 BL1PR13CA0439.namprd13.prod.outlook.com (2603:10b6:208:2c3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.7 via Frontend Transport; Thu, 23 Sep 2021 11:42:20 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mTN7L-004OOW-Gu; Thu, 23 Sep 2021 08:42:19 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5aa4a723-b75e-4f48-e703-08d97e8733aa X-MS-TrafficTypeDiagnostic: BL1PR12MB5379: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qrmpmcx5CrrRtQEVEyrZgKtbwLWs6tKR86EMtr5M50MLZKMcYgLtqfHiwBTaq7H7K+2ddiJkCoEb7YMfTIy0/mFyU/0AZV+FBHBe/qr/aI1ciZYqqd07z1nuYsHwoMVzt/0sPp3xYE+uAVFIqePZIJGd1W1YA1bE51EpHUDVlwu3rAfBopnmfV+Uj5HK51F1ywtUbAa2NcxaX0Gh7nMkPXR+4J/JuQsqKSLMIaKXxrXofZQYYSZTAbYR86UgA8KIjRcuD+efcwwgfHaboORhjT19CioLXQXI3nXCoB4ZoHfWA8vfm8o6lXmdQm5VWjwTo0FeDQLkNM2kCLpKG+qrseFc3OVEu1Cft52KrY8+rBARZl8cVSQ8pnZ4fev1rAsro7Wq75S+mOnHpp0A1A7g+Yyp7+Paskz3+e+EOo9YYxkLOQpMkkObM6bMmFm12ir/NpyRIbrvfK1lWBJSzsoSRNcPoZmikvbsVHxZBO0hTK/tUunRh8Zl9eMwhJKjbRVSfP2v5uj7MDX/tpD4iR79hn3NYPWgUBLx2iq/SwVNqNChQtGb+24MoROPmY5Qm3qUQA+VQh1xnDtLouFYXEOZF5gMnY4gM/yOZyDMZIlNIQEiK7HSsQhqpaIlyOg2ZKgSyMDflPp/iFhWPD9XUI73wmdT/1Te6dCFYQmaZOS85QqVaD+u12PdHYVbC1hOj34F 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)(107886003)(66556008)(2616005)(426003)(508600001)(9786002)(316002)(4326008)(186003)(66476007)(54906003)(8936002)(9746002)(26005)(8676002)(83380400001)(1076003)(5660300002)(7416002)(38100700002)(2906002)(6916009)(86362001)(66946007)(33656002)(36756003)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EVPsLiMlQTFeedz6QO5VNUN7fe49S6QznlZVsYuL3HsgBNXyI64ZAQE73xTE?= =?us-ascii?Q?pFIgRPXqnUEeHx6nd4NKqf4uzORuHfntQ+tKG1avRYPb0DmizmoTfbtjiM2W?= =?us-ascii?Q?lh19c2OCBhHnlBwUvzWrJge6A6Sa0/aUiRMRNV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P3rd1zab63F1vvJSU3VrMOcKPLS15TkeU4L5kq4yjNI/m?= =?us-ascii?Q?bHYfF6sRneyfObKt8499Yl38f8wQjfYovAHVjsI9cxTwVxZ8JzwbvDNe5Hiu?= =?us-ascii?Q?giM4gieHbSwBmWZJZbIKYuBKQ7sKd6nTHfg1kR6MFLttAf2PyvHCPf3cvxYo?= =?us-ascii?Q?ZjLHIvT5jS1FUYF9imZjHXBjK+S7b/FNBPYWraCjSRUXPABW7x9o9IRfvNvw?= =?us-ascii?Q?ZL3sSDJ+EpmbDBQMXFZ5ENZwW7UsKPrOdJYMrpnPaCkgeNpRQKWoyTMPtlS8?= =?us-ascii?Q?PPKP0mCW/SqqI6JOSytDzA70?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5aa4a723-b75e-4f48-e703-08d97e8733aa X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 11:42:20.4309 (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: mEN7b36ohiDo13Gl6rhUz3wycKOEZEtBUNjINf+MxRaLgTF6dH+JXulK2ZwascQ6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5379 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 23, 2021 at 03:38:10AM +0000, Tian, Kevin wrote: > > From: Tian, Kevin > > Sent: Thursday, September 23, 2021 11:11 AM > > > > > > > > The required behavior for iommufd is to have the IOMMU ignore the > > > no-snoop bit so that Intel HW can disable wbinvd. This bit should be > > > clearly documented for its exact purpose and if other arches also have > > > instructions that need to be disabled if snoop TLPs are allowed then > > > they can re-use this bit. It appears ARM does not have this issue and > > > does not need the bit. > > > > Disabling wbinvd is one purpose. imo the more important intention > > is that iommu vendor uses different PTE formats between snoop and > > !snoop. As long as we want allow userspace to opt in case of isoch > > performance requirement (unlike current vfio which always choose > > snoop format if available), such mechanism is required for all vendors. > > > > btw I'm not sure whether the wbinvd trick is Intel specific. All other > platforms (amd, arm, s390, etc.) currently always claim OMMU_CAP_ > CACHE_COHERENCY (the source of IOMMU_CACHE). This only means they don't need to use the arch cache flush helpers. It has nothing to do with no-snoop on those platforms. > They didn't hit this problem because vfio always sets IOMMU_CACHE to > force every DMA to snoop. Will they need to handle similar > wbinvd-like trick (plus necessary memory type virtualization) when > non-snoop format is enabled? Or are their architectures highly > optimized to afford isoch traffic even with snoop (then fine to not > support user opt-in)? In other arches the question is: - Do they allow non-coherent DMA to exist in a VM? - Can the VM issue cache maintaince ops to fix the decoherence? The Intel functional issue is that Intel blocks the cache maintaince ops from the VM and the VM has no way to self-discover that the cache maintaince ops don't work. Other arches don't seem to have this specific problem... The other warped part of this is that Linux doesn't actually support no-snoop DMA through the DMA API. The users in Intel GPU drivers are all hacking it up, so it may well be that on other arches Linux never ask devices to issue no-snoop DMA because there is no portable way for the driver to restore coherence on a DMA by DMA basis.. Jason