Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1433346lqj; Tue, 4 Jun 2024 01:00:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUb65f4q24uT0kuvYqAmV59uRCHwczFoxQzjAY9b4G6n3Jw0/J93RGOeE9Y4hV8w6NWJwO3EWLyxXqdvhEVPutNge5OzX70e8pLfLYK8w== X-Google-Smtp-Source: AGHT+IGASyOle9HwkUPhBrgX8rSpeHHoTCp4zI6h40xP8ZrpM4RAWApkUkXDLsNtBkABGA/9dubG X-Received: by 2002:a67:f4cb:0:b0:48b:a1c4:40c6 with SMTP id ada2fe7eead31-48bc20b25f8mr11590926137.4.1717488027049; Tue, 04 Jun 2024 01:00:27 -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 af79cd13be357-794f32a539fsi1009037385a.599.2024.06.04.01.00.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 01:00:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200209-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=@intel.com header.s=Intel header.b="Tp/CZ7wt"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-200209-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 76F831C2152D for ; Tue, 4 Jun 2024 08:00:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58A89138484; Tue, 4 Jun 2024 08:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Tp/CZ7wt" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 4BF8D1422D1 for ; Tue, 4 Jun 2024 08:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.14 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717488014; cv=fail; b=epBoFuWXtQ68uNCtYlmwPrnpxwxqub7i71G6Qlp9QlInCQJkWs8cQJIQVGZcLsno7QFn+kCBlNI9dPoHLx2GOBjPXR1nDyVBMNtA2H185TXBULNAZwQB5q4CUiw6tVawCF4bN67CLAnEzoBZJvNVqHvgsjrhuvJXNyGriXF/IPU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717488014; c=relaxed/simple; bh=eA7WQGd28dmYOVYmRMRkOz1jRa+zdHGtK6Lvni0LvII=; h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To: Content-Type:MIME-Version; b=utJfiOIU3Q+nIq4Nca8OZk4+KK4jp72Ss9mL50cCEeRNEI94JLsv2nbYboTov4Ce2qyoywSSxXr8St5ZAoi5dbTStPToduAIAg8AUG/AxMB+SHfiYs5M/nc8MDFGJepNRJXt+NXBQJeVss3TyeUMM4Il7SRsQBy0wlMEZQL5Xxk= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Tp/CZ7wt; arc=fail smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717488012; x=1749024012; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=eA7WQGd28dmYOVYmRMRkOz1jRa+zdHGtK6Lvni0LvII=; b=Tp/CZ7wt4IQjtqB25TXo1uIlZrTdH+wMlBWmS9nIcbTdwHFHFMyoa2G1 UfXYjexavTC9BJRx5+OlVwsaWCcY+2MK3YsJsquMmCzKtQ8UObl/9HDoi wWR+bhTkH2hQZiZfwtNKzKBHA+e/wMjmw9QGa8V4xr+ZvcKD2CZWUP3VB P1c6sE2ZhJ101f9TPN3zPicjhXaC46D/0zDJAw+TomIFvtgFhQmZ7rRGi LT78YkThk7VwlaafjJVjkLWdM+7KLnXdj5FLdqKqjaBvUJxW8RbrRMSxq hiuQVuIMX7zMmWojehfdz8K+wzyPQtbbiAr38qkGk9en3WkXI6CCuK3Uc g==; X-CSE-ConnectionGUID: AL7z1SJJRAi2iisF2zaINw== X-CSE-MsgGUID: MuslHj9jRTenmvKbJOQNdg== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="14240984" X-IronPort-AV: E=Sophos;i="6.08,213,1712646000"; d="scan'208";a="14240984" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2024 01:00:10 -0700 X-CSE-ConnectionGUID: NC/sslmPSRiTtULqQ/Fr5g== X-CSE-MsgGUID: lWfd8BD6RBOSZ1GhrkZulQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,213,1712646000"; d="scan'208";a="37213300" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa009.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Jun 2024 01:00:10 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 4 Jun 2024 01:00:09 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Tue, 4 Jun 2024 01:00:09 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.171) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 4 Jun 2024 01:00:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nlqfGXu+BxFIo06PX31pdTn5BuzZJrTTwriAwM2m3rHVJnY4GblqTBZGkC8tN5jrHGEjCWhQuZfH89rKcNDNYeBUZUtevlWc3WiuMhx956bXrVrgyxiHLXGXsVAOsQ6TgPq3OgvasuF6VqnFc3uH01CVj3hjkxgqLi3OAzzz9lnjfbQhSBtTMYNqoxv36hgcY2o/f/LhgRwjEarTVd7AZIrrvmH9ZlEzSyn47O3DAtD73i3dmzbDY/ZEZ854YMwvMTTKV6BSlY6sZqro8ndtR2sH5mVMSt5KiEh/3MS525OX5t1eHOzaQmWKkXiK0sjQEYzlaO9HIDk6qxHC86NiRw== 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=L3HH4CJHhYfHxXDoXhLWgN2V82Io7vdCQ2XmXiPsqfY=; b=NzYFwsXyfSpAVml0J84JBWkC7uNym6/v84svkmGNa3Bz+xceZyu/lPsXLXiEREGKcO+pzj5S2zCXJk4Sh71u3p2TmLH7VJD/6SGFhKnahqzh/vW1FydhZrQslowncuS44GA61NHotNu5HsxjiNCfbnjQd1mbBvcXZAa1uAOi0D5PBxjunlTglBRIFccZ6MQ34nTM3lzv0sJUkoWDVkCjmBQTHAnY3fOvVTMRxPGOTXHPe2qqm4Z5GONK5inie2k5AMk8pJNdNsZdMxlO6Bbe6tuOtJd+7QwEiX4xzvHXFLYAORyAg7cQdQzFFwyXi6o0sZyC3nJEVcRRNZxMevymaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7529.namprd11.prod.outlook.com (2603:10b6:8:141::20) by CY5PR11MB6308.namprd11.prod.outlook.com (2603:10b6:930:20::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Tue, 4 Jun 2024 08:00:07 +0000 Received: from DS0PR11MB7529.namprd11.prod.outlook.com ([fe80::d244:15cd:1060:941a]) by DS0PR11MB7529.namprd11.prod.outlook.com ([fe80::d244:15cd:1060:941a%7]) with mapi id 15.20.7633.018; Tue, 4 Jun 2024 08:00:06 +0000 Message-ID: <445fae9f-ea1e-4864-9f0e-f348c51146a1@intel.com> Date: Tue, 4 Jun 2024 16:03:58 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/22] iommu: Add iommu_user_domain_alloc() interface To: Lu Baolu , Joerg Roedel , "Will Deacon" , Robin Murphy , "Jason Gunthorpe" , Kevin Tian CC: David Airlie , Daniel Vetter , "Kalle Valo" , Bjorn Andersson , "Mathieu Poirier" , Alex Williamson , , Jason Wang , Thierry Reding , "Jonathan Hunter" , Mikko Perttunen , , , References: <20240604015134.164206-1-baolu.lu@linux.intel.com> <20240604015134.164206-2-baolu.lu@linux.intel.com> Content-Language: en-US From: Yi Liu In-Reply-To: <20240604015134.164206-2-baolu.lu@linux.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SI2P153CA0027.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::22) To DS0PR11MB7529.namprd11.prod.outlook.com (2603:10b6:8:141::20) 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: DS0PR11MB7529:EE_|CY5PR11MB6308:EE_ X-MS-Office365-Filtering-Correlation-Id: 39a8ab03-a3df-4770-49ce-08dc846c58dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Q3FrT2FCSUswMGtJUnhPaENFWVMzd0FuNTlnNHRGVjhoOTcxQjEwVUZ2TGQv?= =?utf-8?B?aitTOXBXUDVpN3ZyMU55Wk1JdE41ZTdESVVXclZNWGhEQzhTck9maFRTaDFv?= =?utf-8?B?ZjZSL1hMWlZJTXUrSlp6MnJldFJLTE5VSjJUbFJYWlg2RGNmVENpeld3ejFO?= =?utf-8?B?aGR6WGYrdTFhUFFISzlyeXl5SnR6UWZFQko5YkJzRDZHSzJIYXlHV2hDWFBH?= =?utf-8?B?MkdmcEtmNlRXRXNWbDc0UmtuWSs3WGpycU1sSkVib2F3UnpIMWUzZk5saXdD?= =?utf-8?B?QXlRYTdWcXd1dU9yRmVNdnFwL2pQRHpITnNMcWdZOS9BUGlTNmlB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TgvRjZWeDZMWGFa?= =?utf-8?B?bVU5T0pua1ZuSHZJQnEvWlEyWmgzUkhBM1pEbWpOQ3JHNVVPMU54NkFwK0lv?= =?utf-8?B?eEl2Ymc0S2tmYnJEQy9veVhsYVkyQ0JsNktwTjl0czRDY1l5dlIxN0wrS1Y5?= =?utf-8?B?dStDU1BNVEdpOHJJSlk3bGlJeHZNS2Uwd2xzNGg3SUtLSkxTV0oySVZKSjhj?= =?utf-8?B?Zkp5QS9OeWlVRHJwVWNTdWdXcURpSGVFS1VrWGxsKzd0aVdHZHVqQ0FTVEVl?= =?utf-8?B?V3M1NElyY1Q2WXBYd2FLTlErWjR1M0ZwcWlUMExkZmVjVG1IU0dLbG8wUE80?= =?utf-8?B?d3FOMWRKMWhkMUxvTWQ3czdUa2ZPUzIySFZoNGhFUVpNS0ltTGhQVGUvQ2Za?= =?utf-8?B?UjRCRGtjSmNHOTRFc3doNGk3Nlh5RDJFOWhYMU9hSkg2NDBRTDJ0RVl6NU0v?= =?utf-8?B?dXZVc2dYb2diem0zdVZyMFBiWnhNRWF5elZWK1VxbnpzV3ZvT2gwMjFBPT0=?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR11MB7529.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aXJHQzMvNXo0Tkp2Z2d3a1lVc0ZzanNEOVRvUkNsVXVieE9iMVBRWUhaMzhv?= =?utf-8?B?NE9xQTAxWTBBcUFvaU5DSldQc0RKRnlJVjZLTjM0a0dCRjBpSnZBdGZ2ZUtC?= =?utf-8?B?OUpaMm42cGFnQ2NxOTdhL2NnL3VXT2h6enBVcjNEK3Ryb0NCa0s5UGtVNFVx?= =?utf-8?B?ekRhb2w5Q1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xLzloSkZYZlVNU1Yy?= =?utf-8?B?QXZCYWN1RlNGMm9ndlUxeStDZ3hpdkZXNSt3RjdGcW84TkVCRHBGWW5qSVg3?= =?utf-8?B?NDZVTTJrYnNsdkd4SnF2eCsxTjRXUmVQMTJKS3o1M1grOXdwVm9JUndsdW9i?= =?utf-8?Q?X780RPU8C9pUV6ThWRYqTZW5o?= X-MS-Exchange-CrossTenant-Network-Message-Id: 39a8ab03-a3df-4770-49ce-08dc846c58dc X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7529.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 08:00:06.4962 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QxZmtKOuj5RpwJtPXylCegX0fwH1VmuRqGKWv/Wi8D63cQEoZveZNiiiE0OaxzFGb6KFmtkdq/gOyFFxphpSxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6308 X-OriginatorOrg: intel.com On 2024/6/4 09:51, Lu Baolu wrote: > Commit <909f4abd1097> ("iommu: Add new iommu op to create domains owned > by userspace") added a dedicated iommu op to allocate a user domain. > While IOMMUFD has already made use of this callback, other frameworks > like vfio/type1 and vDPA still use the paging domain allocation interface. > > Add a new interface named iommu_user_domain_alloc(), which indicates the > allocation of a domain for device DMA managed by user space driver. All > device passthrough frameworks could use this interface for their domain > allocation. > > Although it is expected that all iommu drivers could implement their own > domain_alloc_user ops, most drivers haven't implemented it yet. Rollback > to the paging domain allocation interface if the iommu driver hasn't > implemented this op yet. > > Signed-off-by: Lu Baolu > --- > include/linux/iommu.h | 6 ++++++ > drivers/iommu/iommu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 48 insertions(+) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 7bc8dff7cf6d..6648b2415474 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -780,6 +780,7 @@ extern bool iommu_present(const struct bus_type *bus); > extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap); > extern bool iommu_group_has_isolated_msi(struct iommu_group *group); > extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); > +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags); > extern void iommu_domain_free(struct iommu_domain *domain); > extern int iommu_attach_device(struct iommu_domain *domain, > struct device *dev); > @@ -1086,6 +1087,11 @@ static inline struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus > return NULL; > } > > +static inline struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags) > +{ > + return ERR_PTR(-ENODEV); > +} > + > static inline void iommu_domain_free(struct iommu_domain *domain) > { > } > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 9df7cc75c1bc..f1416892ef8e 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -2032,6 +2032,48 @@ struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus) > } > EXPORT_SYMBOL_GPL(iommu_domain_alloc); > > +/** > + * iommu_user_domain_alloc() - Allocate a user domain > + * @dev: device for which the domain is allocated > + * @flags: iommufd_hwpt_alloc_flags defined in uapi/linux/iommufd.h > + * > + * Allocate a user domain which will be managed by a userspace driver. Return > + * allocated domain if successful, or a ERR pointer for failure. do you want to mention that this is for paging domain allocation? > + */ > +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags) > +{ > + struct iommu_domain *domain; > + const struct iommu_ops *ops; > + > + if (!dev_has_iommu(dev)) > + return ERR_PTR(-ENODEV); > + > + ops = dev_iommu_ops(dev); > + if (ops->domain_alloc_user) { > + domain = ops->domain_alloc_user(dev, flags, NULL, NULL); > + if (IS_ERR(domain)) > + return domain; > + > + domain->type = IOMMU_DOMAIN_UNMANAGED; > + domain->owner = ops; > + domain->pgsize_bitmap = ops->pgsize_bitmap; this seems to break the iommufd selftest as the mock driver sets extra bits in the domain->pgsize_bitmap in allocation. Override it may fail something in the testing. you may need to check if domain->pgsize_bitmap is set or use &=. static struct iommu_domain *mock_domain_alloc_paging(struct device *dev) { struct mock_dev *mdev = container_of(dev, struct mock_dev, dev); struct mock_iommu_domain *mock; mock = kzalloc(sizeof(*mock), GFP_KERNEL); if (!mock) return NULL; mock->domain.geometry.aperture_start = MOCK_APERTURE_START; mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST; mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE; if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA) mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE; mock->domain.ops = mock_ops.default_domain_ops; mock->domain.type = IOMMU_DOMAIN_UNMANAGED; xa_init(&mock->pfns); return &mock->domain; } > + domain->ops = ops->default_domain_ops; > + > + return domain; > + } > + > + /* > + * The iommu driver doesn't support domain_alloc_user callback. > + * Rollback to a UNMANAGED paging domain which doesn't support > + * the allocation flags. > + */ > + if (flags) > + return ERR_PTR(-EOPNOTSUPP); > + > + return __iommu_domain_alloc(ops, dev, IOMMU_DOMAIN_UNMANAGED); > +} > +EXPORT_SYMBOL_GPL(iommu_user_domain_alloc); > + > void iommu_domain_free(struct iommu_domain *domain) > { > if (domain->type == IOMMU_DOMAIN_SVA) -- Regards, Yi Liu