Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp528100lqb; Fri, 24 May 2024 06:05:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPhbhy1ch0tthvKaiuj5YMHN6tRahNUszCNYep4u+CifyCKWjEeZuFAZ0NVeAJ1rtuX7J22c2oPNHj2Bmq2Ea+mg03BFCHBbXJwUqcKQ== X-Google-Smtp-Source: AGHT+IGCPxfl7sQNeXTI49w1s8d9OTO3dDcMNKKZG5elgo2zUoS0WtTR5ryu0FzbH4yq4IH1cdM0 X-Received: by 2002:a17:902:e746:b0:1e4:3909:47c0 with SMTP id d9443c01a7336-1f4498f0d96mr29986055ad.62.1716555936114; Fri, 24 May 2024 06:05:36 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9cf13bsi13879485ad.510.2024.05.24.06.05.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 06:05:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188707-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=mR+CSFnm; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-188707-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188707-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B74A5281276 for ; Fri, 24 May 2024 13:05:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4395486657; Fri, 24 May 2024 13:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="mR+CSFnm" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) (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 A770785639; Fri, 24 May 2024 13:05:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.83 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716555928; cv=fail; b=cH2lb9Xa2R2rQowX6AstYOwFJO45mN1kBJ6bwxTMwtWjYBjsr+v/WJNcRo00ry+nkQSI1SGi4ASv6uT6PEJu9egY+2yPdEL93OADNX2V6g/nVt5TfODTfOYhU9xytkQ+29cBzu6fkDpZY0OHOURC8c3RSkWOq/uSNVNG1zyaNyc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716555928; c=relaxed/simple; bh=d9V5RWWcl+TM2TWEQq1LLLIeha9CNJH9mN7+SAncLdE=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=KblC6dapdTY2x5MFS++kLus2YaXNFTeeKl5W0K6i2RNdVpgjwgStH+0Cy+0R9bZ/XflH/GZXXjMAGlhUXCA+tU4i9/9Cek7y15WjeO5DGlRG4iGen0nBpeeU1XdrUQ4bdMnTap472oHskRvUiovMAcU6Ykspwl11hCwW+JZMOOE= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=mR+CSFnm; arc=fail smtp.client-ip=40.107.223.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FyYBXMnRuIHlrTinWKoxQDNABVChBfWdoHVjN44/eJT+tMSggvScaCqS8dtURQ6jw2hpwsy9vwNW3t5aBFtVkk0KHVWAIhhk6gwpwq1NFwdDFbM4dnNIpv3kt7kJ9oDZ/q82vTvWxLQ5bmq6EQeKxIKPQgzXbZjSrxOOVE6pmT1jeRhytgciMSSlkl7NonN0Q1Ee2q9GySk1dhAX/evxIq8wrLRLLgVqMzLMCz/WolsfrwuZemKWLdH89Z4zp2sd9k6X3f+QTgVfeARbeyzWt1ud6nlJyz988gqH/L5pDtcaIAiDVaAVrxnK4QBfBv6g+re+MjhKMiX6cUT/c87Gww== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uZENabiq0tQpvAdDdPTNtQHpvO1K8KyZtzVpkktdiXo=; b=T0BoNf5oggRI0pOCeorkHn9Y0KEFxKsNWKqsLm1rjuucQQVImZZRYyd91W4jhWwTttScFGFBc+CBMXuzLkoTplCmY9JGjGM1HJ/7kJeI25drbQgGjZb+o84KgIcot8fwOkTOhYlkhXkrbXxm9Z9huG/Xp8gXM/W97BjFTjV6DNwAQqX21vGcXc9TG9Sbxqu1NIU4c6EbAhUGNO4bs0pcDnluOZib2M2jqzRwntYJYiiG0fsYJcAz8/lns0IZAdd1etcoiD/Yb0r2Ah/ZTcQODeoTY7iWU3kj1iGCB6UHdaKyTy5YoZpoVI0cPxSixM62SHjYslsUZSpROfAZdEGhLA== 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=uZENabiq0tQpvAdDdPTNtQHpvO1K8KyZtzVpkktdiXo=; b=mR+CSFnm5gLsVxwZOgBk8WVhDIUaffc6zD/rZcK1UCDe+sV2WPT+e/KFAiuIE7FkKF9l86ljlDUta79SU2hoSf7+3zoBbWgFK6aTlmFqHnPRPj4NKfYna82+LIOrugAIEYjcVLTpHXllyjqiT3sQQ2ORKborePaRvO00wS2NunzAIDk4JMb1NMMYeBqnoDmq+ghYEt8pFlu1e2ppciju9C77EkIc1If98TJiHxoskU4IE3q0sVbHaDMAppu6aAzuSjbGmqJ9JhIbTEwge8NZio+Kl0U2xdEVPGcapqLzN3bOih9wAwzBj8M0xk8qp5DE+uybnsZoHBBxb/e4G57CKA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by MN0PR12MB6079.namprd12.prod.outlook.com (2603:10b6:208:3c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 13:05:19 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%4]) with mapi id 15.20.7611.016; Fri, 24 May 2024 13:05:19 +0000 Date: Fri, 24 May 2024 10:05:18 -0300 From: Jason Gunthorpe To: "Tian, Kevin" Cc: Nicolin Chen , "will@kernel.org" , "robin.murphy@arm.com" , "suravee.suthikulpanit@amd.com" , "joro@8bytes.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-tegra@vger.kernel.org" , "Liu, Yi L" , "eric.auger@redhat.com" , "vasant.hegde@amd.com" , "jon.grimm@amd.com" , "santosh.shukla@amd.com" , "Dhaval.Giani@amd.com" , "shameerali.kolothum.thodi@huawei.com" Subject: Re: [PATCH RFCv1 07/14] iommufd: Add viommu set/unset_dev_id ops Message-ID: <20240524130518.GR20229@nvidia.com> References: <6e57d7b5aa1705bdd547b1cd2aca93d3bf70dfa4.1712978212.git.nicolinc@nvidia.com> <20240521182448.GN20229@nvidia.com> <20240523150120.GO20229@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: YT4PR01CA0130.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d5::19) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|MN0PR12MB6079:EE_ X-MS-Office365-Filtering-Correlation-Id: 497b8145-2d88-468d-3dbb-08dc7bf229dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|7416005|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vsnjbMgOwjrQ5xFYrIzMAl0M71jLr7FmY4YYyNHxbj2zmz9sNf62OkoImd7K?= =?us-ascii?Q?bxdBPTjbfV+aqmIA0E9Fs6dgL3bm017mW4Nb0WmNwg5hJqmIua4j5tebS6Y2?= =?us-ascii?Q?i9TT3y7A5X3a6dXA9ZxTrUuylBH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=?us-ascii?Q?gpZFZLQ/hmwkjJwFbVVE24ht61pYe92e/4pzhzvozs2ripDPZHjBn+Tckstd?= =?us-ascii?Q?zvHgOleo6Es2JC5rPe7QgqspXavXBegAPLEZX6vP3kkmk1vx9uphwwd22Q7S?= =?us-ascii?Q?u501VdhBWiVXSUkmK13VHYJlHCMldoHRBa/umFDQ27QuufWSkYa+i1LmKvAL?= =?us-ascii?Q?5MxtgiUV9xqcpBu5RoMM5dHM3fa2g8ypjlVrS3EZIYZSV3nAzSa2ZtGGYlgH?= =?us-ascii?Q?tUw85Ly7Z3LVzoiKo8tiHe0Nj2ShV1pWeyn26sVcdA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(7416005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Qf4kJqSLc4QPdf/tTgvmFj/qwG6JDHk8DrmvNfnzflvjRPjD6dTM2mIFiDKW?= =?us-ascii?Q?wDe3gwcRFez/Y6d5WalKbEwpucuqZGMEIWkq0FiTmJl74pXEko17kJB+55IJ?= =?us-ascii?Q?sUV1x2iDjR63e/Deld6VBMbcmLiZiB8oF0FKdx09yGHPHTlVBUU4LC7s11Vq?= =?us-ascii?Q?j+QdRRDp0tQuZxcDmtPaaNxYMmVOz0iVBvR9SDjonKnoNsmwFzQwBolnUqzy?= =?us-ascii?Q?a8BNqQ1nqQOKp6AGwwwus8cS/JgvPxYbB4YxxX2eoE+Bon9RoRsoPjFQfLGe?= =?us-ascii?Q?A5hNU5mSr62jNZuDICrgyA/fLpOttsKZnqPuy1kTJBn9mOfrj3pd9AytfmS6?= =?us-ascii?Q?n6oLivDdH8FBXaLHg6VIozmdHY7D+3Fk2/t8oHbPOPGADss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oXPO4GSeSV+gHx8gJ4sW9mkC8wGEpusmewttdbkANg4KfJ?= =?us-ascii?Q?NdDaoU1p/RDLxeFv1yKOAAfCY9qO7bvMNEuJtbZY80kXjXEkrAYFiVqN355t?= =?us-ascii?Q?YvOrB/8Un8QNI3mFzBrwQ6ueDDIb9VB/UH/isBycQ2FfZ8bsFv07RbVfeBed?= =?us-ascii?Q?TEF55/GUw08CjDFinbu7wkG7VXgapMRvjT+xT7cvpGpEUJS9J6MSisA3W5yG?= =?us-ascii?Q?B8jvmP9XZSxxq8Yn4LY5ItZUDnYrKXZ6MjusxwvtypyL6bWnXQosdkj4HJfY?= =?us-ascii?Q?R6u/6VR7vsGog6/DG+PigOICLj6cYR1cPTZ5UDH9?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 497b8145-2d88-468d-3dbb-08dc7bf229dd X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 13:05:19.5700 (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: DAhT+xO02L15NR0etfwBtR1wrJsEvtDvJNUnjyfUPayiKXst8DwcWT8mqf0LF+nc X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6079 On Fri, May 24, 2024 at 02:21:23AM +0000, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Thursday, May 23, 2024 11:01 PM > > > > On Thu, May 23, 2024 at 06:19:59AM +0000, Tian, Kevin wrote: > > > > From: Jason Gunthorpe > > > > Sent: Wednesday, May 22, 2024 2:25 AM > > > > > > > > On Tue, May 14, 2024 at 06:59:07PM -0700, Nicolin Chen wrote: > > > > > So, you want a proxy S1 domain for a device to attach, in case > > > > > of a stage-2 only setup, because an S2 domain will no longer has > > > > > a VMID, since it's shared among viommus. In the SMMU driver case, > > > > > an arm_smmu_domain won't have an smmu pointer, so a device can't > > > > > attach to an S2 domain but always an nested S1 domain, right? > > > > > > > > That seems like a simple solution to the VMID lifetime, but it means > > > > the kernel has to decode more types of vSTE. > > > > > > > > > > why does ATC invalidation need to know about VMID? > > > > ATC invalidation always requires a vRID to pRID translation and the > > VIOMMU will hold that translation. > > > > On vCMDQ HW and on AMD HW the vRID to pRID translation is pushed into > > HW, and vCMDQ requires the VMID to do that. > > > > At a quick glance VMID and vRID->pRID translation are both configurations > of a vintf. > > My impression was that vintf->vmid is added to guest cmd when it's > about iotlb invalidation. > > then vintf->sid_slots is walked when handling a guest cmd for ATC > invalidation. > > I'm not sure why the latter one requires a valid VMID to do the walking > except it's a implementation choice made by vCMDQ? Yeah, that is probably right. And then in iommufd we are sort of doubling down by saying the VIOMMU object holds the S2 and the vRID->pRID as a bundle together. Jason