Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp474491lqp; Wed, 22 May 2024 09:46:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2PiqCiEcfKoD74/ARY8VYyGS40fjTDkDUSfjlXA0jeE6rh4LyjRCXF2SXGpdX7WEj1UQRKGuR9MSN/sl4owCJhB9nqn5GXaUdAChkJA== X-Google-Smtp-Source: AGHT+IHo8D/iIgSKEeKtf58aZpMubMwKoGHlu32QUNvw2Lf6TS+HmStYrdrFLgANwKvN3SGjV+92 X-Received: by 2002:ac8:7d51:0:b0:43c:562f:e07b with SMTP id d75a77b69052e-43f9e09d6a3mr25251871cf.7.1716396401733; Wed, 22 May 2024 09:46:41 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df54a1fa7si48026561cf.51.2024.05.22.09.46.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 09:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186507-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=T7MImrad; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-186507-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186507-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 640DB1C210E6 for ; Wed, 22 May 2024 16:46:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 590AD141987; Wed, 22 May 2024 16:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="T7MImrad" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) (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 BAD3379D1; Wed, 22 May 2024 16:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.73 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716396393; cv=fail; b=dtMPgaZkjX5Q1gjgNzbgmIusXspgEmIfC8tnu7F3cgRQmZ1/QCz70T3ss3kIgqCsUX+qIxgzLrpCFt3wMD2u5vmC+Ra3QUeBSvwf6uRm2aaPhuOVfvRXxZpy+AHzrYVcAImr3GlUyKVcCudsOA0uy+h4Fo0407bEX16i8gh2Zg0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716396393; c=relaxed/simple; bh=x18STXpD3d29xjKD9C9lapUiG2WVNFiFxYuyPZrVeDk=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=suT06AGA8dLJGIWXDCXuT13n2rvEfnLc9oHd84LTX5YhEpJmfYUp+NQ1qDnuwsrVYr0hspsRI+1QeV/TztO5bX7IiC/VkL+DxNEtgdqqATxujM5357fI/IiFlZX7SmE8UvoSlOai3yJ/9LF0b14EzRIGtsf8IZFsZd2W4jEzfqI= 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=T7MImrad; arc=fail smtp.client-ip=40.107.220.73 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=URwSXMpVRG43WYYBNOBDvpVKHr2AuM0s/fBuQGis/6cYaO4CkWf05ISHX/u3lbr6Qhxo2CoYp8YtH6OJqV/NWAPCo+79TxO1G5uCz0AsibgG6AiqtWfYA+QYCo2n1RrMAyuLbwZYbPzElofS9EF4hwJEJxNHmLTOijXqo3yC4yBgSeoNG7mHB0Lo+AgmJzz5K9o6PHGsavrmqG3GYI3yMSkIDgZDwcyana/ij5I0Xp4qyLL2aQf38YEtMXs7mDLFyA/zyudVnlQMP66FOSfGrZ7KnkQe7/6v66S3TdLqRYBmOcJR1BIidl+xEYmfw4ByG0gGW6gWiHQD+Ix0azS5Qw== 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=x18STXpD3d29xjKD9C9lapUiG2WVNFiFxYuyPZrVeDk=; b=IDyi8xDB1aNL2xHBS8oAvOFJIY0hzEOlmnHuEipP24MnocFL+GFQVcMldPNV8+nM7ifO6GBRUMn3HQNL6Vw9EZl+NGZvtYRCcws+eGjw1znl2ndoRgd6qne1CPxzezeEqqIXmw2FoBaSF9HZY3HVkEC4g5RWqOF/SfKXmduVRZoIsYjrKPz1CcCWFeVdT+CEa5wRa/fqOpoiOpcrA9sm9lO/soYJcRa302MafrhUnsDWpsW7vYXQJF4theYertxIiMfzE0AFkDnana+qQD9/+aeClqRL5NABF3o3y4u3u9alqPe002qw+aTfH1tKNNkDPZd22v3FRnuTuimLJuJklA== 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=x18STXpD3d29xjKD9C9lapUiG2WVNFiFxYuyPZrVeDk=; b=T7MImradIZKWriuVhJkwRp5jUCC5SiESGdF/d75fpdkhNcBsd/A1kxE6+CszYMt32A6awhFsCk3NzIFWNnGjeat93t4f7fKVcrpXJyKPqwXcqyQLS9PArp3GlevYCbigEbYMcLBu9Ja73ztvYUwCgRk8Zg8SnyiCLklr0C1toUC7v+8UN0AshvIdR24oGm4bk+ofYMCOwE0HqmvwEB1NVuKeCk+I1Gms88yGxTSSQ1U4UjqD0yn/Nfyt0CV9e77lTIGF8xzJCSqwMO26WrW5WeMTwwGp7TYXoA9XhcGm/QJqM6lM1bF6XuTtJIYsC6zUoB0tVl8hBL7YtsRhyzqjRw== 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 BY5PR12MB4307.namprd12.prod.outlook.com (2603:10b6:a03:20c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Wed, 22 May 2024 16:46:26 +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.7587.035; Wed, 22 May 2024 16:46:26 +0000 Date: Wed, 22 May 2024 13:46:23 -0300 From: Jason Gunthorpe To: Nicolin Chen Cc: will@kernel.org, robin.murphy@arm.com, kevin.tian@intel.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, yi.l.liu@intel.com, 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 05/14] iommufd: Add IOMMUFD_OBJ_VIOMMU and IOMMUFD_CMD_VIOMMU_ALLOC Message-ID: <20240522164623.GA20229@nvidia.com> References: <3aa9bc1df6a2ee58a03c6ea6ededbc210a2d23a8.1712978212.git.nicolinc@nvidia.com> <20240521180555.GM20229@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0432.namprd13.prod.outlook.com (2603:10b6:208:2c3::17) 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_|BY5PR12MB4307:EE_ X-MS-Office365-Filtering-Correlation-Id: 61de9dbb-a70d-4d88-9b16-08dc7a7eb86a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|366007|7416005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?k2TDq3Be62nqyBqEx8sBtztZX2VSA+frdbxVwUJsi3OkuAiOMmM4/fPgYkkx?= =?us-ascii?Q?CgIy02ZhCTIE8QGRYAzPU+MKhFJoAa5LHPlzZPCncbYmOcKr8NFx7HKEVi2L?= =?us-ascii?Q?xsAWlt9886vOH7EoeyLd1uN3571TNt6q02eQz5cV+hVKa99FEepfeBkuQcBb?= =?us-ascii?Q?Gq79rRQq37nzc8QCOp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j?= =?us-ascii?Q?fLWRF4hFUQtp0Pci8pW3h5HCRK+Ff2uXmcAqt+ILhZKZjmcFSQwQjvjiHQ1M?= =?us-ascii?Q?SwjchtLXN1Mdszy7Pda+lfedTiVq2Mi0AWuNKFzzrvEtd+/qKM6jgTutZfHl?= =?us-ascii?Q?IPMd6zq1rV5xoU5VbcLeShnYoORbbHNgN3YJn7j2jK+NyyMikH1dmHN8Ksqf?= =?us-ascii?Q?ibbT3V53L420K0kNPutZYoUpFmvDRQ7C8SxlZVcmnQ=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)(1800799015)(366007)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?AQSZ44eadGE5q86pizPfpkKwY+XKTW4O74sGoanV9EbYoLTXfZnZDIMteAAD?= =?us-ascii?Q?jWQiVFLw967ggECFq7lxFxL6p2Yfn+zFBZtjde2w8BDcLI/ZX9IqRTf8UCIQ?= =?us-ascii?Q?zmIFjdO8/+ixq26qH3A0i53+8pBVtzejPZUoDy4lC7G72/Bf5bjXwD8VVxJh?= =?us-ascii?Q?DiXx/Am30UrYBfvsOYAiwxvkU5mC8C37qYToAj7U+MQXOrbEjkayMzBYOU0t?= =?us-ascii?Q?/+Wmw5/lSHXLCBy3hPGuleI0SeZyi7n5kBJrck78reoA5OtKWndikSEKjMvY?= =?us-ascii?Q?47eBukbLsAmT9rjese6QUrSiMW8Qe7tdj9ATFsQdBfKnejFAZOgxOZcybsBy?= =?us-ascii?Q?O9NuIOVjdAePMOKHKPlgAFV+BuJVvyaLhN7yhdoBKJbe01kOdpAuK0z5rQpW?= =?us-ascii?Q?iCwXH/E5N4lolYB4sacrYgoRAFh0zAOWLKMzVxutgoPjKt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5glAYQairkIYRWqK0/9h3moWmXsEm5We3u1cTwOrFOZs3sWqJVbnBFOP09O1?= =?us-ascii?Q?RSpU3GNijYa4WiIKRY7KWOKtEzoXIygf101tYxtQYUlg3dc4Kp0C87G/dH9k?= =?us-ascii?Q?2Jqk3J6vyTsjN9nuvcO+C4sL01EGqwYmOohuXfHVQ0r1zGqem7U+1Hn6i28i?= =?us-ascii?Q?L/2/6NbdxpG/z+EoXsT4fuEc2qQUYf87rfN4othsP92Kyatj9SIz0ifngvyT?= =?us-ascii?Q?2UDjE5ppwAqYT9cRtmA=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61de9dbb-a70d-4d88-9b16-08dc7a7eb86a X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2024 16:46:25.9612 (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: 6uIjB6y3quVyMkyaKt+sldsND8fYcpEx3UJSa8pbfyjDJcCjv3qIX+Nv6ikwfCiH X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4307 On Tue, May 21, 2024 at 05:13:50PM -0700, Nicolin Chen wrote: > Yea. VMM is always allowed to create a viommu to wrap an S2 > HWPT. Then, I assume iommufd in this case should allocate a > viommu object if !domain_ops->viommu_alloc. Yeah > On one side, it may not be straightforward for a qemu viommu > driver to hold a shared S2 hwpt, as the driver is typically > per instance, though I think it can keep viommu to its own. > So passing the S2 hwpt back to qemu core and tie to iommufd > handler (ictx) makes sense. Yes, qemu will need some per-driver-type but not per-instance storage to make this work. Ie the ARM per-driver-type shared storage would hold the ARM specific list of S2 hwpts. > On the other side, there can be some future HW potentially > supporting two+ kinds of IO page tables so a VM may have two+ > S2 hwpts? Then the core would hold a list of S2 hwpts and the > viommu driver would need to try-n-allocate viommu against the > list.. Yes, it is supported in the API. Userspace should try to create viommus with all the S2 hwpts available and build a new one if it can't, just like hwpt attachment to a device. Jason