Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp100134lqr; Tue, 4 Jun 2024 23:20:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7gBJJsWTQEDDhsFjHzzhdi+wLFL+GytBD66vp0VKF6DfTLVvaRYivcxYOmqDIrPz3KhEv71v6o8WSnQUvNvFbIB7El5lUnB8FpBI1DA== X-Google-Smtp-Source: AGHT+IH6+k4s4bc3liVUo2Cp/cFZMy398ibnnmyOXjSYhIL65g2HW7uk7dCZXP3MXZjVyM+Lq+QF X-Received: by 2002:a50:f69a:0:b0:57a:2274:850b with SMTP id 4fb4d7f45d1cf-57a8b708ac0mr975973a12.24.1717568425996; Tue, 04 Jun 2024 23:20:25 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b815ccsi5806472a12.88.2024.06.04.23.20.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 23:20:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WKtJTDu5; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-201800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201800-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 413711F236F3 for ; Wed, 5 Jun 2024 06:20:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63B8E21C19D; Wed, 5 Jun 2024 06:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WKtJTDu5" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 DAB612BD0D for ; Wed, 5 Jun 2024 06:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.9 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717568416; cv=fail; b=F9PWBhLCGAViY4fZTF/wOu1QwwUvTlvGuKwB4j1XT7DMt1thYrc+fPgwyor97X57QYujPDnL1rycimTXGfMIXuQbm9TFpBjHL5T9uS9rbXAjVHMKJIiDmgbgsNMR53FCu435WzHddr7WE4+2uhKy2hpXhA5Jo9c8s6/svoua6ck= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717568416; c=relaxed/simple; bh=e9B7+pxe0ivM7d1+E9GQfvIclz9hiPkszIfz5BHDecE=; h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To: Content-Type:MIME-Version; b=em4X2/lM8FdOAzGVDrbdO1DQ4FfWzofOhnfkXUdvl/OrYXVzBQAccf5DcNYUmwFDLGvpm+EyJYduIw7zdv/MDzKvxRQQRz7lIMs2DPkHHOKx+dOYQmNMfiwXB+sfKDFEMTnkCTOuGyy3ZAfUJETQDxb6Z3uTFQzy/84hFCq5csI= 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=WKtJTDu5; arc=fail smtp.client-ip=198.175.65.9 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=1717568415; x=1749104415; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=e9B7+pxe0ivM7d1+E9GQfvIclz9hiPkszIfz5BHDecE=; b=WKtJTDu5Jzab7Y/ZXrde3HeVZQE/vcOyQKr/UKgx5jekvegv1LIvWGrn VvVf3iexPnBJBfpbIJFh2n+HTD78Dv+jb4Feyp5Omby0Y77XXe4DSeFrw NZtddFPHSRz3e3kk8rotShwGMiNIhOKzzOVYbgbGayeXKC+MJNzrqalxk QLuwUSQCcmfJEJX+3lN1/BXTTbdx92QFvmiL4QgVaj+KByEbafx/qM7Or 0stEfnkluOUshb0TWISQleHbrXBlEvY0TrGXJ074K98J2X/U63zablMC7 CBkkTBgHRqfR2tnwct59AXrxmVInrQIVPqWDB0ZiqQMzgAaSWLq7evfa9 Q==; X-CSE-ConnectionGUID: hAg+O0v6S2OyQSlt8zHG6w== X-CSE-MsgGUID: SmuSZ+6YT7alJByzNCRi9Q== X-IronPort-AV: E=McAfee;i="6600,9927,11093"; a="36673373" X-IronPort-AV: E=Sophos;i="6.08,215,1712646000"; d="scan'208";a="36673373" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2024 23:20:14 -0700 X-CSE-ConnectionGUID: F2q6EDUpRjCGIeks7k7VEg== X-CSE-MsgGUID: eazLnQKnTvyQOJ5hjBmaJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,215,1712646000"; d="scan'208";a="37409025" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orviesa010.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Jun 2024 23:20:13 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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 23:20:13 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 23:20:13 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (192.55.55.70) 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 23:20:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PlDb3yOGVrCTlBB+WqacqwU/xTTp9vod8zYedbZydnG8bUf5Hcx6HTDDFXDR6va+t+lD43AR7IzisjY7qLA7p+GI9L4HQoyjm3EgkszxTc1DSOWU5i40psoSf7J2tHXmXvyH8oATCsScVnrLq43O+hZor2gpwzJqGLUvsHvLalSxxhyX/m8e8ehIWzVrxUehTf+xZQoA+4bOQuV2BmMj5r/S8m8ErR+TehI2y6Eupw2oN4rryBj+RR/oD125vKuyoxPv2MJI63TegBxNCFsFN0l3kkF3ZKpnNhN/XVKSR/SIiwCDupBaSfclJciAxCcdLRwGkh18InhcOUKiuZ1xrQ== 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=NDS3kiMkTEiBSxJGfD2R1DtoiTWSysgMgDhoc2nBxP8=; b=K6T38lGPly3hwaVDhRe2EZmGA+rglnYAe6VCJ+jy5wW1atmvSwvgqJtOEoE0IYhGXpafBzKeRLm0v+UT0IWbV9ZjeITynVzMzEZ4rpM9bJjr/TBv/NbVrqYBcq1P7EDxY0kccyGUmCQ2CIhGj09ez5fAjLcfLhabMd3cD1Xn2m8tTKW96NKP7III4lun2N2rOrHTQ57mrwjtlkfopxZpX5ufyayIYbHpKpkprDKZx/E+11sB6iPTP+BukeDBqDEqUvRxTdyXO9tlREMfcCl3CtOTW7PprkO9ObNlx+GSYhBHePqWuJe88/NMRzKolsxpyzn9iYCQh4HdYmgMJQzMaA== 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 SN7PR11MB6994.namprd11.prod.outlook.com (2603:10b6:806:2ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Wed, 5 Jun 2024 06:20:01 +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; Wed, 5 Jun 2024 06:20:01 +0000 Message-ID: Date: Wed, 5 Jun 2024 14:23:56 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/22] iommu: Add iommu_user_domain_alloc() interface To: Baolu Lu , 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> <445fae9f-ea1e-4864-9f0e-f348c51146a1@intel.com> <91a42f46-060a-4430-a10a-7bfded67c4a9@linux.intel.com> Content-Language: en-US From: Yi Liu In-Reply-To: <91a42f46-060a-4430-a10a-7bfded67c4a9@linux.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: TYBP286CA0043.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:10a::31) 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_|SN7PR11MB6994:EE_ X-MS-Office365-Filtering-Correlation-Id: a2bf3d0c-a711-4d61-c698-08dc85278826 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015|7416005; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Mk5hQWNoOG9JSG1aa2tmWXQ0enZOVGY1K2VjNnFHSURTWWJKMVVTa1FPNm1i?= =?utf-8?B?SExpalYrYnoxOE5oRmpEaHkvVkl3VjVKdC8ycXpJMndYWFhQVVlmbDFGTWpT?= =?utf-8?B?ZEtjbTFiOUYwSVI1WE04VFluS1VLUGE5ek5lNmhxbGlYdVAySEJwWGtiYW1v?= =?utf-8?B?TTl4RGRCOVQxaEdFTXR3Y0dsWW9jeEszaTZTeTllU2hmZnZ4THdNbGtOYzMx?= =?utf-8?B?bmxIZVdmVDhHczRaL0ZCT0J4WGtUcW95Ri95YUxFQ29tSmd1R08xS2Y2NFl5?= =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TTzRT?= =?utf-8?B?UjNtbDVFZG5KdnFtQlBreXFaYndUWUx2UjdYSzdydm8wbFFiQUFvNy93WVpk?= =?utf-8?B?YWQ2TVVrNTdnZGltRE5nTmwvL0FRT3A0dTdNRlREdVlHSTZYcEE0NGdDd2NI?= =?utf-8?B?Q0dFV3p0MjR2MjZUek1SVmVQaG5QYi9OTFVHell3VFlCMWxRalI0aXkvZ29L?= =?utf-8?B?aklEbTBhWWM0MFhpaDZVRzVWSVdBQU9URURvTkhYNFNVa0g5eGJjeUNSaU1G?= =?utf-8?B?WDRtZjdJejlhWUtRWTVhNDA5L1VSS2N5L2xyTkZmUmZlUUp3WWl2Nyt6QzFO?= =?utf-8?B?NEdKMURxTmo1ekd5TTVwN0JjUUVpUUdXSWZpdHVmOTI2VjRNaWhSZnFVMkpE?= =?utf-8?B?T05DeGZiclI5UHNyY1A0amljeUFnTEtqUzVSbDBHc3RNVWVUZzZCN0tSVFJu?= =?utf-8?B?QTdDNkF3MlhBcExDUTRLVXNLY21icVNxZitIcVVMSkJ0NVF6UE0ycnJyVTFV?= =?utf-8?B?RXJCVGdpOVMyVlk5anhKMjgyWW1JT2FhaUJPbmphcGhtYUtoZDl3d2FBPT0=?= 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)(376005)(366007)(1800799015)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NzVmZlVTU09GZjBXdis4K0VWaTNhYWF1RUplVUtwTVdIUHh5Z0xYYjdLMFk3?= =?utf-8?B?ekFQVlV3MElOTUYwSzFvcGYyQnVpbW5aYnlUYlFCY2tyUnhHNjhMZG1GMFEz?= =?utf-8?B?akEvLzNaeU0vM284MWxJNWh3T0s4YmlWZFJaaG42azFKanp4dE5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1g3QnR3MVhvemVmTDVzazZyWVcrd245bjVlVHk2ZlN1aXZBMEdMaU5D?= =?utf-8?B?TlZveHBJamN4THVyelVZVWhqQ2swSjVpNjk3eFFaMDJlWExyRktYeVhOaUs1?= =?utf-8?B?VGNJeEVmYXAyV2RjTEJTK2RNWEpDNEdsT1MybnV3UTg3VnBXOUhHdEdkUGdT?= =?utf-8?Q?SJ3OTv/gPGYnv9khpv8s6fpn6?= X-MS-Exchange-CrossTenant-Network-Message-Id: a2bf3d0c-a711-4d61-c698-08dc85278826 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7529.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 06:20:01.6772 (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: Jff8HfHOYDCc49ShrrPFeqcJcaIJabOLkBzND+PYQ91CGZQRgB6Cz/poQRYEzPS/O7dNanSUuTBCgr2VU7a5WQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB6994 X-OriginatorOrg: intel.com On 2024/6/5 10:00, Baolu Lu wrote: > On 6/4/24 4:03 PM, Yi Liu wrote: >> 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? > > You are worrying about its confusion with nesting domain allocation, > right? yes. As I replied in last version, user_domain is a bit confusing since nested domain is also a user_domain. That's why we introduced the alloc_domain_user op. > My understanding is that if we want a common interface for > nesting domain allocation, we should make it in another interface. Here, > the user domain is a paging domain for GVA->HPA mapping, which is common > across iommufd, vfio, and vdpa. do you mean user_domain only includes paging domain? >> >>> + */ >>> +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; >> } > > You are right. I should follow the code in __iommu_domain_alloc() > >         /* >          * If not already set, assume all sizes by default; the driver >          * may override this later >          */ >         if (!domain->pgsize_bitmap) >                 domain->pgsize_bitmap = ops->pgsize_bitmap; > > Does it work? I think so. This should work. -- Regards, Yi Liu