Skip to contentSkip to conversation

PCI passthrough will cause unknown device appearance in device manager of Windows OS via xenstore keys

DISCUSSION NAK lidonglin 7 participants 15 messages Apr 10, 2017 – Apr 13, 2017 Xen hypervisor interface

lore
Share & tools
lore

lidonglin

author
#0 lore raw

Hi all:
I have one question about PCI passthrough. I found that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore? I think Passthrough is not PV, was it possible that we just used these keys to record something?

2. After review the code, I think backend keys are used to record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will appear in device manager. Can we fix this? For an obsessive, he can't stand for this.

Cfg file as below:
builder = "hvm"
name = "win2008_server_r2_sp1_64"
viridian = 1
memory = 8192
maxmem = 8192
vcpus = 4
disk = [ '/mnt /win2008_server_ent_r2_sp1_64_gputhrough_vhd,vhd,xvda,rw' ] vnc = 1
vnclisten = 'xxx.xxx.xxx.xxx'
vncdisplay = 0
usb = 1
usbdevice = ['tablet']
pci = ["0000:06:00.0"]

I use xen-4.8.0 version.

Xenstore keys
For domU
/local/domain/5/device/vkbd/0/backend = "/local/domain/0/backend/vkbd/5/0" /local/domain/5/device/vkbd/0/backend-id = "0" /local/domain/5/device/vkbd/0/state = "1" /local/domain/5/device/pci = ""
/local/domain/5/device/pci/0 = "" /local/domain/5/device/pci/0/backend = "/local/domain/0/backend/pci/5/0" /local/domain/5/device/pci/0/backend-id = "0" /local/domain/5/device/pci/0/state = "1" /local/domain/5/control = ""

For dom0
/local/domain/0/backend/vkbd/5/0/feature-abs-pointer = "1" /local/domain/0/backend/vkbd/5/0/hotplug-status = "connected" /local/domain/0/backend/pci = ""
/local/domain/0/backend/pci/5 = ""
/local/domain/0/backend/pci/5/0 = "" /local/domain/0/backend/pci/5/0/frontend = "/local/domain/5/device/pci/0" /local/domain/0/backend/pci/5/0/frontend-id = "5" /local/domain/0/backend/pci/5/0/online = "1" /local/domain/0/backend/pci/5/0/state = "3" /local/domain/0/backend/pci/5/0/domain = "win2008_server_r2_sp1_64" /local/domain/0/backend/pci/5/0/key-0 = "0000:06:00.0" /local/domain/0/backend/pci/5/0/dev-0 = "0000:06:00.0" /local/domain/0/backend/pci/5/0/vdevfn-0 = "20" /local/domain/0/backend/pci/5/0/opts-0 = "msitranslate=0,power_mgmt=0,permissive=0" /local/domain/0/backend/pci/5/0/state-0 = "3" /local/domain/0/backend/pci/5/0/num_devs = "1" /local/domain/0/backend/pci/5/0/vdev-0 = "0000:00:00.00" /local/domain/0/backend/pci/5/0/root-0 = "0000:00" /local/domain/0/backend/pci/5/0/root_num = "1"
/local/domain/5 = ""
/local/domain/5/vm = "/vm/81296e36-1576-4b58-bb6e-17dc2b4ea1f6"

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 16 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

This is a libxl bug which has been reported before, but nothing happened.

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 26 lines · Andrew Cooper
Quoted 16 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

Quoted 9 lines

This is a libxl bug which has been reported before, but nothing happened.

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

ISTR Konrad made some comments about it. CC Konrad.

Quoted 1 line

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 33 lines · Wei Liu
Quoted 32 lines · Andrew Cooper
Quoted 16 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

This is a libxl bug which has been reported before, but nothing happened.

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

Quoted 5 lines
Quoted 3 lines

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

ISTR Konrad made some comments about it. CC Konrad.

Aye. My primary beef was that you need some FLR mechanism and pciback does that. The 'do_flr' was the solution to that - as you could effectively do it via an ioctl and all would be good.

Except I am probably missing some edge case (like guest is killed and we need to do an FLR again, or there are AERs to deal with, etc) so some pciback -> xenstore -> libxl needs to be in place even for HVM guests.

Just disabling pciback for HVM does not solve the problem that:

- We need FLR
- We need AER support (CC-ing Venu who is working on this for libxl/pciback)

Quoted 2 lines
Quoted 2 lines

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 40 lines · Konrad Rzeszutek Wilk
Quoted 27 lines · Wei Liu
Quoted 26 lines · Andrew Cooper
Quoted 15 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

This is a libxl bug which has been reported before, but nothing happened.

Quoted 8 lines
Quoted 7 lines

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

ISTR Konrad made some comments about it. CC Konrad.

Aye. My primary beef was that you need some FLR mechanism and pciback does that. The 'do_flr' was the solution to that - as you could effectively do it via an ioctl and all would be good.

Quoted 8 lines

Except I am probably missing some edge case (like guest is killed and we need to do an FLR again, or there are AERs to deal with, etc) so some pciback -> xenstore -> libxl needs to be in place even for HVM guests.

Just disabling pciback for HVM does not solve the problem that:

- We need FLR
- We need AER support (CC-ing Venu who is working on this for libxl/pciback)

The problem is that pciback is two distinct pieces of functionality. It should be split in half, so the "steal a device from its real driver and provide reset functionality" is purposefully separate from "be the reverse half the PV interface".

Qemu has no problems with resetting the device when necessary, though, which is why this patch functions perfectly well in a real system.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
Quoted 45 lines · Andrew Cooper
Quoted 44 lines · Konrad Rzeszutek Wilk
Quoted 27 lines · Wei Liu
Quoted 26 lines · Andrew Cooper
Quoted 15 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

This is a libxl bug which has been reported before, but nothing happened.

Quoted 8 lines
Quoted 7 lines

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

ISTR Konrad made some comments about it. CC Konrad.

Aye. My primary beef was that you need some FLR mechanism and pciback does that. The 'do_flr' was the solution to that - as you could effectively do it via an ioctl and all would be good.

Except I am probably missing some edge case (like guest is killed and we need to do an FLR again, or there are AERs to deal with, etc) so some pciback -> xenstore -> libxl needs to be in place even for HVM guests.

Quoted 7 lines
Quoted 4 lines

Just disabling pciback for HVM does not solve the problem that:

- We need FLR
- We need AER support (CC-ing Venu who is working on this for libxl/pciback)

The problem is that pciback is two distinct pieces of functionality. It should be split in half, so the "steal a device from its real driver and

Yes sure.

Quoted 5 lines

provide reset functionality" is purposefully separate from "be the reverse half the PV interface".

Qemu has no problems with resetting the device when necessary, though,

It does? The sysfs 'reset' is does not do everything you expect.

Quoted 3 lines

which is why this patch functions perfectly well in a real system.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
Quoted 56 lines · you
Quoted 45 lines · Andrew Cooper
Quoted 44 lines · Konrad Rzeszutek Wilk
Quoted 27 lines · Wei Liu
Quoted 26 lines · Andrew Cooper
Quoted 15 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

This is a libxl bug which has been reported before, but nothing happened.

Quoted 8 lines
Quoted 7 lines

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

ISTR Konrad made some comments about it. CC Konrad.

Aye. My primary beef was that you need some FLR mechanism and pciback does that. The 'do_flr' was the solution to that - as you could effectively do it via an ioctl and all would be good.

Except I am probably missing some edge case (like guest is killed and we need to do an FLR again, or there are AERs to deal with, etc) so some pciback -> xenstore -> libxl needs to be in place even for HVM guests.

Quoted 7 lines
Quoted 4 lines

Just disabling pciback for HVM does not solve the problem that:

- We need FLR
- We need AER support (CC-ing Venu who is working on this for libxl/pciback)

The problem is that pciback is two distinct pieces of functionality. It should be split in half, so the "steal a device from its real driver and

Yes sure.

Quoted 7 lines
Quoted 5 lines

provide reset functionality" is purposefully separate from "be the reverse half the PV interface".

Qemu has no problems with resetting the device when necessary, though,

It does? The sysfs 'reset' is does not do everything you expect.

I can concur, i use this "do_flr" patchset from Konrad for quite some time now. Without it i can't shutdown and restart HVM guest which use (secondary) GPU passthrough (without rebooting the host), with this patchset that works fine!

With other PCI devices there seems to be less of a problem, but for what i have as a test case these all function with this patchset as well.

In the past the patchset was blocked from upstreaming to the kernel
by David Vrabel on the naming.
Since "FLR" is an actual existing (but not widely spread i guess) hardware reset function from the PCI spec. This patchset does however do something that is more like a "bus reset" and is not limited to devices having the hardware FLR option.

Since the libxl code that runs the sysfs do_flr thing is kind of dead code now, perhaps it's best to rename it to something generic, so it could be extended in the future if support for more reset-methods will be bolted on here ? (so writing some other value to the ioctl could specify which reset methods should be tried on this device)

--
Sander

Quoted 3 lines
Quoted 3 lines

which is why this patch functions perfectly well in a real system.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw
In reply to Andrew Cooper
Quoted 26 lines · Andrew Cooper
Quoted 16 lines · lidonglin

Hi all:

I have one question about PCI passthrough. I found
that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore?
I think Passthrough is not PV, was it possible that we just used
these keys to record something?

Quoted 8 lines

2. After review the code, I think backend keys are used to
record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will
appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

Quoted 5 lines

This is a libxl bug which has been reported before, but nothing happened.

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr ioctl and combine it with your patch.

Quoted 3 lines

The patch, unchanged from before, is
https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

Attaching the flr one (inline) and attachemnt

Quoted 1 line

From 314a0ff66af9380de4cd4c8a7f4f648c6f593bb8 Mon Sep 17 00:00:00 2001

From: Konrad Rzeszutek Wilk <[email protected]>
Date: Wed, 3 Dec 2014 15:47:02 -0500
Subject: [PATCH] xen/pciback: Implement PCI reset slot or bus with 'do_flr'
SysFS attribute

The life-cycle of a PCI device in Xen pciback is complex and is constrained by the PCI generic locking mechanism.

It starts with the device being binded to us - for which we do a device function reset (and done via SysFS so the PCI lock is held)

If the device is unbinded from us - we also do a function reset (also done via SysFS so the PCI lock is held).

If the device is un-assigned from a guest - we do a function reset (no PCI lock).

All on the individual PCI function level (so bus:device:function).

Unfortunatly a function reset is not adequate for certain PCIe devices. The reset for an individual PCI function "means device must support FLR (PCIe or AF), PM reset on D3hot->D0 device specific reset, or be a singleton device on a bus a secondary bus reset. FLR does not have widespread support, reset is not very reliable, and bus topology is dictated by the and device design. We need to provide a means for a user to a bus reset in cases where the existing mechanisms are not
or not reliable. " (Adam Williamson, 'vfio-pci: PCI hot reset
interface' commit 8b27ee60bfd6bbb84d2df28fa706c5c5081066ca).

As such to do a slot or a bus reset is we need another mechanism. This is not exposed SysFS as there is no good way of exposing a bus topology there.

This is due to the complexity - we MUST know that the different functions off a PCIe device are not in use by other drivers, or if they are in use (say one of them is assigned to a guest and the other is idle) - it is still OK to reset the slot (assuming both of them are owned by Xen pciback).

This patch does that by doing an slot or bus reset (if slot not supported) if all of the functions of a PCIe device belong to Xen PCIback. We do not care if the device is in-use as we depend on the toolstack to be aware of this - however if it is we will WARN the user.

Due to the complexity with the PCI lock we cannot do
the reset when a device is binded ('echo $BDF > bind') or when unbinded ('echo $BDF > unbind') as the pci_[slot|bus]_reset also take the same lock resulting in a dead-lock.

Putting the reset function in a workqueue or thread won't work either - as we have to do the reset function outside the 'unbind' context (it holds the PCI lock). But once you 'unbind' a device the device is no longer under the ownership of Xen pciback and the pci_set_drvdata has been reset so we cannot use a thread for this.

Instead of doing all this complex dance, we depend on the toolstack doing the right thing. As such implement the 'do_flr' SysFS attribute which 'xl' uses when a device is detached or attached from/to a guest. It bypasses the need to worry about the PCI lock.

To not inadvertly do a bus reset that would affect devices that are in use by other drivers (other than Xen pciback) prior to the reset we check that all of the devices under the bridge are owned by Xen pciback. If they are not we do not do the bus (or slot) reset.

We also warn the user if the device is in use - but still continue with the reset. This should not happen as the toolstack also does the check.

---
 Documentation/ABI/testing/sysfs-driver-pciback |  12 +++
 drivers/xen/xen-pciback/pci_stub.c             | 124 ++++++++++++++++++++++---
 2 files changed, 125 insertions(+), 11 deletions(-)
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
index 6a733bf..2d4e32f 100644
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           December 2014
+KernelVersion:  3.19
+Contact:        [email protected]
+Description:
+                An option to slot or bus reset an PCI device owned by
+                Xen PCI backend. Writing a string of DDDD:BB:DD.F will cause
+                the driver to perform an slot or bus reset if the device
+                supports. It also checks to make sure that all of the devices
+                under the bridge are owned by Xen PCI backend.
drivers/xen/xen-pciback/pci_stub.c +113 -11

168 lines not on this page · raw message

Signature · 1 line
2.9.3
Quoted 9 lines

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

From 314a0ff66af9380de4cd4c8a7f4f648c6f593bb8 Mon Sep 17 00:00:00 2001

From: Konrad Rzeszutek Wilk <[email protected]>
Date: Wed, 3 Dec 2014 15:47:02 -0500
Subject: [PATCH] xen/pciback: Implement PCI reset slot or bus with 'do_flr'
SysFS attribute

The life-cycle of a PCI device in Xen pciback is complex and is constrained by the PCI generic locking mechanism.

It starts with the device being binded to us - for which we do a device function reset (and done via SysFS so the PCI lock is held)

If the device is unbinded from us - we also do a function reset (also done via SysFS so the PCI lock is held).

If the device is un-assigned from a guest - we do a function reset (no PCI lock).

All on the individual PCI function level (so bus:device:function).

Unfortunatly a function reset is not adequate for certain PCIe devices. The reset for an individual PCI function "means device must support FLR (PCIe or AF), PM reset on D3hot->D0 device specific reset, or be a singleton device on a bus a secondary bus reset. FLR does not have widespread support, reset is not very reliable, and bus topology is dictated by the and device design. We need to provide a means for a user to a bus reset in cases where the existing mechanisms are not
or not reliable. " (Adam Williamson, 'vfio-pci: PCI hot reset
interface' commit 8b27ee60bfd6bbb84d2df28fa706c5c5081066ca).

As such to do a slot or a bus reset is we need another mechanism. This is not exposed SysFS as there is no good way of exposing a bus topology there.

This is due to the complexity - we MUST know that the different functions off a PCIe device are not in use by other drivers, or if they are in use (say one of them is assigned to a guest and the other is idle) - it is still OK to reset the slot (assuming both of them are owned by Xen pciback).

This patch does that by doing an slot or bus reset (if slot not supported) if all of the functions of a PCIe device belong to Xen PCIback. We do not care if the device is in-use as we depend on the toolstack to be aware of this - however if it is we will WARN the user.

Due to the complexity with the PCI lock we cannot do
the reset when a device is binded ('echo $BDF > bind') or when unbinded ('echo $BDF > unbind') as the pci_[slot|bus]_reset also take the same lock resulting in a dead-lock.

Putting the reset function in a workqueue or thread won't work either - as we have to do the reset function outside the 'unbind' context (it holds the PCI lock). But once you 'unbind' a device the device is no longer under the ownership of Xen pciback and the pci_set_drvdata has been reset so we cannot use a thread for this.

Instead of doing all this complex dance, we depend on the toolstack doing the right thing. As such implement the 'do_flr' SysFS attribute which 'xl' uses when a device is detached or attached from/to a guest. It bypasses the need to worry about the PCI lock.

To not inadvertly do a bus reset that would affect devices that are in use by other drivers (other than Xen pciback) prior to the reset we check that all of the devices under the bridge are owned by Xen pciback. If they are not we do not do the bus (or slot) reset.

We also warn the user if the device is in use - but still continue with the reset. This should not happen as the toolstack also does the check.

---
 Documentation/ABI/testing/sysfs-driver-pciback |  12 +++
 drivers/xen/xen-pciback/pci_stub.c             | 124 ++++++++++++++++++++++---
 2 files changed, 125 insertions(+), 11 deletions(-)
Documentation/ABI/testing/sysfs-driver-pciback +12 -0
index 6a733bf..2d4e32f 100644
@@ -11,3 +11,15 @@ Description:
                 #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
                 will allow the guest to read and write to the configuration
                 register 0x0E.
+
+
+What:           /sys/bus/pci/drivers/pciback/do_flr
+Date:           December 2014
+KernelVersion:  3.19
+Contact:        [email protected]
+Description:
+                An option to slot or bus reset an PCI device owned by
+                Xen PCI backend. Writing a string of DDDD:BB:DD.F will cause
+                the driver to perform an slot or bus reset if the device
+                supports. It also checks to make sure that all of the devices
+                under the bridge are owned by Xen PCI backend.
drivers/xen/xen-pciback/pci_stub.c +113 -11

168 lines not on this page · raw message

Signature · 1 line
2.9.3

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw

On Mon, Apr 10, 2017 at 09:43:13AM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 7 lines

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr ioctl and combine it with your patch.

OK. Does that mean the bug is in Linux and I should just take Ross's patch as-is for 4.9?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Nacked-by NAK
#9 lore raw
Quoted 11 lines · Wei Liu

On Mon, Apr 10, 2017 at 09:43:13AM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 7 lines

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr ioctl and combine it with your patch.

OK. Does that mean the bug is in Linux and I should just take Ross's

Please don't.

Or if you would like I can do

Quoted 3 lines

patch as-is for 4.9?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Wei Liu

On Mon, Apr 10, 2017 at 09:43:13AM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 7 lines

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr ioctl and combine it with your patch.

Quoted 8 lines
Quoted 1 line

OK. Does that mean the bug is in Linux and I should just take Ross's

Please don't.

Or if you would like I can do

Please correct me if I'm wrong: current libxl code is broken in one way and taking that patch means to break it in another way?

What is the way forward? Do you want me to wait until those kernel patches are upstreamed?

Wei.

Quoted 4 lines
Quoted 4 lines

patch as-is for 4.9?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw
Quoted 18 lines · Wei Liu
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 11 lines · Wei Liu

On Mon, Apr 10, 2017 at 09:43:13AM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 7 lines

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr ioctl and combine it with your patch.

OK. Does that mean the bug is in Linux and I should just take Ross's

Please don't.

Or if you would like I can do

Quoted 8 lines
Quoted 2 lines

Please correct me if I'm wrong: current libxl code is broken in one way and taking that patch means to break it in another way?

What is the way forward? Do you want me to wait until those kernel patches are upstreamed?

Julien was looking into moving all this reset logic into the hypervisor itself, so that ARM and PVHv2 passthrough doesn't use pciback at all. Maybe it could be done now? AFAICT this would solve the issue under discussion here.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw
Quoted 25 lines · Roger Pau Monné
Quoted 24 lines · Wei Liu
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Wei Liu

On Mon, Apr 10, 2017 at 09:43:13AM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 7 lines

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr ioctl and combine it with your patch.

Quoted 8 lines
Quoted 1 line

OK. Does that mean the bug is in Linux and I should just take Ross's

Please don't.

Or if you would like I can do

Please correct me if I'm wrong: current libxl code is broken in one way and taking that patch means to break it in another way?

Quoted 6 lines
Quoted 2 lines

What is the way forward? Do you want me to wait until those kernel patches are upstreamed?

Julien was looking into moving all this reset logic into the hypervisor itself, so that ARM and PVHv2 passthrough doesn't use pciback at all. Maybe it could be done now? AFAICT this would solve the issue under discussion here.

That is a medium to long term goal and I wouldn't rely on it to fix an outstanding bug.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw
In reply to Wei Liu
Quoted 24 lines · Wei Liu
Quoted 2 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Wei Liu

On Mon, Apr 10, 2017 at 09:43:13AM -0400, Konrad Rzeszutek Wilk

Quoted 6 lines · wrote:
Quoted 6 lines

[...]

Quoted 5 lines

.. Except that we need some way of doing FLR and Pciback is the one doing it.

The right way would be to expand pciback to support the do_flr

ioctl

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

and combine it with your patch.

OK. Does that mean the bug is in Linux and I should just take

Ross's

Quoted 7 lines

Please don't.

Or if you would like I can do

Quoted 6 lines

Please correct me if I'm wrong: current libxl code is broken in one way and
taking that patch means to break it in another way?

What is the way forward? Do you want me to wait until those kernel patches are upstreamed?

Yes, as we cannot allow PCI pass through devices to not have an FLR or proper configuration register reset when a passing a device to a guest (or from one guest to another).

I can figure something up next week on how to restructure the pciback module.

Quoted 7 lines

Wei.

Quoted 4 lines
Quoted 4 lines

patch as-is for 4.9?

Wei.

Thanks!

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#14 lore raw
In reply to Andrew Cooper
Quoted 1 line

The patch, unchanged from before, is https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

This patch means that no xenstore keys will be created for HVM. For this, I have one question that :
libxl__device_pci_add --> libxl_pcidev_assignable --> libxl_device_pci_assignable_list --> get_all_assigned_devices

this call stack will happen when creating pci passthrough vm. If no backend keys exist in xenstore, get_all_assigned_devices() will not work. Because get_all_assigned_devices needs to get info from backend xenstore keys.

So am I right?
发件人: Andrew Cooper [mailto:[email protected]]
发送时间: 2017年4月10日 20:46
收件人: Wei Liu <[email protected]>; Ian Jackson <[email protected]>
抄送: lidonglin <[email protected]>; [email protected]; Xuquan (Quan Xu) <[email protected]>; [email protected]; Wei Liu ([email protected]) <[email protected]>; Yanqiangjun <[email protected]>; Fanhenglong <[email protected]>; dengkai (A) <[email protected]> 主题: Re: [Xen-devel] PCI passthrough will cause unknown device appearance in device manager of Windows OS via xenstore keys

On 10/04/17 12:24, lidonglin wrote:
Hi all:
I have one question about PCI passthrough. I found that if I created a VM with host pci device(cfg file as below), there were some xenstore keys exsiting in /local/domain/0 and /local/domain/DomID/. Besides I found one unknown device in device manager of Windows OS with Class ID FF80 from vendor ID 5853. My questions are as below:

1. Why do we create frontend and backend key pairs in xenstore? I think Passthrough is not PV, was it possible that we just used these keys to record something?

2. After review the code, I think backend keys are used to record state of hostdev, some codes will query something using these keys. But for frontend keys, can we delete them?

3. if frontend keys exist in xenstore, then unknown device will appear in device manager. Can we fix this? For an obsessive, he can’t stand for this.

This is a libxl bug which has been reported before, but nothing happened.

libxl must not start a PV pci-back when doing HVM PCI passthrough using qemu, because absolutely nothing good can come of having two different ways of poking at PCI state.

The patch, unchanged from before, is https://github.com/xenserver/xen-4.7.pg/blob/master/master/0001-libxl-Don-t-insert-PCI-device-into-xenstore-for-HVM-.patch

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel