Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp382911lqb; Tue, 28 May 2024 20:22:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXD0fMELe+YkV5GZSP7jGasItWAew9eqKgAHIjretKmJdtLPn+3r/wyOhciQe2VGiA/7f6nVw6fmok6yXDmW1ZlAf0h/EySUymijX8Twg== X-Google-Smtp-Source: AGHT+IGTMEWPqRxVqPF6ukRMDPLacGi6JRBG9q113vEpX2tISXdswHf8bJBWlDhH0WDd18WMJuI9 X-Received: by 2002:a17:90a:68c7:b0:2bd:e639:686c with SMTP id 98e67ed59e1d1-2bf5e568830mr13032689a91.23.1716952932813; Tue, 28 May 2024 20:22:12 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdd9ef0a78si10737032a91.42.2024.05.28.20.22.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 20:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193399-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=SCZLt4Tk; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-193399-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193399-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 5BA2F289D0E for ; Wed, 29 May 2024 03:21:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D52B615B127; Wed, 29 May 2024 03:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SCZLt4Tk" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2051.outbound.protection.outlook.com [40.107.236.51]) (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 EE8A22F2A; Wed, 29 May 2024 03:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.51 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716952872; cv=fail; b=p1u4GHZpGwv7iUXE0AofVgZwekLTZoPj37ZQLa3hPUcPCho8dCdchWOQyvxlskR3e+A9V3PplNzya41/Y11GP639Uxn3T6uIkaOMHDyZTuCXJ0+75i6po/DmKVX4v93IYU+k36bDRLjl5Cvxg4mCex6sx8NUK+Hjj/cZ2F9Wso4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716952872; c=relaxed/simple; bh=SOMm15IT+JkhWYZa++LFvmzrrNSLuy1gh4Z/HKUcfwQ=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=afKsyhri6v00oTgfLF6biXu8EGi5T4R88XzdvSRBoq4s8WZrrNnFm/7+DNOXITFGq75fBCaOCzCgJkt4itiOeyG6sDhwkrfBfyI2gLXJ5JVq2mXWwZndGEhmHOT74oh8fBqnSLt6fvSY9E3hNhPBinFF2QdBx770hENEE9794X8= 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=SCZLt4Tk; arc=fail smtp.client-ip=40.107.236.51 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=hjA7xYFm49K6WMTqznCCVgtUTaw9dJM+TjspRNwMA1di6uLE1SYeuE0FUPER34E1dFyhj6gjmQuUBWfI0AFH5tt+SwsyHaFceKxZ4TWdQ/finC0KBfiILy1Bg3fN1kB42y2IyEYjdtbQOev/kbrZPHGE+vMueHbzY1FutCLpz99MilKd+4EBh11u11anF2h1WnVLMnKVnkMue/FGKPjZcSwaw2EcBuinCaHEU5KeDI4BmAR1JrrtxG/OBzDAJlHIrounuZxJ0r+SHhDukytuh4oL2yYm5ringNiK0HFgTg1e1vcq3ecIb584LnuCGGczWxWrXFRCJiSuBUMJOLD5yg== 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=WTTunXqXtujk54sWHoY347iA3cWxu+VHyjCJ2mW72eQ=; b=hyTBwlbJ5oNvdTPmdr674q8YkTfkY8lyo9hgzobsrViaaxmqsrkoCF7+ygKGtUZChK7e6nWUrBXP6pLnjGXIX+kgofAIMDqfvuUYXOwf9n/Z+r6yWOB4EF8I8TUf94AphqBuWNRKeTYpGm7umX3neWbvoWRjy2f+J7bysv2ziAaa5pfVrT0fX5HVsycr3ubK632TQKgksODRfqjypmyJhlnZBp2qh+hZUKvN28oDwm5BNS4MpHk2AfLfLbelnGTqwAp5fE7Wq2F/EUdL/p4RCZTNzt6AvwlRdEbKAxqcw3vkENO+BHNcRdqI7SmG4ddkbvDz6MFLcKEbPAc2n702eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=WTTunXqXtujk54sWHoY347iA3cWxu+VHyjCJ2mW72eQ=; b=SCZLt4TkrLDNOtMZhF5FtZYVwSA5WnauYy/aS00jYvEE8Zcchk+uC6teniWEh/MUKGZkup/qnObMPy3sIzDv96sl42LZD5md4eqNErpWL8b1216lObtY7DtyFpWPPcjdyRDCXD5U+zG3wTYGSIEIXex1gW7UN+7Kbquxp0+Za6/ELAI5Wb5+JgHokc0zc8t8u1r199CwGAzcXmHDCPEwQ2P7qOXH0pPcKLjwDaiV3tZu5yFehWMbcYbKQ5dhUtW4l0cRgW4BI95MR23ESpxAL4hsmqpnQsXRTP6Ynhe1aHayk/b8kcmcPdon9kdSADvM3CkexpbAMkAqQQc5G739sw== Received: from MN2PR16CA0036.namprd16.prod.outlook.com (2603:10b6:208:134::49) by CH3PR12MB9121.namprd12.prod.outlook.com (2603:10b6:610:1a1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 03:21:08 +0000 Received: from BL6PEPF0001AB53.namprd02.prod.outlook.com (2603:10b6:208:134:cafe::71) by MN2PR16CA0036.outlook.office365.com (2603:10b6:208:134::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30 via Frontend Transport; Wed, 29 May 2024 03:21:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0001AB53.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 03:21:07 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 28 May 2024 20:20:54 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 28 May 2024 20:20:53 -0700 Received: from Asurada-Nvidia (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Tue, 28 May 2024 20:20:52 -0700 Date: Tue, 28 May 2024 20:20:50 -0700 From: Nicolin Chen To: "Tian, Kevin" CC: Jason Gunthorpe , "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 08/14] iommufd: Add IOMMU_VIOMMU_SET_DEV_ID ioctl Message-ID: References: <20240524131912.GT20229@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB53:EE_|CH3PR12MB9121:EE_ X-MS-Office365-Filtering-Correlation-Id: ea5b4631-7ccb-46c5-e081-08dc7f8e61ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|7416005|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1ggiU19qpYBnYc7Ac6b+p+e33zMPo5jzqGr3xoDFvvKT/FckeHcp0EBLIEPk?= =?us-ascii?Q?gzqJ5Jn7umursg3I4KaD5xUNkYDdCJQ10GKOueMPYPw8SIM1NXLtxT7I7Q6W?= =?us-ascii?Q?/AakyH7u2vOQH2zl38IN8mBWD6b2hobTI1BjEs9k4Ogh3IYd73HLHIBP7m3B?= =?us-ascii?Q?co5VFi2WvrT7iq7uQgNB19Djpfx46T4js5LGbQtYtyXT5r45/UBES0y0MB+l?= =?us-ascii?Q?EFvX8ZGh64P0KLuMEWxb02gT6IDsJ3frrsK2or2cP1xnzf4leL2mQWQmaEHH?= =?us-ascii?Q?MKtUdx+U2otZIRN+x2X28OBz6uqg94KsNJ7Z0nUE0WL85Gd/DR7uJcSTUU9v?= =?us-ascii?Q?r+MheXCbztEl4KzkGKWFcertF2doM+8rvFvUUU+4KWBuiPgNMTNHNE8UfQCx?= =?us-ascii?Q?7bUFtENV3V+irTUgOWKsCX40/nfTL1MnFE0668Tf+feYOMVZjOKEAsqU4WFA?= =?us-ascii?Q?Qe16I6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m139yVy?= =?us-ascii?Q?7zUasbU=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400017)(7416005)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 03:21:07.8449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea5b4631-7ccb-46c5-e081-08dc7f8e61ad X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB53.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9121 On Wed, May 29, 2024 at 02:58:11AM +0000, Tian, Kevin wrote: > > From: Nicolin Chen > > Sent: Wednesday, May 29, 2024 4:23 AM > > What I mean is for regular vSMMU. Without VCMDQ, a regular vSMMU > > on a multi-pSMMU setup will look like (e.g. three devices behind > > different SMMUs): > > |<------ VMM ------->|<------ kernel ------>| > > |-- viommu0 --|-- pSMMU0 --| > > vSMMU--|-- viommu1 --|-- pSMMU1 --|--s2_hwpt > > |-- viommu2 --|-- pSMMU2 --| > > > > And device would attach to: > > |<---- guest ---->|<--- VMM --->|<- kernel ->| > > |-- dev0 --|-- viommu0 --|-- pSMMU0 --| > > vSMMU--|-- dev1 --|-- viommu1 --|-- pSMMU1 --| > > |-- dev2 --|-- viommu2 --|-- pSMMU2 --| > > > > When trapping a device cache invalidation: it is straightforward > > by deciphering the virtual device ID to pick the viommu that the > > device is attached to. > > I understand how above works. > > My question is why that option is chosen instead of going with 1:1 > mapping between vSMMU and viommu i.e. letting the kernel to > figure out which pSMMU should be sent an invalidation cmd to, as > how VT-d is virtualized. > > I want to know whether doing so is simply to be compatible with > what VCMDQ requires, or due to another untold reason. Because we use viommu as a VMID holder for SMMU. So a pSMMU must have its own viommu to store its VMID for a shared s2_hwpt: |-- viommu0 (VMIDx) --|-- pSMMU0 --| vSMMU--|-- viommu1 (VMIDy) --|-- pSMMU1 --|--s2_hwpt |-- viommu2 (VMIDz) --|-- pSMMU2 --| Thanks Nicolin