Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp990492lqb; Wed, 29 May 2024 17:59:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkR1s4O9Rqcr4pBYojO18l1fde/WBpft4/3j9ble/GpMS7t994WFfRWE2xxtMe4hf/GT/Et/AfOVfQryGQ/MkvXTl/xs4z2eAFqjnikw== X-Google-Smtp-Source: AGHT+IEYDUEAbtkkGpLwfPU+FytRAFbT6RpHZvo21ntqq+n6vNk1XIhv+dzZgM1Q+f6LgZ3JYChO X-Received: by 2002:a05:6358:990:b0:199:8d7:4386 with SMTP id e5c5f4694b2df-199b986c23dmr61373655d.31.1717030742343; Wed, 29 May 2024 17:59:02 -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 41be03b00d2f7-6bfce419fa4si344066a12.641.2024.05.29.17.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 17:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194828-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=m2BNelbK; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-194828-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194828-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 ED97F284830 for ; Thu, 30 May 2024 00:59:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C881F4FB; Thu, 30 May 2024 00:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="m2BNelbK" Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2074.outbound.protection.outlook.com [40.107.212.74]) (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 05248C14F; Thu, 30 May 2024 00:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.74 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717030733; cv=fail; b=lGoZ4Vb87xkufoDEu1mCU5QlxeXGDyYKJXjOrSa8oLBawTCv7E6u3fmZBw/4SMKkbeM4Fx27C4MWegup05DwpXquHlZxeuKhRKrqWFxDPeBa9a0Hw++3j+9n9XFACzYB1yOxS+1VbBW5LmScovaTtqaHZSVXB+ocriC5OUi/Efs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717030733; c=relaxed/simple; bh=4SApNmrRlC6byZF0DScI4KCi+gqLL8i16fBWc/x4hRQ=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OUfWANb8B3W970qpGql/vb3Svw7Y0ABoL35rwfQWcBkWrvEOKfJ1jj8F7cHunAq1AHiGXFd30xi5n5K/nyBVsJpTo8zWFnoTZyugID3f1CBMdvyqwm3nMhJkJAhuqrZnL0nZD5fyuOGgWaMJDgVdk4/BRGygBlELDWKfS64LVvA= 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=m2BNelbK; arc=fail smtp.client-ip=40.107.212.74 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=UY/H83I3B7XRSXwK3o4mX+xypr4yUzBnrE8cOCm5vgYZG3Z8MOS2jSaKXfvquedjqc946GVZsNxiJsPRmSpXptUrej/8K04ZJfXDcKoqooboqs0ozG0RAusbUB9moyNatYLHh8OpQSbNFSXqG121r834djRRgQ5vcJRS/nAcb+8rzAQFYSw5E2aeOzgCCZjIjKtTHTu4wShduB6U/bDsSr/lIGGomojOAhFI9c4FqThoi6j/AH11Le6ebQoEq4bYFV6U65vDmNvdN5pU/z+uIf7Vj/ap0WkUnW8dliyzcpwRLHF2/PtstOcYgvrAg+p9fMoT7PiGhbaO5V1BgqlXPw== 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=7PIyQSdMGgZJE10VqElhHjNieFxrfbjDqV7ruuARKdc=; b=BAIPA8WY9LnfJ4UE+lTa30//zWX9wz4FcxJabpc4V9Dz1s/HDY1P0ge9NcG910n+sYJCy8qLUQYD7Q+3VpJBD/dH/ctn9+btK5AWNzXaSqitAm6Q2YnH8v3lXIvBHUyZ4nnvkMC/7wj9DTD2wMQi9NEX9bPJ82Uzji0ZRUTfjg/7uK2P1FdKlBx/my9IQG74dCPeClLvlDZKHZYTzAbD77MOjC+ah2leRjU7zp4LekJ5BmV63IciMfeyWNHmQ4tZv9QVTMu9h/2FQYHPekaurk6lfPYGJjhp5J7MnFjeeNCCmN/R7IPGkVOc96h6lwRXb3i2TkWuf/73Jayja8d/OA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=7PIyQSdMGgZJE10VqElhHjNieFxrfbjDqV7ruuARKdc=; b=m2BNelbKcDLANIi5lk8zMVzUtdKzZ5WunuvP7sLTIxRYRwiEhPXlbb8ShZvCYU5CxZyaDn0kBJeYkkHxdZ328cHXKMoQqT/gGr7kodSSyWJnY8Pp2wE60PnnnDIAH2PB3A2E67luKUF95lvOhHukUJAyx7wyBiJpw6QUPoVVVqwfSE/FqXIoA2pT+Og97e9QG8NFmxwTAru/FpvUShV47u97Y7QBSDK+9NNwaSqtb5SYR5qu+0n5t0wCDSdhiiF4dUNBA5fJrIZY2kcenetGZeeYw/v3+hPat+xdEq8VLpfkqhGueB+BA/MlkEvsE8yD5qrLDaWfPpOvREg6UbOeZQ== Received: from DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) by SN7PR12MB8148.namprd12.prod.outlook.com (2603:10b6:806:351::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Thu, 30 May 2024 00:58:49 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:5:40:cafe::13) by DM6PR03CA0033.outlook.office365.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.31 via Frontend Transport; Thu, 30 May 2024 00:58:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 00:58:48 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 29 May 2024 17:58:42 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 29 May 2024 17:58:41 -0700 Received: from Asurada-Nvidia (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Wed, 29 May 2024 17:58:41 -0700 Date: Wed, 29 May 2024 17:58:39 -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="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A346:EE_|SN7PR12MB8148:EE_ X-MS-Office365-Filtering-Correlation-Id: a070490a-16c3-412a-4296-08dc8043aa45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|7416005|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?B?TDNRbHREclhJc256SDk2MDQxRUh6djZwc2JHUWwvZ3dIdXpURkZHZDZBRUIx?= =?utf-8?B?L3hiMkRxSkZUMHBnYmJMMHlBZ3hBY1F0YUZISlVTUEp1RU80c3pkV2hpUW5C?= =?utf-8?B?TVVqdCsydTNnaVdiam5sZHExcU9wZjRZVXFxRlNNa0U1bXR3d3BNNGR6b0Yx?= =?utf-8?B?SDlaR1dtMEZIanFiOTIyODdmQkF1L1FmQXdEWlpDWnFaSlF6TTlXUHpqdDJu?= =?utf-8?B?M0NSWE5jTWF5N3pORXZ5U1VvS0U2Z1hhVVpZc1diVGRjU2poV1NOYW5VUWQx?= =?utf-8?B?V1B0aUhzMHdrL0l4ajE1WVd1RXhCWXBSM3JQTlcxSUMzN1FjaXNkc3lUQ0Er?= =?utf-8?B?RU9YV2FsSDdOcThrYkgrT3F6ekFmaE5YMlluZndJYVZiWGx3cTRGeFRxUHhO?= =?utf-8?B?NHA2ZlZWNTVGb0dlblBMRzk2dWxrRGZrYVpiYWlMVTRIOW9nUXZaR1Viay8y?= =?utf-8?B?ci9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8?B?aXhQWW9reFZmdzFybXJ2RXovQXBZbFBBVS9kOXpreWVHV1dneUpTTG55MkFR?= =?utf-8?B?Tjh6anJZQUxTTDZTNjF6VTlDMnpGbFZYaU5zTFpjWW51Ly9aMmpzbEJFaGhE?= =?utf-8?B?VVFqUWllb2d4WG9hZkp3dVRsMlR5M0RFQTlTVGYxc0c1QVFuOU9FUUNpdnZ4?= =?utf-8?B?anFJR3ZsenhoTzdTRTZmcmt2cEVvWmhDME9EbXdwYzhIMU1ubVc3N0R3L2Vw?= =?utf-8?B?WVNybS9ORlVoRkY1cUdSZUxLaER1QVBEOTU2M2hQZWRYRWV6QW81SlpaYi9H?= =?utf-8?B?MzVxQWVETUV5S1lkU3MvOVkwT0NWbEoxMDdFSkFkYVlJRDhyM1E2bkd6WHMx?= =?utf-8?B?QndFWDlsM0pvSHRqREI0UHU0UjBGYVJEUkRFN2VDYm5iQmdkTnRVSWJGSThj?= =?utf-8?B?a2F1Wmp6OXVUb1VMN2k3OXkraHVZUHNrakJnVUphZDI1NEtIU3gzbUd1cy9F?= =?utf-8?Q?nfliz6V31/7Hj?= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(7416005)(1800799015)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 00:58:48.6191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a070490a-16c3-412a-4296-08dc8043aa45 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8148 On Thu, May 30, 2024 at 12:28:43AM +0000, Tian, Kevin wrote: > > From: Nicolin Chen > > Sent: Wednesday, May 29, 2024 11:21 AM > > On Wed, May 29, 2024 at 02:58:11AM +0000, Tian, Kevin wrote: > > > 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 --| > > > > there are other options, e.g. you can have one viommu holding multiple > VMIDs each associating to a pSMMU. Well, possibly. But everything previously in a viommu would have to be a list (for number of VMIDs) in the kernel level: not only a VMID list, but also a 2D virtual ID lists, something like: struct xarray vdev_ids[num_of_vmid]; // per-IOMMU vID to pID lookup And a driver in this case would be difficult to get a complete concept of a viommu object since it's core object and shared by all kernel-level IOMMU instances. If a driver wants to extend a viommu object for some additional feature, e.g. VINTF in this series, it would likely have to create another per-driver object and again another list of this kind of objects in struct viommu. At the end of day, we have to duplicate it one way or another for the amount of physical IOMMUs. And it seems to cleaner by doing it with multiple viommu objects. > so it's really an implementation choice that you want a same viommu > topology scheme w/ or w/o VCMDQ. > > we all know there are some constraints of copying the physical topology, > e.g. hotplugging a device or migration. for VCMDQ it's clearly an > acceptable tradeoff for performance. w/o VCMDQ I'm not sure whether > you want to keep more flexibility for the user. ???? Oh. With regular nested SMMU, there is only one virtual SMMU in the guest VM. No need of copying physical topology. Just the VMM needs to allocate three viommus to add them to a list of its own. Thanks Nicolin