static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)

{

    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);

    struct vfio_iommu_spapr_tce_info info = { .argsz = sizeof(info) };

    int ret;

    sPAPRTCETable *tcet;

    uint32_t liobn = svphb->phb.dma_liobn;



    if (svphb->iommugroupid == -1) {

        error_setg(errp, "Wrong IOMMU group ID %d", svphb->iommugroupid);

        return;

    }



    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,

                               VFIO_CHECK_EXTENSION,

                               (void *) VFIO_SPAPR_TCE_IOMMU);

    if (ret != 1) {

        error_setg_errno(errp, -ret,

                         "spapr-vfio: SPAPR extension is not supported");

        return;

    }



    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,

                               VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);

    if (ret) {

        error_setg_errno(errp, -ret,

                         "spapr-vfio: get info from container failed");

        return;

    }



    tcet = spapr_tce_new_table(DEVICE(sphb), liobn, info.dma32_window_start,

                               SPAPR_TCE_PAGE_SHIFT,

                               info.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT,

                               true);

    if (!tcet) {

        error_setg(errp, "spapr-vfio: failed to create VFIO TCE table");

        return;

    }



    /* Register default 32bit DMA window */

    memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset,

                                spapr_tce_get_iommu(tcet));

}

static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)

{

    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);

    struct vfio_iommu_spapr_tce_info info = { .argsz = sizeof(info) };

    int ret;

    sPAPRTCETable *tcet;

    uint32_t liobn = svphb->phb.dma_liobn;



    if (svphb->iommugroupid == -1) {

        error_setg(errp, "Wrong IOMMU group ID %d", svphb->iommugroupid);

        return;

    }



    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,

                               VFIO_CHECK_EXTENSION,

                               (void *) VFIO_SPAPR_TCE_IOMMU);

    if (ret != 1) {

        error_setg_errno(errp, -ret,

                         "spapr-vfio: SPAPR extension is not supported");

        return;

    }



    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,

                               VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);

    if (ret) {

        error_setg_errno(errp, -ret,

                         "spapr-vfio: get info from container failed");

        return;

    }



    tcet = spapr_tce_new_table(DEVICE(sphb), liobn, info.dma32_window_start,

                               SPAPR_TCE_PAGE_SHIFT,

                               info.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT,

                               true);

    if (!tcet) {

        error_setg(errp, "spapr-vfio: failed to create VFIO TCE table");

        return;

    }



    

    memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset,

                                spapr_tce_get_iommu(tcet));

}

static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)     sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);     struct vfio_iommu_spapr_tce_info info = { .argsz = sizeof(info) };     int ret;     sPAPRTCETable *tcet;     uint32_t liobn = svphb->phb.dma_liobn;     if (svphb->iommugroupid == -1) {         error_setg(errp, "Wrong IOMMU group ID %d", svphb->iommugroupid);     ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,                                VFIO_CHECK_EXTENSION,                                (void *) VFIO_SPAPR_TCE_IOMMU);     if (ret != 1) {         error_setg_errno(errp, -ret,                          "spapr-vfio: SPAPR extension is not supported");     ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,                                VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);     if (ret) {         error_setg_errno(errp, -ret,                          "spapr-vfio: get info from container failed");     tcet = spapr_tce_new_table(DEVICE(sphb), liobn, info.dma32_window_start,                                SPAPR_TCE_PAGE_SHIFT,                                info.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT,                                true);     if (!tcet) {         error_setg(errp, "spapr-vfio: failed to create VFIO TCE table");     memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset,                                 spapr_tce_get_iommu(tcet));
static void FUNC_0(sPAPRPHBState *VAR_0, Error **VAR_1)

{

    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(VAR_0);

    struct vfio_iommu_spapr_tce_info VAR_2 = { .argsz = sizeof(VAR_2) };

    int VAR_3;

    sPAPRTCETable *tcet;

    uint32_t liobn = svphb->phb.dma_liobn;



    if (svphb->iommugroupid == -1) {

        error_setg(VAR_1, "Wrong IOMMU group ID %d", svphb->iommugroupid);

        return;

    }



    VAR_3 = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,

                               VFIO_CHECK_EXTENSION,

                               (void *) VFIO_SPAPR_TCE_IOMMU);

    if (VAR_3 != 1) {

        error_setg_errno(VAR_1, -VAR_3,

                         "spapr-vfio: SPAPR extension is not supported");

        return;

    }



    VAR_3 = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,

                               VFIO_IOMMU_SPAPR_TCE_GET_INFO, &VAR_2);

    if (VAR_3) {

        error_setg_errno(VAR_1, -VAR_3,

                         "spapr-vfio: get VAR_2 from container failed");

        return;

    }



    tcet = spapr_tce_new_table(DEVICE(VAR_0), liobn, VAR_2.dma32_window_start,

                               SPAPR_TCE_PAGE_SHIFT,

                               VAR_2.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT,

                               true);

    if (!tcet) {

        error_setg(VAR_1, "spapr-vfio: failed to create VFIO TCE table");

        return;

    }



    

    memory_region_add_subregion(&VAR_0->iommu_root, tcet->bus_offset,

                                spapr_tce_get_iommu(tcet));

}

static void FUNC_0(sPAPRPHBState *VAR_0, Error **VAR_1)
{ sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(VAR_0); struct vfio_iommu_spapr_tce_info VAR_2 = { .argsz = sizeof(VAR_2) }; int VAR_3; sPAPRTCETable *tcet; uint32_t liobn = svphb->phb.dma_liobn; if (svphb->iommugroupid == -1) { error_setg(VAR_1, "Wrong IOMMU group ID %d", svphb->iommugroupid); return; } VAR_3 = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
VFIO_CHECK_EXTENSION,
(void *) VFIO_SPAPR_TCE_IOMMU); if (VAR_3 != 1) { error_setg_errno(VAR_1, -VAR_3,
"spapr-vfio: SPAPR extension is not supported"); return; } VAR_3 = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
VFIO_IOMMU_SPAPR_TCE_GET_INFO, &VAR_2); if (VAR_3) { error_setg_errno(VAR_1, -VAR_3,
"spapr-vfio: get VAR_2 from container failed"); return; } tcet = spapr_tce_new_table(DEVICE(VAR_0), liobn, VAR_2.dma32_window_start,
SPAPR_TCE_PAGE_SHIFT,
VAR_2.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT,
true); if (!tcet) { error_setg(VAR_1, "spapr-vfio: failed to create VFIO TCE table"); return; } memory_region_add_subregion(&VAR_0->iommu_root, tcet->bus_offset,
spapr_tce_get_iommu(tcet)); }