[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 11:55:12 +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=UtcqwSzJ+bpD9L6Y1nKeuj9oIALTP6fA2+FOqPlLlYs=; b=LKFhYNyPiTPr+3dJYSGOAx7dmX4HrwpIEXuGGt2YCkrrGFDyaqSoLfLNeABEs/bqJga+AKGqqOTt7DdpuiHnNYwj+zSO+yw8lfsXaXL79D0flQki1yeGhX5HO2FPdYBFp0NLrGo2l2S+Pg0TMr4pHe+/WHvjsJPe73varp8ueaz5GhL5y1wB3KvWYVGAG3reuUvPbuw6Bme89z0GY/OBad4mBbiTQDPhyomCX1AI0nwPdnoGQ+Bz55og+NUx2Ga0OZsmJfrOevq4f1uD/S5ekHLS4DHt2XnPsPG1odqpZ+938UbrqX6OmUJkX/Prk0d+LuY7tPLgka74yI43a7nSXQ==
  • 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=UtcqwSzJ+bpD9L6Y1nKeuj9oIALTP6fA2+FOqPlLlYs=; b=uoVDv94KrfoPt6RrVeXmTXKrzt0oVjMhIfxPnem4OS2pEsxU9fGV4FQ/QP/9je7F1WPKOEdt78R0kNJKc7KIWPt2S+LJB6hlWZuhP+ulF+qp/6sjL8Fqk1333t8TqCTiKSgBPxRyywRn//d5iQ3Iqb/EWNd0pSei7tjYHWp5YUvujE/njmKw9BC/xYMrVY8Y+fwa8KxZ7LWiptRxLhHgvflC/7EbqX8qVFrh0L6Slry81H1FdRhxwxgz9frwoGiHQ/ggatVM6B5L1xIPYrGj5CxIS/XyGzfvA5K08MfyLzRGpHJHI7vVYUhLcS+0DwzBYCzCuyAxG5sBxX2cs+biHQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=vPmdZfK110FhqItE85vb5iGpZ4RCsiS+7K8AUuLZsNaVcd6JZeR9mx0PMRjiL3PdReVeV77gJqxOJoCQ6VVlf148phOf1jVl3uglVqC2iS//ioE839DGZcgzkW/WA9NXUm31N5FkNclIwN+40Dk4DUVN60JtSCNSmK35ZGWWiLuMTG0KDvO965RZqlI9tDUDdhnkBGEcVqbQTVWKsCJcntteeZKbfXteb9gxd499dXl6l8imT5nPSu60TFSphZD+apHQeVXvFoyUr5L6JrerqCEfEZ5knxXZ9T/t5euC+y6TMcQoCXMYdPivawKpCp5FzVcnQi1Y5v/d+Gl7RfMxOQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gJisObkDkVZXR2TVtM26AFh9l0ktAKiWx9Y5cqBzt6TjnSXCXv5ABZsJ+9S/9uusIyYa+eVWnWhiTT5AGbUlaOklocfAj55VDPIns+zYcntzxfM0sni5YC2zWfYFAfVkyewTBkcUz8TyHQDCY2wacjCQb2HdVojzmn9juAgRzSKsv7Okt8Xnb344MtykcgNUKFBOVIIWpEp9tF2+9n7J65bpZB8i4LGC0mfKGfKR2rU5xVFzjTqgH5Ov2trZh6j0rHZ7dktclDbwB8tdJFZd4t7VNAgqzQ/iAqXYLzrhRlUDGFqjjLF4B3i26LVdQw7pVNLTJEhClKzM+dVvQZFppA==
  • 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 11:55:38 +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+0drNLUUYAgAAR4YA=
  • Thread-topic: [PATCH v2 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH

Hi Jan,

thanks for your review,

> On 17 Feb 2025, at 10:50, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 17.02.2025 11:27, Luca Fancellu wrote:
>> When Xen is built without HAS_PASSTHROUGH, there are some parts
>> in arm and x86 where iommu_* functions are called in the codebase,
>> but their implementation is under xen/drivers/passthrough that is
>> not built.
> 
> Why the mention of x86, where HAS_PASSTHROUGH is always selected?

sure, I’ll remove x86

> 
>> 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.
> 
> Is this fixing a build issue when MPU=y? If so, ...
> 
>> For gnttab_need_iommu_mapping() in the Arm part, modify the macro
>> to use IS_ENABLED for the HAS_PASSTHROUGH Kconfig.
>> 
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> 
> ... is there a Fixes: tag missing?

right, I’ll add a tag, but I don’t expect it to be backported, also the MPU 
will still
have some changes needed before being able to build, should I put a tag even
if this is the case?

> 
>> --- 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)?

> 
>> @@ -381,17 +423,19 @@ struct domain_iommu {
>> #define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
>> #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
>> 
>> +/* Does the IOMMU pagetable need to be kept synchronized with the P2M */
> 
> This comment belongs to just ...
> 
>> +#ifdef CONFIG_HAS_PASSTHROUGH
>> /* Are we using the domain P2M table as its IOMMU pagetable? */
>> #define iommu_use_hap_pt(d)       (IS_ENABLED(CONFIG_HVM) && \
>>                                    dom_iommu(d)->hap_pt_share)
>> 
>> -/* Does the IOMMU pagetable need to be kept synchronized with the P2M */
>> -#ifdef CONFIG_HAS_PASSTHROUGH
>> #define need_iommu_pt_sync(d)     (dom_iommu(d)->need_sync)
> 
> ... this, not also iommu_use_hap_pt().

I’ll move that close to need_iommu_pt_sync(d)

> There's a connection between the
> two, but that is unrelated to what the comment says. I'm also not clear
> about the need for ...
> 
>> int iommu_do_domctl(struct xen_domctl *domctl, struct domain *d,
>>                     XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl);
>> #else
>> +#define iommu_use_hap_pt(d)       ({ (void)(d); false; })
>> +
>> #define need_iommu_pt_sync(d)     ({ (void)(d); false; })
> 
> ... this change, i.e. the need for a stub. Afaics there's nothing in the
> description to help understanding this need.

Ok, so in arch/arm/p2m.c the function p2m_set_way_flush() uses this,
so I provided a stub, do you think I should provide something in the
commit message to explain that or shold I try to find another way in order to
don’t provide this stub?

Cheers,
Luca

 


Rackspace

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