SlideShare a Scribd company logo
1 of 39
Download to read offline
Expose and pass through platform hidden PCIe devices to SOS
SSP.ACRN
Li, Fei
agenda
⚫ The background
⚫ Why does ACRN need to expose and pass through
platform hidden PCI(e) devices to SOS
⚫ How ACRN to expose and pass through platform hidden
PCI(e) devices to SOS
Part One - The background
Terms
PCI - Peripheral Component Interconnect
PCIe - Peripheral Component Interconnect Express
Address Spaces
Four address spaces are defined
The Layout of PCI Configuration Space
The Layout of PCIe Configuration Space
PCI-compatible Configuration Mechanism
Bus Number - is an encoded value used to select 1 of 256 buses in a system.
Device Number - is an encoded value used to select one of 32 devices on a given bus.
Function Number - is an encoded value used to select one of eight possible functions
on a multifunction device.
Register Number - is an encoded value used to select a DWORD in the Configuration
Space of the intended target.
PCI-compatible Configuration Mechanism
CONFIG_ADDRESS (CF8h)
CONFIG_DATA (CFCh - CFFh)
IE: read PCIe device 00:1c.0 Header Type (0xEh)
Write (1 << 31) | (0 << 16) | (1c << 11) | (0 << 8) | (0xE & 0xFC) to IO Port CF8h
Read one byte data from IO Port CFCh + (0xE – (0xE & 0xFC))
PCI Express Enhanced Configuration Access Mechanism
(ECAM)
PCI Express Enhanced Configuration Access Mechanism
(ECAM)
PCI MMCONFIG Address 0xe0000000 (physical address,
bus 00-ff)
IE: read PCIe device 00:1c.0 Header Type (0xEh)
Read four bytes data form MMIO 0xe0000000 + (0 << 20) |
(1c << 15) | (0 << 12) | (0xE & 0xFC)
PCIe devices on NUC
Vendor ID Register (Offset 00h)
The Vendor ID register is HwInit and the value in this register identifies the
manufacturer of the Function. In keeping with PCI-SIG procedures, valid vendor
identifiers must be allocated by the PCI-SIG to ensure uniqueness. Each vendor must
have at least one Vendor ID. It is recommended that software read the Vendor ID
register to determine if a Function is present, where a value of FFFFh indicates that no
Function is present.
Part Two - Why does ACRN need to
expose and pass through platform
hidden PCI(e) devices to SOS
ACRN needs to trap ECAM for SOS
⚫ SOS shouldn’t access the PCIe devices which have assigned to
UOS.
⚫ SOS needs to trap some PCIe external capability access and handle
this correctly. For example, for the SR-IOV support.
So now ACRN hypervisor will trap each PCIe configuration access (no
matter by IO port or MMIO) and check whether the PCIe device
belongs to the guest which trigger the access.
Why does ACRN need to expose and pass through
platform hidden PCI(e) devices to SOS
However, there’re some PCIe devices hidden by BIOS which can’t been discovered by
read Vendor ID simply. For example, Intel Primary to Sideband Bridge. The BIOS could
hide/unhide it by enabling/disabling HIDE bit in P2SB Control Register.
To make things worse, SOS on APL UP2 will call ACPI method to set eMMC controller to
D3Hot Power State which will trigger P2SB ECAM access.
Why does ACRN need to expose and pass through
platform hidden PCI(e) devices to SOS
Scope (_SB.PCI0)
{
OperationRegion (P2CG, SystemMemory, 0xE00680D0, 0x20) – PCI device 00:0d.0 CFG Space [0xD0 – 0x100)
Field (P2CG, DWordAcc, NoLock, Preserve)
{
SBAD, 32,
SBDA, 32,
IRDY, 1,
, 6,
POST, 1,
OPCD, 8,
SBID, 16,
SBEA, 32,
Offset (0x11),
P2HD, 8 - P2SB Control Hide Device
}
Why does ACRN need to expose and pass through
platform hidden PCI(e) devices to SOS
Method (SBIM, 4, Serialized)
{
Local0 = Zero
Local1 = Acquire (_GL, 0x1F40)
If ((Local1 == Zero))
{
P2HD = Zero
While (IRDY)
{
Sleep (One)
}
SBAD &= 0x00F00000
SBAD |= Arg0
SBEA = Zero
SBDA = Arg1
SBID &= 0x0800
SBID |= Arg3
POST = Zero
OPCD = Arg2
IRDY = One
While (IRDY)
{
Sleep (One)
}
Local0 = SBDA /* _SB_.PCI0.SBDA */
P2HD = One
}
Release (_GL)
Scope (SDHA)
{
Name (_DDN, "Intel(R) eMMC Controller - 80865ACC") // _DDN:
DOS Device Name
Name (_UID, One) // _UID: Unique ID
Method (_PS3, 0, NotSerialized) // _PS3: Power State 3
{
Local0 = SBIM (0xD600003C, Zero, Zero, 0x30E0)
Local1 = SBIM (0xD6000834, Zero, Zero, 0x30E0)
Local2 = SBIM (0xD6000840, Zero, Zero, 0x30E0)
If ((Local0 & 0x00800000))
{
Local3 = (((Local2 & 0x1F) * 0x02) + ((Local1 &
0x3F00) >> 0x08))
Local1 = ((Local1 & 0xFFFFFF80) | (Local3 & 0x7F))
SBIM (0xD6000834, Local1, One, 0x30E0)
}
DPGE = One
I3EN = One
SCPG (One, 0x41)
Local0 = PMSR /* _SB_.PCI0.SDHA.PMSR */
Local0 &= One
}
Why does ACRN need to expose and pass through
platform hidden PCI(e) devices to SOS
We didn’t assign hidden PCIe devices to SOS before. As a result, SOS thought this
device didn’t belong to itself. So this access was ignored.
And the eMMC controller Power State setting was failed. This would make SOS
hardly working since it seemed this was the only thing it cared – keeping setting if
failed.
Part Three - How ACRN to expose and pass through
platform hidden PCI(e) devices to SOS
How ACRN to expose and pass through platform hidden
PCI(e) devices to SOS
Just add the platform hidden PCIe devices into plat_hidden_pdevs structure on your
board configuration in arch/x86/configs/$(BOARD)/board.c and the platform hidden
PCIe devices number (MAX_HIDDEN_PDEVS_NUM) in
arch/x86/configs/$(BOARD)/misc_cfg.h
NOTE: Not each platform hidden PCIe device should expose and pass through to SOS. If
this hidden device only used to trigger watchdog. (After we support RT-VM, SOS should
not trigger hardware watchdog to reset the whole system if RT-VM is alive)
How ACRN to discover platform hidden PCI(e) devices
dm/vpci/vpci.c
Q & A
Thanks
DM Emulated/Touched Legacy/ACPI Devices
IRQ IO/MMIO Expose to UOS by Comments
RTC 8 0x70~0x71 DSDT: PNP0B00 Expose if enabled LPC
UART 3,4 0x2F8, 0x3F8 DSDT: PNP0501 Expose if enabled LPC
ACPI PM 9 0xCF9,
0x400~0x404,
0xb2
FADT
reset register, PM1A, SMI
Always Expose
ACPI Idle N/A N/A DSDT Always Expose
HV emulated, hcall to fetch Cx info; no need after
CPU sharing
ACPI P-state N/A N/A DSDT Always Expose
HV emulated, hcall to fetch Px info; no need after
CPU sharing
PIC 2 0x20, 0xA0 DSDT: PNP0000 Expose if enabled LPC
(except RTVM)
HV emulated
PIT 0 0x40 DSDT: PNP0100 Expose if enabled LPC
HPET N/A 0xFED00000 HPET
DSDT: PNP0103
Always Expose
KBD/MOU 1,12 0x60,0x64 DSDT: PNP0303, PNP0F13 Expose if enabled LPC
TPM N/A 0xFED40000 TPM2
DSDT: MSFT0101
Optional (through cmdline opt)
DM Emulated PCI Devices
• Interrupt (if the device request INTx support)
• DM allocate INTA/B/C/D for each device in same slot (bus:dev) -> fill to IRQ_PIN (0x3d)
• DM allocate PIRQ (pin & pic_irq) for each slot INTA/B/C/D -> fill to IRQ_LINE(0x3c)
• DM allocate AIRQ (IOAPIC gsi) for each slot INTA/B/C/D
• DM create PPRT & APRT based on PIRQ (SLOT:INTx vs. PIRQ) & AIRQ (SLOT:INTx vs. AIRQ)
• Bar
• Each PCI bridge 32bit/64bit MMIO range -> DSDT
• DM allocate bar for each device based on each bus
• BDF
• Set by DM cmdline
Assumption for Device Emulation between HV & DM
• Limit HV emulated devices
• Legacy device for vUART & vRTC
• PCI devices for PCI bridge (for pre-launched or service VM), PT devices, vWatchdog & PCI based vUART
• NO ACPI device
• For PCI devices in a post-launched VM
• DM own PCI bridge and other pure emulated PCI devices
• HV own PT devices
• HV own necessary pure emulated PCI device, only support MSI interrupt
• For RTVM under LAPIC PT mode, PT devices shall only support MSI interrupt, NO INTx
• If a PT device explicitly depend on other PT devices, only support it when all depend PT devices pass-thru to this VM
• If a PT device implicitly depend on some other resource coming from native ACPI table, NOT support it
• If a PT device depend on DM emulated device, NOT support it?
Proposal for HV Emulated Legacy Device in DM-
launched VM
• DM own overall resource management
• Interrupt – IOAPIC/PIC pins
• ACPI – DSDT (_PTR) etc
• Legacy devices
• Pre-alignment for the resource configuration between DM & HV
• Configurable to choose DM or HV one, or just directly use HV vm_config and ignore DM config, as HV IO emulation has
priority
Proposal-1 for HV Emulated PCI Devices in DM-
launched VM
• DM own overall resource management
• Interrupt – IOAPIC/PIC pins
• PCI – BDF, bar range, INTx
• ACPI – DSDT (_PTR) etc
• PCI devices
• PT PCI device move to HV
• vPCI for UOS
• DM add device through hypercall with necessary resource info allocated
• type : could be vWatchdog, vUART, PT
• vBDF, pBDF: pBDF only for PT device type
• INTx
• bar (include MSIX bar)
SOS
PT vPCI Dev in DM
Proposal-1 – PT PCI Dev in UOS
Initialization
vBDF
HV
UOS
PCI Dev
INTx
BAR
hypercall
IO Request
UOS vpci
PCI Request
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBD
F
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
Other Dev in DM
1 2
1) DM allocate resource
❑ DM analyze PT device physical info based on SOS vPCI, to
allocate all necessary resource [vBDF, BAR, INTx]
2) DM hypercall to add_dev
❑ Combine hypercalls (ASSIGN_PTDEV,
SET_PTDEV_INTR_INFO) into one – ADD_DEV [type=PTDEV,
vBDF, pBDF, BAR, INTx]
❑ vpci_init_pt_dev with DM allocated resource
3) UOS PCI Dev access trap to HV
❑ Parse PCI IO request
❑ Filter out PCI IO request for HV owned PT PCI Device
❑ Others PCI IO request still send up to DM like the old way
SOS vpci
3
Proposal-2 for HV Emulated PCI Devices in DM-
launched VM
• Pre-partitioned resource between DM & HV
• BDF:
• DM own bus 0 and HV own bus 1
• Bar:
• pre-aligned partition MMIO range for bus 0 and bus 1, DM need prepare ACPI info for bus 1 PCI bridge
• INTx:
• pre-aligned partition INTx gsi range, DM need prepare ACPI PRT for PCI devices under bus 1
• Config:
• HV could pre-define UOS Ptdev list in its vm_config, or DM define it during runtime configuration
Suggestion for Emulated Device Matrix
Resource[1] allocated
in Emulated in ACPI prepared by Support Assumption
DM HV DM HV DM HV
Host Bridge Y Y Y Always need
Normal Bridge Y Y Y If there is extra PCI bus
PTDev
INTx
(w/ vLAPIC) Proposal 1 Proposal 2 Y Y - for PRT
Not support if VM is using PT lapic;
It's necessary to PT UART/I2C kind of legacy
PCI devices;
ACPI table only cover PRT;
MSI/MSIX Proposal 1 Proposal 2 Y No ACPI table for it
other PTDev
explicitly dep on [2] Proposal 1 Proposal 2 Y Y - for PSx
Only support if all dep devices pass-thru to this
VM;
ACPI table only cover PM related if needed??
other implicitly
Resource dep on [3] No plan to support
Other
devices
HV emulated
PCI device Proposal 1 Proposal 2 Y Only support MSI for emulated PCI device
HV emulated legacy
device Pre-aligned Pre-aligned Y Y ACPI only cover for emulated legacy device
DM emulated
legacy & PCI device Y Y Y
[1] Resource include BAR, INTx and BDF etc.
[2] PTDev may explicitly depend on other PTDev like I2C, UART, its driver or ACPI method like PSx need work based on such devices
[3] PTDev may depend on other implicitly resource or DM emulated device, for example, it may need DM emulated GPIO, or its ACPI method like PSx need work based on NVS ram passed MMIO
like side-band access
Backup
SOS
Pure vPCI Dev in DM
DM Emulated PCI Devices
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
hypercall
vLAPIC/vIOAPIC/vPI
C
IO Request
MMIO BAR
• DM emulate all PCI resource
• Virtual config space
• INTx
• BAR range
• vBDF
• ACPI table (PRT etc)
• DM inject virq through hypercall
SOS
PT vPCI Dev in DM
DM Emulated PT PCI Devices - Initialization
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR Map
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBDF
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
hypercall
IOMMU
PTIRQ
EPT
1
2
3
4
5
• SOS own PT dev original – DM access
through SOS vPCI
1) DM build
❑ vDev cfg space based on SOS vPCI dev
❑ vMSIX bar map based on SOS vPCI dev
2) DM initialize HV stuff through hypercall
3) Assign IOMMU domain for this PT dev to UOS
4) Assign PTIRQ entries for this PT dev to UOS
❑ vINTx vs. pINTx
❑ vMSI vs. pMSI
❑ vMSIX vs. pMSIX
5) Add EPT mapping of MMIO bar for this PT dev to
UOS
SOS vpci
SOS
PT vPCI Dev in DM
DM Emulated PT PCI Devices – MMIO BAR Access
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR Map
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBDF
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
EPT
• UOS PCI Dev directly access physical bar
based on EPT mapping
SOS
PT vPCI Dev in DM
DM Emulated PT PCI Devices – Interrupt Injection
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR Map
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBDF
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
PTIRQ
1) Physical device trigger physical interrupt
❑ pINTx
❑ pMSI/pMSIX
2) Do_irq match ptirq mapping
❑ pINTx -> vINTx -> vVector
❑ pMSI/pMSIX -> vMSI/vMSIX -> vVector
3) Do_irq inject vVector to guest
Do_irq
1
2
3
SOS
PT vPCI Dev in DM
DM Emulated PT PCI Devices – Modify MMIO BAR CFG
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
IO Request
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR Map
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBDF
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
EPT
1
23
1) UOS PCI Dev access cfg space trap to HV
2) HV raise IO request to DM
3) DM notice MMIO bar update
❑ Directly modify BAR cfg based on SOS vPCI dev
❑ SOS vPCI will remap the EPT mapping
** it’s actually a long & obscure flow
SOS vpci
SOS
PT vPCI Dev in DM
DM Emulated PT PCI Devices – Modify MSIX
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
IO Request
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR Map
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBDF
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
1
23
1) UOS PCI Dev access MSIX MMIO trap to HV
2) HV raise IO request to DM
3) DM notice MSIX MMIO access
❑ Directly modify MSIX BAR map based on SOS vPCI dev
❑ SOS vPCI will modify the PTIRQ entry for related MSIX entry
** Modify MSIX could be destination, delivery mode
change which lead to physical MSI msg change
** it’s actually a long & obscure flow
PTIRQ
SOS vpci
SOS
PT vPCI Dev in DM
DM Emulated PT PCI Devices – Modify MSI cfg
VIRT CFG SPACE
BAR cfg
vBDF
HV
UOS
PCI Dev
IO Request
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
PT Physical Dev in HV
CFG SPACE
BAR cfg MMIO BAR
pBDF
INTx cfg
MSI cfg
MSIX cfg
MSIX BAR
1
23
1) UOS PCI Dev access cfg space trap to HV
2) HV raise IO request to DM
3) DM notice MSI cfg space access
❑ Directly modify MSI cfg based on SOS vPCI dev
❑ SOS vPCI will modify the PTIRQ entry for related MSI entry
** it’s actually a long & obscure flow
PTIRQ
SOS vpci

More Related Content

What's hot

/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity
Takuya ASADA
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 

What's hot (20)

Project ACRN Device Model architecture introduction
Project ACRN Device Model architecture introductionProject ACRN Device Model architecture introduction
Project ACRN Device Model architecture introduction
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
 
HKG15-107: ACPI Power Management on ARM64 Servers (v2)
HKG15-107: ACPI Power Management on ARM64 Servers (v2)HKG15-107: ACPI Power Management on ARM64 Servers (v2)
HKG15-107: ACPI Power Management on ARM64 Servers (v2)
 
/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity/proc/irq/&lt;irq>/smp_affinity
/proc/irq/&lt;irq>/smp_affinity
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
 
Hardware accelerated Virtualization in the ARM Cortex™ Processors
Hardware accelerated Virtualization in the ARM Cortex™ ProcessorsHardware accelerated Virtualization in the ARM Cortex™ Processors
Hardware accelerated Virtualization in the ARM Cortex™ Processors
 
A day in the life of a VSAN I/O - STO7875
A day in the life of a VSAN I/O - STO7875A day in the life of a VSAN I/O - STO7875
A day in the life of a VSAN I/O - STO7875
 
Achieving the ultimate performance with KVM
Achieving the ultimate performance with KVM Achieving the ultimate performance with KVM
Achieving the ultimate performance with KVM
 
Linux PV on HVM
Linux PV on HVMLinux PV on HVM
Linux PV on HVM
 
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIKernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
SR-IOV Introduce
SR-IOV IntroduceSR-IOV Introduce
SR-IOV Introduce
 
NVMe Over Fabrics Support in Linux
NVMe Over Fabrics Support in LinuxNVMe Over Fabrics Support in Linux
NVMe Over Fabrics Support in Linux
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
 
Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
 
RISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a TimeRISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a Time
 

Similar to Project ACRN expose and pass through platform hidden PCIe devices to SOS

Information Gathering 2
Information Gathering 2Information Gathering 2
Information Gathering 2
Aero Plane
 
PCI_Express_Basics_Background.pdf
PCI_Express_Basics_Background.pdfPCI_Express_Basics_Background.pdf
PCI_Express_Basics_Background.pdf
zahixdd
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
chiportal
 
Io Architecture
Io ArchitectureIo Architecture
Io Architecture
Aero Plane
 
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsI/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
CrowdStrike
 
2011 02-18 plan de-sesion_integrado -eng-
2011 02-18 plan de-sesion_integrado -eng-2011 02-18 plan de-sesion_integrado -eng-
2011 02-18 plan de-sesion_integrado -eng-
Alberto Vargas
 

Similar to Project ACRN expose and pass through platform hidden PCIe devices to SOS (20)

Slideshare - PCIe
Slideshare - PCIeSlideshare - PCIe
Slideshare - PCIe
 
Information Gathering 2
Information Gathering 2Information Gathering 2
Information Gathering 2
 
Linux PCI device driver
Linux PCI device driverLinux PCI device driver
Linux PCI device driver
 
PCI_Express_Basics_Background.pdf
PCI_Express_Basics_Background.pdfPCI_Express_Basics_Background.pdf
PCI_Express_Basics_Background.pdf
 
ACPI and FreeBSD (Part 1)
ACPI and FreeBSD (Part 1)ACPI and FreeBSD (Part 1)
ACPI and FreeBSD (Part 1)
 
haifux-pcie.pdf
haifux-pcie.pdfhaifux-pcie.pdf
haifux-pcie.pdf
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Io Architecture
Io ArchitectureIo Architecture
Io Architecture
 
Orbleaf: Integrated Smart Card Development Platform
Orbleaf: Integrated Smart Card Development PlatformOrbleaf: Integrated Smart Card Development Platform
Orbleaf: Integrated Smart Card Development Platform
 
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsI/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
 
Raspberry Pi tutorial
Raspberry Pi tutorialRaspberry Pi tutorial
Raspberry Pi tutorial
 
ACPI In Windows Vista
ACPI In Windows VistaACPI In Windows Vista
ACPI In Windows Vista
 
Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
 
101 1.1 hardware settings
101 1.1 hardware settings101 1.1 hardware settings
101 1.1 hardware settings
 
Nvidia tegra K1 Presentation
Nvidia tegra K1 PresentationNvidia tegra K1 Presentation
Nvidia tegra K1 Presentation
 
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner FischerOSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
 
2011 02-18 plan de-sesion_integrado -eng-
2011 02-18 plan de-sesion_integrado -eng-2011 02-18 plan de-sesion_integrado -eng-
2011 02-18 plan de-sesion_integrado -eng-
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
 

More from Project ACRN

More from Project ACRN (20)

ACRN vMeet-Up EU 2021 - installation and configuration introduction
ACRN vMeet-Up EU 2021 - installation and configuration introductionACRN vMeet-Up EU 2021 - installation and configuration introduction
ACRN vMeet-Up EU 2021 - installation and configuration introduction
 
ACRN vMeet-Up EU 2021 - Bridging Orchestrator and Hard Realtime Workload Cons...
ACRN vMeet-Up EU 2021 - Bridging Orchestrator and Hard Realtime Workload Cons...ACRN vMeet-Up EU 2021 - Bridging Orchestrator and Hard Realtime Workload Cons...
ACRN vMeet-Up EU 2021 - Bridging Orchestrator and Hard Realtime Workload Cons...
 
ACRN vMeet-Up EU 2021 - Boot Process and Secure Boot
ACRN vMeet-Up EU 2021 - Boot Process and Secure BootACRN vMeet-Up EU 2021 - Boot Process and Secure Boot
ACRN vMeet-Up EU 2021 - Boot Process and Secure Boot
 
ACRN vMeet-Up EU 2021 - debug ACRN hypervisor
ACRN vMeet-Up EU 2021 - debug ACRN hypervisorACRN vMeet-Up EU 2021 - debug ACRN hypervisor
ACRN vMeet-Up EU 2021 - debug ACRN hypervisor
 
ACRN vMeet-Up EU 2021 - functional safety design and certification plan
ACRN vMeet-Up EU 2021 -  functional safety design and certification planACRN vMeet-Up EU 2021 -  functional safety design and certification plan
ACRN vMeet-Up EU 2021 - functional safety design and certification plan
 
ACRN vMeet-Up EU 2021 - community and development model
ACRN vMeet-Up EU 2021 - community and development modelACRN vMeet-Up EU 2021 - community and development model
ACRN vMeet-Up EU 2021 - community and development model
 
ACRN vMeet-Up EU 2021 - hypervisor new platform enabling
ACRN vMeet-Up EU 2021 - hypervisor new platform enablingACRN vMeet-Up EU 2021 - hypervisor new platform enabling
ACRN vMeet-Up EU 2021 - hypervisor new platform enabling
 
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introductionACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
 
ACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
ACRN vMeet-Up EU 2021 - Real Time Management and Performance OptimizationACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
ACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
 
ACRN vMeet-Up EU 2021 - Introduction and Architecture Look Forward
ACRN vMeet-Up EU 2021 - Introduction and Architecture Look ForwardACRN vMeet-Up EU 2021 - Introduction and Architecture Look Forward
ACRN vMeet-Up EU 2021 - Introduction and Architecture Look Forward
 
ACRN Kata Container on ACRN
ACRN Kata Container on ACRNACRN Kata Container on ACRN
ACRN Kata Container on ACRN
 
Project ACRN Yocto Project meta-acrn layer introduction
Project ACRN Yocto Project meta-acrn layer introductionProject ACRN Yocto Project meta-acrn layer introduction
Project ACRN Yocto Project meta-acrn layer introduction
 
Project ACRN USB mediator introduction
Project ACRN USB mediator introductionProject ACRN USB mediator introduction
Project ACRN USB mediator introduction
 
Project ACRN I2C mediator introduction
Project ACRN I2C mediator introductionProject ACRN I2C mediator introduction
Project ACRN I2C mediator introduction
 
Project ACRN system debug
Project ACRN system debugProject ACRN system debug
Project ACRN system debug
 
Project ACRN SR-IOV on ACRN
Project ACRN SR-IOV on ACRNProject ACRN SR-IOV on ACRN
Project ACRN SR-IOV on ACRN
 
Project ACRN configuration scenarios and config tool
Project ACRN configuration scenarios and config toolProject ACRN configuration scenarios and config tool
Project ACRN configuration scenarios and config tool
 
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
Project ACRN CPU sharing BVT scheduler in ACRN hypervisorProject ACRN CPU sharing BVT scheduler in ACRN hypervisor
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
 
Project ACRN how to build a Yocto Project-based SOS
Project ACRN how to build a Yocto Project-based SOSProject ACRN how to build a Yocto Project-based SOS
Project ACRN how to build a Yocto Project-based SOS
 
Project ACRN EtherCAT 101
Project ACRN EtherCAT 101Project ACRN EtherCAT 101
Project ACRN EtherCAT 101
 

Recently uploaded

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

Project ACRN expose and pass through platform hidden PCIe devices to SOS

  • 1. Expose and pass through platform hidden PCIe devices to SOS SSP.ACRN Li, Fei
  • 2. agenda ⚫ The background ⚫ Why does ACRN need to expose and pass through platform hidden PCI(e) devices to SOS ⚫ How ACRN to expose and pass through platform hidden PCI(e) devices to SOS
  • 3. Part One - The background
  • 4. Terms PCI - Peripheral Component Interconnect PCIe - Peripheral Component Interconnect Express
  • 5. Address Spaces Four address spaces are defined
  • 6. The Layout of PCI Configuration Space
  • 7. The Layout of PCIe Configuration Space
  • 8. PCI-compatible Configuration Mechanism Bus Number - is an encoded value used to select 1 of 256 buses in a system. Device Number - is an encoded value used to select one of 32 devices on a given bus. Function Number - is an encoded value used to select one of eight possible functions on a multifunction device. Register Number - is an encoded value used to select a DWORD in the Configuration Space of the intended target.
  • 9. PCI-compatible Configuration Mechanism CONFIG_ADDRESS (CF8h) CONFIG_DATA (CFCh - CFFh) IE: read PCIe device 00:1c.0 Header Type (0xEh) Write (1 << 31) | (0 << 16) | (1c << 11) | (0 << 8) | (0xE & 0xFC) to IO Port CF8h Read one byte data from IO Port CFCh + (0xE – (0xE & 0xFC))
  • 10. PCI Express Enhanced Configuration Access Mechanism (ECAM)
  • 11. PCI Express Enhanced Configuration Access Mechanism (ECAM) PCI MMCONFIG Address 0xe0000000 (physical address, bus 00-ff) IE: read PCIe device 00:1c.0 Header Type (0xEh) Read four bytes data form MMIO 0xe0000000 + (0 << 20) | (1c << 15) | (0 << 12) | (0xE & 0xFC)
  • 12. PCIe devices on NUC Vendor ID Register (Offset 00h) The Vendor ID register is HwInit and the value in this register identifies the manufacturer of the Function. In keeping with PCI-SIG procedures, valid vendor identifiers must be allocated by the PCI-SIG to ensure uniqueness. Each vendor must have at least one Vendor ID. It is recommended that software read the Vendor ID register to determine if a Function is present, where a value of FFFFh indicates that no Function is present.
  • 13. Part Two - Why does ACRN need to expose and pass through platform hidden PCI(e) devices to SOS
  • 14. ACRN needs to trap ECAM for SOS ⚫ SOS shouldn’t access the PCIe devices which have assigned to UOS. ⚫ SOS needs to trap some PCIe external capability access and handle this correctly. For example, for the SR-IOV support. So now ACRN hypervisor will trap each PCIe configuration access (no matter by IO port or MMIO) and check whether the PCIe device belongs to the guest which trigger the access.
  • 15. Why does ACRN need to expose and pass through platform hidden PCI(e) devices to SOS However, there’re some PCIe devices hidden by BIOS which can’t been discovered by read Vendor ID simply. For example, Intel Primary to Sideband Bridge. The BIOS could hide/unhide it by enabling/disabling HIDE bit in P2SB Control Register. To make things worse, SOS on APL UP2 will call ACPI method to set eMMC controller to D3Hot Power State which will trigger P2SB ECAM access.
  • 16. Why does ACRN need to expose and pass through platform hidden PCI(e) devices to SOS Scope (_SB.PCI0) { OperationRegion (P2CG, SystemMemory, 0xE00680D0, 0x20) – PCI device 00:0d.0 CFG Space [0xD0 – 0x100) Field (P2CG, DWordAcc, NoLock, Preserve) { SBAD, 32, SBDA, 32, IRDY, 1, , 6, POST, 1, OPCD, 8, SBID, 16, SBEA, 32, Offset (0x11), P2HD, 8 - P2SB Control Hide Device }
  • 17. Why does ACRN need to expose and pass through platform hidden PCI(e) devices to SOS Method (SBIM, 4, Serialized) { Local0 = Zero Local1 = Acquire (_GL, 0x1F40) If ((Local1 == Zero)) { P2HD = Zero While (IRDY) { Sleep (One) } SBAD &= 0x00F00000 SBAD |= Arg0 SBEA = Zero SBDA = Arg1 SBID &= 0x0800 SBID |= Arg3 POST = Zero OPCD = Arg2 IRDY = One While (IRDY) { Sleep (One) } Local0 = SBDA /* _SB_.PCI0.SBDA */ P2HD = One } Release (_GL) Scope (SDHA) { Name (_DDN, "Intel(R) eMMC Controller - 80865ACC") // _DDN: DOS Device Name Name (_UID, One) // _UID: Unique ID Method (_PS3, 0, NotSerialized) // _PS3: Power State 3 { Local0 = SBIM (0xD600003C, Zero, Zero, 0x30E0) Local1 = SBIM (0xD6000834, Zero, Zero, 0x30E0) Local2 = SBIM (0xD6000840, Zero, Zero, 0x30E0) If ((Local0 & 0x00800000)) { Local3 = (((Local2 & 0x1F) * 0x02) + ((Local1 & 0x3F00) >> 0x08)) Local1 = ((Local1 & 0xFFFFFF80) | (Local3 & 0x7F)) SBIM (0xD6000834, Local1, One, 0x30E0) } DPGE = One I3EN = One SCPG (One, 0x41) Local0 = PMSR /* _SB_.PCI0.SDHA.PMSR */ Local0 &= One }
  • 18. Why does ACRN need to expose and pass through platform hidden PCI(e) devices to SOS We didn’t assign hidden PCIe devices to SOS before. As a result, SOS thought this device didn’t belong to itself. So this access was ignored. And the eMMC controller Power State setting was failed. This would make SOS hardly working since it seemed this was the only thing it cared – keeping setting if failed.
  • 19. Part Three - How ACRN to expose and pass through platform hidden PCI(e) devices to SOS
  • 20. How ACRN to expose and pass through platform hidden PCI(e) devices to SOS Just add the platform hidden PCIe devices into plat_hidden_pdevs structure on your board configuration in arch/x86/configs/$(BOARD)/board.c and the platform hidden PCIe devices number (MAX_HIDDEN_PDEVS_NUM) in arch/x86/configs/$(BOARD)/misc_cfg.h NOTE: Not each platform hidden PCIe device should expose and pass through to SOS. If this hidden device only used to trigger watchdog. (After we support RT-VM, SOS should not trigger hardware watchdog to reset the whole system if RT-VM is alive)
  • 21. How ACRN to discover platform hidden PCI(e) devices dm/vpci/vpci.c
  • 23.
  • 24. DM Emulated/Touched Legacy/ACPI Devices IRQ IO/MMIO Expose to UOS by Comments RTC 8 0x70~0x71 DSDT: PNP0B00 Expose if enabled LPC UART 3,4 0x2F8, 0x3F8 DSDT: PNP0501 Expose if enabled LPC ACPI PM 9 0xCF9, 0x400~0x404, 0xb2 FADT reset register, PM1A, SMI Always Expose ACPI Idle N/A N/A DSDT Always Expose HV emulated, hcall to fetch Cx info; no need after CPU sharing ACPI P-state N/A N/A DSDT Always Expose HV emulated, hcall to fetch Px info; no need after CPU sharing PIC 2 0x20, 0xA0 DSDT: PNP0000 Expose if enabled LPC (except RTVM) HV emulated PIT 0 0x40 DSDT: PNP0100 Expose if enabled LPC HPET N/A 0xFED00000 HPET DSDT: PNP0103 Always Expose KBD/MOU 1,12 0x60,0x64 DSDT: PNP0303, PNP0F13 Expose if enabled LPC TPM N/A 0xFED40000 TPM2 DSDT: MSFT0101 Optional (through cmdline opt)
  • 25. DM Emulated PCI Devices • Interrupt (if the device request INTx support) • DM allocate INTA/B/C/D for each device in same slot (bus:dev) -> fill to IRQ_PIN (0x3d) • DM allocate PIRQ (pin & pic_irq) for each slot INTA/B/C/D -> fill to IRQ_LINE(0x3c) • DM allocate AIRQ (IOAPIC gsi) for each slot INTA/B/C/D • DM create PPRT & APRT based on PIRQ (SLOT:INTx vs. PIRQ) & AIRQ (SLOT:INTx vs. AIRQ) • Bar • Each PCI bridge 32bit/64bit MMIO range -> DSDT • DM allocate bar for each device based on each bus • BDF • Set by DM cmdline
  • 26. Assumption for Device Emulation between HV & DM • Limit HV emulated devices • Legacy device for vUART & vRTC • PCI devices for PCI bridge (for pre-launched or service VM), PT devices, vWatchdog & PCI based vUART • NO ACPI device • For PCI devices in a post-launched VM • DM own PCI bridge and other pure emulated PCI devices • HV own PT devices • HV own necessary pure emulated PCI device, only support MSI interrupt • For RTVM under LAPIC PT mode, PT devices shall only support MSI interrupt, NO INTx • If a PT device explicitly depend on other PT devices, only support it when all depend PT devices pass-thru to this VM • If a PT device implicitly depend on some other resource coming from native ACPI table, NOT support it • If a PT device depend on DM emulated device, NOT support it?
  • 27. Proposal for HV Emulated Legacy Device in DM- launched VM • DM own overall resource management • Interrupt – IOAPIC/PIC pins • ACPI – DSDT (_PTR) etc • Legacy devices • Pre-alignment for the resource configuration between DM & HV • Configurable to choose DM or HV one, or just directly use HV vm_config and ignore DM config, as HV IO emulation has priority
  • 28. Proposal-1 for HV Emulated PCI Devices in DM- launched VM • DM own overall resource management • Interrupt – IOAPIC/PIC pins • PCI – BDF, bar range, INTx • ACPI – DSDT (_PTR) etc • PCI devices • PT PCI device move to HV • vPCI for UOS • DM add device through hypercall with necessary resource info allocated • type : could be vWatchdog, vUART, PT • vBDF, pBDF: pBDF only for PT device type • INTx • bar (include MSIX bar)
  • 29. SOS PT vPCI Dev in DM Proposal-1 – PT PCI Dev in UOS Initialization vBDF HV UOS PCI Dev INTx BAR hypercall IO Request UOS vpci PCI Request PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBD F INTx cfg MSI cfg MSIX cfg MSIX BAR Other Dev in DM 1 2 1) DM allocate resource ❑ DM analyze PT device physical info based on SOS vPCI, to allocate all necessary resource [vBDF, BAR, INTx] 2) DM hypercall to add_dev ❑ Combine hypercalls (ASSIGN_PTDEV, SET_PTDEV_INTR_INFO) into one – ADD_DEV [type=PTDEV, vBDF, pBDF, BAR, INTx] ❑ vpci_init_pt_dev with DM allocated resource 3) UOS PCI Dev access trap to HV ❑ Parse PCI IO request ❑ Filter out PCI IO request for HV owned PT PCI Device ❑ Others PCI IO request still send up to DM like the old way SOS vpci 3
  • 30. Proposal-2 for HV Emulated PCI Devices in DM- launched VM • Pre-partitioned resource between DM & HV • BDF: • DM own bus 0 and HV own bus 1 • Bar: • pre-aligned partition MMIO range for bus 0 and bus 1, DM need prepare ACPI info for bus 1 PCI bridge • INTx: • pre-aligned partition INTx gsi range, DM need prepare ACPI PRT for PCI devices under bus 1 • Config: • HV could pre-define UOS Ptdev list in its vm_config, or DM define it during runtime configuration
  • 31. Suggestion for Emulated Device Matrix Resource[1] allocated in Emulated in ACPI prepared by Support Assumption DM HV DM HV DM HV Host Bridge Y Y Y Always need Normal Bridge Y Y Y If there is extra PCI bus PTDev INTx (w/ vLAPIC) Proposal 1 Proposal 2 Y Y - for PRT Not support if VM is using PT lapic; It's necessary to PT UART/I2C kind of legacy PCI devices; ACPI table only cover PRT; MSI/MSIX Proposal 1 Proposal 2 Y No ACPI table for it other PTDev explicitly dep on [2] Proposal 1 Proposal 2 Y Y - for PSx Only support if all dep devices pass-thru to this VM; ACPI table only cover PM related if needed?? other implicitly Resource dep on [3] No plan to support Other devices HV emulated PCI device Proposal 1 Proposal 2 Y Only support MSI for emulated PCI device HV emulated legacy device Pre-aligned Pre-aligned Y Y ACPI only cover for emulated legacy device DM emulated legacy & PCI device Y Y Y [1] Resource include BAR, INTx and BDF etc. [2] PTDev may explicitly depend on other PTDev like I2C, UART, its driver or ACPI method like PSx need work based on such devices [3] PTDev may depend on other implicitly resource or DM emulated device, for example, it may need DM emulated GPIO, or its ACPI method like PSx need work based on NVS ram passed MMIO like side-band access
  • 33. SOS Pure vPCI Dev in DM DM Emulated PCI Devices VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev INTx cfg MSI cfg MSIX cfg MSIX BAR hypercall vLAPIC/vIOAPIC/vPI C IO Request MMIO BAR • DM emulate all PCI resource • Virtual config space • INTx • BAR range • vBDF • ACPI table (PRT etc) • DM inject virq through hypercall
  • 34. SOS PT vPCI Dev in DM DM Emulated PT PCI Devices - Initialization VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev INTx cfg MSI cfg MSIX cfg MSIX BAR Map PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBDF INTx cfg MSI cfg MSIX cfg MSIX BAR hypercall IOMMU PTIRQ EPT 1 2 3 4 5 • SOS own PT dev original – DM access through SOS vPCI 1) DM build ❑ vDev cfg space based on SOS vPCI dev ❑ vMSIX bar map based on SOS vPCI dev 2) DM initialize HV stuff through hypercall 3) Assign IOMMU domain for this PT dev to UOS 4) Assign PTIRQ entries for this PT dev to UOS ❑ vINTx vs. pINTx ❑ vMSI vs. pMSI ❑ vMSIX vs. pMSIX 5) Add EPT mapping of MMIO bar for this PT dev to UOS SOS vpci
  • 35. SOS PT vPCI Dev in DM DM Emulated PT PCI Devices – MMIO BAR Access VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev INTx cfg MSI cfg MSIX cfg MSIX BAR Map PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBDF INTx cfg MSI cfg MSIX cfg MSIX BAR EPT • UOS PCI Dev directly access physical bar based on EPT mapping
  • 36. SOS PT vPCI Dev in DM DM Emulated PT PCI Devices – Interrupt Injection VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev INTx cfg MSI cfg MSIX cfg MSIX BAR Map PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBDF INTx cfg MSI cfg MSIX cfg MSIX BAR PTIRQ 1) Physical device trigger physical interrupt ❑ pINTx ❑ pMSI/pMSIX 2) Do_irq match ptirq mapping ❑ pINTx -> vINTx -> vVector ❑ pMSI/pMSIX -> vMSI/vMSIX -> vVector 3) Do_irq inject vVector to guest Do_irq 1 2 3
  • 37. SOS PT vPCI Dev in DM DM Emulated PT PCI Devices – Modify MMIO BAR CFG VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev IO Request INTx cfg MSI cfg MSIX cfg MSIX BAR Map PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBDF INTx cfg MSI cfg MSIX cfg MSIX BAR EPT 1 23 1) UOS PCI Dev access cfg space trap to HV 2) HV raise IO request to DM 3) DM notice MMIO bar update ❑ Directly modify BAR cfg based on SOS vPCI dev ❑ SOS vPCI will remap the EPT mapping ** it’s actually a long & obscure flow SOS vpci
  • 38. SOS PT vPCI Dev in DM DM Emulated PT PCI Devices – Modify MSIX VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev IO Request INTx cfg MSI cfg MSIX cfg MSIX BAR Map PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBDF INTx cfg MSI cfg MSIX cfg MSIX BAR 1 23 1) UOS PCI Dev access MSIX MMIO trap to HV 2) HV raise IO request to DM 3) DM notice MSIX MMIO access ❑ Directly modify MSIX BAR map based on SOS vPCI dev ❑ SOS vPCI will modify the PTIRQ entry for related MSIX entry ** Modify MSIX could be destination, delivery mode change which lead to physical MSI msg change ** it’s actually a long & obscure flow PTIRQ SOS vpci
  • 39. SOS PT vPCI Dev in DM DM Emulated PT PCI Devices – Modify MSI cfg VIRT CFG SPACE BAR cfg vBDF HV UOS PCI Dev IO Request INTx cfg MSI cfg MSIX cfg MSIX BAR PT Physical Dev in HV CFG SPACE BAR cfg MMIO BAR pBDF INTx cfg MSI cfg MSIX cfg MSIX BAR 1 23 1) UOS PCI Dev access cfg space trap to HV 2) HV raise IO request to DM 3) DM notice MSI cfg space access ❑ Directly modify MSI cfg based on SOS vPCI dev ❑ SOS vPCI will modify the PTIRQ entry for related MSI entry ** it’s actually a long & obscure flow PTIRQ SOS vpci