All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Pass through in Xen
@ 2017-07-20  6:36 ajmalmalib4u
  2017-07-20  8:35 ` Roger Pau Monné
  0 siblings, 1 reply; 7+ messages in thread
From: ajmalmalib4u @ 2017-07-20  6:36 UTC (permalink / raw)
  To: Roger Pau Monné, xen-devel; +Cc: georgeeldhojohn

[-- Attachment #1: Type: text/html, Size: 4328 bytes --]

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

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

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

* Re: Pass through in Xen
  2017-07-20  6:36 Pass through in Xen ajmalmalib4u
@ 2017-07-20  8:35 ` Roger Pau Monné
  2017-07-25 12:29   ` ajmalmalib4u
  0 siblings, 1 reply; 7+ messages in thread
From: Roger Pau Monné @ 2017-07-20  8:35 UTC (permalink / raw)
  To: ajmalmalib4u; +Cc: georgeeldhojohn, xen-devel

On Thu, Jul 20, 2017 at 12:06:18PM +0530, ajmalmalib4u wrote:
>     Hi,
>    >> > Can anyone please explain or point me to a thread where I can read
>    about 
>    >> > the internals of PCI passthrough or How passthrough actually works? 
>    >>
>    >> For PV: 
>    >>
>    >> http://elixir.free-electrons.com/linux/latest/source/drivers/xen/xen-pciback 
>    >> http://elixir.free-electrons.com/linux/latest/source/drivers/pci/xen-pcifront.c 
>    I tried going through the source code but I'am unable to derive a flow of
>    control through the drivers.
>    Is there any source which can explain the behavior of these drivers
>    elaborately?
>    How are xen-pciback and xen-pcifront utilizing the PCI functions offered
>    by Linux?

No, I'm afraid there's no other source of documentation for Xen
pciback/pcifront in Linux. There's also a pciback/pcifront
implementation in NetBSD, you might find that one easier to
understand:

http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/arch/xen/xen/pciback.c?rev=1.12&content-type=text/plain
http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/arch/xen/xen/xpci_xenbus.c?rev=1.14.10.1&content-type=text/plain

Roger.

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

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

* Re: Pass through in Xen
  2017-07-20  8:35 ` Roger Pau Monné
@ 2017-07-25 12:29   ` ajmalmalib4u
  2017-07-26  8:42     ` Roger Pau Monné
  0 siblings, 1 reply; 7+ messages in thread
From: ajmalmalib4u @ 2017-07-25 12:29 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: georgeeldhojohn, xen-devel

[-- Attachment #1: Type: text/html, Size: 1570 bytes --]

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

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

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

* Re: Pass through in Xen
  2017-07-25 12:29   ` ajmalmalib4u
@ 2017-07-26  8:42     ` Roger Pau Monné
  2017-07-27  8:27       ` ajmalmalib4u
  0 siblings, 1 reply; 7+ messages in thread
From: Roger Pau Monné @ 2017-07-26  8:42 UTC (permalink / raw)
  To: ajmalmalib4u; +Cc: georgeeldhojohn, xen-devel

On Tue, Jul 25, 2017 at 05:59:04PM +0530, ajmalmalib4u wrote:
>    Hi,
>    >> > I have successfully tested a PCI device in my PC. 
>    >> > As per my current understanding, the control flow for PCI passthrough
>    is 
>    >> > “xen-pcifront -> xen-pciback -> driver”. Is this correct? 
>    >> That's for PV guests, and only for accesses to the PCI config space. 
>    >> Device MMIO regions are mapped directly into DomU.
>    I am using PV guests.
>    Where does the PCI MMIO gets mapped to DomU? Is it done by the front and
>    back drivers?

I don't think so, AFAIK (and I'm not expert in PV passthrough), the
toolstack sets the permissions of the DomU to allow it to map MMIO
regions that belong to the device (see do_pci_add in libxl_pci.c), and
then the DomU itself establishes the mappings using the PV MMU
interface.

>    Or Is the mapping only happening at the hardware level where IOMMU handles
>    it without Dom0's or DomU's knowledge?

How's that possible? IOMMU needs to know the GFN -> MFN relation, so
some entity in the system has to program it.

>    If possible, could you please point me to the right source file or block
>    of code in Xen source which handles this mapping of PCI memory regions?
>    Also, Does the normal PCI driver in the Linux kernel plays any role in PCI
>    passthrough?

Yes, the native Linux driver is still used. Pcifront is only used as a
different mechanism to access the configuration space, but that's just
it, it's just a different transport than writing to IO ports or MMCFG
areas.

> Or Is it the front and back drivers, that does all of it?
>    Does the front and back drivers access the PCI driver in the Linux kernel
>    at any point?

No, the flow is the following:

             Config space        Shared ring
Native driver +--------> pcifront +-------> pciback
     +
     |
     |   BAR access
     +-----------------> MMIO

Roger.

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

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

* Re: Pass through in Xen
  2017-07-26  8:42     ` Roger Pau Monné
@ 2017-07-27  8:27       ` ajmalmalib4u
  0 siblings, 0 replies; 7+ messages in thread
From: ajmalmalib4u @ 2017-07-27  8:27 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: georgeeldhojohn, xen-devel

[-- Attachment #1: Type: text/html, Size: 907 bytes --]

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

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

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

* Re: Pass through in Xen
  2017-07-18 11:13 ajmalmalib4u
@ 2017-07-18 11:23 ` Roger Pau Monné
  0 siblings, 0 replies; 7+ messages in thread
From: Roger Pau Monné @ 2017-07-18 11:23 UTC (permalink / raw)
  To: ajmalmalib4u; +Cc: georgeeldhojohn, xen-devel

On Tue, Jul 18, 2017 at 04:43:53PM +0530, ajmalmalib4u wrote:
>    Hi,
>     
>    I am trying to learn how Passthrough works in xen. As an initial step I
>    have tried to do PCI passthrough in my PC with Ubuntu 16.04 LTS (Xenial
>    Xerus) as Dom0 and DomU. For that I had to rebuild the kernel to add xen
>    support and with the procedure explained in,
>     
>    https://wiki.xenproject.org/wiki/Xen_PCI_Passthrough

Not really sure whether you need to do that anymore, I would expect
Ubuntu to ship a kernel with pcifront/pciback already enabled, at
least as modules.

>    I have successfully tested a PCI device in my PC.
>    As per my current understanding, the control flow for PCI passthrough is
>    “xen-pcifront -> xen-pciback -> driver”. Is this correct?

That's for PV guests, and only for accesses to the PCI config space.
Device MMIO rehions are mapped directy into DomU.

For HVM guests QEMU is used instead, which emulates and forwards PCI
config space accesses from DomU to the real hardware.

>    Should the Dom0 and DomU have the Driver enabled in there kernel?

Which Driver? If you mean the device driver, then yes, you need a
driver in order to operate the hardware in DomU, just as you do on
native.

It's not needed on Dom0 if you never plan to use the device on Dom0.

>    Can anyone please explain or point me to a thread where I can read about
>    the internals of PCI passthrough or How passthrough actually works?

For PV:

http://elixir.free-electrons.com/linux/latest/source/drivers/xen/xen-pciback
http://elixir.free-electrons.com/linux/latest/source/drivers/pci/xen-pcifront.c

For HVM:

http://git.qemu.org/?p=qemu.git;a=blob;f=hw/xen/xen_pt.c
http://git.qemu.org/?p=qemu.git;a=blob;f=hw/xen/xen_pt_config_init.c
http://git.qemu.org/?p=qemu.git;a=blob;f=hw/xen/xen_pt_graphics.c
http://git.qemu.org/?p=qemu.git;a=blob;f=hw/xen/xen_pt_msi.c

Roger.

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

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

* Pass through in Xen
@ 2017-07-18 11:13 ajmalmalib4u
  2017-07-18 11:23 ` Roger Pau Monné
  0 siblings, 1 reply; 7+ messages in thread
From: ajmalmalib4u @ 2017-07-18 11:13 UTC (permalink / raw)
  To: xen-devel; +Cc: georgeeldhojohn

[-- Attachment #1: Type: text/html, Size: 1539 bytes --]

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

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

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

end of thread, other threads:[~2017-07-27  8:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20  6:36 Pass through in Xen ajmalmalib4u
2017-07-20  8:35 ` Roger Pau Monné
2017-07-25 12:29   ` ajmalmalib4u
2017-07-26  8:42     ` Roger Pau Monné
2017-07-27  8:27       ` ajmalmalib4u
  -- strict thread matches above, loose matches on Subject: below --
2017-07-18 11:13 ajmalmalib4u
2017-07-18 11:23 ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.