xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Issues with PCI-Passtrough (VT-d) in HVM with Xen 4.6
@ 2016-06-02 19:59 Sylwester Sosnowski
  2016-06-02 20:06 ` Konrad Rzeszutek Wilk
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Sylwester Sosnowski @ 2016-06-02 19:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Jeremy Fitzhardinge


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

Background
----------

I am trying to passthrough an Industrial Ethernet Interface
(Hilscher GmbH CIFX 50E-DP(M/S)) on a HVM DomU running the
Xen 4.6 Hypervisor. The card is being pass-trough to the HVM
using the PCI permissive mode and VT-d is active on this platform.

The Linux driver of the card (available only with NDA) at first
sight seems to work properly (e.g. no system stability problems,
no call traces in dmesg).

Hilscher provides the libcifx, which is an user-level library
for accessing the card. libcfix uses the generic UIO interface
and some card-specific interfaces to communicate.

Issue
-----

Whenever libcifx tries perform a reset sequence initializing
the card peripherals, we get an empty / invalid result.

I digged deeper into this by adding some debug hooks into the
xen-pciback kernel module.

The card performs writes to offset 0x10 and 0x30 at card
initialization (mostly writing dwords and words).

To verify if the writes were performed successfully, I read
back the values after writing and can see that the read data
differs from the written one.

Temporary Fix
-------------

After checking the source[1] of the PCI configuration space
handling in xen-pciback, I found out that changing line 258
to read

    if (handled && !err) {

instead of:

    if (!handled && !err) {

solves the issue and I can successfully write to the interface.

I am unsure why this works and if it's the right way to do it
or possibly a Xen bug, so I would like to ask for feedback
for this.


Please let me know whenever I can supply additional logfiles or
info. I'd be happy if we can resolve whenever this is a hardware-
specific, driver-specific or Xen issue.

Thank you,
Sylwester

PS: I tried to CC Ryan Wilson and Konrad Rzeszutek Wilk, but the
E-Mail seems to be no longer active. This is where the changes
originated.

Refereces
---------
1.
https://github.com/google/kasan/blob/master/drivers/xen/xen-pciback/conf_space.c

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Issues with PCI-Passtrough (VT-d) in HVM with Xen 4.6
@ 2016-06-15 10:45 Andrey Grodzovsky
  2016-06-15 13:14 ` Jan Beulich
  0 siblings, 1 reply; 22+ messages in thread
From: Andrey Grodzovsky @ 2016-06-15 10:45 UTC (permalink / raw)
  To: xen-devel; +Cc: Jürgen Walter • Quattru


[-- Attachment #1.1: Type: text/plain, Size: 1321 bytes --]

In reply to -
http://lists.xen.org/archives/html/xen-devel/2016-06/msg00622.html

HI, I am working with Jurgen on the issue, as per Jan's request I tried to
write explicitly only latency timer to be written -
bool force_write = false;
if ((dev_data->permissive || xen_pcibk_permissive) &&
              offset == PCI_CACHE_LINE_SIZE && size == 4)
             force_write = true;
...

if ((force_write || !handled) && !err) {...}

But then it exposed another issue, the command register field seems not to
be restored also
because I think the bits which are to be restored are not
in PCI_COMMAND_GUEST mask.

The only hack which always works for me is force write even if the
confpsace fields filter doens't allow it -

+       int remainder = size;
+
        if (unlikely(verbose_request))
                printk(KERN_DEBUG
                       DRV_NAME ": %s: write request %d bytes at 0x%x =
%x\n",
@@ -252,10 +254,11 @@ int xen_pcibk_config_write(struct pci_dev *dev, int
offset, int size, u32 value)
                         * special helpers to work correctly.
                         */
                        handled = 1;
+                       remainder -= field->size
                }
        }

-       if (!handled && !err) {
+       if ((remainder || !handled) && !err) {


Thanks.

Andrey Grodzovsky.

[-- Attachment #1.2: Type: text/html, Size: 2029 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread
* Issues with PCI-Passtrough (VT-d) in HVM with Xen 4.6
@ 2016-06-02 19:49 Sylwester Sosnowski
  0 siblings, 0 replies; 22+ messages in thread
From: Sylwester Sosnowski @ 2016-06-02 19:49 UTC (permalink / raw)
  To: xen-devel; +Cc: Jeremy Fitzhardinge


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

Background
----------

I am trying to passthrough an Industrial Ethernet Interface
(Hilscher GmbH CIFX 50E-DP(M/S)) on a HVM DomU running the
Xen 4.6 Hypervisor. The card is being pass-trough to the HVM
using the PCI permissive mode and VT-d is active on this platform.

The Linux driver of the card (available only with NDA) at first
sight seems to work properly (e.g. no system stability problems,
no call traces in dmesg).

Hilscher provides the libcifx, which is an user-level library
for accessing the card. libcfix uses the generic UIO interface
and some card-specific interfaces to communicate.

Issue
-----

Whenever libcifx tries perform a reset sequence initializing
the card peripherals, we get an empty / invalid result.

I digged deeper into this by adding some debug hooks into the
xen-pciback kernel module.

The card performs writes to offset 0x10 and 0x30 at card
initialization (mostly writing dwords and words).

To verify if the writes were performed successfully, I read
back the values after writing and can see that the read data
differs from the written one.

Temporary Fix
-------------

After checking the source[1] of the PCI configuration space
handling in xen-pciback, I found out that changing line 258
to read

    if (handled && !err) {

instead of:

    if (!handled && !err) {

solves the issue and I can successfully write to the interface.

I am unsure why this works and if it's the right way to do it
or possibly a Xen bug, so I would like to ask for feedback
for this.


Please let me know whenever I can supply additional logfiles or
info. I'd be happy if we can resolve whenever this is a hardware-
specific, driver-specific or Xen issue.

Thank you,
Sylwester

PS: I tried to CC Ryan Wilson and Konrad Rzeszutek Wilk, but the
E-Mail seems to be no longer active. This is where the changes
originated.

Refereces
---------
1.
https://github.com/google/kasan/blob/master/drivers/xen/xen-pciback/conf_space.c

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-06-20  6:57 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-02 19:59 Issues with PCI-Passtrough (VT-d) in HVM with Xen 4.6 Sylwester Sosnowski
2016-06-02 20:06 ` Konrad Rzeszutek Wilk
2016-06-02 20:11   ` Sylwester Sosnowski
2016-06-03  7:24 ` Sylwester Sosnowski
2016-06-03 11:52 ` Jan Beulich
2016-06-03 12:02   ` Jürgen Walter
2016-06-03 13:26     ` Jan Beulich
2016-06-03 14:20       ` Jan Beulich
2016-06-04 14:36         ` Jürgen Walter
2016-06-06  7:59           ` Jan Beulich
2016-06-04 15:15       ` Jürgen Walter
2016-06-06  8:41         ` Jan Beulich
2016-06-06  9:09           ` Jürgen Walter
2016-06-06  9:43             ` Jan Beulich
2016-06-06 14:01           ` Boris Ostrovsky
2016-06-06 14:21             ` Jan Beulich
2016-06-06 14:45               ` Boris Ostrovsky
  -- strict thread matches above, loose matches on Subject: below --
2016-06-15 10:45 Andrey Grodzovsky
2016-06-15 13:14 ` Jan Beulich
2016-06-18  3:24   ` Andrey Grodzovsky
2016-06-20  6:57     ` Jan Beulich
2016-06-02 19:49 Sylwester Sosnowski

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).