XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D

The Linux Foundation
The Linux FoundationDirector, Open Source Solutions at Citrix
Status of PCI emulation in Xen
Roger Pau Monn´e
roger.pau@citrix.com
Chicago – July 9th, 2019
PCI bus PCI-passthroughon Xen Moving forward
PCI bus
Allows attaching hardware devices in a computer.
First specification developed by Intel in 1992.
Superseded VESA, MCA, EISA, NuBus...
Two standards:
PCI local bus.
PCI Express.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 2 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI slots on a motherboard
Obtained from wikipedia author snickerdo.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 3 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI card
Chicago – July 9th, 2019 Status of PCI emulation in Xen 4 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI configuration space
The PCI configuration space provides 256bytes or 4096bytes
of configuration space to each device.
Devices are identified by a 8bit bus, 5bit device and 3bit
function integers.
First 64bytes is standardized, the rest is device dependent
(contains capability structures).
Allows for easy discovery of devices. OS can scan the whole
bus in order to detect present devices.
On x86 can be accessed from IO space (legacy) or memory
(enhanced).
Chicago – July 9th, 2019 Status of PCI emulation in Xen 5 / 20
PCI bus PCI-passthroughon Xen Moving forward
Legacy PCI configuration access
Indirect access using the IO address space.
Address port at 0xcf8:
012781011151623243031
E RSV Bus Device Func Register RSV
Data port at 0xcfc.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 6 / 20
PCI bus PCI-passthroughon Xen Moving forward
Enhanced PCI configuration access
Maps the full config space registers into memory space.
0111214151920272831
Base Bus Device Func Register
If on 64bit mode bits from 63-32 also contain the base
address.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 7 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI header
0781516232431
Status Command 04h
Base Address 0 16h
Base Address 1 20h
Base Address 2 24h
Base Address 3 28h
Base Address 4 32h
Base Address 5 36h
CardBus CIS Pointer 40h
Subsystem ID Subsystem Vendor ID 44h
Expansion ROM Base Address 44h
Chicago – July 9th, 2019 Status of PCI emulation in Xen 8 / 20
PCI bus PCI-passthroughon Xen Moving forward
MSI capability
0781516232431
Message control Next pointer Capability ID 00h
Message Address [31, 0] 04h
Message Address [63, 32] 08h
Reserved Message Data 12h
Mask Bits 16h
Pending bits 20h
Chicago – July 9th, 2019 Status of PCI emulation in Xen 9 / 20
PCI bus PCI-passthroughon Xen Moving forward
MSI-X capability
0781516232431
Message control Next pointer Capability ID 00h
MSI-X Table Offset BIR 04h
PBA Offset BIR 08h
0
31
32
63
64
Vector Control Message Data
Upper Address Lower Address
Entry 0
...
...
Vector Control Message Data
Upper Address Lower Address
Entry N
Chicago – July 9th, 2019 Status of PCI emulation in Xen 10 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI handling in Xen
PV privileged domain (dom0) gets almost unlimited access to
the PCI config space:
Xen controls the MSI(-X) mask bits in order to keep a
coherent state when doing PCI-passthrough to HVM guests.
Read only access is allowed to the MSI-X table and the MSI
data and address registers.
Passthrough of PCI devices to unprivileged guests:
PV guests can access the PCI config space using a Xen PV
specific protocol (pciif).
HVM guests can access the PCI config space emulated by a
device model (QEMU).
PVH guests have no PCI-passthrough support yet.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 11 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI-passthrough for domUs
Hardware
Xen
Control Domain (VM0)
PV1 HVM1
user-space
kernel
QEMU
evtchn devpciback
Chicago – July 9th, 2019 Status of PCI emulation in Xen 12 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI-passthrough for domUs
PV domU communicates directly with pciback using a shared
memory ring and a Xen specific protocol.
Passthrough to HVM domUs is handled by QEMU, much like
emulated devices:
PCI config space accesses are forwarded by Xen to QEMU
using ioreqs.
QEMU emulates or forwards those accesses to the underlying
device.
Xen directly handles guest writes to the MSI-X mask bits for
performance reasons.
Device MMIO regions (BARs) are directly mapped to the
guest physmap, except for the MSI-X region if present.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 13 / 20
PCI bus PCI-passthroughon Xen Moving forward
PV dom0
Has almost unlimited read/write access to the configuration
space except for certain parts of the MSI(-X) capabilities.
Has to use hypercalls to deal with certain capabilities:
MSI/MSI-X.
Is fully trusted to not misbehave.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 14 / 20
PCI bus PCI-passthroughon Xen Moving forward
PVH dom0
PVH is a HVM guest from Xen’s point of view.
HVM-like access to the configuration space:
Transparent access to the MSI/MSI-X capabilities.
Transparent mapping of BARs into the physmap and handling
of writes to the BAR registers.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 15 / 20
PCI bus PCI-passthroughon Xen Moving forward
PVH dom0
Current PCI-passthrough code for HVM is in QEMU.
Impossible to use QEMU for PVH dom0.
No re-use of the QEMU PCI-passthrough code: would need
heavy modifications that would make sharing changes very
difficult.
Added a PCI config space mediator to the hypervisor: vPCI.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 16 / 20
PCI bus PCI-passthroughon Xen Moving forward
PCI-passthrough mediators in Xen
QEMU (user-space) and Xen for MSI-X mask bits for HVM
domUs.
pciback (hardware domain OS) for PV domUs.
Direct access / hypercalls for PV dom0.
vPCI (hypervisor) for PVH dom0.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 17 / 20
PCI bus PCI-passthroughon Xen Moving forward
Shortcomings
No support for VFIO/MDEV on Xen:
Threatening support for vGPU/XenGT in future releases.
3 different code bases to deal with PCI config space accesses:
More maintainership work.
Non uniform behaviour across different guests types.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 18 / 20
PCI bus PCI-passthroughon Xen Moving forward
Future items
Re-work vPCI so it can be used both inside the hypervisor and
in user-space.
Could be used by HVM and PVH guests as a standalone
PCI-passthrough utility.
Unify PCI-passthrough for HVM and PVH both domU and
dom0 into a single code-base.
Add support for the extended config space to HVM domUs:
allow to passthrough PCIe capabilities.
Add support to passthrough SRIOV capability to vPCI, for
PVH dom0.
Chicago – July 9th, 2019 Status of PCI emulation in Xen 19 / 20
PCI bus PCI-passthroughon Xen Moving forward
Q&A
Thanks
Questions?
Chicago – July 9th, 2019 Status of PCI emulation in Xen 20 / 20
1 of 20

Recommended

03_03_Implementing_PCIe_ATS_in_ARM-based_SoCs_Final by
03_03_Implementing_PCIe_ATS_in_ARM-based_SoCs_Final03_03_Implementing_PCIe_ATS_in_ARM-based_SoCs_Final
03_03_Implementing_PCIe_ATS_in_ARM-based_SoCs_FinalGopi Krishnamurthy
2.3K views28 slides
PCIe and PCIe driver in WEC7 (Windows Embedded compact 7) by
PCIe and PCIe driver in WEC7 (Windows Embedded compact 7)PCIe and PCIe driver in WEC7 (Windows Embedded compact 7)
PCIe and PCIe driver in WEC7 (Windows Embedded compact 7)gnkeshava
5.3K views24 slides
PCIe by
PCIePCIe
PCIeChiaYang Tsai
2.7K views14 slides
How To Use AGL CAN Signal by
How To Use AGL CAN SignalHow To Use AGL CAN Signal
How To Use AGL CAN SignalYuichi Kusakabe
392 views34 slides
IBM Flex System CN4054 10Gb Virtual Fabric Adapter and EN4054 4-port 10Gb Eth... by
IBM Flex System CN4054 10Gb Virtual Fabric Adapter and EN4054 4-port 10Gb Eth...IBM Flex System CN4054 10Gb Virtual Fabric Adapter and EN4054 4-port 10Gb Eth...
IBM Flex System CN4054 10Gb Virtual Fabric Adapter and EN4054 4-port 10Gb Eth...IBM India Smarter Computing
600 views13 slides
Fosdem 17 - Towards a HVM-like Dom0 for Xen by
Fosdem 17 - Towards a HVM-like Dom0 for XenFosdem 17 - Towards a HVM-like Dom0 for Xen
Fosdem 17 - Towards a HVM-like Dom0 for XenThe Linux Foundation
690 views18 slides

More Related Content

Similar to XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D

XPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, Citrix by
XPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, CitrixXPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, Citrix
XPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, CitrixThe Linux Foundation
390 views17 slides
Status update-qemu-pcie by
Status update-qemu-pcieStatus update-qemu-pcie
Status update-qemu-pcieThe Linux Foundation
2.2K views39 slides
XS Boston 2008 VT-D PCI by
XS Boston 2008 VT-D PCIXS Boston 2008 VT-D PCI
XS Boston 2008 VT-D PCIThe Linux Foundation
830 views12 slides
PCI_Express_Basics_Background.pdf by
PCI_Express_Basics_Background.pdfPCI_Express_Basics_Background.pdf
PCI_Express_Basics_Background.pdfzahixdd
14 views45 slides
Graphics virtualization by
Graphics virtualizationGraphics virtualization
Graphics virtualizationThe Linux Foundation
1.1K views20 slides
Graphics virtualization by
Graphics virtualizationGraphics virtualization
Graphics virtualizationThe Linux Foundation
1 view20 slides

Similar to XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D(20)

XPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, Citrix by The Linux Foundation
XPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, CitrixXPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, Citrix
XPDDS17: PVH Dom0: The Road so Far - Roger Pau Monné, Citrix
PCI_Express_Basics_Background.pdf by zahixdd
PCI_Express_Basics_Background.pdfPCI_Express_Basics_Background.pdf
PCI_Express_Basics_Background.pdf
zahixdd14 views
Slideshare - PCIe by Jin Wu
Slideshare - PCIeSlideshare - PCIe
Slideshare - PCIe
Jin Wu12.3K views
PCIe BUS: A State-of-the-Art-Review by IOSRJVSP
PCIe BUS: A State-of-the-Art-ReviewPCIe BUS: A State-of-the-Art-Review
PCIe BUS: A State-of-the-Art-Review
IOSRJVSP305 views
PLNOG 13: Artur Pająk: Storage w sieciach Ethernet, czyli coś o iSCSI I FCoE by PROIDEA
PLNOG 13: Artur Pająk: Storage w sieciach Ethernet, czyli coś o iSCSI I FCoEPLNOG 13: Artur Pająk: Storage w sieciach Ethernet, czyli coś o iSCSI I FCoE
PLNOG 13: Artur Pająk: Storage w sieciach Ethernet, czyli coś o iSCSI I FCoE
PROIDEA649 views
XPDDS17: Keynote: Towards a Configurable and Slimmer x86 Hypervisor - Wei Liu... by The Linux Foundation
XPDDS17: Keynote: Towards a Configurable and Slimmer x86 Hypervisor - Wei Liu...XPDDS17: Keynote: Towards a Configurable and Slimmer x86 Hypervisor - Wei Liu...
XPDDS17: Keynote: Towards a Configurable and Slimmer x86 Hypervisor - Wei Liu...
Cisco UCS vs HP Virtual Connect by Stefano Soliani
Cisco UCS vs HP Virtual ConnectCisco UCS vs HP Virtual Connect
Cisco UCS vs HP Virtual Connect
Stefano Soliani5.1K views
Io Architecture by Aero Plane
Io ArchitectureIo Architecture
Io Architecture
Aero Plane505 views
Project ACRN expose and pass through platform hidden PCIe devices to SOS by Project ACRN
Project ACRN expose and pass through platform hidden PCIe devices to SOSProject ACRN expose and pass through platform hidden PCIe devices to SOS
Project ACRN expose and pass through platform hidden PCIe devices to SOS
Project ACRN114 views
An AI accelerator ASIC architecture by Khanh Le
An AI accelerator ASIC architectureAn AI accelerator ASIC architecture
An AI accelerator ASIC architecture
Khanh Le970 views
directCell - Cell/B.E. tightly coupled via PCI Express by Heiko Joerg Schick
directCell - Cell/B.E. tightly coupled via PCI ExpressdirectCell - Cell/B.E. tightly coupled via PCI Express
directCell - Cell/B.E. tightly coupled via PCI Express
Heiko Joerg Schick786 views
ACRN Kata Container on ACRN by Project ACRN
ACRN Kata Container on ACRNACRN Kata Container on ACRN
ACRN Kata Container on ACRN
Project ACRN415 views

More from The Linux Foundation

ELC2019: Static Partitioning Made Simple by
ELC2019: Static Partitioning Made SimpleELC2019: Static Partitioning Made Simple
ELC2019: Static Partitioning Made SimpleThe Linux Foundation
4.1K views33 slides
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ... by
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...The Linux Foundation
1K views17 slides
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu... by
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...The Linux Foundation
1K views19 slides
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op... by
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...The Linux Foundation
819 views24 slides
XPDDS19 Keynote: Unikraft Weather Report by
XPDDS19 Keynote:  Unikraft Weather ReportXPDDS19 Keynote:  Unikraft Weather Report
XPDDS19 Keynote: Unikraft Weather ReportThe Linux Foundation
923 views58 slides
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E... by
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...The Linux Foundation
941 views17 slides

More from The Linux Foundation(20)

XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ... by The Linux Foundation
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu... by The Linux Foundation
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op... by The Linux Foundation
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E... by The Linux Foundation
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx by The Linux Foundation
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxXPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys... by The Linux Foundation
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender by The Linux Foundation
XPDDS19: Memories of a VM Funk - Mihai Donțu, BitdefenderXPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
XPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng... by The Linux Foundation
OSSJP/ALS19:  The Road to Safety Certification: Overcoming Community Challeng...OSSJP/ALS19:  The Road to Safety Certification: Overcoming Community Challeng...
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...
OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making... by The Linux Foundation
 OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making... OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix by The Linux Foundation
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, CitrixXPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd by The Linux Foundation
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltdXPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant... by The Linux Foundation
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems by The Linux Foundation
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM SystemsXPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven... by The Linux Foundation
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib... by The Linux Foundation
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr... by The Linux Foundation
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE by The Linux Foundation
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSEXPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Implementing AMD MxGPU - Jonathan Farrell, Assured Information Security by The Linux Foundation
XPDDS19: Implementing AMD MxGPU - Jonathan Farrell, Assured Information SecurityXPDDS19: Implementing AMD MxGPU - Jonathan Farrell, Assured Information Security
XPDDS19: Implementing AMD MxGPU - Jonathan Farrell, Assured Information Security

Recently uploaded

STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
13 views1 slide
DALI Basics Course 2023 by
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023Ivory Egg
16 views12 slides
Special_edition_innovator_2023.pdf by
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
17 views6 slides
ChatGPT and AI for Web Developers by
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web DevelopersMaximiliano Firtman
187 views82 slides
Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
27 views39 slides

Recently uploaded(20)

STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb13 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg16 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2217 views
6g - REPORT.pdf by Liveplex
6g - REPORT.pdf6g - REPORT.pdf
6g - REPORT.pdf
Liveplex10 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex22 views
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291616 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta19 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker33 views

XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D

  • 1. Status of PCI emulation in Xen Roger Pau Monn´e roger.pau@citrix.com Chicago – July 9th, 2019
  • 2. PCI bus PCI-passthroughon Xen Moving forward PCI bus Allows attaching hardware devices in a computer. First specification developed by Intel in 1992. Superseded VESA, MCA, EISA, NuBus... Two standards: PCI local bus. PCI Express. Chicago – July 9th, 2019 Status of PCI emulation in Xen 2 / 20
  • 3. PCI bus PCI-passthroughon Xen Moving forward PCI slots on a motherboard Obtained from wikipedia author snickerdo. Chicago – July 9th, 2019 Status of PCI emulation in Xen 3 / 20
  • 4. PCI bus PCI-passthroughon Xen Moving forward PCI card Chicago – July 9th, 2019 Status of PCI emulation in Xen 4 / 20
  • 5. PCI bus PCI-passthroughon Xen Moving forward PCI configuration space The PCI configuration space provides 256bytes or 4096bytes of configuration space to each device. Devices are identified by a 8bit bus, 5bit device and 3bit function integers. First 64bytes is standardized, the rest is device dependent (contains capability structures). Allows for easy discovery of devices. OS can scan the whole bus in order to detect present devices. On x86 can be accessed from IO space (legacy) or memory (enhanced). Chicago – July 9th, 2019 Status of PCI emulation in Xen 5 / 20
  • 6. PCI bus PCI-passthroughon Xen Moving forward Legacy PCI configuration access Indirect access using the IO address space. Address port at 0xcf8: 012781011151623243031 E RSV Bus Device Func Register RSV Data port at 0xcfc. Chicago – July 9th, 2019 Status of PCI emulation in Xen 6 / 20
  • 7. PCI bus PCI-passthroughon Xen Moving forward Enhanced PCI configuration access Maps the full config space registers into memory space. 0111214151920272831 Base Bus Device Func Register If on 64bit mode bits from 63-32 also contain the base address. Chicago – July 9th, 2019 Status of PCI emulation in Xen 7 / 20
  • 8. PCI bus PCI-passthroughon Xen Moving forward PCI header 0781516232431 Status Command 04h Base Address 0 16h Base Address 1 20h Base Address 2 24h Base Address 3 28h Base Address 4 32h Base Address 5 36h CardBus CIS Pointer 40h Subsystem ID Subsystem Vendor ID 44h Expansion ROM Base Address 44h Chicago – July 9th, 2019 Status of PCI emulation in Xen 8 / 20
  • 9. PCI bus PCI-passthroughon Xen Moving forward MSI capability 0781516232431 Message control Next pointer Capability ID 00h Message Address [31, 0] 04h Message Address [63, 32] 08h Reserved Message Data 12h Mask Bits 16h Pending bits 20h Chicago – July 9th, 2019 Status of PCI emulation in Xen 9 / 20
  • 10. PCI bus PCI-passthroughon Xen Moving forward MSI-X capability 0781516232431 Message control Next pointer Capability ID 00h MSI-X Table Offset BIR 04h PBA Offset BIR 08h 0 31 32 63 64 Vector Control Message Data Upper Address Lower Address Entry 0 ... ... Vector Control Message Data Upper Address Lower Address Entry N Chicago – July 9th, 2019 Status of PCI emulation in Xen 10 / 20
  • 11. PCI bus PCI-passthroughon Xen Moving forward PCI handling in Xen PV privileged domain (dom0) gets almost unlimited access to the PCI config space: Xen controls the MSI(-X) mask bits in order to keep a coherent state when doing PCI-passthrough to HVM guests. Read only access is allowed to the MSI-X table and the MSI data and address registers. Passthrough of PCI devices to unprivileged guests: PV guests can access the PCI config space using a Xen PV specific protocol (pciif). HVM guests can access the PCI config space emulated by a device model (QEMU). PVH guests have no PCI-passthrough support yet. Chicago – July 9th, 2019 Status of PCI emulation in Xen 11 / 20
  • 12. PCI bus PCI-passthroughon Xen Moving forward PCI-passthrough for domUs Hardware Xen Control Domain (VM0) PV1 HVM1 user-space kernel QEMU evtchn devpciback Chicago – July 9th, 2019 Status of PCI emulation in Xen 12 / 20
  • 13. PCI bus PCI-passthroughon Xen Moving forward PCI-passthrough for domUs PV domU communicates directly with pciback using a shared memory ring and a Xen specific protocol. Passthrough to HVM domUs is handled by QEMU, much like emulated devices: PCI config space accesses are forwarded by Xen to QEMU using ioreqs. QEMU emulates or forwards those accesses to the underlying device. Xen directly handles guest writes to the MSI-X mask bits for performance reasons. Device MMIO regions (BARs) are directly mapped to the guest physmap, except for the MSI-X region if present. Chicago – July 9th, 2019 Status of PCI emulation in Xen 13 / 20
  • 14. PCI bus PCI-passthroughon Xen Moving forward PV dom0 Has almost unlimited read/write access to the configuration space except for certain parts of the MSI(-X) capabilities. Has to use hypercalls to deal with certain capabilities: MSI/MSI-X. Is fully trusted to not misbehave. Chicago – July 9th, 2019 Status of PCI emulation in Xen 14 / 20
  • 15. PCI bus PCI-passthroughon Xen Moving forward PVH dom0 PVH is a HVM guest from Xen’s point of view. HVM-like access to the configuration space: Transparent access to the MSI/MSI-X capabilities. Transparent mapping of BARs into the physmap and handling of writes to the BAR registers. Chicago – July 9th, 2019 Status of PCI emulation in Xen 15 / 20
  • 16. PCI bus PCI-passthroughon Xen Moving forward PVH dom0 Current PCI-passthrough code for HVM is in QEMU. Impossible to use QEMU for PVH dom0. No re-use of the QEMU PCI-passthrough code: would need heavy modifications that would make sharing changes very difficult. Added a PCI config space mediator to the hypervisor: vPCI. Chicago – July 9th, 2019 Status of PCI emulation in Xen 16 / 20
  • 17. PCI bus PCI-passthroughon Xen Moving forward PCI-passthrough mediators in Xen QEMU (user-space) and Xen for MSI-X mask bits for HVM domUs. pciback (hardware domain OS) for PV domUs. Direct access / hypercalls for PV dom0. vPCI (hypervisor) for PVH dom0. Chicago – July 9th, 2019 Status of PCI emulation in Xen 17 / 20
  • 18. PCI bus PCI-passthroughon Xen Moving forward Shortcomings No support for VFIO/MDEV on Xen: Threatening support for vGPU/XenGT in future releases. 3 different code bases to deal with PCI config space accesses: More maintainership work. Non uniform behaviour across different guests types. Chicago – July 9th, 2019 Status of PCI emulation in Xen 18 / 20
  • 19. PCI bus PCI-passthroughon Xen Moving forward Future items Re-work vPCI so it can be used both inside the hypervisor and in user-space. Could be used by HVM and PVH guests as a standalone PCI-passthrough utility. Unify PCI-passthrough for HVM and PVH both domU and dom0 into a single code-base. Add support for the extended config space to HVM domUs: allow to passthrough PCIe capabilities. Add support to passthrough SRIOV capability to vPCI, for PVH dom0. Chicago – July 9th, 2019 Status of PCI emulation in Xen 19 / 20
  • 20. PCI bus PCI-passthroughon Xen Moving forward Q&A Thanks Questions? Chicago – July 9th, 2019 Status of PCI emulation in Xen 20 / 20