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

Re: [PATCH] xen/arm: vpci: Remove PCI I/O ranges property value


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Fri, 17 Dec 2021 09:19:43 +0000
  • Accept-language: en-US
  • 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=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=Txg9Jaq3eKDnyB6browgzLyrTGasYQusrflRASZqvZo=; b=LRMxvHMP385ls1oYaH9o8rUZ7zNtp1KqZALX3vPMu/cuTJv78ShjOt9y0tfCCFHFRmGgAcHX8zU3IWZkFt7/smqtJxGQ+gZnT72zzCx40w9Yccn/0XaQZSQCxwNNsCBxx7qUv5UUYtMH8AyOzlUT3xj+TgOEyy9+w1Veuc2VOVrcIBK/l7UD3ldMOe9zE5jfLm1UWT5hfU1UezE+CVhwGOPgF5isCzOTb5gO1IWenjlG7LLFAgXmhfuJo9FqGnpPLlt+oAagf2wjJjjliV9rssCIRKGClw8bRgCXWirRVMlJhFIobnnw7OCk1U4FqRbSuKEI8RQp50VFiBF344SnXQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IUjXbCLWgOm/hfzUlijPTmGwGg/RfGkv1DBB4VnPNPU54/Q+Qkawz/op9l/tYamZDIKpPlqXeAbM2c0CQnLdNUQBtVMh/HWdDhvX/e2N959/cUPfgGrB3SdQOkGo0X0LvL2nGcoe2MpYWMTo9H2Kt9yrvDcxhi7kb3jTKIlruVUot2IqGAum8853Y8cDppVJCOnxxjzaiw7WZfBBe2zKT91QMX42WFTtEo+01U9Sz4GcSOcApqefTHQWSWp1A1CAKBKsHT2qRgD/qnLUMeU+0lIaJ9SWCQjsGkK45F+a42/SckjpfYDHwoCsbfTsE2xs4I6nJNcvwSr0tsfCcaMWgw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 17 Dec 2021 09:20:30 +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: AQHX8NfE0k+LAAwoDUiQfCEULp9EE6w0aQgAgAB74ACAAMbRAIAAwQkA
  • Thread-topic: [PATCH] xen/arm: vpci: Remove PCI I/O ranges property value

Hi Stefano,

> On 16 Dec 2021, at 9:48 pm, Stefano Stabellini <sstabellini@xxxxxxxxxx> wrote:
> 
> On Thu, 16 Dec 2021, Rahul Singh wrote:
>> Hi Stefano,
>> 
>>> On 16 Dec 2021, at 2:33 am, Stefano Stabellini <sstabellini@xxxxxxxxxx> 
>>> wrote:
>>> 
>>> On Tue, 14 Dec 2021, Rahul Singh wrote:
>>>> IO ports on ARM don't exist so all IO ports related hypercalls are going
>>>> to fail on ARM when we passthrough a PCI device.
>>>> Failure of xc_domain_ioport_permission(..) would turn into a critical
>>>> failure at domain creation. We need to avoid this outcome, instead we
>>>> want to continue with domain creation as normal even if
>>>> xc_domain_ioport_permission(..) fails. XEN_DOMCTL_ioport_permission
>>>> is not implemented on ARM so it would return -ENOSYS.
>>>> 
>>>> To solve above issue remove PCI I/O ranges property value from dom0
>>>> device tree node so that dom0 linux will not allocate I/O space for PCI
>>>> devices if pci-passthrough is enabled.
>>>> 
>>>> Another valid reason to remove I/O ranges is that PCI I/O space are not
>>>> mapped to dom0 when PCI passthrough is enabled, also there is no vpci
>>>> trap handler register for IO bar.
>>>> 
>>>> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
>>>> ---
>>>> xen/arch/arm/domain_build.c   | 14 +++++++
>>>> xen/common/device_tree.c      | 72 +++++++++++++++++++++++++++++++++++
>>>> xen/include/xen/device_tree.h | 10 +++++
>>>> 3 files changed, 96 insertions(+)
>>>> 
>>>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>>>> index d02bacbcd1..60f6b2c73b 100644
>>>> --- a/xen/arch/arm/domain_build.c
>>>> +++ b/xen/arch/arm/domain_build.c
>>>> @@ -749,6 +749,11 @@ static int __init write_properties(struct domain *d, 
>>>> struct kernel_info *kinfo,
>>>>                continue;
>>>>        }
>>>> 
>>>> +        if ( is_pci_passthrough_enabled() &&
>>>> +                dt_device_type_is_equal(node, "pci") )
>>>> +            if ( dt_property_name_is_equal(prop, "ranges") )
>>>> +                continue;
>>> 
>>> It looks like we are skipping the "ranges" property entirely for the PCI
>>> node, is that right? Wouldn't that also remove the other (not ioports)
>>> address ranges?
>> 
>> We are skipping the “ranges” property here to avoid setting the “ranges” 
>> property when
>> pci_passthrough is enabled. We will remove only remove IO port and set the 
>> other ‘ranges” property 
>> value in dt_pci_remove_io_ranges() in next if() condition.
>> 
>> 
>>>>        res = fdt_property(kinfo->fdt, prop->name, prop_data, prop_len);
>>>> 
>>>>        if ( res )
>>>> @@ -769,6 +774,15 @@ static int __init write_properties(struct domain *d, 
>>>> struct kernel_info *kinfo,
>>>>            if ( res )
>>>>                return res;
>>>>        }
>>>> +
>>>> +        /*
>>>> +         * PCI IO bar are not mapped to dom0 when PCI passthrough is 
>>>> enabled,
>>>> +         * also there is no trap handler registered for IO bar therefor 
>>>> remove
>>>> +         * the IO range property from the device tree node for dom0.
>>>> +         */
>>>> +        res = dt_pci_remove_io_ranges(kinfo->fdt, node);
>>>> +        if ( res )
>>>> +            return res;
>>> 
>>> I tried to apply this patch to staging to make it easier to review but I
>>> think this chuck got applied wrongly: I can see
>>> dt_pci_remove_io_ranges() added to the function "handle_prop_pfdt" which
>>> is for guest partial DTBs and not for dom0.
>> 
>> Oleksandr’s patch series was merged yesterday because of that there is 
>> conflict in applying 
>> this patch. I will rebase the patch and will send it again for review.
>> 
>>> 
>>> Is dt_pci_remove_io_ranges() meant to be called from write_properties
>>> instead? It looks like it would be best to call it from
>>> write_properties, maybe it could be combined with the other new check
>>> just above in this patch?
>> 
>> Yes dt_pci_remove_io_ranges() is to be called from write_properties().
> 
> OK. In that case the only feedback that is I have is that it might be
> possible to avoid the first change of this patch to skip "ranges" by
> moving the call to dt_pci_remove_io_ranges() earlier in the
> write_properties function.

Ok. I will modify the code based on your comment.

Regards,
Rahul


 


Rackspace

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