mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
To: Stefano Stabellini <sstabellini@kernel.org>,
	"jgross@suse.com" <jgross@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>,
	"julien@xen.org" <julien@xen.org>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	Anastasiia Lukianenko <Anastasiia_Lukianenko@epam.com>,
	Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
Subject: Re: [PATCH v3 2/2] xen-pciback: allow compiling on other archs than x86
Date: Fri, 24 Sep 2021 11:38:22 +0000	[thread overview]
Message-ID: <7310d23e-4193-3f4c-06da-606b30e73f24@epam.com> (raw)
In-Reply-To: <f62a1e2c-4253-c998-c206-6bb0681a84fb@epam.com>


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@epam.com>
>>>
>>> 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@epam.com>
>>> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
>> 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?


  reply	other threads:[~2021-09-24 12:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  9:53 [PATCH v3 1/2] xen-pciback: prepare for the split for stub and PV Oleksandr Andrushchenko
2021-09-23  9:53 ` [PATCH v3 2/2] xen-pciback: allow compiling on other archs than x86 Oleksandr Andrushchenko
2021-09-23 20:00   ` Stefano Stabellini
2021-09-24  5:46     ` Oleksandr Andrushchenko
2021-09-24 11:38       ` Oleksandr Andrushchenko [this message]
2021-09-24 20:04         ` Stefano Stabellini
2021-09-27  5:13           ` Oleksandr Andrushchenko
2021-09-23 11:10 ` [PATCH v3 1/2] xen-pciback: prepare for the split for stub and PV Jan Beulich
2021-09-23 11:12   ` Juergen Gross
2021-09-23 11:17     ` Jan Beulich
2021-09-23 11:13   ` Oleksandr Andrushchenko
2021-09-23 19:47 ` Stefano Stabellini
2021-09-24  5:37   ` Oleksandr Andrushchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7310d23e-4193-3f4c-06da-606b30e73f24@epam.com \
    --to=oleksandr_andrushchenko@epam.com \
    --cc=Anastasiia_Lukianenko@epam.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®