qemu vfio-powerpc: added initial support
RFC PATCH 1/1 qemu vfio-powerpc: added initial support
The idea of the patch is to demonstrate what POWER needs to support VFIO. It will not compile as many other patches are needed and they are not posted anywhere yet.
The patch includes:
1) sPAPR PCI bus got an additional flag "is_vfio" which defines IOMMU behavior
2) Added POWER-specific IOMMU handling, at the moment to vfio_pci.c as it accesses VFIODevice and VFIOIOMMU structs in ordet to call vfio_dma_map/vfio_dma_unmap.
3) #ifdef/#else for EOI handlers as POWER uses XICS interrupt controller rather than APIC. Also, sys/io.h has been moved under #ifdef.
4) IRQ update notifier is disabled for POWER. Cannot see how IRQ can change on POWER dynamically.
--- hw/spapr_iommu.c | 4 +++ hw/spapr_pci.c | 12 ++++++++++ hw/spapr_pci.h | 2 + hw/vfio_pci.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++- hw/vfio_pci.h | 3 ++ 5 files changed, 85 insertions(+), 1 deletions(-)
hw/spapr_iommu.c +4 -0
@@ -23,6 +23,7 @@#include "dma.h" #include "hw/spapr.h" +#include "hw/vfio_pci.h" #include <libfdt.h>
@@ -198,6 +199,9 @@ static target_ulong h_put_tce(CPUPPCState *env, sPAPREnvironment *spapr,if (tcet) {return put_tce_emu (tcet, ioba, tce); } +if (!put_tce_vfio (liobn, ioba, tce)) { +return H_SUCCESS ; + }#ifdef DEBUG_TCE fprintf(stderr, "%s on liobn=" TARGET_FMT_lx /*%s*/ " ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n",
hw/spapr_pci.c +12 -0
@@ -29,6 +29,7 @@#include "pci_host.h" #include "hw/spapr.h" #include "hw/spapr_pci.h" +#include "hw/vfio_pci.h" #include "exec-memory.h" #include <libfdt.h>
@@ -563,6 +564,7 @@ static Property spapr_emulatedpci_properties[] = {DEFINE_PROP_UINT8 ("min_busid" , sPAPREmulatedPCIState, s.min_busid,0 ),DEFINE_PROP_UINT8 ("max_busid" , sPAPREmulatedPCIState, s.max_busid,0xff ),DEFINE_PROP_HEX64 ("msi_win_addr" , sPAPREmulatedPCIState, msi_win_addr,0 ), +DEFINE_PROP_UINT8 ("vfio" , sPAPREmulatedPCIState, is_vfio,0 ), DEFINE_PROP_END_OF_LIST(), };
@@ -606,6 +608,16 @@ void spapr_create_phb(sPAPREnvironment *spapr,/* Finalize PCI setup, called when all devices are already created */ int spapr_finalize_pci_setup (sPAPREmulatedPCIState *ephb) { +if (ephb->is_vfio) { +/* Add VFIO DMA window configuration! */ + ephb->s.dma_window_start =0 ; + ephb->s.dma_window_size =0x40000000 ; +spapr_vfio_create_dma_context (ephb->host_state.bus, ephb->s.dma_liobn); +/* ephb->s.dma = spapr_tce_new_dma_context(ephb->s.dma_liobn, +ephb->s.dma_window_size);*/ +return 0 ; + } + ephb->s.dma_window_start =0 ; ephb->s.dma_window_size =0x40000000 ; ephb->s.dma = spapr_tce_new_dma_context(ephb->s.dma_liobn,
hw/spapr_pci.h +2 -0
@@ -64,6 +64,8 @@ typedef struct sPAPREmulatedPCIState {target_phys_addr_t msi_win_addr;MemoryRegion msiwindow; +uint8_t is_vfio; +QLIST_ENTRY (sPAPREmulatedPCIState) list; } sPAPREmulatedPCIState;
hw/vfio_pci.c +64 -1
110 lines not on this page · raw message
hw/vfio_pci.h +3 -0
@@ -104,4 +104,7 @@ typedef struct VFIOGroup {#define VFIO_FLAG_IOMMU_SHARED_BIT 0#define VFIO_FLAG_IOMMU_SHARED (1U << VFIO_FLAG_UIOMMU_SHARED_BIT) +void spapr_vfio_create_dma_context (struct PCIBus *pbus,uint32_t liobn); +int put_tce_vfio (uint32_t liobn,target_ulong ioba,target_ulong tce); +#endif /* __VFIO_H__ */
Signature · 4 lines
1.7.0.4 -- Alexey