vpci: introduce basic handlers to trap accesses to the PCI config space
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 22 Mar 2018 13:59:00 +0000 (14:59 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 23 Mar 2018 09:16:43 +0000 (10:16 +0100)
commite90580f25bd71681a97e0cdba238c1f0c7e6bec7
tree86e3fb11007a901b43a3ba46cf0e75930241e548
parente633b13a18f7a7e407cba2de42a5a2a86aaec9c1
vpci: introduce basic handlers to trap accesses to the PCI config space

This functionality is going to reside in vpci.c (and the corresponding
vpci.h header), and should be arch-agnostic. The handlers introduced
in this patch setup the basic functionality required in order to trap
accesses to the PCI config space, and allow decoding the address and
finding the corresponding handler that should handle the access
(although no handlers are implemented).

Note that the traps to the PCI IO ports registers (0xcf8/0xcfc) are
setup inside of a x86 HVM file, since that's not shared with other
arches.

A new XEN_X86_EMU_VPCI x86 domain flag is added in order to signal Xen
whether a domain should use the newly introduced vPCI handlers, this
is only enabled for PVH Dom0 at the moment.

A very simple user-space test is also provided, so that the basic
functionality of the vPCI traps can be asserted. This has been proven
quite helpful during development, since the logic to handle partial
accesses or accesses that expand across multiple registers is not
trivial.

The handlers for the registers are added to a linked list that's keep
sorted at all times. Both the read and write handlers support accesses
that expand across multiple emulated registers and contain gaps not
emulated.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
[IO parts]
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
[ARM]
Acked-by: Julien Grall <julien.grall@arm.com>
[Tools]
Acked-by: Wei Liu <wei.liu2@citrix.com>
24 files changed:
.gitignore
tools/libxl/libxl_x86.c
tools/tests/Makefile
tools/tests/vpci/Makefile [new file with mode: 0644]
tools/tests/vpci/emul.h [new file with mode: 0644]
tools/tests/vpci/main.c [new file with mode: 0644]
xen/arch/arm/xen.lds.S
xen/arch/x86/Kconfig
xen/arch/x86/domain.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/io.c
xen/arch/x86/setup.c
xen/arch/x86/xen.lds.S
xen/drivers/Kconfig
xen/drivers/Makefile
xen/drivers/passthrough/pci.c
xen/drivers/vpci/Makefile [new file with mode: 0644]
xen/drivers/vpci/vpci.c [new file with mode: 0644]
xen/include/asm-x86/domain.h
xen/include/asm-x86/hvm/io.h
xen/include/public/arch-x86/xen.h
xen/include/xen/pci.h
xen/include/xen/pci_regs.h
xen/include/xen/vpci.h [new file with mode: 0644]