4 * Copyright 2014 IBM Corp.
5 * Author(s): Frank Blaschka <frank.blaschka@de.ibm.com>
6 * Hong Bo Li <lihbbj@cn.ibm.com>
7 * Yi Min Zhao <zyimin@cn.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or (at
10 * your option) any later version. See the COPYING file in the top-level
14 #include "qemu/osdep.h"
15 #include "qapi/error.h"
16 #include "qapi/visitor.h"
17 #include "hw/s390x/s390-pci-bus.h"
18 #include "hw/s390x/s390-pci-inst.h"
19 #include "hw/s390x/s390-pci-kvm.h"
20 #include "hw/s390x/s390-pci-vfio.h"
21 #include "hw/pci/pci_bus.h"
22 #include "hw/qdev-properties.h"
23 #include "hw/pci/pci_bridge.h"
24 #include "hw/pci/msi.h"
25 #include "qemu/error-report.h"
26 #include "qemu/module.h"
28 #ifndef DEBUG_S390PCI_BUS
29 #define DEBUG_S390PCI_BUS 0
32 #define DPRINTF(fmt, ...) \
34 if (DEBUG_S390PCI_BUS) { \
35 fprintf(stderr, "S390pci-bus: " fmt, ## __VA_ARGS__); \
39 S390pciState
*s390_get_phb(void)
41 static S390pciState
*phb
;
44 phb
= S390_PCI_HOST_BRIDGE(
45 object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE
, NULL
));
52 int pci_chsc_sei_nt2_get_event(void *res
)
54 ChscSeiNt2Res
*nt2_res
= (ChscSeiNt2Res
*)res
;
58 SeiContainer
*sei_cont
;
59 S390pciState
*s
= s390_get_phb();
61 sei_cont
= QTAILQ_FIRST(&s
->pending_sei
);
63 QTAILQ_REMOVE(&s
->pending_sei
, sei_cont
, link
);
65 nt2_res
->cc
= sei_cont
->cc
;
66 nt2_res
->length
= cpu_to_be16(sizeof(ChscSeiNt2Res
));
67 switch (sei_cont
->cc
) {
68 case 1: /* error event */
69 eccdf
= (PciCcdfErr
*)nt2_res
->ccdf
;
70 eccdf
->fid
= cpu_to_be32(sei_cont
->fid
);
71 eccdf
->fh
= cpu_to_be32(sei_cont
->fh
);
72 eccdf
->e
= cpu_to_be32(sei_cont
->e
);
73 eccdf
->faddr
= cpu_to_be64(sei_cont
->faddr
);
74 eccdf
->pec
= cpu_to_be16(sei_cont
->pec
);
76 case 2: /* availability event */
77 accdf
= (PciCcdfAvail
*)nt2_res
->ccdf
;
78 accdf
->fid
= cpu_to_be32(sei_cont
->fid
);
79 accdf
->fh
= cpu_to_be32(sei_cont
->fh
);
80 accdf
->pec
= cpu_to_be16(sei_cont
->pec
);
92 int pci_chsc_sei_nt2_have_event(void)
94 S390pciState
*s
= s390_get_phb();
96 return !QTAILQ_EMPTY(&s
->pending_sei
);
99 S390PCIBusDevice
*s390_pci_find_next_avail_dev(S390pciState
*s
,
100 S390PCIBusDevice
*pbdev
)
102 S390PCIBusDevice
*ret
= pbdev
? QTAILQ_NEXT(pbdev
, link
) :
103 QTAILQ_FIRST(&s
->zpci_devs
);
105 while (ret
&& ret
->state
== ZPCI_FS_RESERVED
) {
106 ret
= QTAILQ_NEXT(ret
, link
);
112 S390PCIBusDevice
*s390_pci_find_dev_by_fid(S390pciState
*s
, uint32_t fid
)
114 S390PCIBusDevice
*pbdev
;
116 QTAILQ_FOREACH(pbdev
, &s
->zpci_devs
, link
) {
117 if (pbdev
->fid
== fid
) {
125 void s390_pci_sclp_configure(SCCB
*sccb
)
127 IoaCfgSccb
*psccb
= (IoaCfgSccb
*)sccb
;
128 S390PCIBusDevice
*pbdev
= s390_pci_find_dev_by_fid(s390_get_phb(),
129 be32_to_cpu(psccb
->aid
));
133 DPRINTF("sclp config no dev found\n");
134 rc
= SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED
;
138 switch (pbdev
->state
) {
139 case ZPCI_FS_RESERVED
:
140 rc
= SCLP_RC_ADAPTER_IN_RESERVED_STATE
;
142 case ZPCI_FS_STANDBY
:
143 pbdev
->state
= ZPCI_FS_DISABLED
;
144 rc
= SCLP_RC_NORMAL_COMPLETION
;
147 rc
= SCLP_RC_NO_ACTION_REQUIRED
;
150 psccb
->header
.response_code
= cpu_to_be16(rc
);
153 static void s390_pci_perform_unplug(S390PCIBusDevice
*pbdev
)
155 HotplugHandler
*hotplug_ctrl
;
157 /* Unplug the PCI device */
159 DeviceState
*pdev
= DEVICE(pbdev
->pdev
);
161 hotplug_ctrl
= qdev_get_hotplug_handler(pdev
);
162 hotplug_handler_unplug(hotplug_ctrl
, pdev
, &error_abort
);
163 object_unparent(OBJECT(pdev
));
166 /* Unplug the zPCI device */
167 hotplug_ctrl
= qdev_get_hotplug_handler(DEVICE(pbdev
));
168 hotplug_handler_unplug(hotplug_ctrl
, DEVICE(pbdev
), &error_abort
);
169 object_unparent(OBJECT(pbdev
));
172 void s390_pci_sclp_deconfigure(SCCB
*sccb
)
174 IoaCfgSccb
*psccb
= (IoaCfgSccb
*)sccb
;
175 S390PCIBusDevice
*pbdev
= s390_pci_find_dev_by_fid(s390_get_phb(),
176 be32_to_cpu(psccb
->aid
));
180 DPRINTF("sclp deconfig no dev found\n");
181 rc
= SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED
;
185 switch (pbdev
->state
) {
186 case ZPCI_FS_RESERVED
:
187 rc
= SCLP_RC_ADAPTER_IN_RESERVED_STATE
;
189 case ZPCI_FS_STANDBY
:
190 rc
= SCLP_RC_NO_ACTION_REQUIRED
;
193 if (pbdev
->summary_ind
) {
194 pci_dereg_irqs(pbdev
);
196 if (pbdev
->iommu
->enabled
) {
197 pci_dereg_ioat(pbdev
->iommu
);
199 pbdev
->state
= ZPCI_FS_STANDBY
;
200 rc
= SCLP_RC_NORMAL_COMPLETION
;
202 if (pbdev
->unplug_requested
) {
203 s390_pci_perform_unplug(pbdev
);
207 psccb
->header
.response_code
= cpu_to_be16(rc
);
210 static S390PCIBusDevice
*s390_pci_find_dev_by_uid(S390pciState
*s
, uint16_t uid
)
212 S390PCIBusDevice
*pbdev
;
214 QTAILQ_FOREACH(pbdev
, &s
->zpci_devs
, link
) {
215 if (pbdev
->uid
== uid
) {
223 S390PCIBusDevice
*s390_pci_find_dev_by_target(S390pciState
*s
,
226 S390PCIBusDevice
*pbdev
;
232 QTAILQ_FOREACH(pbdev
, &s
->zpci_devs
, link
) {
233 if (!strcmp(pbdev
->target
, target
)) {
241 static S390PCIBusDevice
*s390_pci_find_dev_by_pci(S390pciState
*s
,
244 S390PCIBusDevice
*pbdev
;
250 QTAILQ_FOREACH(pbdev
, &s
->zpci_devs
, link
) {
251 if (pbdev
->pdev
== pci_dev
) {
259 S390PCIBusDevice
*s390_pci_find_dev_by_idx(S390pciState
*s
, uint32_t idx
)
261 return g_hash_table_lookup(s
->zpci_table
, &idx
);
264 S390PCIBusDevice
*s390_pci_find_dev_by_fh(S390pciState
*s
, uint32_t fh
)
266 uint32_t idx
= FH_MASK_INDEX
& fh
;
267 S390PCIBusDevice
*pbdev
= s390_pci_find_dev_by_idx(s
, idx
);
269 if (pbdev
&& pbdev
->fh
== fh
) {
276 static void s390_pci_generate_event(uint8_t cc
, uint16_t pec
, uint32_t fh
,
277 uint32_t fid
, uint64_t faddr
, uint32_t e
)
279 SeiContainer
*sei_cont
;
280 S390pciState
*s
= s390_get_phb();
282 sei_cont
= g_new0(SeiContainer
, 1);
287 sei_cont
->faddr
= faddr
;
290 QTAILQ_INSERT_TAIL(&s
->pending_sei
, sei_cont
, link
);
291 css_generate_css_crws(0);
294 static void s390_pci_generate_plug_event(uint16_t pec
, uint32_t fh
,
297 s390_pci_generate_event(2, pec
, fh
, fid
, 0, 0);
300 void s390_pci_generate_error_event(uint16_t pec
, uint32_t fh
, uint32_t fid
,
301 uint64_t faddr
, uint32_t e
)
303 s390_pci_generate_event(1, pec
, fh
, fid
, faddr
, e
);
306 static void s390_pci_set_irq(void *opaque
, int irq
, int level
)
311 static int s390_pci_map_irq(PCIDevice
*pci_dev
, int irq_num
)
317 static uint64_t s390_pci_get_table_origin(uint64_t iota
)
319 return iota
& ~ZPCI_IOTA_RTTO_FLAG
;
322 static unsigned int calc_rtx(dma_addr_t ptr
)
324 return ((unsigned long) ptr
>> ZPCI_RT_SHIFT
) & ZPCI_INDEX_MASK
;
327 static unsigned int calc_sx(dma_addr_t ptr
)
329 return ((unsigned long) ptr
>> ZPCI_ST_SHIFT
) & ZPCI_INDEX_MASK
;
332 static unsigned int calc_px(dma_addr_t ptr
)
334 return ((unsigned long) ptr
>> TARGET_PAGE_BITS
) & ZPCI_PT_MASK
;
337 static uint64_t get_rt_sto(uint64_t entry
)
339 return ((entry
& ZPCI_TABLE_TYPE_MASK
) == ZPCI_TABLE_TYPE_RTX
)
340 ? (entry
& ZPCI_RTE_ADDR_MASK
)
344 static uint64_t get_st_pto(uint64_t entry
)
346 return ((entry
& ZPCI_TABLE_TYPE_MASK
) == ZPCI_TABLE_TYPE_SX
)
347 ? (entry
& ZPCI_STE_ADDR_MASK
)
351 static bool rt_entry_isvalid(uint64_t entry
)
353 return (entry
& ZPCI_TABLE_VALID_MASK
) == ZPCI_TABLE_VALID
;
356 static bool pt_entry_isvalid(uint64_t entry
)
358 return (entry
& ZPCI_PTE_VALID_MASK
) == ZPCI_PTE_VALID
;
361 static bool entry_isprotected(uint64_t entry
)
363 return (entry
& ZPCI_TABLE_PROT_MASK
) == ZPCI_TABLE_PROTECTED
;
366 /* ett is expected table type, -1 page table, 0 segment table, 1 region table */
367 static uint64_t get_table_index(uint64_t iova
, int8_t ett
)
371 return calc_px(iova
);
373 return calc_sx(iova
);
375 return calc_rtx(iova
);
381 static bool entry_isvalid(uint64_t entry
, int8_t ett
)
385 return pt_entry_isvalid(entry
);
388 return rt_entry_isvalid(entry
);
394 /* Return true if address translation is done */
395 static bool translate_iscomplete(uint64_t entry
, int8_t ett
)
399 return (entry
& ZPCI_TABLE_FC
) ? true : false;
407 static uint64_t get_frame_size(int8_t ett
)
421 static uint64_t get_next_table_origin(uint64_t entry
, int8_t ett
)
425 return entry
& ZPCI_PTE_ADDR_MASK
;
427 return get_st_pto(entry
);
429 return get_rt_sto(entry
);
436 * table_translate: do translation within one table and return the following
439 * @entry: the entry being translated, the result is stored in this.
440 * @to: the address of table origin.
441 * @ett: expected table type, 1 region table, 0 segment table and -1 page table.
444 static uint64_t table_translate(S390IOTLBEntry
*entry
, uint64_t to
, int8_t ett
,
447 uint64_t tx
, te
, nto
= 0;
450 tx
= get_table_index(entry
->iova
, ett
);
451 te
= address_space_ldq(&address_space_memory
, to
+ tx
* sizeof(uint64_t),
452 MEMTXATTRS_UNSPECIFIED
, NULL
);
455 err
= ERR_EVENT_INVALTE
;
459 if (!entry_isvalid(te
, ett
)) {
460 entry
->perm
&= IOMMU_NONE
;
464 if (ett
== ZPCI_ETT_RT
&& ((te
& ZPCI_TABLE_LEN_RTX
) != ZPCI_TABLE_LEN_RTX
465 || te
& ZPCI_TABLE_OFFSET_MASK
)) {
466 err
= ERR_EVENT_INVALTL
;
470 nto
= get_next_table_origin(te
, ett
);
476 if (entry_isprotected(te
)) {
477 entry
->perm
&= IOMMU_RO
;
479 entry
->perm
&= IOMMU_RW
;
482 if (translate_iscomplete(te
, ett
)) {
485 entry
->translated_addr
= te
& ZPCI_PTE_ADDR_MASK
;
488 entry
->translated_addr
= (te
& ZPCI_SFAA_MASK
) |
489 (entry
->iova
& ~ZPCI_SFAA_MASK
);
496 entry
->perm
= IOMMU_NONE
;
499 entry
->len
= get_frame_size(ett
);
503 uint16_t s390_guest_io_table_walk(uint64_t g_iota
, hwaddr addr
,
504 S390IOTLBEntry
*entry
)
506 uint64_t to
= s390_pci_get_table_origin(g_iota
);
510 entry
->iova
= addr
& TARGET_PAGE_MASK
;
511 entry
->translated_addr
= 0;
512 entry
->perm
= IOMMU_RW
;
514 if (entry_isprotected(g_iota
)) {
515 entry
->perm
&= IOMMU_RO
;
519 to
= table_translate(entry
, to
, ett
--, &error
);
525 static IOMMUTLBEntry
s390_translate_iommu(IOMMUMemoryRegion
*mr
, hwaddr addr
,
526 IOMMUAccessFlags flag
, int iommu_idx
)
528 S390PCIIOMMU
*iommu
= container_of(mr
, S390PCIIOMMU
, iommu_mr
);
529 S390IOTLBEntry
*entry
;
530 uint64_t iova
= addr
& TARGET_PAGE_MASK
;
532 IOMMUTLBEntry ret
= {
533 .target_as
= &address_space_memory
,
535 .translated_addr
= 0,
536 .addr_mask
= ~(hwaddr
)0,
540 switch (iommu
->pbdev
->state
) {
541 case ZPCI_FS_ENABLED
:
542 case ZPCI_FS_BLOCKED
:
543 if (!iommu
->enabled
) {
551 DPRINTF("iommu trans addr 0x%" PRIx64
"\n", addr
);
553 if (addr
< iommu
->pba
|| addr
> iommu
->pal
) {
554 error
= ERR_EVENT_OORANGE
;
558 entry
= g_hash_table_lookup(iommu
->iotlb
, &iova
);
560 ret
.iova
= entry
->iova
;
561 ret
.translated_addr
= entry
->translated_addr
;
562 ret
.addr_mask
= entry
->len
- 1;
563 ret
.perm
= entry
->perm
;
566 ret
.addr_mask
= ~TARGET_PAGE_MASK
;
567 ret
.perm
= IOMMU_NONE
;
570 if (flag
!= IOMMU_NONE
&& !(flag
& ret
.perm
)) {
571 error
= ERR_EVENT_TPROTE
;
575 iommu
->pbdev
->state
= ZPCI_FS_ERROR
;
576 s390_pci_generate_error_event(error
, iommu
->pbdev
->fh
,
577 iommu
->pbdev
->fid
, addr
, 0);
582 static void s390_pci_iommu_replay(IOMMUMemoryRegion
*iommu
,
583 IOMMUNotifier
*notifier
)
585 /* It's impossible to plug a pci device on s390x that already has iommu
586 * mappings which need to be replayed, that is due to the "one iommu per
587 * zpci device" construct. But when we support migration of vfio-pci
588 * devices in future, we need to revisit this.
593 static S390PCIIOMMU
*s390_pci_get_iommu(S390pciState
*s
, PCIBus
*bus
,
596 uint64_t key
= (uintptr_t)bus
;
597 S390PCIIOMMUTable
*table
= g_hash_table_lookup(s
->iommu_table
, &key
);
601 table
= g_new0(S390PCIIOMMUTable
, 1);
603 g_hash_table_insert(s
->iommu_table
, &table
->key
, table
);
606 iommu
= table
->iommu
[PCI_SLOT(devfn
)];
608 iommu
= S390_PCI_IOMMU(object_new(TYPE_S390_PCI_IOMMU
));
610 char *mr_name
= g_strdup_printf("iommu-root-%02x:%02x.%01x",
614 char *as_name
= g_strdup_printf("iommu-pci-%02x:%02x.%01x",
618 memory_region_init(&iommu
->mr
, OBJECT(iommu
), mr_name
, UINT64_MAX
);
619 address_space_init(&iommu
->as
, &iommu
->mr
, as_name
);
620 iommu
->iotlb
= g_hash_table_new_full(g_int64_hash
, g_int64_equal
,
622 table
->iommu
[PCI_SLOT(devfn
)] = iommu
;
631 static AddressSpace
*s390_pci_dma_iommu(PCIBus
*bus
, void *opaque
, int devfn
)
633 S390pciState
*s
= opaque
;
634 S390PCIIOMMU
*iommu
= s390_pci_get_iommu(s
, bus
, devfn
);
639 static uint8_t set_ind_atomic(uint64_t ind_loc
, uint8_t to_be_set
)
641 uint8_t expected
, actual
;
643 /* avoid multiple fetches */
644 uint8_t volatile *ind_addr
;
646 ind_addr
= cpu_physical_memory_map(ind_loc
, &len
, true);
648 s390_pci_generate_error_event(ERR_EVENT_AIRERR
, 0, 0, 0, 0);
654 actual
= qatomic_cmpxchg(ind_addr
, expected
, expected
| to_be_set
);
655 } while (actual
!= expected
);
656 cpu_physical_memory_unmap((void *)ind_addr
, len
, 1, len
);
661 static void s390_msi_ctrl_write(void *opaque
, hwaddr addr
, uint64_t data
,
664 S390PCIBusDevice
*pbdev
= opaque
;
665 uint32_t vec
= data
& ZPCI_MSI_VEC_MASK
;
670 DPRINTF("write_msix data 0x%" PRIx64
" idx %d vec 0x%x\n", data
,
673 if (pbdev
->state
!= ZPCI_FS_ENABLED
) {
677 ind_bit
= pbdev
->routes
.adapter
.ind_offset
;
678 sum_bit
= pbdev
->routes
.adapter
.summary_offset
;
680 set_ind_atomic(pbdev
->routes
.adapter
.ind_addr
+ (ind_bit
+ vec
) / 8,
681 0x80 >> ((ind_bit
+ vec
) % 8));
682 if (!set_ind_atomic(pbdev
->routes
.adapter
.summary_addr
+ sum_bit
/ 8,
683 0x80 >> (sum_bit
% 8))) {
684 css_adapter_interrupt(CSS_IO_ADAPTER_PCI
, pbdev
->isc
);
688 static uint64_t s390_msi_ctrl_read(void *opaque
, hwaddr addr
, unsigned size
)
693 static const MemoryRegionOps s390_msi_ctrl_ops
= {
694 .write
= s390_msi_ctrl_write
,
695 .read
= s390_msi_ctrl_read
,
696 .endianness
= DEVICE_LITTLE_ENDIAN
,
699 void s390_pci_iommu_enable(S390PCIIOMMU
*iommu
)
702 * The iommu region is initialized against a 0-mapped address space,
703 * so the smallest IOMMU region we can define runs from 0 to the end
704 * of the PCI address space.
706 char *name
= g_strdup_printf("iommu-s390-%04x", iommu
->pbdev
->uid
);
707 memory_region_init_iommu(&iommu
->iommu_mr
, sizeof(iommu
->iommu_mr
),
708 TYPE_S390_IOMMU_MEMORY_REGION
, OBJECT(&iommu
->mr
),
709 name
, iommu
->pal
+ 1);
710 iommu
->enabled
= true;
711 memory_region_add_subregion(&iommu
->mr
, 0, MEMORY_REGION(&iommu
->iommu_mr
));
715 void s390_pci_iommu_disable(S390PCIIOMMU
*iommu
)
717 iommu
->enabled
= false;
718 g_hash_table_remove_all(iommu
->iotlb
);
719 memory_region_del_subregion(&iommu
->mr
, MEMORY_REGION(&iommu
->iommu_mr
));
720 object_unparent(OBJECT(&iommu
->iommu_mr
));
723 static void s390_pci_iommu_free(S390pciState
*s
, PCIBus
*bus
, int32_t devfn
)
725 uint64_t key
= (uintptr_t)bus
;
726 S390PCIIOMMUTable
*table
= g_hash_table_lookup(s
->iommu_table
, &key
);
727 S390PCIIOMMU
*iommu
= table
? table
->iommu
[PCI_SLOT(devfn
)] : NULL
;
729 if (!table
|| !iommu
) {
733 table
->iommu
[PCI_SLOT(devfn
)] = NULL
;
734 g_hash_table_destroy(iommu
->iotlb
);
736 * An attached PCI device may have memory listeners, eg. VFIO PCI.
737 * The associated subregion will already have been unmapped in
738 * s390_pci_iommu_disable in response to the guest deconfigure request.
739 * Remove the listeners now before destroying the address space.
741 address_space_remove_listeners(&iommu
->as
);
742 address_space_destroy(&iommu
->as
);
743 object_unparent(OBJECT(&iommu
->mr
));
744 object_unparent(OBJECT(iommu
));
745 object_unref(OBJECT(iommu
));
748 S390PCIGroup
*s390_group_create(int id
)
751 S390pciState
*s
= s390_get_phb();
753 group
= g_new0(S390PCIGroup
, 1);
755 QTAILQ_INSERT_TAIL(&s
->zpci_groups
, group
, link
);
759 S390PCIGroup
*s390_group_find(int id
)
762 S390pciState
*s
= s390_get_phb();
764 QTAILQ_FOREACH(group
, &s
->zpci_groups
, link
) {
765 if (group
->id
== id
) {
772 static void s390_pci_init_default_group(void)
775 ClpRspQueryPciGrp
*resgrp
;
777 group
= s390_group_create(ZPCI_DEFAULT_FN_GRP
);
778 resgrp
= &group
->zpci_group
;
781 resgrp
->msia
= ZPCI_MSI_ADDR
;
782 resgrp
->mui
= DEFAULT_MUI
;
784 resgrp
->maxstbl
= 128;
786 resgrp
->dtsm
= ZPCI_DTSM
;
789 static void set_pbdev_info(S390PCIBusDevice
*pbdev
)
791 pbdev
->zpci_fn
.sdma
= ZPCI_SDMA_ADDR
;
792 pbdev
->zpci_fn
.edma
= ZPCI_EDMA_ADDR
;
793 pbdev
->zpci_fn
.pchid
= 0;
794 pbdev
->zpci_fn
.pfgid
= ZPCI_DEFAULT_FN_GRP
;
795 pbdev
->zpci_fn
.fid
= pbdev
->fid
;
796 pbdev
->zpci_fn
.uid
= pbdev
->uid
;
797 pbdev
->pci_group
= s390_group_find(ZPCI_DEFAULT_FN_GRP
);
800 static void s390_pcihost_realize(DeviceState
*dev
, Error
**errp
)
804 PCIHostState
*phb
= PCI_HOST_BRIDGE(dev
);
805 S390pciState
*s
= S390_PCI_HOST_BRIDGE(dev
);
807 DPRINTF("host_init\n");
809 b
= pci_register_root_bus(dev
, NULL
, s390_pci_set_irq
, s390_pci_map_irq
,
810 NULL
, get_system_memory(), get_system_io(), 0,
812 pci_setup_iommu(b
, s390_pci_dma_iommu
, s
);
815 qbus_set_hotplug_handler(bus
, OBJECT(dev
));
818 s
->bus
= S390_PCI_BUS(qbus_new(TYPE_S390_PCI_BUS
, dev
, NULL
));
819 qbus_set_hotplug_handler(BUS(s
->bus
), OBJECT(dev
));
821 s
->iommu_table
= g_hash_table_new_full(g_int64_hash
, g_int64_equal
,
823 s
->zpci_table
= g_hash_table_new_full(g_int_hash
, g_int_equal
, NULL
, NULL
);
825 QTAILQ_INIT(&s
->pending_sei
);
826 QTAILQ_INIT(&s
->zpci_devs
);
827 QTAILQ_INIT(&s
->zpci_dma_limit
);
828 QTAILQ_INIT(&s
->zpci_groups
);
830 s390_pci_init_default_group();
831 css_register_io_adapters(CSS_IO_ADAPTER_PCI
, true, false,
832 S390_ADAPTER_SUPPRESSIBLE
, errp
);
835 static void s390_pcihost_unrealize(DeviceState
*dev
)
838 S390pciState
*s
= S390_PCI_HOST_BRIDGE(dev
);
840 while (!QTAILQ_EMPTY(&s
->zpci_groups
)) {
841 group
= QTAILQ_FIRST(&s
->zpci_groups
);
842 QTAILQ_REMOVE(&s
->zpci_groups
, group
, link
);
846 static int s390_pci_msix_init(S390PCIBusDevice
*pbdev
)
853 pos
= pci_find_capability(pbdev
->pdev
, PCI_CAP_ID_MSIX
);
858 ctrl
= pci_host_config_read_common(pbdev
->pdev
, pos
+ PCI_MSIX_FLAGS
,
859 pci_config_size(pbdev
->pdev
), sizeof(ctrl
));
860 table
= pci_host_config_read_common(pbdev
->pdev
, pos
+ PCI_MSIX_TABLE
,
861 pci_config_size(pbdev
->pdev
), sizeof(table
));
862 pba
= pci_host_config_read_common(pbdev
->pdev
, pos
+ PCI_MSIX_PBA
,
863 pci_config_size(pbdev
->pdev
), sizeof(pba
));
865 pbdev
->msix
.table_bar
= table
& PCI_MSIX_FLAGS_BIRMASK
;
866 pbdev
->msix
.table_offset
= table
& ~PCI_MSIX_FLAGS_BIRMASK
;
867 pbdev
->msix
.pba_bar
= pba
& PCI_MSIX_FLAGS_BIRMASK
;
868 pbdev
->msix
.pba_offset
= pba
& ~PCI_MSIX_FLAGS_BIRMASK
;
869 pbdev
->msix
.entries
= (ctrl
& PCI_MSIX_FLAGS_QSIZE
) + 1;
871 name
= g_strdup_printf("msix-s390-%04x", pbdev
->uid
);
872 memory_region_init_io(&pbdev
->msix_notify_mr
, OBJECT(pbdev
),
873 &s390_msi_ctrl_ops
, pbdev
, name
, TARGET_PAGE_SIZE
);
874 memory_region_add_subregion(&pbdev
->iommu
->mr
,
875 pbdev
->pci_group
->zpci_group
.msia
,
876 &pbdev
->msix_notify_mr
);
882 static void s390_pci_msix_free(S390PCIBusDevice
*pbdev
)
884 memory_region_del_subregion(&pbdev
->iommu
->mr
, &pbdev
->msix_notify_mr
);
885 object_unparent(OBJECT(&pbdev
->msix_notify_mr
));
888 static S390PCIBusDevice
*s390_pci_device_new(S390pciState
*s
,
889 const char *target
, Error
**errp
)
891 Error
*local_err
= NULL
;
894 dev
= qdev_try_new(TYPE_S390_PCI_DEVICE
);
896 error_setg(errp
, "zPCI device could not be created");
900 if (!object_property_set_str(OBJECT(dev
), "target", target
, &local_err
)) {
901 object_unparent(OBJECT(dev
));
902 error_propagate_prepend(errp
, local_err
,
903 "zPCI device could not be created: ");
906 if (!qdev_realize_and_unref(dev
, BUS(s
->bus
), &local_err
)) {
907 object_unparent(OBJECT(dev
));
908 error_propagate_prepend(errp
, local_err
,
909 "zPCI device could not be created: ");
913 return S390_PCI_DEVICE(dev
);
916 static bool s390_pci_alloc_idx(S390pciState
*s
, S390PCIBusDevice
*pbdev
)
921 while (s390_pci_find_dev_by_idx(s
, idx
)) {
922 idx
= (idx
+ 1) & FH_MASK_INDEX
;
923 if (idx
== s
->next_idx
) {
932 static void s390_pcihost_pre_plug(HotplugHandler
*hotplug_dev
, DeviceState
*dev
,
935 S390pciState
*s
= S390_PCI_HOST_BRIDGE(hotplug_dev
);
937 if (!s390_has_feat(S390_FEAT_ZPCI
)) {
938 warn_report("Plugging a PCI/zPCI device without the 'zpci' CPU "
939 "feature enabled; the guest will not be able to see/use "
943 if (object_dynamic_cast(OBJECT(dev
), TYPE_PCI_DEVICE
)) {
944 PCIDevice
*pdev
= PCI_DEVICE(dev
);
946 if (pdev
->cap_present
& QEMU_PCI_CAP_MULTIFUNCTION
) {
947 error_setg(errp
, "multifunction not supported in s390");
950 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_S390_PCI_DEVICE
)) {
951 S390PCIBusDevice
*pbdev
= S390_PCI_DEVICE(dev
);
953 if (!s390_pci_alloc_idx(s
, pbdev
)) {
954 error_setg(errp
, "no slot for plugging zpci device");
960 static void s390_pci_update_subordinate(PCIDevice
*dev
, uint32_t nr
)
964 pci_default_write_config(dev
, PCI_SUBORDINATE_BUS
, nr
, 1);
965 while (!pci_bus_is_root(pci_get_bus(dev
))) {
966 dev
= pci_get_bus(dev
)->parent_dev
;
968 old_nr
= pci_default_read_config(dev
, PCI_SUBORDINATE_BUS
, 1);
970 pci_default_write_config(dev
, PCI_SUBORDINATE_BUS
, nr
, 1);
975 static int s390_pci_interp_plug(S390pciState
*s
, S390PCIBusDevice
*pbdev
)
979 if (!s390_pci_get_host_fh(pbdev
, &fh
)) {
984 * The host device is already in an enabled state, but we always present
985 * the initial device state to the guest as disabled (ZPCI_FS_DISABLED).
986 * Therefore, mask off the enable bit from the passthrough handle until
987 * the guest issues a CLP SET PCI FN later to enable the device.
989 pbdev
->fh
= fh
& ~FH_MASK_ENABLE
;
991 /* Next, see if the idx is already in-use */
992 idx
= pbdev
->fh
& FH_MASK_INDEX
;
993 if (pbdev
->idx
!= idx
) {
994 if (s390_pci_find_dev_by_idx(s
, idx
)) {
998 * Update the idx entry with the passed through idx
999 * If the relinquished idx is lower than next_idx, use it
1000 * to replace next_idx
1002 g_hash_table_remove(s
->zpci_table
, &pbdev
->idx
);
1003 if (idx
< s
->next_idx
) {
1007 g_hash_table_insert(s
->zpci_table
, &pbdev
->idx
, pbdev
);
1013 static void s390_pcihost_plug(HotplugHandler
*hotplug_dev
, DeviceState
*dev
,
1016 S390pciState
*s
= S390_PCI_HOST_BRIDGE(hotplug_dev
);
1017 PCIDevice
*pdev
= NULL
;
1018 S390PCIBusDevice
*pbdev
= NULL
;
1021 if (object_dynamic_cast(OBJECT(dev
), TYPE_PCI_BRIDGE
)) {
1022 PCIBridge
*pb
= PCI_BRIDGE(dev
);
1024 pdev
= PCI_DEVICE(dev
);
1025 pci_bridge_map_irq(pb
, dev
->id
, s390_pci_map_irq
);
1026 pci_setup_iommu(&pb
->sec_bus
, s390_pci_dma_iommu
, s
);
1028 qbus_set_hotplug_handler(BUS(&pb
->sec_bus
), OBJECT(s
));
1030 if (dev
->hotplugged
) {
1031 pci_default_write_config(pdev
, PCI_PRIMARY_BUS
,
1032 pci_dev_bus_num(pdev
), 1);
1034 pci_default_write_config(pdev
, PCI_SECONDARY_BUS
, s
->bus_no
, 1);
1036 s390_pci_update_subordinate(pdev
, s
->bus_no
);
1038 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_PCI_DEVICE
)) {
1039 pdev
= PCI_DEVICE(dev
);
1042 /* In the case the PCI device does not define an id */
1043 /* we generate one based on the PCI address */
1044 dev
->id
= g_strdup_printf("auto_%02x:%02x.%01x",
1045 pci_dev_bus_num(pdev
),
1046 PCI_SLOT(pdev
->devfn
),
1047 PCI_FUNC(pdev
->devfn
));
1050 pbdev
= s390_pci_find_dev_by_target(s
, dev
->id
);
1052 pbdev
= s390_pci_device_new(s
, dev
->id
, errp
);
1059 pbdev
->iommu
= s390_pci_get_iommu(s
, pci_get_bus(pdev
), pdev
->devfn
);
1060 pbdev
->iommu
->pbdev
= pbdev
;
1061 pbdev
->state
= ZPCI_FS_DISABLED
;
1062 set_pbdev_info(pbdev
);
1064 if (object_dynamic_cast(OBJECT(dev
), "vfio-pci")) {
1066 * By default, interpretation is always requested; if the available
1067 * facilities indicate it is not available, fallback to the
1068 * interception model.
1070 if (pbdev
->interp
) {
1071 if (s390_pci_kvm_interp_allowed()) {
1072 rc
= s390_pci_interp_plug(s
, pbdev
);
1074 error_setg(errp
, "Plug failed for zPCI device in "
1075 "interpretation mode: %d", rc
);
1079 DPRINTF("zPCI interpretation facilities missing.\n");
1080 pbdev
->interp
= false;
1083 pbdev
->iommu
->dma_limit
= s390_pci_start_dma_count(s
, pbdev
);
1084 /* Fill in CLP information passed via the vfio region */
1085 s390_pci_get_clp_info(pbdev
);
1086 if (!pbdev
->interp
) {
1087 /* Do vfio passthrough but intercept for I/O */
1088 pbdev
->fh
|= FH_SHM_VFIO
;
1091 pbdev
->fh
|= FH_SHM_EMUL
;
1092 /* Always intercept emulated devices */
1093 pbdev
->interp
= false;
1096 if (s390_pci_msix_init(pbdev
)) {
1097 error_setg(errp
, "MSI-X support is mandatory "
1098 "in the S390 architecture");
1102 if (dev
->hotplugged
) {
1103 s390_pci_generate_plug_event(HP_EVENT_TO_CONFIGURED
,
1104 pbdev
->fh
, pbdev
->fid
);
1106 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_S390_PCI_DEVICE
)) {
1107 pbdev
= S390_PCI_DEVICE(dev
);
1109 /* the allocated idx is actually getting used */
1110 s
->next_idx
= (pbdev
->idx
+ 1) & FH_MASK_INDEX
;
1111 pbdev
->fh
= pbdev
->idx
;
1112 QTAILQ_INSERT_TAIL(&s
->zpci_devs
, pbdev
, link
);
1113 g_hash_table_insert(s
->zpci_table
, &pbdev
->idx
, pbdev
);
1115 g_assert_not_reached();
1119 static void s390_pcihost_unplug(HotplugHandler
*hotplug_dev
, DeviceState
*dev
,
1122 S390pciState
*s
= S390_PCI_HOST_BRIDGE(hotplug_dev
);
1123 S390PCIBusDevice
*pbdev
= NULL
;
1125 if (object_dynamic_cast(OBJECT(dev
), TYPE_PCI_DEVICE
)) {
1126 PCIDevice
*pci_dev
= PCI_DEVICE(dev
);
1130 pbdev
= s390_pci_find_dev_by_pci(s
, PCI_DEVICE(dev
));
1133 s390_pci_generate_plug_event(HP_EVENT_STANDBY_TO_RESERVED
,
1134 pbdev
->fh
, pbdev
->fid
);
1135 bus
= pci_get_bus(pci_dev
);
1136 devfn
= pci_dev
->devfn
;
1137 qdev_unrealize(dev
);
1139 s390_pci_msix_free(pbdev
);
1140 s390_pci_iommu_free(s
, bus
, devfn
);
1142 pbdev
->state
= ZPCI_FS_RESERVED
;
1143 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_S390_PCI_DEVICE
)) {
1144 pbdev
= S390_PCI_DEVICE(dev
);
1146 QTAILQ_REMOVE(&s
->zpci_devs
, pbdev
, link
);
1147 g_hash_table_remove(s
->zpci_table
, &pbdev
->idx
);
1148 if (pbdev
->iommu
->dma_limit
) {
1149 s390_pci_end_dma_count(s
, pbdev
->iommu
->dma_limit
);
1151 qdev_unrealize(dev
);
1155 static void s390_pcihost_unplug_request(HotplugHandler
*hotplug_dev
,
1159 S390pciState
*s
= S390_PCI_HOST_BRIDGE(hotplug_dev
);
1160 S390PCIBusDevice
*pbdev
;
1162 if (object_dynamic_cast(OBJECT(dev
), TYPE_PCI_BRIDGE
)) {
1163 error_setg(errp
, "PCI bridge hot unplug currently not supported");
1164 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_PCI_DEVICE
)) {
1166 * Redirect the unplug request to the zPCI device and remember that
1167 * we've checked the PCI device already (to prevent endless recursion).
1169 pbdev
= s390_pci_find_dev_by_pci(s
, PCI_DEVICE(dev
));
1171 pbdev
->pci_unplug_request_processed
= true;
1172 qdev_unplug(DEVICE(pbdev
), errp
);
1173 } else if (object_dynamic_cast(OBJECT(dev
), TYPE_S390_PCI_DEVICE
)) {
1174 pbdev
= S390_PCI_DEVICE(dev
);
1177 * If unplug was initially requested for the zPCI device, we
1178 * first have to redirect to the PCI device, which will in return
1179 * redirect back to us after performing its checks (if the request
1180 * is not blocked, e.g. because it's a PCI bridge).
1182 if (pbdev
->pdev
&& !pbdev
->pci_unplug_request_processed
) {
1183 qdev_unplug(DEVICE(pbdev
->pdev
), errp
);
1186 pbdev
->pci_unplug_request_processed
= false;
1188 switch (pbdev
->state
) {
1189 case ZPCI_FS_STANDBY
:
1190 case ZPCI_FS_RESERVED
:
1191 s390_pci_perform_unplug(pbdev
);
1195 * Allow to send multiple requests, e.g. if the guest crashed
1196 * before releasing the device, we would not be able to send
1197 * another request to the same VM (e.g. fresh OS).
1199 pbdev
->unplug_requested
= true;
1200 s390_pci_generate_plug_event(HP_EVENT_DECONFIGURE_REQUEST
,
1201 pbdev
->fh
, pbdev
->fid
);
1204 g_assert_not_reached();
1208 static void s390_pci_enumerate_bridge(PCIBus
*bus
, PCIDevice
*pdev
,
1211 S390pciState
*s
= opaque
;
1212 PCIBus
*sec_bus
= NULL
;
1214 if ((pci_default_read_config(pdev
, PCI_HEADER_TYPE
, 1) !=
1215 PCI_HEADER_TYPE_BRIDGE
)) {
1220 pci_default_write_config(pdev
, PCI_PRIMARY_BUS
, pci_dev_bus_num(pdev
), 1);
1221 pci_default_write_config(pdev
, PCI_SECONDARY_BUS
, s
->bus_no
, 1);
1222 pci_default_write_config(pdev
, PCI_SUBORDINATE_BUS
, s
->bus_no
, 1);
1224 sec_bus
= pci_bridge_get_sec_bus(PCI_BRIDGE(pdev
));
1229 /* Assign numbers to all child bridges. The last is the highest number. */
1230 pci_for_each_device_under_bus(sec_bus
, s390_pci_enumerate_bridge
, s
);
1231 pci_default_write_config(pdev
, PCI_SUBORDINATE_BUS
, s
->bus_no
, 1);
1234 static void s390_pcihost_reset(DeviceState
*dev
)
1236 S390pciState
*s
= S390_PCI_HOST_BRIDGE(dev
);
1237 PCIBus
*bus
= s
->parent_obj
.bus
;
1238 S390PCIBusDevice
*pbdev
, *next
;
1240 /* Process all pending unplug requests */
1241 QTAILQ_FOREACH_SAFE(pbdev
, &s
->zpci_devs
, link
, next
) {
1242 if (pbdev
->unplug_requested
) {
1243 if (pbdev
->summary_ind
) {
1244 pci_dereg_irqs(pbdev
);
1246 if (pbdev
->iommu
->enabled
) {
1247 pci_dereg_ioat(pbdev
->iommu
);
1249 pbdev
->state
= ZPCI_FS_STANDBY
;
1250 s390_pci_perform_unplug(pbdev
);
1255 * When resetting a PCI bridge, the assigned numbers are set to 0. So
1256 * on every system reset, we also have to reassign numbers.
1259 pci_for_each_device_under_bus(bus
, s390_pci_enumerate_bridge
, s
);
1262 static void s390_pcihost_class_init(ObjectClass
*klass
, void *data
)
1264 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1265 HotplugHandlerClass
*hc
= HOTPLUG_HANDLER_CLASS(klass
);
1267 dc
->reset
= s390_pcihost_reset
;
1268 dc
->realize
= s390_pcihost_realize
;
1269 dc
->unrealize
= s390_pcihost_unrealize
;
1270 hc
->pre_plug
= s390_pcihost_pre_plug
;
1271 hc
->plug
= s390_pcihost_plug
;
1272 hc
->unplug_request
= s390_pcihost_unplug_request
;
1273 hc
->unplug
= s390_pcihost_unplug
;
1274 msi_nonbroken
= true;
1277 static const TypeInfo s390_pcihost_info
= {
1278 .name
= TYPE_S390_PCI_HOST_BRIDGE
,
1279 .parent
= TYPE_PCI_HOST_BRIDGE
,
1280 .instance_size
= sizeof(S390pciState
),
1281 .class_init
= s390_pcihost_class_init
,
1282 .interfaces
= (InterfaceInfo
[]) {
1283 { TYPE_HOTPLUG_HANDLER
},
1288 static const TypeInfo s390_pcibus_info
= {
1289 .name
= TYPE_S390_PCI_BUS
,
1291 .instance_size
= sizeof(S390PCIBus
),
1294 static uint16_t s390_pci_generate_uid(S390pciState
*s
)
1300 if (!s390_pci_find_dev_by_uid(s
, uid
)) {
1303 } while (uid
< ZPCI_MAX_UID
);
1305 return UID_UNDEFINED
;
1308 static uint32_t s390_pci_generate_fid(S390pciState
*s
, Error
**errp
)
1313 if (!s390_pci_find_dev_by_fid(s
, fid
)) {
1316 } while (fid
++ != ZPCI_MAX_FID
);
1318 error_setg(errp
, "no free fid could be found");
1322 static void s390_pci_device_realize(DeviceState
*dev
, Error
**errp
)
1324 S390PCIBusDevice
*zpci
= S390_PCI_DEVICE(dev
);
1325 S390pciState
*s
= s390_get_phb();
1327 if (!zpci
->target
) {
1328 error_setg(errp
, "target must be defined");
1332 if (s390_pci_find_dev_by_target(s
, zpci
->target
)) {
1333 error_setg(errp
, "target %s already has an associated zpci device",
1338 if (zpci
->uid
== UID_UNDEFINED
) {
1339 zpci
->uid
= s390_pci_generate_uid(s
);
1341 error_setg(errp
, "no free uid could be found");
1344 } else if (s390_pci_find_dev_by_uid(s
, zpci
->uid
)) {
1345 error_setg(errp
, "uid %u already in use", zpci
->uid
);
1349 if (!zpci
->fid_defined
) {
1350 Error
*local_error
= NULL
;
1352 zpci
->fid
= s390_pci_generate_fid(s
, &local_error
);
1354 error_propagate(errp
, local_error
);
1357 } else if (s390_pci_find_dev_by_fid(s
, zpci
->fid
)) {
1358 error_setg(errp
, "fid %u already in use", zpci
->fid
);
1362 zpci
->state
= ZPCI_FS_RESERVED
;
1363 zpci
->fmb
.format
= ZPCI_FMB_FORMAT
;
1366 static void s390_pci_device_reset(DeviceState
*dev
)
1368 S390PCIBusDevice
*pbdev
= S390_PCI_DEVICE(dev
);
1370 switch (pbdev
->state
) {
1371 case ZPCI_FS_RESERVED
:
1373 case ZPCI_FS_STANDBY
:
1376 pbdev
->fh
&= ~FH_MASK_ENABLE
;
1377 pbdev
->state
= ZPCI_FS_DISABLED
;
1381 if (pbdev
->summary_ind
) {
1382 pci_dereg_irqs(pbdev
);
1384 if (pbdev
->iommu
->enabled
) {
1385 pci_dereg_ioat(pbdev
->iommu
);
1388 fmb_timer_free(pbdev
);
1391 static void s390_pci_get_fid(Object
*obj
, Visitor
*v
, const char *name
,
1392 void *opaque
, Error
**errp
)
1394 Property
*prop
= opaque
;
1395 uint32_t *ptr
= object_field_prop_ptr(obj
, prop
);
1397 visit_type_uint32(v
, name
, ptr
, errp
);
1400 static void s390_pci_set_fid(Object
*obj
, Visitor
*v
, const char *name
,
1401 void *opaque
, Error
**errp
)
1403 S390PCIBusDevice
*zpci
= S390_PCI_DEVICE(obj
);
1404 Property
*prop
= opaque
;
1405 uint32_t *ptr
= object_field_prop_ptr(obj
, prop
);
1407 if (!visit_type_uint32(v
, name
, ptr
, errp
)) {
1410 zpci
->fid_defined
= true;
1413 static const PropertyInfo s390_pci_fid_propinfo
= {
1415 .get
= s390_pci_get_fid
,
1416 .set
= s390_pci_set_fid
,
1419 #define DEFINE_PROP_S390_PCI_FID(_n, _s, _f) \
1420 DEFINE_PROP(_n, _s, _f, s390_pci_fid_propinfo, uint32_t)
1422 static Property s390_pci_device_properties
[] = {
1423 DEFINE_PROP_UINT16("uid", S390PCIBusDevice
, uid
, UID_UNDEFINED
),
1424 DEFINE_PROP_S390_PCI_FID("fid", S390PCIBusDevice
, fid
),
1425 DEFINE_PROP_STRING("target", S390PCIBusDevice
, target
),
1426 DEFINE_PROP_BOOL("interpret", S390PCIBusDevice
, interp
, true),
1427 DEFINE_PROP_END_OF_LIST(),
1430 static const VMStateDescription s390_pci_device_vmstate
= {
1431 .name
= TYPE_S390_PCI_DEVICE
,
1433 * TODO: add state handling here, so migration works at least with
1434 * emulated pci devices on s390x
1439 static void s390_pci_device_class_init(ObjectClass
*klass
, void *data
)
1441 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1443 dc
->desc
= "zpci device";
1444 set_bit(DEVICE_CATEGORY_MISC
, dc
->categories
);
1445 dc
->reset
= s390_pci_device_reset
;
1446 dc
->bus_type
= TYPE_S390_PCI_BUS
;
1447 dc
->realize
= s390_pci_device_realize
;
1448 device_class_set_props(dc
, s390_pci_device_properties
);
1449 dc
->vmsd
= &s390_pci_device_vmstate
;
1452 static const TypeInfo s390_pci_device_info
= {
1453 .name
= TYPE_S390_PCI_DEVICE
,
1454 .parent
= TYPE_DEVICE
,
1455 .instance_size
= sizeof(S390PCIBusDevice
),
1456 .class_init
= s390_pci_device_class_init
,
1459 static const TypeInfo s390_pci_iommu_info
= {
1460 .name
= TYPE_S390_PCI_IOMMU
,
1461 .parent
= TYPE_OBJECT
,
1462 .instance_size
= sizeof(S390PCIIOMMU
),
1465 static void s390_iommu_memory_region_class_init(ObjectClass
*klass
, void *data
)
1467 IOMMUMemoryRegionClass
*imrc
= IOMMU_MEMORY_REGION_CLASS(klass
);
1469 imrc
->translate
= s390_translate_iommu
;
1470 imrc
->replay
= s390_pci_iommu_replay
;
1473 static const TypeInfo s390_iommu_memory_region_info
= {
1474 .parent
= TYPE_IOMMU_MEMORY_REGION
,
1475 .name
= TYPE_S390_IOMMU_MEMORY_REGION
,
1476 .class_init
= s390_iommu_memory_region_class_init
,
1479 static void s390_pci_register_types(void)
1481 type_register_static(&s390_pcihost_info
);
1482 type_register_static(&s390_pcibus_info
);
1483 type_register_static(&s390_pci_device_info
);
1484 type_register_static(&s390_pci_iommu_info
);
1485 type_register_static(&s390_iommu_memory_region_info
);
1488 type_init(s390_pci_register_types
)