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

Re: [PATCH v3 2/2] xen-pciback: allow compiling on other archs than x86


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "jgross@xxxxxxxx" <jgross@xxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Fri, 24 Sep 2021 11:38:22 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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; bh=IOmFWBEPT++RtLjxPBdbE8hk0xmS1z+BauBEJuz3d40=; b=WSOmVbdeOk3sSmGkYwWheHNEgNiHRrqUSYL93YubqiNiAbERae8cx2NOXNbhqzOk/ExikaE0v0AOiHEcPIEplUq1hylXqFBkHXPviTQWp2YXh/cOl3TYynusdpsVXbWI3KIqno1SiXVX/OHFaPBSuTu+w5PInMDheIdDSC+FS8Y2w964EIrhIP7AlkJ5PjyHE2d3B5q0BpHWrwlTf2SNvPuQsej1LCXq9D+hO7Hj7Ac63NvnD2uNgS8QztdiTAf8BR209KEp2MrC+JV2RnxBwVYU7ssEpmdOeQwS8VVJRaF8wqo8M4MD0kG371Jiql78dw1g7HDhRruYFgEE5zJQKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SpNYp0N5ejI+ACQ5gdG3WqDY116mkchXXi4mtqmP9YDrDfabvatVnRAqd3g+2CfvvaG3gzdz0hPS8GMuOTG5ZNReMo9llErhWYIEZ1zwQ60IFN9UjmauO/WabCqmNvbzta5rx7sWwrqAvrqs3JSeuZK6sdGfBai5Hnk8zlrH64DWKITipDCTvhJP61vBu6h5JTwZOmuImXHA8VIBfCHxiKrOzidAWo6HkzgA4VE9kBhHoI3HyXx/B83BH55tMYbG5ZJZLP5kMM9BpeREdh0HP7MsPB8PwfHFVMDNu4AZyfHlUCXaiXRET1z4zU6OtR/erUvrWM00P7tqKYyWqCNlDA==
  • Authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "boris.ostrovsky@xxxxxxxxxx" <boris.ostrovsky@xxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, Anastasiia Lukianenko <Anastasiia_Lukianenko@xxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Fri, 24 Sep 2021 11:38:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXsGDrkewW5NG+ZkqXauJ2P2aIyauyCpkAgACjoYCAAGJfAA==
  • Thread-topic: [PATCH v3 2/2] xen-pciback: allow compiling on other archs than x86

On 24.09.21 08:46, Oleksandr Andrushchenko wrote:
> On 23.09.21 23:00, Stefano Stabellini wrote:
>> On Thu, 23 Sep 2021, Oleksandr Andrushchenko wrote:
>>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>>>
>>> Xen-pciback driver was designed to be built for x86 only. But it
>>> can also be used by other architectures, e.g. Arm.
>>> Re-structure the driver in a way that it can be built for other
>>> platforms as well.
>>>
>>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>>> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@xxxxxxxx>
>> The patch looks good to me. Only one thing: on ARM32 I get:
> WE do not yet support Xen PCI passthrough for ARM32
>> drivers/xen/xen-pciback/conf_space_header.c: In function ‘bar_init’:
>> drivers/xen/xen-pciback/conf_space_header.c:239:34: warning: right shift 
>> count >= width of type [-Wshift-count-overflow]
>>       bar->val = res[pos - 1].start >> 32;
>>                                     ^~
>> drivers/xen/xen-pciback/conf_space_header.c:240:49: warning: right shift 
>> count >= width of type [-Wshift-count-overflow]
>>       bar->len_val = -resource_size(&res[pos - 1]) >> 32;
>>    
>>    
>> resource_size_t is defined as phys_addr_t and it can be 32bit on arm32.
>>
>>
>> One fix is to surround:
>>
>>              if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64)) {
>>                      bar->val = res[pos - 1].start >> 32;
>>                      bar->len_val = -resource_size(&res[pos - 1]) >> 32;
>>                      return bar;
>>              }
>>
>> with #ifdef PHYS_ADDR_T_64BIT
>>
> This might not be correct. We are dealing here with a 64-bit BAR on a 32-bit 
> OS.
>
> I think that this can still be valid use-case if BAR64.hi == 0. So, not sure
>
> we can just skip it with ifdef.
>
> Instead, to be on the safe side, we can have:
>
> config XEN_PCIDEV_STUB
>          tristate "Xen PCI-device stub driver"
>          depends on PCI && ARM64 && XEN
> e.g. only allow building the "stub" for ARM64 for now.

Or... there are couple of places in the kernel where PCI deals with the 32 bit 
shift as:

drivers/pci/setup-res.c:108:        new = region.start >> 16 >> 16;
drivers/pci/iov.c:949:        new = region.start >> 16 >> 16;

commit cf7bee5a0bf270a4eace0be39329d6ac0136cc47
Date:   Sun Aug 7 13:49:59 *2005* +0400

[snip]

     Also make sure to write high bits - use "x >> 16 >> 16" (rather than the
     simpler ">> 32") to avoid warnings on 32-bit architectures where we're
     not going to have any high bits.

This might not be(?) immediately correct in case of LPAE though, e.g.

64-bit BAR may tolerate 40-bit address in some use-cases?


 


Rackspace

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