spapr: vfio: Enable Dynamic DMA windows (DDW)
v11 cover spapr: vfio: Enable Dynamic DMA windows (DDW)
Each Partitionable Endpoint (IOMMU group) has an address range on a PCI bus where devices are allowed to do DMA. These ranges are called DMA windows. By default, there is a single DMA window, 1 or 2GB big, mapped at zero on a PCI bus.
PAPR defines a DDW RTAS API which allows pseries guests querying the hypervisor about DDW support and capabilities (page size mask for now). A pseries guest may request an additional (to the default) DMA windows using this RTAS API.
The existing pseries Linux guests request an additional window as big as the guest RAM and map the entire guest window which effectively creates direct mapping of the guest memory to a PCI bus.
This patchset reworks PPC64 IOMMU code and adds necessary structures to support big windows.
Once a Linux guest discovers the presence of DDW, it does:
1. query hypervisor about number of available windows and page size masks;
2. create a window with the biggest possible page size (today 4K/64K/16M);
3. map the entire guest RAM via H_PUT_TCE* hypercalls;
4. switche dma_ops to direct_dma_ops on the selected PE.
Once this is done, H_PUT_TCE is not called anymore for 64bit devices and the guest does not waste time on DMA map/unmap operations.
Note that 32bit devices won't use DDW and will keep using the default DMA window so KVM optimizations will be required (to be posted later).
This patchset adds DDW support for pseries. The host kernel changes are required, available in the current upstream.
This patchset is based on git://github.com/dgibson/qemu.git spapr-next branch.
This compiles but the feature can be only enabled with
"[RFC PATCH qemu v3 0/4] vfio: SPAPR IOMMU v2 (memory preregistration support)".
Please comment. Thanks!
Changes:
v11:
* moved VFIO Container changes to a separate patchset:
[RFC PATCH qemu v3 0/4] vfio: SPAPR IOMMU v2 (memory preregistration support)
* reworked "spapr_pci: Enable vfio-pci hotplug" to reenable acceleration for emulated devices after last VFIO is removed
* replaced @has_vfio with a vfio devices counter; removed RCU to track container release (not needed)
v10:
* reworked "spapr_pci: Enable vfio-pci hotplug"
* added "vfio: Unregister IOMMU notifiers when container is destroyed"
* updated kernel header update with a tag
v9:
* removed "vfio: spapr: Move SPAPR-related code to a separate file"
* rebased on top of current dwg/spapr-next
* moved hw/vfio/* related patches to the end of the patchset
* included kernel headers update
* reworked "spapr_pci: Enable vfio-pci hotplug" a lot
v8:
* reworked unreferencing in "spapr_iommu: Introduce "enabled" state for TCE table"
* added clean-up patch "spapr_iommu: Remove vfio_accel flag from sPAPRTCETable"
* rebased on latest spapr-next
v7:
* bunch of cleanups, renames after David+Thomas+Michael review
* patches are reorganized and those which do not need the host kernel headers update are put first and can be pulled if these are good enough :)
v6:
* spapr-pci-vfio-host-bridge is now a synonim of spapr-pci-host-bridge - same PHB can host emulated and VFIO devices
* changed patches order
* lot of small changes
v5:
* TCE tables got "enabled" state and are persistent, i.e. not recreated every reboot
* added v2 of SPAPR_TCE_IOMMU
* fixed migration for emulated PHB with enabled DDW
* huge pile of other changes
v4:
* reimplemented the whole thing
* machine reset and ddw-reset RTAS call both remove all TCE tables and create the default one
* IOMMU group id is not needed to use VFIO PHB anymore, multiple groups are supported on the same VFIO container and virtual PHB
v3:
* removed "reset" from API now
* reworked machine versions
* applied multiple comments
* includes David's machine QOM rework as this patchset adds a new machine type
v2:
* tested on emulated PHB
* removed "ddw" machine property, now it is PHB property
* disabled by default
* defined "pseries-2.2" machine which enables DDW by default
* fixed reset() and reference counting
# Please edit the description for the branch
# _vfio-v11
# Lines starting with '#' will be stripped.
Alexey Kardashevskiy (11):
vmstate: Define VARRAY with VMS_ALLOC
spapr_pci: Convert finish_realize() to
dma_capabilities_update()+dma_init_window()
spapr_iommu: Move table allocation to helpers
spapr_iommu: Introduce "enabled" state for TCE table
spapr_iommu: Remove vfio_accel flag from sPAPRTCETable
spapr_iommu: Add root memory region
spapr_pci: Do complete reset of DMA config when resetting PHB
spapr_vfio_pci: Remove redundant spapr-pci-vfio-host-bridge
spapr_pci: Enable vfio-pci hotplug
spapr_pci_vfio: Enable multiple groups per container spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)
hw/ppc/Makefile.objs | 6 +- hw/ppc/spapr.c | 5 + hw/ppc/spapr_iommu.c | 227 ++++++++++++++++++++++++++------ hw/ppc/spapr_pci.c | 310 +++++++++++++++++++++++++++++++++----------- hw/ppc/spapr_pci_vfio.c | 242 ++++++++++++++++++++++------------ hw/ppc/spapr_rtas_ddw.c | 304 +++++++++++++++++++++++++++++++++++++++++++ hw/ppc/spapr_vio.c | 9 +- hw/vfio/common.c | 23 ++-- include/hw/pci-host/spapr.h | 50 +++++-- include/hw/ppc/spapr.h | 34 +++-- include/hw/vfio/vfio.h | 3 +- include/migration/vmstate.h | 10 ++ trace-events | 10 +- 13 files changed, 990 insertions(+), 243 deletions(-) create mode 100644 hw/ppc/spapr_rtas_ddw.c
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 1/11 vmstate: Define VARRAY with VMS_ALLOC
This allows dynamic allocation for migrating arrays.
Already existing VMSTATE_VARRAY_UINT32 requires an array to be pre-allocated, however there are cases when the size is not known in advance and there is no real need to enforce it.
This defines another variant of VMSTATE_VARRAY_UINT32 with WMS_ALLOC flag which tells the receiving side to allocate memory for the array before receiving the data.
The first user of it is a dynamic DMA window which existence and size are totally dynamic.
--- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/migration/vmstate.h +10 -0
@@ -295,6 +295,16 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_pointer(_state, _field, _type), \ } +#define VMSTATE_VARRAY_UINT32_ALLOC (_field, _state, _field_num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \ + .offset = vmstate_offset_pointer(_state, _field, _type), \ +} +#define VMSTATE_VARRAY_UINT16_UNSAFE (_field, _state, _field_num, _version, _info, _type) {\ .name = (stringify(_field)), \ .version_id = (_version), \
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 2/11 spapr_pci: Convert finish_realize() to dma_capabilities_update()+dma_init_window()
In reply to Alexey KardashevskiyThis reworks finish_realize() which used to finalize DMA setup with an assumption that it will not change later.
New callbacks supports various window parameters such as page and windows sizes. The new callback return error code rather than Error**.
This is a mechanical change so no change in behaviour is expected. This is a part of getting rid of spapr-pci-vfio-host-bridge type.
---
Changes:
v8:
* moved spapr_phb_dma_capabilities_update() higher to avoid forward declaration in following patches and keep DMA code together (i.e. next to spapr_pci_dma_iommu())
--- hw/ppc/spapr_pci.c | 59 ++++++++++++++++++++++++++------------------- hw/ppc/spapr_pci_vfio.c | 53 ++++++++++++++++------------------------ include/hw/pci-host/spapr.h | 8 +++++- 3 files changed, 62 insertions(+), 58 deletions(-)
hw/ppc/spapr_pci.c +34 -25
@@ -810,6 +810,28 @@ static char *spapr_phb_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)return buf; } +static int spapr_phb_dma_capabilities_update (sPAPRPHBState *sphb) +{ + sphb->dma32_window_start =0 ; + sphb->dma32_window_size =SPAPR_PCI_DMA32_SIZE ; + +return 0 ; +} + +static int spapr_phb_dma_init_window (sPAPRPHBState *sphb, +uint32_t liobn,uint32_t page_shift, +uint64_t window_size) +{ +uint64_t bus_offset = sphb->dma32_window_start; +sPAPRTCETable *tcet; + + tcet =spapr_tce_new_table (DEVICE (sphb), liobn, bus_offset, page_shift, + window_size >> page_shift, + false); + +return tcet ?0 :-1 ; +} +/* Macros to operate with address in OF binding to PCI */ #define b_x (x, p, l) (((x) & ((1<<(l))-1)) << (p))#define b_n (x) b_x((x), 31, 1)/* 0 if relocatable */
@@ -1222,6 +1244,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)int i;PCIBus *bus;uint64_t msi_window_size =4096 ; +sPAPRTCETable *tcet;if (sphb->index != (uint32_t )-1 ) {hwaddr windows_base;
@@ -1371,33 +1394,18 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) } } -if (!info->finish_realize) { -error_setg (errp,"finish_realize not defined" ); -return ; - } - - info->finish_realize (sphb, errp); - - sphb->msi =g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free); -} - -static void spapr_phb_finish_realize (sPAPRPHBState *sphb,Error **errp) -{ -sPAPRTCETable *tcet; -uint32_t nb_table; - - nb_table =SPAPR_PCI_DMA32_SIZE >>SPAPR_TCE_PAGE_SHIFT ; - tcet =spapr_tce_new_table (DEVICE (sphb), sphb->dma_liobn, -0 ,SPAPR_TCE_PAGE_SHIFT , nb_table, false); + info->dma_capabilities_update (sphb); + info->dma_init_window (sphb, sphb->dma_liobn,SPAPR_TCE_PAGE_SHIFT , + sphb->dma32_window_size); + tcet =spapr_tce_find_by_liobn (sphb->dma_liobn);if (!tcet) { -error_setg (errp,"Unable to create TCE table for %s" , - sphb->dtbusname); -return ; +error_setg (errp,"failed to create TCE table" ); +return ; } - -/* Register default 32bit DMA window */ -memory_region_add_subregion (&sphb->iommu_root,0 , +memory_region_add_subregion (&sphb->iommu_root, tcet->bus_offset,spapr_tce_get_iommu (tcet)); + + sphb->msi =g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free); }static int spapr_phb_children_reset (Object *child,void *opaque)
@@ -1545,9 +1553,10 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_spapr_pci;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); dc->cannot_instantiate_with_device_add_yet = false; - spc->finish_realize = spapr_phb_finish_realize; hp->plug = spapr_phb_hot_plug_child; hp->unplug = spapr_phb_hot_unplug_child; + spc->dma_capabilities_update = spapr_phb_dma_capabilities_update; + spc->dma_init_window = spapr_phb_dma_init_window; }static const TypeInfo spapr_phb_info = {
hw/ppc/spapr_pci_vfio.c +21 -32
76 lines not on this page · raw message
include/hw/pci-host/spapr.h +7 -1
@@ -48,7 +48,10 @@ typedef struct sPAPRPHBVFIOState sPAPRPHBVFIOState;struct sPAPRPHBClass {PCIHostBridgeClass parent_class; -void (*finish_realize)(sPAPRPHBState *sphb,Error **errp); +int (*dma_capabilities_update)(sPAPRPHBState *sphb); +int (*dma_init_window)(sPAPRPHBState *sphb, +uint32_t liobn,uint32_t page_shift, +uint64_t window_size);int (*eeh_set_option)(sPAPRPHBState *sphb,unsigned int addr,int option);int (*eeh_get_state)(sPAPRPHBState *sphb,int *state);int (*eeh_reset)(sPAPRPHBState *sphb,int option);
@@ -90,6 +93,9 @@ struct sPAPRPHBState {int32_t msi_devs_num;spapr_pci_msi_mig *msi_devs; +uint32_t dma32_window_start; +uint32_t dma32_window_size; +QLIST_ENTRY (sPAPRPHBState) list; };
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 3/11 spapr_iommu: Move table allocation to helpers
In reply to Alexey KardashevskiyAt the moment presence of vfio-pci devices on a bus affect the way the guest view table is allocated. If there is no vfio-pci on a PHB and the host kernel supports KVM acceleration of H_PUT_TCE, a table is allocated in KVM. However, if there is vfio-pci and we do yet not KVM acceleration for these, the table has to be allocated by the userspace. At the moment the table is allocated once at boot time but next patches will reallocate it.
This moves kvmppc_create_spapr_tce/g_malloc0 and their counterparts to helpers.
--- hw/ppc/spapr_iommu.c | 58 +++++++++++++++++++++++++++++++++++----------------- trace-events | 2 +- 2 files changed, 40 insertions(+), 20 deletions(-)
hw/ppc/spapr_iommu.c +39 -19
@@ -74,6 +74,37 @@ static IOMMUAccessFlags spapr_tce_iommu_access_flags(uint64_t tce) } } +static uint64_t *spapr_tce_alloc_table (uint32_t liobn, +uint32_t nb_table, +uint32_t page_shift, +int *fd, +bool vfio_accel) +{ +uint64_t *table =NULL ; +uint64_t window_size = (uint64_t )nb_table << page_shift; + +if (kvm_enabled () && !(window_size >>32 )) { + table =kvmppc_create_spapr_tce (liobn, window_size, fd, vfio_accel); + } + +if (!table) { + *fd =-1 ; + table =g_malloc0 (nb_table *sizeof (uint64_t )); + } + +trace_spapr_iommu_alloc_table (liobn, table, *fd); + +return table; +} + +static void spapr_tce_free_table (uint64_t *table,int fd,uint32_t nb_table) +{ +if (!kvm_enabled () || + (kvmppc_remove_spapr_tce (table, fd, nb_table) !=0 )) { +g_free (table); + } +} +/* Called from RCU critical section */ static IOMMUTLBEntry spapr_tce_translate_iommu (MemoryRegion *iommu,hwaddr addr,bool is_write)
@@ -140,21 +171,13 @@ static MemoryRegionIOMMUOps spapr_iommu_ops = {static int spapr_tce_table_realize (DeviceState *dev) {sPAPRTCETable *tcet =SPAPR_TCE_TABLE (dev); -uint64_t window_size = (uint64_t )tcet->nb_table << tcet->page_shift; -if (kvm_enabled () && !(window_size >>32 )) { - tcet->table =kvmppc_create_spapr_tce (tcet->liobn, - window_size, - &tcet->fd, - tcet->vfio_accel); - } - -if (!tcet->table) { -size_t table_size = tcet->nb_table *sizeof (uint64_t ); - tcet->table =g_malloc0 (table_size); - } - -trace_spapr_iommu_new_table (tcet->liobn, tcet, tcet->table, tcet->fd); + tcet->fd =-1 ; + tcet->table =spapr_tce_alloc_table (tcet->liobn, + tcet->nb_table, + tcet->page_shift, + &tcet->fd, + tcet->vfio_accel); memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops, "iommu-spapr",
@@ -208,11 +231,8 @@ static void spapr_tce_table_unrealize(DeviceState *dev, Error **errp)QLIST_REMOVE (tcet, list); -if (!kvm_enabled () || - (kvmppc_remove_spapr_tce (tcet->table, tcet->fd, - tcet->nb_table) !=0 )) { -g_free (tcet->table); - } +spapr_tce_free_table (tcet->table, tcet->fd, tcet->nb_table); + tcet->fd =-1 ; }MemoryRegion *spapr_tce_get_iommu (sPAPRTCETable *tcet)
trace-events +1 -1
@@ -1362,7 +1362,7 @@ spapr_iommu_pci_get(uint64_t liobn, uint64_t ioba, uint64_t ret, uint64_t tce) " spapr_iommu_pci_indirect(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t iobaN, uint64_t tceN, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tcelist=0x%"PRIx64" iobaN=0x%"PRIx64" tceN=0x%"PRIx64" ret=%"PRId64 spapr_iommu_pci_stuff(uint64_t liobn, uint64_t ioba, uint64_t tce_value, uint64_t npages, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tcevalue=0x%"PRIx64" npages=%"PRId64" ret=%"PRId64 spapr_iommu_xlate(uint64_t liobn, uint64_t ioba, uint64_t tce, unsigned perm, unsigned pgsize) "liobn=%"PRIx64" 0x%"PRIx64" -> 0x%"PRIx64" perm=%u mask=%x" -spapr_iommu_new_table(uint64_t liobn, void *tcet, void *table, int fd) "liobn=%"PRIx64" tcet=%p table=%p fd=%d" +spapr_iommu_alloc_table(uint64_t liobn, void *table, int fd) "liobn=%"PRIx64" table=%p fd=%d" # hw/ppc/ppc.c ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 4/11 spapr_iommu: Introduce "enabled" state for TCE table
In reply to Alexey KardashevskiyCurrently TCE tables are created once at start and their size never changes. We are going to change that by introducing a Dynamic DMA windows support where DMA configuration may change during the guest execution.
This changes spapr_tce_new_table() to create an empty stub object. Only LIOBN is assigned by the time of creation. It still will be called once at the owner object (VIO or PHB) creation.
This introduces an "enabled" state for TCE table objects with two helper functions - spapr_tce_table_enable()/spapr_tce_table_disable(). spapr_tce_table_enable() receives TCE table parameters and allocates a guest view of the TCE table (in the user space or KVM). spapr_tce_table_disable() disposes the table.
Follow up patches will disable+enable tables on reset (system reset or DDW reset).
No visible change in behaviour is expected except the actual table will be reallocated every reset. We might optimize this later.
The other way to implement this would be dynamically create/remove the TCE table QOM objects but this would make migration impossible as migration expects all QOM objects to exist at the receiver so we have to have TCE table objects created when migration begins.
spapr_tce_table_do_enable() is separated from from spapr_tce_table_enable() as later it will be called at the sPAPRTCETable post-migration stage when it has all the properties set after the migration.
---
Changes:
v10:
* check if zero size window was requested and return an error; coming DDW patch will check for this
v9 (no changes really):
* IOMMU regions are referenced by their parent which is the PHB root region, there is no need in explicit unparenting so ignore first note from v8 changelog.
v8:
* add missing unparent_object() to spapr_tce_table_unrealize() (parenting is made by memory_region_init_iommu)
* tcet->iommu is alive as long as sPAPRTCETable is, memory_region_set_size() is used to enable/disable MR
v7:
* s'tmp[64]'tmp[32]' as we need less than 64bytes and more than 16 bytes and 32 is the closest power-of-two (just looks nices to have power-of-two values)
* updated commit log about having spapr_tce_table_do_enable() splitted from spapr_tce_table_enable()
v6:
* got rid of set_props()
--- hw/ppc/spapr_iommu.c | 79 +++++++++++++++++++++++++++++++++++-------------- hw/ppc/spapr_pci.c | 19 ++++++++---- hw/ppc/spapr_pci_vfio.c | 10 +++---- hw/ppc/spapr_vio.c | 9 +++--- include/hw/ppc/spapr.h | 11 +++---- 5 files changed, 85 insertions(+), 43 deletions(-)
hw/ppc/spapr_iommu.c +56 -23
@@ -173,15 +173,9 @@ static int spapr_tce_table_realize(DeviceState *dev)sPAPRTCETable *tcet =SPAPR_TCE_TABLE (dev); tcet->fd =-1 ; - tcet->table =spapr_tce_alloc_table (tcet->liobn, - tcet->nb_table, - tcet->page_shift, - &tcet->fd, - tcet->vfio_accel);memory_region_init_iommu (&tcet->iommu,OBJECT (dev), &spapr_iommu_ops, -"iommu-spapr" , - (uint64_t )tcet->nb_table << tcet->page_shift); +"iommu-spapr" ,0 );QLIST_INSERT_HEAD (&spapr_tce_tables, tcet, list);
@@ -191,14 +185,10 @@ static int spapr_tce_table_realize(DeviceState *dev)return 0 ; } -sPAPRTCETable *spapr_tce_new_table (DeviceState *owner,uint32_t liobn, -uint64_t bus_offset, -uint32_t page_shift, -uint32_t nb_table, -bool vfio_accel) +sPAPRTCETable *spapr_tce_new_table (DeviceState *owner,uint32_t liobn) {sPAPRTCETable *tcet; -char tmp[64 ]; +char tmp[32 ];if (spapr_tce_find_by_liobn (liobn)) { fprintf(stderr, "Attempted to create TCE table with duplicate"
@@ -206,16 +196,8 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,return NULL ; } -if (!nb_table) { -return NULL ; - } - tcet =SPAPR_TCE_TABLE (object_new (TYPE_SPAPR_TCE_TABLE )); tcet->liobn = liobn; - tcet->bus_offset = bus_offset; - tcet->page_shift = page_shift; - tcet->nb_table = nb_table; - tcet->vfio_accel = vfio_accel;snprintf (tmp,sizeof (tmp),"tce-table-%x" , liobn);object_property_add_child (OBJECT (owner), tmp,OBJECT (tcet),NULL );
@@ -225,14 +207,65 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,return tcet; } +static void spapr_tce_table_do_enable (sPAPRTCETable *tcet) +{ +if (!tcet->nb_table) { +return ; + } + + tcet->table =spapr_tce_alloc_table (tcet->liobn, + tcet->nb_table, + tcet->page_shift, + &tcet->fd, + tcet->vfio_accel); + +memory_region_set_size (&tcet->iommu, + (uint64_t )tcet->nb_table << tcet->page_shift); + + tcet->enabled = true; +} + +void spapr_tce_table_enable (sPAPRTCETable *tcet, +uint64_t bus_offset,uint32_t page_shift, +uint32_t nb_table,bool vfio_accel) +{ +if (tcet->enabled) { +return ; + } + + tcet->bus_offset = bus_offset; + tcet->page_shift = page_shift; + tcet->nb_table = nb_table; + tcet->vfio_accel = vfio_accel; + +spapr_tce_table_do_enable (tcet); +} + +void spapr_tce_table_disable (sPAPRTCETable *tcet) +{ +if (!tcet->enabled) { +return ; + } + +memory_region_set_size (&tcet->iommu,0 ); + +spapr_tce_free_table (tcet->table, tcet->fd, tcet->nb_table); + tcet->fd =-1 ; + tcet->table =NULL ; + tcet->enabled = false; + tcet->bus_offset =0 ; + tcet->page_shift =0 ; + tcet->nb_table =0 ; + tcet->vfio_accel = false; +} +static void spapr_tce_table_unrealize (DeviceState *dev,Error **errp) {sPAPRTCETable *tcet =SPAPR_TCE_TABLE (dev);QLIST_REMOVE (tcet, list); -spapr_tce_free_table (tcet->table, tcet->fd, tcet->nb_table); - tcet->fd =-1 ; +spapr_tce_table_disable (tcet); }MemoryRegion *spapr_tce_get_iommu (sPAPRTCETable *tcet)
hw/ppc/spapr_pci.c +14 -5
@@ -823,13 +823,16 @@ static int spapr_phb_dma_init_window(sPAPRPHBState *sphb, uint64_t window_size) {uint64_t bus_offset = sphb->dma32_window_start; -sPAPRTCETable *tcet; +sPAPRTCETable *tcet =spapr_tce_find_by_liobn (liobn); +uint32_t nb_table = window_size >> page_shift; - tcet =spapr_tce_new_table (DEVICE (sphb), liobn, bus_offset, page_shift, - window_size >> page_shift, - false); +if (!nb_table) { +return -1 ; + } -return tcet ?0 :-1 ; +spapr_tce_table_enable (tcet, bus_offset, page_shift, nb_table, false); + +return 0 ; }/* Macros to operate with address in OF binding to PCI */
@@ -1394,6 +1397,12 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) } } + tcet =spapr_tce_new_table (DEVICE (sphb), sphb->dma_liobn); +if (!tcet) { +error_setg (errp,"failed to create TCE table" ); +return ; + } + info->dma_capabilities_update (sphb); info->dma_init_window (sphb, sphb->dma_liobn,SPAPR_TCE_PAGE_SHIFT , sphb->dma32_window_size);
hw/ppc/spapr_pci_vfio.c +5 -5
@@ -51,13 +51,13 @@ static int spapr_phb_vfio_dma_init_window(sPAPRPHBState *sphb, uint64_t window_size) {uint64_t bus_offset = sphb->dma32_window_start; -sPAPRTCETable *tcet; +sPAPRTCETable *tcet =spapr_tce_find_by_liobn (liobn); - tcet =spapr_tce_new_table (DEVICE (sphb), liobn, bus_offset, page_shift, - window_size >> page_shift, - true); +spapr_tce_table_enable (tcet, bus_offset, page_shift, + window_size >> page_shift, + true); -return tcet ?0 :-1 ; +return 0 ; }static void spapr_phb_vfio_eeh_reenable (sPAPRPHBVFIOState *svphb)
hw/ppc/spapr_vio.c +4 -5
@@ -479,11 +479,10 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)memory_region_add_subregion_overlap (&dev->mrroot,0 , &dev->mrbypass,1 );address_space_init (&dev->as, &dev->mrroot, qdev->id); - dev->tcet =spapr_tce_new_table (qdev, liobn, -0 , -SPAPR_TCE_PAGE_SHIFT , - pc->rtce_window_size >> -SPAPR_TCE_PAGE_SHIFT , false); + dev->tcet =spapr_tce_new_table (qdev, liobn); +spapr_tce_table_enable (dev->tcet,0 ,SPAPR_TCE_PAGE_SHIFT , + pc->rtce_window_size >>SPAPR_TCE_PAGE_SHIFT , + false); dev->tcet->vdev = dev;memory_region_add_subregion_overlap (&dev->mrroot,0 ,spapr_tce_get_iommu (dev->tcet),2 );
include/hw/ppc/spapr.h +6 -5
@@ -555,6 +555,7 @@ typedef struct sPAPRTCETable sPAPRTCETable;struct sPAPRTCETable {DeviceState parent; +bool enabled;uint32_t liobn;uint32_t nb_table;uint64_t bus_offset;
@@ -582,11 +583,11 @@ void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq);int spapr_h_cas_compose_response (sPAPRMachineState *sm,target_ulong addr,target_ulong size,bool cpu_update,bool memory_update); -sPAPRTCETable *spapr_tce_new_table (DeviceState *owner,uint32_t liobn, -uint64_t bus_offset, -uint32_t page_shift, -uint32_t nb_table, -bool vfio_accel); +sPAPRTCETable *spapr_tce_new_table (DeviceState *owner,uint32_t liobn); +void spapr_tce_table_enable (sPAPRTCETable *tcet, +uint64_t bus_offset,uint32_t page_shift, +uint32_t nb_table,bool vfio_accel); +void spapr_tce_table_disable (sPAPRTCETable *tcet);MemoryRegion *spapr_tce_get_iommu (sPAPRTCETable *tcet);int spapr_dma_dt (void *fdt,int node_off,const char *propname,uint32_t liobn,uint64_t window,uint32_t size);
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 5/11 spapr_iommu: Remove vfio_accel flag from sPAPRTCETable
In reply to Alexey KardashevskiysPAPRTCETable has a vfio_accel flag which is passed to kvmppc_create_spapr_tce() and controls whether to create a guest view table in KVM as this depends on the host kernel ability to accelerate H_PUT_TCE for VFIO devices. We would set this flag at the moment when sPAPRTCETable is created in spapr_tce_new_table() and use when the table is allocated in spapr_tce_table_realize().
Now we explicitly enable/disable DMA windows via spapr_tce_table_enable() and spapr_tce_table_disable() and can pass this flag directly without caching it in sPAPRTCETable.
This removes the flag. This should cause no behavioural change.
---
Changes:
v8:
* new to patchset, this is cleanup
--- hw/ppc/spapr_iommu.c | 8 +++----- include/hw/ppc/spapr.h | 1 - 2 files changed, 3 insertions(+), 6 deletions(-)
hw/ppc/spapr_iommu.c +3 -5
@@ -207,7 +207,7 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn)return tcet; } -static void spapr_tce_table_do_enable (sPAPRTCETable *tcet) +static void spapr_tce_table_do_enable (sPAPRTCETable *tcet,bool vfio_accel) {if (!tcet->nb_table) {return ;
@@ -217,7 +217,7 @@ static void spapr_tce_table_do_enable(sPAPRTCETable *tcet) tcet->nb_table, tcet->page_shift, &tcet->fd, - tcet->vfio_accel); + vfio_accel);memory_region_set_size (&tcet->iommu, (uint64_t )tcet->nb_table << tcet->page_shift);
@@ -236,9 +236,8 @@ void spapr_tce_table_enable(sPAPRTCETable *tcet, tcet->bus_offset = bus_offset; tcet->page_shift = page_shift; tcet->nb_table = nb_table; - tcet->vfio_accel = vfio_accel; -spapr_tce_table_do_enable (tcet); +spapr_tce_table_do_enable (tcet, vfio_accel); }void spapr_tce_table_disable (sPAPRTCETable *tcet)
@@ -256,7 +255,6 @@ void spapr_tce_table_disable(sPAPRTCETable *tcet) tcet->bus_offset =0 ; tcet->page_shift =0 ; tcet->nb_table =0 ; - tcet->vfio_accel = false; }static void spapr_tce_table_unrealize (DeviceState *dev,Error **errp)
include/hw/ppc/spapr.h +0 -1
@@ -562,7 +562,6 @@ struct sPAPRTCETable {uint32_t page_shift;uint64_t *table;bool bypass; -bool vfio_accel;int fd;MemoryRegion iommu;struct VIOsPAPRDevice *vdev;/* for @bypass migration compatibility only */
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 6/11 spapr_iommu: Add root memory region
In reply to Alexey KardashevskiyWe are going to have multiple DMA windows at different offsets on a PCI bus. For the sake of migration, we will have as many TCE table objects pre-created as many windows supported.
So we need a way to map windows dynamically onto a PCI bus when migration of a table is completed but at this stage a TCE table object does not have access to a PHB to ask it to map a DMA window backed by just migrated TCE table.
This adds a "root" memory region (UINT64_MAX long) to the TCE object. This new region is mapped on a PCI bus with enabled overlapping as there will be one root MR per TCE table, each of them mapped at 0. The actual IOMMU memory region is a subregion of the root region and a TCE table enables/disables this subregion and maps it at the specific offset inside the root MR which is 1:1 mapping of a PCI address space.
--- hw/ppc/spapr_iommu.c | 13 ++++++++++--- hw/ppc/spapr_pci.c | 2 +- include/hw/ppc/spapr.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-)
hw/ppc/spapr_iommu.c +10 -3
@@ -171,11 +171,16 @@ static MemoryRegionIOMMUOps spapr_iommu_ops = {static int spapr_tce_table_realize (DeviceState *dev) {sPAPRTCETable *tcet =SPAPR_TCE_TABLE (dev); +Object *tcetobj =OBJECT (tcet); +char tmp[32 ]; tcet->fd =-1 ; -memory_region_init_iommu (&tcet->iommu,OBJECT (dev), &spapr_iommu_ops, -"iommu-spapr" ,0 ); +snprintf (tmp,sizeof (tmp),"tce-root-%x" , tcet->liobn); +memory_region_init (&tcet->root, tcetobj, tmp,UINT64_MAX ); + +snprintf (tmp,sizeof (tmp),"tce-iommu-%x" , tcet->liobn); +memory_region_init_iommu (&tcet->iommu, tcetobj, &spapr_iommu_ops, tmp,0 );QLIST_INSERT_HEAD (&spapr_tce_tables, tcet, list);
@@ -221,6 +226,7 @@ static void spapr_tce_table_do_enable(sPAPRTCETable *tcet, bool vfio_accel)memory_region_set_size (&tcet->iommu, (uint64_t )tcet->nb_table << tcet->page_shift); +memory_region_add_subregion (&tcet->root, tcet->bus_offset, &tcet->iommu); tcet->enabled = true; }
@@ -246,6 +252,7 @@ void spapr_tce_table_disable(sPAPRTCETable *tcet)return ; } +memory_region_del_subregion (&tcet->root, &tcet->iommu);memory_region_set_size (&tcet->iommu,0 );spapr_tce_free_table (tcet->table, tcet->fd, tcet->nb_table);
@@ -268,7 +275,7 @@ static void spapr_tce_table_unrealize(DeviceState *dev, Error **errp)MemoryRegion *spapr_tce_get_iommu (sPAPRTCETable *tcet) { -return &tcet->iommu; +return &tcet->root; }static void spapr_tce_reset (DeviceState *dev)
hw/ppc/spapr_pci.c +1 -1
@@ -1411,7 +1411,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)error_setg (errp,"failed to create TCE table" );return ; } -memory_region_add_subregion (&sphb->iommu_root, tcet->bus_offset, +memory_region_add_subregion (&sphb->iommu_root,0 ,spapr_tce_get_iommu (tcet)); sphb->msi =g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);
include/hw/ppc/spapr.h +1 -1
@@ -563,7 +563,7 @@ struct sPAPRTCETable {uint64_t *table;bool bypass;int fd; -MemoryRegion iommu; +MemoryRegion root, iommu;struct VIOsPAPRDevice *vdev;/* for @bypass migration compatibility only */ QLIST_ENTRY (sPAPRTCETable) list; };
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 7/11 spapr_pci: Do complete reset of DMA config when resetting PHB
In reply to Alexey KardashevskiyOn a system reset, DMA configuration has to reset too. At the moment it clears the table content. This is enough for the single table case but with DDW, we will also have to disable all DMA windows except the default one. Furthermore according to sPAPR, if the guest removed the default window and created a huge one at the same zero offset on a PCI bus, the reset handler has to recreate the default window with the default properties (2GB big, 4K pages).
This reworks SPAPR PHB code to disable the existing DMA window on reset and then configure and enable the default window.
Without DDW that means that the same window will be disabled and then enabled with no other change in behaviour.
This changes the table creation to do it in one place in PHB (VFIO PHB just inherits the behaviour from PHB). The actual table allocation is done from the reset handler and this is where dma_init_window() is called.
This disables all DMA windows on a PHB reset. It does not make any difference now as there is just one DMA window but it will later with DDW patches.
This makes spapr_phb_dma_reset() and spapr_phb_dma_remove_window() public as these will be used in DDW RTAS "ibm,reset-pe-dma-window" and "ibm,remove-pe-dma-window" handlers later; the handlers will reside in hw/ppc/spapr_rtas_ddw.c.
---
Changes:
v9:
* as spapr_phb_vfio_reset() became not empty, this does not remove it but adds spapr_phb_dma_reset() call
* added SPAPR_PCI_DMA_MAX_WINDOWS (was in "spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)")
* object_child_foreach() is replaced with explicit loop over DMA windows as later in the patchset we will be doing same loop and there the order will matter (small windows should be enumerated first)
v7:
* s'finish_realize'dma_init_window' in the commit log
* added details (initial clause about reuse was there :) ) why exactly spapr_phb_dma_remove_window is public
--- hw/ppc/spapr_pci.c | 42 +++++++++++++++++++++++++++++++++--------- hw/ppc/spapr_pci_vfio.c | 4 ++++ include/hw/pci-host/spapr.h | 5 +++++ 3 files changed, 42 insertions(+), 9 deletions(-)
hw/ppc/spapr_pci.c +33 -9
@@ -835,6 +835,35 @@ static int spapr_phb_dma_init_window(sPAPRPHBState *sphb,return 0 ; } +int spapr_phb_dma_remove_window (sPAPRPHBState *sphb, +sPAPRTCETable *tcet) +{ +spapr_tce_table_disable (tcet); + +return 0 ; +} + +int spapr_phb_dma_reset (sPAPRPHBState *sphb) +{ +int i; +sPAPRTCETable *tcet; +sPAPRPHBClass *spc =SPAPR_PCI_HOST_BRIDGE_GET_CLASS (sphb); + + spc->dma_capabilities_update (sphb);/* Refresh @has_vfio status */ + +for (i =0 ; i <SPAPR_PCI_DMA_MAX_WINDOWS ; ++i) { + tcet =spapr_tce_find_by_liobn (SPAPR_PCI_LIOBN (sphb->index, i)); +if (tcet) { +spapr_phb_dma_remove_window (sphb, tcet); + } + } + + spc->dma_init_window (sphb,SPAPR_PCI_LIOBN (sphb->index,0 ), +SPAPR_TCE_PAGE_SHIFT , sphb->dma32_window_size); + +return 0 ; +} +/* Macros to operate with address in OF binding to PCI */ #define b_x (x, p, l) (((x) & ((1<<(l))-1)) << (p))#define b_n (x) b_x((x), 31, 1)/* 0 if relocatable */
@@ -1242,7 +1271,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)SysBusDevice *s =SYS_BUS_DEVICE (dev);sPAPRPHBState *sphb =SPAPR_PCI_HOST_BRIDGE (s);PCIHostState *phb =PCI_HOST_BRIDGE (s); -sPAPRPHBClass *info =SPAPR_PCI_HOST_BRIDGE_GET_CLASS (s);char *namebuf;int i;PCIBus *bus;
@@ -1403,14 +1431,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)return ; } - info->dma_capabilities_update (sphb); - info->dma_init_window (sphb, sphb->dma_liobn,SPAPR_TCE_PAGE_SHIFT , - sphb->dma32_window_size); - tcet =spapr_tce_find_by_liobn (sphb->dma_liobn); -if (!tcet) { -error_setg (errp,"failed to create TCE table" ); -return ; - }memory_region_add_subregion (&sphb->iommu_root,0 ,spapr_tce_get_iommu (tcet));
@@ -1430,6 +1450,10 @@ static int spapr_phb_children_reset(Object *child, void *opaque)static void spapr_phb_reset (DeviceState *qdev) { +sPAPRPHBState *sphb =SPAPR_PCI_HOST_BRIDGE (qdev); + +spapr_phb_dma_reset (sphb); +/* Reset the IOMMU state */ object_child_foreach (OBJECT (qdev), spapr_phb_children_reset,NULL ); }
hw/ppc/spapr_pci_vfio.c +4 -0
@@ -73,6 +73,10 @@ static void spapr_phb_vfio_eeh_reenable(sPAPRPHBVFIOState *svphb)static void spapr_phb_vfio_reset (DeviceState *qdev) { +sPAPRPHBState *sphb =SPAPR_PCI_HOST_BRIDGE (qdev); + +spapr_phb_dma_reset (sphb); +/* * The PE might be in frozen state. To reenable the EEH * functionality on it will clean the frozen state, which
include/hw/pci-host/spapr.h +5 -0
@@ -123,6 +123,8 @@ struct sPAPRPHBVFIOState {#define SPAPR_PCI_DMA32_SIZE 0x40000000 +#define SPAPR_PCI_DMA_MAX_WINDOWS 1 +static inline qemu_irq spapr_phb_lsi_qirq (struct sPAPRPHBState *phb,int pin) {sPAPRMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ());
@@ -143,5 +145,8 @@ void spapr_pci_rtas_init(void);sPAPRPHBState *spapr_pci_find_phb (sPAPRMachineState *spapr,uint64_t buid);PCIDevice *spapr_pci_find_dev (sPAPRMachineState *spapr,uint64_t buid,uint32_t config_addr); +int spapr_phb_dma_remove_window (sPAPRPHBState *sphb, +sPAPRTCETable *tcet); +int spapr_phb_dma_reset (sPAPRPHBState *sphb);#endif /* __HW_SPAPR_PCI_H__ */
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 8/11 spapr_vfio_pci: Remove redundant spapr-pci-vfio-host-bridge
In reply to Alexey KardashevskiysPAPRTCETable is handling 2 TCE tables already:
1) guest view of the TCE table - emulated devices use only this table;
2) hardware IOMMU table - VFIO PCI devices use it for actual work but it does not replace 1) and it is not visible to the guest. The initialization of this table is driven by vfio-pci device, DMA map/unmap requests are handled via MemoryListener so there is very little to do in spapr-pci-vfio-host-bridge.
This moves VFIO bits to the generic spapr-pci-host-bridge which allows putting emulated and VFIO devices on the same PHB. It is still possible to create multiple PHBs and avoid sharing PHB resouces for emulated and VFIO devices.
If there is no VFIO-PCI device attaches, no special ioctls will be called. If there are some VFIO-PCI devices attached, PHB may refuse to attach another VFIO-PCI device if a VFIO container on the host kernel side does not support container sharing.
This changes spapr-pci-host-bridge to support properties of spapr-pci-vfio-host-bridge. This makes spapr-pci-vfio-host-bridge type equal to spapr-pci-host-bridge except it has an additional "iommu" property for backward compatibility reasons.
This moves PCI device lookup from spapr_phb_vfio_eeh_set_option() to rtas_ibm_set_eeh_option() as we need to know if the device is "vfio-pci" and decide whether to call spapr_phb_vfio_eeh_set_option() or not.
---
Changes:
v11:
* fixed compilation for non-linux case: spapr_pci_vfio.c now always compiles and has stubs when no CONFIG_LINUX
* replaced @has_vfio flag with a number of vfio-pci devices
v9:
* s'iommugroupid shall not be used'iommugroupid is deprecated and will be ignored' in error log
v8:
* call spapr_phb_vfio_eeh_set_option() on vfio-pci devices only (reported by Gavin)
--- hw/ppc/Makefile.objs | 5 +- hw/ppc/spapr_pci.c | 85 +++++++++++------------------- hw/ppc/spapr_pci_vfio.c | 122 +++++++++++++++++++------------------------- include/hw/pci-host/spapr.h | 25 ++++----- 4 files changed, 95 insertions(+), 142 deletions(-)
hw/ppc/Makefile.objs +1 -4
@@ -3,10 +3,7 @@ obj-y += ppc.o ppc_booke.o # IBM pSeries (sPAPR) obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o -obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o -ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) -obj-y += spapr_pci_vfio.o -endif +obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_pci_vfio.o spapr_rtc.o spapr_drc.o # PowerPC 4xx boards obj-y += ppc405_boards.o ppc4xx_devs.o ppc405_uc.o ppc440_bamboo.o obj-y += ppc4xx_pci.o
hw/ppc/spapr_pci.c +31 -54
227 lines not on this page · raw message
hw/ppc/spapr_pci_vfio.c +53 -69
225 lines not on this page · raw message
include/hw/pci-host/spapr.h +10 -15
@@ -47,15 +47,6 @@ typedef struct sPAPRPHBVFIOState sPAPRPHBVFIOState;struct sPAPRPHBClass {PCIHostBridgeClass parent_class; - -int (*dma_capabilities_update)(sPAPRPHBState *sphb); -int (*dma_init_window)(sPAPRPHBState *sphb, -uint32_t liobn,uint32_t page_shift, -uint64_t window_size); -int (*eeh_set_option)(sPAPRPHBState *sphb,unsigned int addr,int option); -int (*eeh_get_state)(sPAPRPHBState *sphb,int *state); -int (*eeh_reset)(sPAPRPHBState *sphb,int option); -int (*eeh_configure)(sPAPRPHBState *sphb); }; typedef struct spapr_pci_msi {
@@ -95,16 +86,12 @@ struct sPAPRPHBState {uint32_t dma32_window_start;uint32_t dma32_window_size; +unsigned vfio_num; +int32_t iommugroupid;/* obsolete */ QLIST_ENTRY (sPAPRPHBState) list; }; -struct sPAPRPHBVFIOState { -sPAPRPHBState phb; - -int32_t iommugroupid; -}; -#define SPAPR_PCI_MAX_INDEX 255#define SPAPR_PCI_BASE_BUID 0x800000020000000ULL
@@ -149,4 +136,12 @@ int spapr_phb_dma_remove_window(sPAPRPHBState *sphb, sPAPRTCETable *tcet);int spapr_phb_dma_reset (sPAPRPHBState *sphb); +int spapr_phb_vfio_dma_capabilities_update (sPAPRPHBState *sphb); +int spapr_phb_vfio_eeh_set_option (sPAPRPHBState *sphb, +PCIDevice *pdev,int option); +int spapr_phb_vfio_eeh_get_state (sPAPRPHBState *sphb,int *state); +int spapr_phb_vfio_eeh_reset (sPAPRPHBState *sphb,int option); +int spapr_phb_vfio_eeh_configure (sPAPRPHBState *sphb); +void spapr_phb_vfio_eeh_reenable (sPAPRPHBState *sphb); +#endif /* __HW_SPAPR_PCI_H__ */
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 9/11 spapr_pci: Enable vfio-pci hotplug
In reply to Alexey KardashevskiysPAPR IOMMU is managing two copies of an TCE table:
1) a guest view of the table - this is what emulated devices use and this is where H_GET_TCE reads from;
2) a hardware TCE table - only present if there is at least one vfio-pci device on a PHB; it is updated via a memory listener on a PHB address space which forwards map/unmap requests to vfio-pci IOMMU host driver.
At the moment presence of vfio-pci devices on a bus affect the way the guest view table is allocated. If there is no vfio-pci on a PHB and the host kernel supports KVM acceleration of H_PUT_TCE, a table is allocated in KVM. However, if there is vfio-pci and we do yet not support KVM acceleration for these, the table has to be allocated by the userspace.
When vfio-pci device is hotplugged and there were no vfio-pci devices already, the guest view table could have been allocated by KVM which means that H_PUT_TCE is handled by the host kernel and since we do not support vfio-pci in KVM, the hardware table will not be updated.
This reallocates the guest view table in QEMU if the first vfio-pci device has just been plugged. spapr_tce_realloc() handles this. When last vfio-pci device is unplugged, this tries reallocating the TCE table in KVM.
This replays all the mappings to make sure that the tables are in sync. This will not have a visible effect though as for a new device the guest kernel will allocate-and-map new addresses and therefore existing mappings from emulated devices will not be used by vfio-pci devices.
This adds calls to spapr_phb_dma_capabilities_update() in PCI hotplug hooks.
---
Changes:
v11:
* removed one level of indent in spapr_phb_hotplug_dma_sync
* removed RCU handler and used @vfio_num counter instead as the actual presense of vfio-pci devices matter, not containers
* s/spapr_tce_realloc_userspace/spapr_tce_realloc/ and support reallocation to KVM space in order to reenable acceleration; this is also necessary for in-kernel acceleration for VFIO - we will drop IOMMU group references by reallocating the KVM table
v10:
* removed unnecessary memory_region_del_subregion() and memory_region_add_subregion() as
"vfio: Unregister IOMMU notifiers when container is destroyed" removes notifiers in a more correct way
v9:
* spapr_phb_hotplug_dma_sync() enumerates TCE tables explicitely rather than via object_child_foreach()
* spapr_phb_hotplug_dma_sync() does memory_region_del_subregion() + memory_region_add_subregion() as otherwise vfio_listener_region_del() is not called and we end up with vfio_iommu_map_notify registered twice (comments welcome!) if we do hotplug+hotunplug+hotplug of the same device.
* moved spapr_phb_hotplug_dma_sync() on unplug event to rcu as before calling spapr_phb_hotplug_dma_sync(), we need VFIO to release the container, otherwise spapr_phb_dma_capabilities_update() will decide that the PHB still has VFIO device. Actual VFIO PCI device release happens from rcu and since we add ours later, it gets executed later and we are good.
--- hw/ppc/spapr_iommu.c | 71 +++++++++++++++++++++++++++++++++++++++++++-- hw/ppc/spapr_pci.c | 60 ++++++++++++++++++++++++++++++++++++++ include/hw/pci-host/spapr.h | 1 + include/hw/ppc/spapr.h | 3 ++ trace-events | 2 ++ 5 files changed, 134 insertions(+), 3 deletions(-)
hw/ppc/spapr_iommu.c +68 -3
@@ -78,12 +78,13 @@ static uint64_t *spapr_tce_alloc_table(uint32_t liobn,uint32_t nb_table, uint32_t page_shift, int *fd, - bool vfio_accel) + bool vfio_accel, + bool force_userspace) { uint64_t *table = NULL;uint64_t window_size = (uint64_t )nb_table << page_shift; -if (kvm_enabled () && !(window_size >>32 )) { +if (kvm_enabled () && !force_userspace && !(window_size >>32 )) { table =kvmppc_create_spapr_tce (liobn, window_size, fd, vfio_accel); }
@@ -222,7 +223,8 @@ static void spapr_tce_table_do_enable(sPAPRTCETable *tcet, bool vfio_accel) tcet->nb_table, tcet->page_shift, &tcet->fd, - vfio_accel); + vfio_accel, + false);memory_region_set_size (&tcet->iommu, (uint64_t )tcet->nb_table << tcet->page_shift);
@@ -495,6 +497,69 @@ int spapr_dma_dt(void *fdt, int node_off, const char *propname,return 0 ; } +static int spapr_tce_do_replay (sPAPRTCETable *tcet,uint64_t *table) +{ +target_ulong ioba = tcet->bus_offset, pgsz = (1ULL << tcet->page_shift); +long i, ret =0 ; + +for (i =0 ; i < tcet->nb_table; ++i, ioba += pgsz) { + ret =put_tce_emu (tcet, ioba, table[i]); +if (ret) { +break ; + } + } + +return ret; +} + +int spapr_tce_replay (sPAPRTCETable *tcet) +{ +return spapr_tce_do_replay (tcet, tcet->table); +} + +int spapr_tce_realloc (sPAPRTCETable *tcet,bool vfio_accel, +bool force_userspace) +{ +int ret, oldfd; +uint64_t *oldtable; + +if (force_userspace) { + oldtable = tcet->table; + oldfd = tcet->fd; + }else { +unsigned long cb = tcet->nb_table *sizeof (uint64_t ); +/* +* We might be trying to reallocate KVM table. +* KVM_CREATE_SPAPR_TCE handler checks for LIOBN and fails if +* is registered. Store KVM table locally and destroy the KVM table. +*/ + oldtable =g_malloc0 (cb); + oldfd =-1 ; +memcpy (oldtable, tcet->table, cb); +spapr_tce_free_table (tcet->table, tcet->fd, tcet->nb_table); + } + + tcet->table =spapr_tce_alloc_table (tcet->liobn, + tcet->nb_table, + tcet->page_shift, + &tcet->fd, + vfio_accel, + force_userspace); +if (!tcet->table) { +return -ENOMEM ; + } + + ret =spapr_tce_do_replay (tcet, oldtable); + +if (force_userspace) { +spapr_tce_free_table (oldtable, oldfd, tcet->nb_table); + }else { +g_free (oldtable); + } + +return ret; +} +int spapr_tcet_dma_dt (void *fdt,int node_off,const char *propname,sPAPRTCETable *tcet) {
hw/ppc/spapr_pci.c +60 -0
85 lines not on this page · raw message
include/hw/pci-host/spapr.h +1 -0
@@ -61,6 +61,7 @@ typedef struct spapr_pci_msi_mig {struct sPAPRPHBState {PCIHostState parent_obj; +struct rcu_head rcu;uint32_t index;uint64_t buid;
include/hw/ppc/spapr.h +3 -0
@@ -592,6 +592,9 @@ int spapr_dma_dt(void *fdt, int node_off, const char *propname, uint32_t liobn, uint64_t window, uint32_t size);int spapr_tcet_dma_dt (void *fdt,int node_off,const char *propname,sPAPRTCETable *tcet); +int spapr_tce_replay (sPAPRTCETable *tcet); +int spapr_tce_realloc (sPAPRTCETable *tcet,bool vfio_accel, +bool force_userspace);void spapr_pci_switch_vga (bool big_endian);void spapr_hotplug_req_add_event (sPAPRDRConnector *drc);void spapr_hotplug_req_remove_event (sPAPRDRConnector *drc);
trace-events +2 -0
@@ -1300,6 +1300,8 @@ spapr_pci_rtas_ibm_query_interrupt_source_number(unsigned ioa, unsigned intr) "q spapr_pci_msi_write(uint64_t addr, uint64_t data, uint32_t dt_irq) "@%"PRIx64"<=%"PRIx64" IRQ %u" spapr_pci_lsi_set(const char *busname, int pin, uint32_t irq) "%s PIN%d IRQ %u" spapr_pci_msi_retry(unsigned config_addr, unsigned req_num, unsigned max_irqs) "Guest device at %x asked %u, have only %u" +spapr_pci_dma_update(uint64_t liobn, long ret) "liobn=%"PRIx64" ret=%ld" +spapr_pci_dma_realloc_update(uint64_t liobn, long ret) "liobn=%"PRIx64" tcet=%ld" # hw/pci/pci.c pci_update_mappings_del(void *d, uint32_t bus, uint32_t func, uint32_t slot, int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x %d,%#"PRIx64"+%#"PRIx64
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 10/11 spapr_pci_vfio: Enable multiple groups per container
In reply to Alexey KardashevskiyThis enables multiple IOMMU groups in one VFIO container which means that multiple devices from different groups can share the same IOMMU table (or tables if DDW).
This removes a group id from vfio_container_ioctl(). The kernel support is required for this; if the host kernel does not have the support, it will allow only one group per container. The PHB's "iommuid" property is ignored. The ioctl is called for every container attached to the address space. At the moment there is just one container anyway.
If there is no container attached to the address space, vfio_container_do_ioctl() returns -1.
This removes casts to sPAPRPHBVFIOState as none of sPAPRPHBVFIOState members is accessed here.
--- hw/ppc/spapr_pci_vfio.c | 17 ++++++----------- hw/vfio/common.c | 21 ++++++--------------- include/hw/vfio/vfio.h | 3 +-- 3 files changed, 13 insertions(+), 28 deletions(-)
hw/ppc/spapr_pci_vfio.c +6 -11
@@ -35,7 +35,7 @@ int spapr_phb_vfio_dma_capabilities_update(sPAPRPHBState *sphb)struct vfio_iommu_spapr_tce_info info = { .argsz =sizeof (info) };int ret; - ret =vfio_container_ioctl (&sphb->iommu_as, sphb->iommugroupid, + ret =vfio_container_ioctl (&sphb->iommu_as,VFIO_IOMMU_SPAPR_TCE_GET_INFO , &info);if (ret) {return ret;
@@ -61,8 +61,7 @@ void spapr_phb_vfio_eeh_reenable(sPAPRPHBState *sphb)* ensures that the contained PCI devices will work properly * after reboot. */ -vfio_container_ioctl (&sphb->iommu_as, - sphb->iommugroupid,VFIO_EEH_PE_OP , &op); +vfio_container_ioctl (&sphb->iommu_as,VFIO_EEH_PE_OP , &op); } int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
@@ -88,8 +87,7 @@ int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,return RTAS_OUT_PARAM_ERROR ; } - ret =vfio_container_ioctl (&sphb->iommu_as, sphb->iommugroupid, -VFIO_EEH_PE_OP , &op); + ret =vfio_container_ioctl (&sphb->iommu_as,VFIO_EEH_PE_OP , &op);if (ret <0 ) {return RTAS_OUT_HW_ERROR ; }
@@ -103,8 +101,7 @@ int spapr_phb_vfio_eeh_get_state(sPAPRPHBState *sphb, int *state)int ret; op.op =VFIO_EEH_PE_GET_STATE ; - ret =vfio_container_ioctl (&sphb->iommu_as, sphb->iommugroupid, -VFIO_EEH_PE_OP , &op); + ret =vfio_container_ioctl (&sphb->iommu_as,VFIO_EEH_PE_OP , &op);if (ret <0 ) {return RTAS_OUT_PARAM_ERROR ; }
@@ -177,8 +174,7 @@ int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb, int option)return RTAS_OUT_PARAM_ERROR ; } - ret =vfio_container_ioctl (&sphb->iommu_as, sphb->iommugroupid, -VFIO_EEH_PE_OP , &op); + ret =vfio_container_ioctl (&sphb->iommu_as,VFIO_EEH_PE_OP , &op);if (ret <0 ) {return RTAS_OUT_HW_ERROR ; }
@@ -192,8 +188,7 @@ int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb)int ret; op.op =VFIO_EEH_PE_CONFIGURE ; - ret =vfio_container_ioctl (&sphb->iommu_as, sphb->iommugroupid, -VFIO_EEH_PE_OP , &op); + ret =vfio_container_ioctl (&sphb->iommu_as,VFIO_EEH_PE_OP , &op);if (ret <0 ) {return RTAS_OUT_PARAM_ERROR ; }
hw/vfio/common.c +6 -15
@@ -926,35 +926,26 @@ void vfio_put_base_device(VFIODevice *vbasedev)close (vbasedev->fd); } -static int vfio_container_do_ioctl (AddressSpace *as,int32_t groupid, +static int vfio_container_do_ioctl (AddressSpace *as,int req,void *param) { -VFIOGroup *group;VFIOContainer *container;int ret =-1 ; +VFIOAddressSpace *space =vfio_get_address_space (as); - group =vfio_get_group (groupid, as); -if (!group) { -error_report ("vfio: group %d not registered" , groupid); -return ret; - } - - container = group->container; -if (group->container) { + QLIST_FOREACH(container, &space->containers, next) { ret =ioctl (container->fd, req, param);if (ret <0 ) {error_report ("vfio: failed to ioctl %d to container: ret=%d, %s" ,_IOC_NR (req) -VFIO_BASE , ret,strerror (errno)); +return -errno; } } -vfio_put_group (group); -return ret; } -int vfio_container_ioctl (AddressSpace *as,int32_t groupid, -int req,void *param) +int vfio_container_ioctl (AddressSpace *as,int req,void *param) {/* We allow only certain ioctls to the container */ switch (req) {
@@ -968,5 +959,5 @@ int vfio_container_ioctl(AddressSpace *as, int32_t groupid,return -1 ; } -return vfio_container_do_ioctl (as, groupid, req, param); +return vfio_container_do_ioctl (as, req, param); }
include/hw/vfio/vfio.h +1 -2
@@ -3,7 +3,6 @@#include "qemu/typedefs.h" -extern int vfio_container_ioctl (AddressSpace *as,int32_t groupid, -int req,void *param); +extern int vfio_container_ioctl (AddressSpace *as,int req,void *param);#endif
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5
PATCH v11 11/11 spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)
In reply to Alexey KardashevskiyThis adds support for Dynamic DMA Windows (DDW) option defined by the SPAPR specification which allows to have additional DMA window(s)
This implements DDW for emulated and VFIO devices. As all TCE root regions are mapped at 0 and 64bit long (and actual tables are child regions), this replaces memory_region_add_subregion() with _overlap() to make QEMU memory API happy.
This reserves RTAS token numbers for DDW calls.
This implements helpers to interact with VFIO kernel interface.
This changes the TCE table migration descriptor to support dynamic tables as from now on, PHB will create as many stub TCE table objects as PHB can possibly support but not all of them might be initialized at the time of migration because DDW might or might not be requested by the guest.
The "ddw" property is enabled by default on a PHB but for compatibility the pseries-2.3 machine and older disable it.
This implements DDW for VFIO. The host kernel support is required. This adds a "levels" property to PHB to control the number of levels in the actual TCE table allocated by the host kernel, 0 is the default value to tell QEMU to calculate the correct value. Current hardware supports up to 5 levels.
The existing linux guests try creating one additional huge DMA window with 64K or 16MB pages and map the entire guest RAM to. If succeeded, the guest switches to dma_direct_ops and never calls TCE hypercalls (H_PUT_TCE,...) again. This enables VFIO devices to use the entire RAM and not waste time on map/unmap later. This adds a "dma64_win_addr" property which is a bus address for the 64bit window and by default set to 0x800.0000.0000.0000 as this is what the modern POWER8 hardware uses and this allows having emulated and VFIO devices on the same bus.
This adds 4 RTAS handlers:
* ibm,query-pe-dma-window
* ibm,create-pe-dma-window
* ibm,remove-pe-dma-window
* ibm,reset-pe-dma-window
These are registered from type_init() callback.
These RTAS handlers are implemented in a separate file to avoid polluting spapr_iommu.c with PCI.
---
Changes:
v11:
* added a comment about windows removal in spapr_phb_hotplug_dma_sync
* do not remove windows on unplug - the host kernel takes care of this anyway
* s/unsigned long long/uint64_t/ in trace-events
* added sanity check for window size not being smaller than page size (i.e. actual window size is not zero)
* fixed compile for non-linux environment (mingw32)
v10:
* added dma64_win_addr property to PHB
* removed redundand check for "!migtable" in spapr_tce_table_post_load()
v9:
* fixed default 64bit window start (from mdroth)
* fixed type cast in dma window update code (from mdroth)
* spapr_phb_dma_update() now can fail and cause hotplug failure if hardware TCE table cannot be mapped to the same bus address as the emulated one
v7:
* fixed uninitialized variables
v6:
* rework as there is no more special device for VFIO PHB
v5:
* total rework
* enabled for machines >2.3
* fixed migration
* merged rtas handlers here
v4:
* reset handler is back in generalized form
v3:
* removed reset
* windows_num is now 1 or bigger rather than 0-based value and it is only changed in PHB code, not in RTAS
* added page mask check in create()
* added SPAPR_PCI_DDW_MAX_WINDOWS to track how many windows are already created
v2:
* tested on hacked emulated E1000
* implemented DDW reset on the PHB reset
* spapr_pci_ddw_remove/spapr_pci_ddw_reset are public for reuse by VFIO
--- hw/ppc/Makefile.objs | 1 + hw/ppc/spapr.c | 5 + hw/ppc/spapr_iommu.c | 32 ++++- hw/ppc/spapr_pci.c | 107 ++++++++++++++-- hw/ppc/spapr_pci_vfio.c | 102 +++++++++++++++ hw/ppc/spapr_rtas_ddw.c | 304 ++++++++++++++++++++++++++++++++++++++++++++ hw/vfio/common.c | 2 + include/hw/pci-host/spapr.h | 21 ++- include/hw/ppc/spapr.h | 17 ++- trace-events | 6 + 10 files changed, 581 insertions(+), 16 deletions(-) create mode 100644 hw/ppc/spapr_rtas_ddw.c
hw/ppc/Makefile.objs +1 -0
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_pci_vfio.o spapr_rtc.o spapr_drc.o +obj-$(CONFIG_PSERIES) += spapr_rtas_ddw.o # PowerPC 4xx boards obj-y += ppc405_boards.o ppc4xx_devs.o ppc405_uc.o ppc440_bamboo.o obj-y += ppc4xx_pci.o
hw/ppc/spapr.c +5 -0
@@ -2237,6 +2237,11 @@ static const TypeInfo spapr_machine_info = { .driver = "spapr-pci-host-bridge",\ .property = "dynamic-reconfiguration",\ .value = "off",\ + },\ + {\ + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE,\ + .property = "ddw",\ + .value = stringify(off),\ },#define SPAPR_COMPAT_2_2 \
hw/ppc/spapr_iommu.c +29 -3
@@ -136,6 +136,15 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr,return ret; } +static void spapr_tce_table_pre_save (void *opaque) +{ +sPAPRTCETable *tcet =SPAPR_TCE_TABLE (opaque); + + tcet->migtable = tcet->table; +} + +static void spapr_tce_table_do_enable (sPAPRTCETable *tcet,bool vfio_accel); +static int spapr_tce_table_post_load (void *opaque,int version_id) {sPAPRTCETable *tcet =SPAPR_TCE_TABLE (opaque);
@@ -144,22 +153,39 @@ static int spapr_tce_table_post_load(void *opaque, int version_id)spapr_vio_set_bypass (tcet->vdev, tcet->bypass); } +if (tcet->enabled) { +if (!tcet->table) { + tcet->enabled = false; +/* VFIO does not migrate so pass vfio_accel == false */ +spapr_tce_table_do_enable (tcet, false); + } +memcpy (tcet->table, tcet->migtable, + tcet->nb_table *sizeof (tcet->table[0 ])); +free (tcet->migtable); + tcet->migtable =NULL ; + } +return 0 ; }static const VMStateDescription vmstate_spapr_tce_table = { .name ="spapr_iommu" , - .version_id =2 , + .version_id =3 , .minimum_version_id =2 , + .pre_save = spapr_tce_table_pre_save, .post_load = spapr_tce_table_post_load, .fields = (VMStateField []) {/* Sanity check */ VMSTATE_UINT32_EQUAL (liobn, sPAPRTCETable), -VMSTATE_UINT32_EQUAL (nb_table, sPAPRTCETable),/* IOMMU state */ +VMSTATE_BOOL_V (enabled, sPAPRTCETable,3 ), +VMSTATE_UINT64_V (bus_offset, sPAPRTCETable,3 ), +VMSTATE_UINT32_V (page_shift, sPAPRTCETable,3 ), +VMSTATE_UINT32 (nb_table, sPAPRTCETable),VMSTATE_BOOL (bypass, sPAPRTCETable), -VMSTATE_VARRAY_UINT32 (table, sPAPRTCETable, nb_table,0 , vmstate_info_uint64, uint64_t), +VMSTATE_VARRAY_UINT32_ALLOC (migtable, sPAPRTCETable, nb_table,0 , + vmstate_info_uint64, uint64_t),VMSTATE_END_OF_LIST () },
hw/ppc/spapr_pci.c +96 -11
186 lines not on this page · raw message
hw/ppc/spapr_pci_vfio.c +102 -0
120 lines not on this page · raw message
hw/ppc/spapr_rtas_ddw.c new file +304 -0
304 lines not on this page · raw message
hw/vfio/common.c +2 -0
@@ -952,6 +952,8 @@ int vfio_container_ioctl(AddressSpace *as, int req, void *param)case VFIO_CHECK_EXTENSION :case VFIO_IOMMU_SPAPR_TCE_GET_INFO :case VFIO_EEH_PE_OP : +case VFIO_IOMMU_SPAPR_TCE_CREATE : +case VFIO_IOMMU_SPAPR_TCE_REMOVE :break ;default :/* Return an error on unknown requests */
include/hw/pci-host/spapr.h +20 -1
@@ -89,6 +89,13 @@ struct sPAPRPHBState {uint32_t dma32_window_size;unsigned vfio_num;int32_t iommugroupid;/* obsolete */ +bool ddw_enabled; +uint32_t windows_supported; +uint64_t page_size_mask; +uint64_t dma64_window_start; +uint64_t dma64_window_size; +uint8_t max_levels; +uint8_t levels;QLIST_ENTRY (sPAPRPHBState) list; };
@@ -111,7 +118,10 @@ struct sPAPRPHBState {#define SPAPR_PCI_DMA32_SIZE 0x40000000 -#define SPAPR_PCI_DMA_MAX_WINDOWS 1 +#define SPAPR_PCI_DMA_MAX_WINDOWS 2 + +/* Default 64bit dynamic window offset */ +#define SPAPR_PCI_DMA64_START 0x800000000000000ULLstatic inline qemu_irq spapr_phb_lsi_qirq (struct sPAPRPHBState *phb,int pin) {
@@ -133,11 +143,20 @@ void spapr_pci_rtas_init(void);sPAPRPHBState *spapr_pci_find_phb (sPAPRMachineState *spapr,uint64_t buid);PCIDevice *spapr_pci_find_dev (sPAPRMachineState *spapr,uint64_t buid,uint32_t config_addr); +int spapr_phb_dma_init_window (sPAPRPHBState *sphb, +uint32_t liobn,uint32_t page_shift, +uint64_t window_size);int spapr_phb_dma_remove_window (sPAPRPHBState *sphb,sPAPRTCETable *tcet);int spapr_phb_dma_reset (sPAPRPHBState *sphb);int spapr_phb_vfio_dma_capabilities_update (sPAPRPHBState *sphb); +int spapr_phb_vfio_dma_init_window (sPAPRPHBState *sphb, +uint32_t page_shift, +uint64_t window_size, +uint64_t *bus_offset); +int spapr_phb_vfio_dma_remove_window (sPAPRPHBState *sphb, +sPAPRTCETable *tcet);int spapr_phb_vfio_eeh_set_option (sPAPRPHBState *sphb,PCIDevice *pdev,int option);int spapr_phb_vfio_eeh_get_state (sPAPRPHBState *sphb,int *state);
include/hw/ppc/spapr.h +16 -1
@@ -419,6 +419,16 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);#define RTAS_OUT_NOT_SUPPORTED -3#define RTAS_OUT_NOT_AUTHORIZED -9002 +/* DDW pagesize mask values from ibm,query-pe-dma-window */ +#define RTAS_DDW_PGSIZE_4K 0x01 +#define RTAS_DDW_PGSIZE_64K 0x02 +#define RTAS_DDW_PGSIZE_16M 0x04 +#define RTAS_DDW_PGSIZE_32M 0x08 +#define RTAS_DDW_PGSIZE_64M 0x10 +#define RTAS_DDW_PGSIZE_128M 0x20 +#define RTAS_DDW_PGSIZE_256M 0x40 +#define RTAS_DDW_PGSIZE_16G 0x80 +/* RTAS tokens */ #define RTAS_TOKEN_BASE 0x2000
@@ -460,8 +470,12 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);#define RTAS_IBM_SET_SLOT_RESET (RTAS_TOKEN_BASE + 0x23)#define RTAS_IBM_CONFIGURE_PE (RTAS_TOKEN_BASE + 0x24)#define RTAS_IBM_SLOT_ERROR_DETAIL (RTAS_TOKEN_BASE + 0x25) +#define RTAS_IBM_QUERY_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x26) +#define RTAS_IBM_CREATE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x27) +#define RTAS_IBM_REMOVE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x28) +#define RTAS_IBM_RESET_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x29) -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x26) +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2A)/* RTAS ibm,get-system-parameter token values */ #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20
@@ -561,6 +575,7 @@ struct sPAPRTCETable {uint64_t bus_offset;uint32_t page_shift;uint64_t *table; +uint64_t *migtable;bool bypass;int fd;MemoryRegion root, iommu;
trace-events +6 -0
@@ -1302,6 +1302,8 @@ spapr_pci_lsi_set(const char *busname, int pin, uint32_t irq) "%s PIN%d IRQ %u" spapr_pci_msi_retry(unsigned config_addr, unsigned req_num, unsigned max_irqs) "Guest device at %x asked %u, have only %u" spapr_pci_dma_update(uint64_t liobn, long ret) "liobn=%"PRIx64" ret=%ld" spapr_pci_dma_realloc_update(uint64_t liobn, long ret) "liobn=%"PRIx64" tcet=%ld" +spapr_pci_vfio_init_window(int ps, uint64_t ws, uint64_t off) "pageshift=0x%x winsize=0x%"PRIx64" offset=0x%"PRIx64 +spapr_pci_vfio_remove_window(uint64_t off) "offset=%"PRIx64 # hw/pci/pci.c pci_update_mappings_del(void *d, uint32_t bus, uint32_t func, uint32_t slot, int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x %d,%#"PRIx64"+%#"PRIx64
@@ -1365,6 +1367,10 @@ spapr_iommu_pci_indirect(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t i spapr_iommu_pci_stuff(uint64_t liobn, uint64_t ioba, uint64_t tce_value, uint64_t npages, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tcevalue=0x%"PRIx64" npages=%"PRId64" ret=%"PRId64 spapr_iommu_xlate(uint64_t liobn, uint64_t ioba, uint64_t tce, unsigned perm, unsigned pgsize) "liobn=%"PRIx64" 0x%"PRIx64" -> 0x%"PRIx64" perm=%u mask=%x" spapr_iommu_alloc_table(uint64_t liobn, void *table, int fd) "liobn=%"PRIx64" table=%p fd=%d" +spapr_iommu_ddw_query(uint64_t buid, uint32_t cfgaddr, unsigned wa, uint64_t win_size, uint32_t pgmask) "buid=%"PRIx64" addr=%"PRIx32", %u windows available, max window size=%"PRIx64", mask=%"PRIx32 +spapr_iommu_ddw_create(uint64_t buid, uint32_t cfgaddr, uint64_t pg_size, uint64_t req_size, uint64_t start, uint32_t liobn, long ret) "buid=%"PRIx64" addr=%"PRIx32", page size=0x%"PRIx64", requested=0x%"PRIx64", start addr=%"PRIx64", liobn=%"PRIx32", ret = %ld" +spapr_iommu_ddw_remove(uint32_t liobn, long ret) "liobn=%"PRIx32", ret = %ld" +spapr_iommu_ddw_reset(uint64_t buid, uint32_t cfgaddr, long ret) "buid=%"PRIx64" addr=%"PRIx32", ret = %ld" # hw/ppc/ppc.c ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
Signature · 1 line
2.4.0.rc3.8.gfb3e7d5