[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH


  • To: Julien Grall <julien@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Fri, 7 Mar 2025 09:20:18 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wYL4OYVij4c+8oBG6Tjq29RndlZHUzxVFHP4bAybbfc=; b=em/OgqgUfXxsymgTuMiNwlT72XUlpcVvu+jJVMbWf/QR7q/JGWPOJCRzvBEgAup9qtrKG1M8YDwRqLAYTiGGW4FG4mB1pbEFgZrcekW1tDbQz99ltPi4RMe8BIJ45De3TbkGj+eyjnSjbSCG1waLmVf96hXXfYH6oY6jbKCuc9NvczYY1IScigrKBCMbNdcffk7s7Gbzu8NSDNTVQ4/BblJdd8e7sJeHD750+xAT83PNH7oAHopxYPqyQV9H/pAqb/8WJyi32iliP7d38nizL6CAM6mzy9yzVw4T0OCKJxrs1Ac9Cc04081MSg9nln7HwVfIu5xiJtmsn5EtjaEA8Q==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wYL4OYVij4c+8oBG6Tjq29RndlZHUzxVFHP4bAybbfc=; b=yIg78nCF1ovGHX5/iwursHG6q+UnRd34MmLhELvZ2LuThvL1qInpW3GN71AdYi3/Qy72a5cC1L95y1kSH6XfMIV/5PD9ULTyygLKuMB8Paye9nZbg2os2yNmQC012w85vMfA0a66SJN05iDhtBNmh18agM0QIaJuLVcK7+DJUFiGwsHJ8Vq2RpcGRmN/qqwsUMlTPbVfdRAplZiMM2OeHsPMJD/YlrYgUp1qqyEBjA+TbGWOdZAsFY3qYUaO077Q+artPRJ+/5enqi8IMnEwWRKuatLLC7eMgZ4BMQFSCSgHzopqpqyuMHdTXUq2BY5j9gAoi2suWOCaYTSACBEVVw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=fzrJMHvDHcTD/QXFnkRO1TSXWr7ty2Y0TGI5/Kee4yE9VwZuKV14TuJkxULkrN/lCoPEJ8+7MNeIwwOg1gjSqrT3ZFerdsmIIzq6u43Fg3gzAzvTBGLsbiN34tYU0qSyR7CwyjQugqJiw3OxZsONpbv6wQigrqjem+Ml6IxBuIBXuOuYenfCD2MUOTpi4vHB8NT+QSSLSceWM4OqMypfOieLhJ9A29GuD25fqupg5kcCEHa/NI9DVfvthkaAf9VZZ7vF9qHwOAuWowy7Ip7FTDELs5RJDINZDJBUgh5iG0/uoLmn9cIdIEm+FKhM07sbKQNQS4N0zGvvFcHnCkp0lw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ERAWiv7btaYTQaday9k/QR4QoU87p7YgMTjST6nRxgUKZQIAtIJyqdnKhnRzjFHk8OqC2vaGDTHsv/6uOCSg6c0I1MKLGFmBWNJaQX4PoOW96Y/Zr5Bsd801V7Q3RhPQA9WANYJa37Qhf0O813j0O0TojA4IQD75bHrZqpw1Kpoy93eqtaw+lDhPJ8OpUxgDZbKj0slUdMvgQ8FjjGwQrQwBwxBRpr4mKo1fVfUFGbav1pnnRn1tDLVGjYr7y7fBCebUopwTJPmHERCYszkGMU+5Y2YEdmh9Cu/lewrziMIquKjXKRndi3GEGHpFOaCm8My6M5F9YLjRFwNJMC+LVw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 07 Mar 2025 09:20:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHbjzbI53lezYd1hUSXD4RbGtfICrNnYsoAgAAC7IA=
  • Thread-topic: [PATCH v4 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Hi Julien,

> On 7 Mar 2025, at 09:09, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi Luca,
> 
> On 07/03/2025 07:58, Luca Fancellu wrote:
>> When Xen is built without HAS_PASSTHROUGH, there are some parts
>> in arm where iommu_* functions are called in the codebase, but
>> their implementation is under xen/drivers/passthrough that is
>> not built.
>> So provide some stub for these functions in order to build Xen
>> when !HAS_PASSTHROUGH, which is the case for example on systems
>> with MPU support.
>> For gnttab_need_iommu_mapping() in the Arm part, modify the macro
>> to use IS_ENABLED for the HAS_PASSTHROUGH Kconfig.
>> Fixes: 0388a5979b21 ("xen/arm: mpu: Introduce choice between MMU and MPU")
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>> ---
>> v4 changes:
>>  - re-introduced stub for iommu_use_hap_pt, Stefano suggested
>>    it is ok to have it in iommu.h.
>>  - Reworded comment in iommu_domain_init from Jan suggestion
>> v3 Changes:
>>  - removed stub for iommu_use_hap_pt, another solution will be
>>    done for the instance in common arm code.
>>  - Moved a comment close to the macro it was referred to
>>  - add comment to iommu_domain_init() stub
>>  - modified commit message
>>  - Add fixes tag
>> v2 Changes:
>>  - modify gnttab_need_iommu_mapping to use IS_ENABLED
>>  - removed macro that didn't allow some of the parameter to be
>>    evaluated
>>  - Changed commit message
>> ---
>> ---
>>  xen/arch/arm/include/asm/grant_table.h |  5 +--
>>  xen/include/xen/iommu.h                | 50 +++++++++++++++++++++++++-
>>  2 files changed, 52 insertions(+), 3 deletions(-)
>> diff --git a/xen/arch/arm/include/asm/grant_table.h 
>> b/xen/arch/arm/include/asm/grant_table.h
>> index d3c518a926b9..c5d87b60c4df 100644
>> --- a/xen/arch/arm/include/asm/grant_table.h
>> +++ b/xen/arch/arm/include/asm/grant_table.h
>> @@ -73,8 +73,9 @@ int replace_grant_host_mapping(uint64_t gpaddr, mfn_t 
>> frame,
>>  #define gnttab_status_gfn(d, t, i)                                       \
>>      page_get_xenheap_gfn(gnttab_status_page(t, i))
>>  -#define gnttab_need_iommu_mapping(d)                    \
>> -    (is_domain_direct_mapped(d) && is_iommu_enabled(d))
>> +#define gnttab_need_iommu_mapping(d)                                     \
>> +    (IS_ENABLED(CONFIG_HAS_PASSTHROUGH) && is_domain_direct_mapped(d) && \
>> +     is_iommu_enabled(d))
>>    #endif /* __ASM_GRANT_TABLE_H__ */
>>  /*
>> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
>> index 77a514019cc6..5ac038521e23 100644
>> --- a/xen/include/xen/iommu.h
>> +++ b/xen/include/xen/iommu.h
>> @@ -110,6 +110,8 @@ extern int8_t iommu_hwdom_reserved;
>>    extern unsigned int iommu_dev_iotlb_timeout;
>>  +#ifdef CONFIG_HAS_PASSTHROUGH
>> +
>>  int iommu_setup(void);
>>  int iommu_hardware_setup(void);
>>  @@ -122,6 +124,28 @@ int arch_iommu_domain_init(struct domain *d);
>>  void arch_iommu_check_autotranslated_hwdom(struct domain *d);
>>  void arch_iommu_hwdom_init(struct domain *d);
>>  +#else
>> +
>> +static inline int iommu_setup(void)
>> +{
>> +    return -ENODEV;
>> +}
>> +
>> +static inline int iommu_domain_init(struct domain *d, unsigned int opts)
>> +{
>> +    /*
>> +     * Return as the real iommu_domain_init() would: Success when
>> +     * !is_iommu_enabled(), following from !iommu_enabled when 
>> !HAS_PASSTHROUGH
>> +     */
>> +    return 0;
>> +}
>> +
>> +static inline void iommu_hwdom_init(struct domain *d) {}
>> +
>> +static inline void iommu_domain_destroy(struct domain *d) {}
>> +
>> +#endif /* HAS_PASSTHROUGH */
>> +
>>  /*
>>   * The following flags are passed to map (applicable ones also to unmap)
>>   * operations, while some are passed back by lookup operations.
>> @@ -209,6 +233,8 @@ struct msi_msg;
>>  #ifdef CONFIG_HAS_DEVICE_TREE
>>  #include <xen/device_tree.h>
>>  +#ifdef CONFIG_HAS_PASSTHROUGH
>> +
>>  int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev);
>>  int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev);
>>  int iommu_dt_domain_init(struct domain *d);
>> @@ -238,6 +264,26 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, 
>> struct domain *d,
>>   */
>>  int iommu_remove_dt_device(struct dt_device_node *np);
>>  +#else
>> +
>> +static inline int iommu_assign_dt_device(struct domain *d,
>> +                                         struct dt_device_node *dev)
>> +{
>> +    return -EINVAL;
>> +}
>> +
>> +static inline int iommu_add_dt_device(struct dt_device_node *np)
>> +{
>> +    return 1;
> 
> I would suggest to add a comment explain what 1 means. IIRC, this means "no 
> iommu" present.

Would it be ok something like in iommu_domain_init:

/*
 * Returns as the real iommu_add_dt_device() would: Error “no iommu" because
 * !iommu_enabled due to the fact that !HAS_PASSTHROUGH
 */

> 
> Other than that:
> 
> Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
> 
> Cheers,
> 
> -- 
> Julien Grall
> 


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.