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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 17 Feb 2025 16:14:55 +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=GPwu5aubfqCJm8LhTtMOnoWbtLgU/4F7JPv8KL/X3Kc=; b=IfskkI811Os+oZTD8FCd9ELVAo2v5ME8cJjayFzANFDg3vMtt0FeTbmPfbC4YojB/DcMPgXTgUxBXj3h7J3NqS3WW+u2w7evgTMK0WK1T/ywyt45jCrz4tb3+CU3xVyPRHzrQl5vIqZp9XeK9PagEAkvdKb0wl7cXpeEQaiM/437zZ6N2UbzbHDlHxdbiYLo1QMOeCKdZB1lEhLMnDRL0OmWkWTLLsymD/FQUZGWMLPBiKzMCq7TNhFojqz+bBWeoqqlE3GKcasY8AiJnHwgA8sQmpoLaPACUbY4Lf5TN9KVXRuBG08vR4YQhyEFncyxn6xF1xCQjDQ/u6jNev8H5w==
  • 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=GPwu5aubfqCJm8LhTtMOnoWbtLgU/4F7JPv8KL/X3Kc=; b=Rrib8D7ZbdGFsD5REmB6tKmCJp523dsdq/iaLKw/ceIZt01olKkM2cYNR6hmtz6eUHr6q6rHsKAFF4E0a1yeyMw/ws2wrpKBrV//H4HIlOUXBlMp48PQRz0bgMlAzhpXxYFl4uIERwJsm2wTg7l0dXeTAN27CwhSzTHbAVPFCt1UPABWQH1wQJhEmjx9XRtkUXI3OulJOsOMlP7Cyel3vl3Gyc/Vs0dleGPIFYdV83rpCtRzW5KxNUpE8wOXU/gX8QT1iTGk2dpLjHlpjKieJg0fKtSgapQk8ziswjtPoISdgwSJT9eieMne1ane5MdQpp3wSzNmzKUZhOQlPKC6yg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=tWkKVywdGIvUAGGE24yaJqW9Xxuvb/Jv9nxUojILdMgMEgTC145u9RyTEa7vs8Foq4SRCxo7FCME9mLjm45Al8solSEiYp0VecQ9FZlVqofBOb/gTgJQh+lWUrtnfHZqltIMp6/x3Rcdi8jiJVDm2GHFlkdGbesVVxLFgAZeZuTP3KvjZXOx2RE8bhHj2yTYC63s5Sfom8zYnmqE9awU1qVAj/iQcroZ7D2t9dASqwDS3TF3Yyi0nIdmcvPRzI5jHDwGicOirLjOvQgwY2t2K1wQgHhOpjNt+zsZ8Q5faB8ZCKl30mgbIYGoR4il2gERYqsc+/LTLsz+P1ZJpXxd5A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KXdGh1ZsStwEyUdY1ZKdRq/lMd3GEIPA/5kE5J7OB3ImIlcM+Io/ruPd0D2FK0sDQD6I39ukPDmaDYXwF858KOFmRjoOTJESLXyCeoRPrCN4FAUlsNRJpsgDCJ5ESOvsRlI1Uav+3A2NAA++0lj8hI54GudbUQ7/UuFhnsg6CbOofJW4qUNMmCNhoGTvRM88rPCKouEp+JwnMwy+G8bxRMeuP6VwuSOshWabSIaGeefG4QGsF4wSfSCKl9HDkbrR8Bpj/Vw/gx+q6t9HdoOwScXaD7FmZTUn+SMUI/PSBah7k+rgm27Zf9vj3ljYNTK3ieAu7bPsMOYgrt+qbKG18A==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 17 Feb 2025 16:15:11 +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: AQHbgSah9ICbo4twrEWuXsaPYY+0drNLUUYAgAAR4YCAAAR4gIAARBmA
  • Thread-topic: [PATCH v2 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

> 
>>>> --- 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,24 @@ 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 0;
>>> 
>>> Shouldn't this fail when is_iommu_enabled(d) is true? (The use of the
>>> predicate here as well as in the real function is slightly strange, but
>>> that's the way it is.)
>> 
>> Right, probably you know better this code than me, I started from the 
>> assumption
>> that when !HAS_PASSTHROUGH, 'iommu_enabled' is false.
>> 
>> is_iommu_enabled(d) checks if the domain structure ‘options’ field has
>> XEN_DOMCTL_CDF_iommu, this flag is set on domain creation when 
>> ‘iommu_enabled'
>> is true on arm and x86.
>> 
>> So when !HAS_PASSTHROUGH can we assume is_iommu_enabled(d) give false?
>> Or shall we return for example the value of is_iommu_enabled(d)?
> 
> Since HAS_PASSTHROUGH being selected conditionally a (pretty) new, I
> fear that assumptions shouldn't be made. It's possible the stub could
> remain as is, yet even then - if only for documentation purposes - I'd
> suggest to have some ASSERT() there. In the end it all depends on how
> XEN_DOMCTL_CDF_iommu is handled when !HAS_PASSTHROUGH.

I’ve tried to add an ASSERT(!is_iommu_enabled(d)); but it’s not building, I’m 
starting to think there
is some reason why I can’t do that but I didn’t figure out why, I’ve added the 
inclusion for xen/sched.h,
but it still says implicit declaration of function ‘is_iommu_enabled’…

But I could assert for !iommu_enabled: I checked into common/domain.c, 
sanitise_domain_config,
if a domain is called with XEN_DOMCTL_CDF_iommu set, the function would fail if 
!iommu_enabled,
so I would say that the stub returns the expected value (0) since for sure 
iommu_enabled is false and
there cannot be a domain with that flag set that has the iommu_enabled=true 
under !HAS_PASSTHROUGH.

But would it be ok to add this assert (ASSERT(!iommu_enabled);) even if we know 
that iommu_enabled
is false, since !HAS_PASSTHROUGH ?

Please let me know your thoughts on this.

Cheers,
Luca



 


Rackspace

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