* Re: [PATCH] xen-pciback: relax BAR sizing write value check
[not found] <59C8D3DD020000780017F39A@suse.com>
@ 2017-09-26 6:43 ` Juergen Gross
2017-09-27 20:00 ` Boris Ostrovsky
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Gross @ 2017-09-26 6:43 UTC (permalink / raw)
To: Jan Beulich, Boris Ostrovsky, Konrad Rzeszutek Wilk; +Cc: xen-devel
On 25/09/17 10:01, Jan Beulich wrote:
> Just like done in d2bd05d88d ("xen-pciback: return proper values during
> BAR sizing") for the ROM BAR, ordinary ones also shouldn't compare the
> written value directly against ~0, but consider the r/o bits at the
> bottom (if any).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] xen-pciback: relax BAR sizing write value check
2017-09-26 6:43 ` [PATCH] xen-pciback: relax BAR sizing write value check Juergen Gross
@ 2017-09-27 20:00 ` Boris Ostrovsky
0 siblings, 0 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2017-09-27 20:00 UTC (permalink / raw)
To: Juergen Gross, Jan Beulich, Konrad Rzeszutek Wilk; +Cc: xen-devel
On 09/26/2017 02:43 AM, Juergen Gross wrote:
> On 25/09/17 10:01, Jan Beulich wrote:
>> Just like done in d2bd05d88d ("xen-pciback: return proper values during
>> BAR sizing") for the ROM BAR, ordinary ones also shouldn't compare the
>> written value directly against ~0, but consider the r/o bits at the
>> bottom (if any).
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Juergen Gross <jgross@suse.com>
Applied to for-linus-14b
-boris
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] xen-pciback: relax BAR sizing write value check
@ 2017-09-25 8:01 Jan Beulich
2017-09-25 11:27 ` Roger Pau Monné
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2017-09-25 8:01 UTC (permalink / raw)
To: Boris Ostrovsky, Konrad Rzeszutek Wilk, Juergen Gross; +Cc: xen-devel
Just like done in d2bd05d88d ("xen-pciback: return proper values during
BAR sizing") for the ROM BAR, ordinary ones also shouldn't compare the
written value directly against ~0, but consider the r/o bits at the
bottom (if any).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
drivers/xen/xen-pciback/conf_space_header.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- 4.14-rc2/drivers/xen/xen-pciback/conf_space_header.c
+++ 4.14-rc2-xen-pciback-BAR-sizing/drivers/xen/xen-pciback/conf_space_header.c
@@ -169,6 +169,9 @@ static int rom_write(struct pci_dev *dev
static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
{
struct pci_bar_info *bar = data;
+ unsigned int pos = (offset - PCI_BASE_ADDRESS_0) / 4;
+ const struct resource *res = dev->resource;
+ u32 mask;
if (unlikely(!bar)) {
pr_warn(DRV_NAME ": driver data not found for %s\n",
@@ -179,7 +182,13 @@ static int bar_write(struct pci_dev *dev
/* A write to obtain the length must happen as a 32-bit write.
* This does not (yet) support writing individual bytes
*/
- if (value == ~0)
+ if (res[pos].flags & IORESOURCE_IO)
+ mask = ~PCI_BASE_ADDRESS_IO_MASK;
+ else if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64))
+ mask = 0;
+ else
+ mask = ~PCI_BASE_ADDRESS_MEM_MASK;
+ if ((value | mask) == ~0U)
bar->which = 1;
else {
u32 tmpval;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] xen-pciback: relax BAR sizing write value check
2017-09-25 8:01 Jan Beulich
@ 2017-09-25 11:27 ` Roger Pau Monné
0 siblings, 0 replies; 4+ messages in thread
From: Roger Pau Monné @ 2017-09-25 11:27 UTC (permalink / raw)
To: Jan Beulich; +Cc: Juergen Gross, xen-devel, Boris Ostrovsky
On Mon, Sep 25, 2017 at 08:01:01AM +0000, Jan Beulich wrote:
> Just like done in d2bd05d88d ("xen-pciback: return proper values during
> BAR sizing") for the ROM BAR, ordinary ones also shouldn't compare the
> written value directly against ~0, but consider the r/o bits at the
> bottom (if any).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-27 20:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <59C8D3DD020000780017F39A@suse.com>
2017-09-26 6:43 ` [PATCH] xen-pciback: relax BAR sizing write value check Juergen Gross
2017-09-27 20:00 ` Boris Ostrovsky
2017-09-25 8:01 Jan Beulich
2017-09-25 11:27 ` Roger Pau Monné
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).