diff mbox

Issues with PCI-Passtrough (VT-d) in HVM with Xen 4.6

Message ID 5751AE6402000078000F1A07@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich June 3, 2016, 2:20 p.m. UTC
>>> On 03.06.16 at 15:26, <JBeulich@suse.com> wrote:
>>>> On 03.06.16 at 14:02, <juwalter@gmail.com> wrote:
>>     or is this just some method the overwrite all registers with 
>> "ffffffff" first and then set the actual value?
>> 
>>    [914572] xbk: 06:00.0: write request 4 bytes at 0x10 = ffffffff
>>    [914574] xbk: 06:00.0: read 4 bytes at 0x10
>>    [914582] xbk: 06:00.0: read 4 bytes at 0x10 = f7a00000
>>    [914591] xbk: 06:00.0: read 4 bytes at 0x10
>>    [914599] xbk: 06:00.0: read 4 bytes at 0x10 = 10000      <---- fail
> 
> That's an unexpected value, indeed (but seems to match up with
> the source, so there's definitely something wrong here - this
> presumably ought to be 0xffff0000, meaning the size of that
> region is 64k).

Mind trying out the attached patch?

Jan
xen-pciback: return proper values during BAR sizing

Reads following writes with all address bits set to 1 should return all
changeable address bits as one, not the BAR size (nor, as was the case
for the upper half of 64-bit BARs, the high half of the region's end
address). Presumably this didn't cause any problems so far because
consumers use the value to calculate the size (usually via val & -val),
and do nothing else with it.

But also consider the exception here: Unimplemented BARs should always
return all zeroes.

And finally, the check for whether to return the sizing address on read
for the ROM BAR should ignore all non-address bits, not just the ROM
Enable one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Jürgen Walter June 4, 2016, 2:36 p.m. UTC | #1
Hi Jan,


On 3 Jun 2016, at 16:20, Jan Beulich wrote:

>>>> On 03.06.16 at 15:26, <JBeulich@suse.com> wrote:
>>>>> On 03.06.16 at 14:02, <juwalter@gmail.com> wrote:
>>>     or is this just some method the overwrite all registers with
>>> "ffffffff" first and then set the actual value?
>>>
>>>    [914572] xbk: 06:00.0: write request 4 bytes at 0x10 = ffffffff
>>>    [914574] xbk: 06:00.0: read 4 bytes at 0x10
>>>    [914582] xbk: 06:00.0: read 4 bytes at 0x10 = f7a00000
>>>    [914591] xbk: 06:00.0: read 4 bytes at 0x10
>>>    [914599] xbk: 06:00.0: read 4 bytes at 0x10 = 10000      <---- 
>>> fail
>>
>> That's an unexpected value, indeed (but seems to match up with
>> the source, so there's definitely something wrong here - this
>> presumably ought to be 0xffff0000, meaning the size of that
>> region is 64k).
>
> Mind trying out the attached patch?

Many thanks for your patch!! I did try it, and it is different now 
(details in files attached)

"best of conf_space_header" see below.

I cannot really make sense of it, though. Can you?

Thank you, Jürgen


original:

xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = 10000


patched:

xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = ffff0000
==> pci-attach-orig-grep <==
3906.673306] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = ffffffff
3906.673307] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
3906.673313] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
--
3906.673338] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = f7a00000
3906.673339] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
3906.673345] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = 10000
--
3906.673405] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = ffffffff
3906.673406] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
3906.673413] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
--
3906.673434] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = 0
3906.673436] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
3906.673442] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 1
--
3906.673496] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = ffffffff
3906.673498] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
3906.673504] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
--
3906.673526] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = 0
3906.673528] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
3906.673533] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 1
--
3906.673590] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = ffffffff
3906.673598] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
3906.673612] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
--
3906.673660] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = 0
3906.673670] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
3906.673684] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 1
--
3906.673747] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = ffffffff
3906.673749] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
3906.673756] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
--
3906.673801] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = 0
3906.673804] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
3906.673812] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 1
--
3906.673988] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = ffffffff
3906.673992] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
3906.674002] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
--
3906.674067] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = 0
3906.674069] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
3906.674076] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 1
--
3906.674146] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = fffff800
3906.674149] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
3906.674156] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
--
3906.674220] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = 0
3906.674223] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
3906.674232] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0

==> pci-attach-jan-grep <==
4743.120637] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = ffffffff
4743.120638] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
4743.120645] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
--
4743.120675] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = f7a00000
4743.120677] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
4743.120685] xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = ffff0000
--
4743.120741] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = ffffffff
4743.120742] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
4743.120749] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
--
4743.120779] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = 0
4743.120781] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
4743.120788] xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
--
4743.120845] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = ffffffff
4743.120847] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
4743.120854] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
--
4743.120884] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = 0
4743.120886] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
4743.120891] xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
--
4743.120954] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = ffffffff
4743.120955] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
4743.120961] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
--
4743.120993] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = 0
4743.120994] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
4743.121000] xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
--
4743.121055] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = ffffffff
4743.121058] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
4743.121064] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
--
4743.121098] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = 0
4743.121099] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
4743.121107] xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
--
4743.121171] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = ffffffff
4743.121173] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
4743.121180] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
--
4743.121205] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = 0
4743.121207] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
4743.121214] xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
--
4743.121278] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = fffff800
4743.121280] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
4743.121287] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
--
4743.121326] xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = 0
4743.121328] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
4743.121333] xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
pciback 0000:06:00.0: enabling permissive mode configuration space accesses!
pciback 0000:06:00.0: permissive mode is potentially unsafe!
xen_pciback: vpci: 0000:06:00.0: assign to virtual slot 0
pciback 0000:06:00.0: registering for 33
xen-pciback: 0000:06:00.0: read 4 bytes at 0x0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x0 = 15cf
xen-pciback: 0000:06:00.0: read 1 bytes at 0xe
xen-pciback: 0000:06:00.0: read 1 bytes at 0xe = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 4 bytes at 0x8
xen-pciback: 0000:06:00.0: read 4 bytes at 0x8 = ff000000
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d = 1
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c = 10
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = 10000
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = 10000
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 1
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 1
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 1
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 1
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 1
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = fffff800
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2c
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2c = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2e
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2e = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: write request 2 bytes at 0x4 = 2
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: enable
pciback 0000:06:00.0: enabling device (0000 -> 0002)
xen: registering gsi 16 triggering 0 polarity 1
Already setup the GSI :16
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c = 10
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 2
pciback 0000:06:00.0: enabling permissive mode configuration space accesses!
pciback 0000:06:00.0: permissive mode is potentially unsafe!
xen_pciback: vpci: 0000:06:00.0: assign to virtual slot 0
pciback 0000:06:00.0: registering for 33
xen-pciback: 0000:06:00.0: read 4 bytes at 0x0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x0 = 15cf
xen-pciback: 0000:06:00.0: read 1 bytes at 0xe
xen-pciback: 0000:06:00.0: read 1 bytes at 0xe = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 4 bytes at 0x8
xen-pciback: 0000:06:00.0: read 4 bytes at 0x8 = ff000000
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d = 1
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c = 10
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = ffff0000
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x10 = f7a00000
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10
xen-pciback: 0000:06:00.0: read 4 bytes at 0x10 = ffff0000
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14
xen-pciback: 0000:06:00.0: read 4 bytes at 0x14 = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18
xen-pciback: 0000:06:00.0: read 4 bytes at 0x18 = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c
xen-pciback: 0000:06:00.0: read 4 bytes at 0x1c = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20
xen-pciback: 0000:06:00.0: read 4 bytes at 0x20 = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = ffffffff
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24
xen-pciback: 0000:06:00.0: read 4 bytes at 0x24 = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = fffff800
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: write request 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30
xen-pciback: 0000:06:00.0: read 4 bytes at 0x30 = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2c
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2c = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2e
xen-pciback: 0000:06:00.0: read 2 bytes at 0x2e = 0
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6
xen-pciback: 0000:06:00.0: read 2 bytes at 0x6 = 200
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: write request 2 bytes at 0x4 = 2
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 0
xen-pciback: 0000:06:00.0: enable
pciback 0000:06:00.0: enabling device (0000 -> 0002)
xen: registering gsi 16 triggering 0 polarity 1
Already setup the GSI :16
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3c = 10
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d
xen-pciback: 0000:06:00.0: read 1 bytes at 0x3d = 1
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4
xen-pciback: 0000:06:00.0: read 2 bytes at 0x4 = 2
Jan Beulich June 6, 2016, 7:59 a.m. UTC | #2
>>> On 04.06.16 at 16:36, <juwalter@gmail.com> wrote:
> On 3 Jun 2016, at 16:20, Jan Beulich wrote:
>> Mind trying out the attached patch?
> 
> Many thanks for your patch!! I did try it, and it is different now 
> (details in files attached)
> 
> "best of conf_space_header" see below.
> 
> I cannot really make sense of it, though. Can you?

Sure - it's now as expected. As said - there are read-only bits at the
bottom of all of the BAR registers.

Jan
diff mbox

Patch

--- head.orig/drivers/xen/xen-pciback/conf_space_header.c	2015-03-16 15:38:59.000000000 +0100
+++ head/drivers/xen/xen-pciback/conf_space_header.c	2016-06-03 15:55:27.629520779 +0200
@@ -149,7 +149,7 @@  static int rom_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 == ~PCI_ROM_ADDRESS_ENABLE)
+	if ((value | ~PCI_ROM_ADDRESS_MASK) == ~0)
 		bar->which = 1;
 	else {
 		u32 tmpval;
@@ -229,38 +229,42 @@  static inline void read_dev_bar(struct p
 			   (PCI_BASE_ADDRESS_SPACE_MEMORY |
 				PCI_BASE_ADDRESS_MEM_TYPE_64))) {
 			bar_info->val = res[pos - 1].start >> 32;
-			bar_info->len_val = res[pos - 1].end >> 32;
+			bar_info->len_val = -resource_size(&res[pos - 1]) >> 32;
 			return;
 		}
 	}
 
+	if (!res[pos].flags ||
+	    (res[pos].flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET |
+			       IORESOURCE_BUSY)))
+		return;
+
 	bar_info->val = res[pos].start |
 			(res[pos].flags & PCI_REGION_FLAG_MASK);
-	bar_info->len_val = resource_size(&res[pos]);
+	bar_info->len_val = -resource_size(&res[pos]) |
+			    (res[pos].flags & PCI_REGION_FLAG_MASK);
 }
 
 static void *bar_init(struct pci_dev *dev, int offset)
 {
-	struct pci_bar_info *bar = kmalloc(sizeof(*bar), GFP_KERNEL);
+	struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL);
 
 	if (!bar)
 		return ERR_PTR(-ENOMEM);
 
 	read_dev_bar(dev, bar, offset, ~0);
-	bar->which = 0;
 
 	return bar;
 }
 
 static void *rom_init(struct pci_dev *dev, int offset)
 {
-	struct pci_bar_info *bar = kmalloc(sizeof(*bar), GFP_KERNEL);
+	struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL);
 
 	if (!bar)
 		return ERR_PTR(-ENOMEM);
 
 	read_dev_bar(dev, bar, offset, ~PCI_ROM_ADDRESS_ENABLE);
-	bar->which = 0;
 
 	return bar;
 }