[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 21/25] xen/domctl: wrap aound iommu-related domctl op
Function iommu_do_domctl() is the main entry for all iommu-related domctl-op. Tracking its calling chaining, the following functions shall all be wrapped: - iommu_do_pci_domctl - xsm_get_device_group - iommu_get_device_group - amd_iommu_group_id/intel_iommu_group_id - xsm_assign_device - device_assigned - assign_device - intel_iommu_assign_device/amd_iommu_assign_devic - xsm_deassign_device - deassign_device - reassign_device_ownership/reassign_device - iommu_do_dt_domctl - xsm_assign_dtdevice - xsm_deassign_dtdevice - iommu_deassign_dt_device - arm_smmu_reassign_dev/arm_smmu_reassign_dev - ipmmu_reassign_dev - ipmmu_deassign_dev - ipmmu_detach_dev - dt_find_node_by_gpath Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx> --- xen/common/device-tree/device-tree.c | 2 ++ xen/drivers/passthrough/amd/pci_amd_iommu.c | 8 ++++++++ xen/drivers/passthrough/arm/ipmmu-vmsa.c | 6 ++++++ xen/drivers/passthrough/arm/smmu-v3.c | 4 ++++ xen/drivers/passthrough/arm/smmu.c | 4 ++++ xen/drivers/passthrough/device_tree.c | 4 ++++ xen/drivers/passthrough/iommu.c | 2 ++ xen/drivers/passthrough/pci.c | 6 +++++- xen/drivers/passthrough/vtd/iommu.c | 6 ++++++ xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 4 ++-- xen/xsm/flask/hooks.c | 12 ++++++------ 12 files changed, 55 insertions(+), 15 deletions(-) diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/device-tree.c index 0b5375f151..4ce6dce2ea 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -371,6 +371,7 @@ struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node *from, return np; } +#ifdef CONFIG_DOMCTL int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, struct dt_device_node **node) { @@ -386,6 +387,7 @@ int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, return (*node == NULL) ? -ESRCH : 0; } +#endif /* CONFIG_DOMCTL */ struct dt_device_node *dt_find_node_by_alias(const char *alias) { diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index 3a14770855..869d2bc3a2 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -461,6 +461,7 @@ static void amd_iommu_disable_domain_device(const struct domain *domain, spin_unlock_irqrestore(&iommu->lock, flags); } +#ifdef CONFIG_DOMCTL static int cf_check reassign_device( struct domain *source, struct domain *target, u8 devfn, struct pci_dev *pdev) @@ -550,6 +551,7 @@ static int cf_check amd_iommu_assign_device( return rc; } +#endif /* CONFIG_DOMCTL */ static void cf_check amd_iommu_clear_root_pgtable(struct domain *d) { @@ -698,12 +700,14 @@ static int cf_check amd_iommu_remove_device(u8 devfn, struct pci_dev *pdev) return 0; } +#ifdef CONFIG_DOMCTL static int cf_check amd_iommu_group_id(u16 seg, u8 bus, u8 devfn) { unsigned int bdf = PCI_BDF(bus, devfn); return (bdf < ivrs_bdf_entries) ? get_dma_requestor_id(seg, bdf) : bdf; } +#endif /* CONFIG_DOMCTL */ #include <asm/io_apic.h> @@ -772,14 +776,18 @@ static const struct iommu_ops __initconst_cf_clobber _iommu_ops = { .quarantine_init = amd_iommu_quarantine_init, .add_device = amd_iommu_add_device, .remove_device = amd_iommu_remove_device, +#ifdef CONFIG_DOMCTL .assign_device = amd_iommu_assign_device, +#endif .teardown = amd_iommu_domain_destroy, .clear_root_pgtable = amd_iommu_clear_root_pgtable, .map_page = amd_iommu_map_page, .unmap_page = amd_iommu_unmap_page, .iotlb_flush = amd_iommu_flush_iotlb_pages, +#ifdef CONFIG_DOMCTL .reassign_device = reassign_device, .get_device_group_id = amd_iommu_group_id, +#endif .enable_x2apic = iov_enable_xt, .update_ire_from_apic = amd_iommu_ioapic_update_ire, .update_ire_from_msi = amd_iommu_msi_msg_update_ire, diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthrough/arm/ipmmu-vmsa.c index dac0dd6d46..719f0a11cc 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -726,6 +726,7 @@ static int ipmmu_attach_device(struct ipmmu_vmsa_domain *domain, return 0; } +#ifdef CONFIG_DOMCTL static void ipmmu_detach_device(struct ipmmu_vmsa_domain *domain, struct device *dev) { @@ -735,6 +736,7 @@ static void ipmmu_detach_device(struct ipmmu_vmsa_domain *domain, for ( i = 0; i < fwspec->num_ids; ++i ) ipmmu_utlb_disable(domain, fwspec->ids[i]); } +#endif /* CONFIG_DOMCTL */ static int ipmmu_init_platform_device(struct device *dev, const struct dt_phandle_args *args) @@ -1209,6 +1211,7 @@ out: return ret; } +#ifdef CONFIG_DOMCTL static int ipmmu_deassign_device(struct domain *d, struct device *dev) { struct ipmmu_vmsa_xen_domain *xen_domain = dom_iommu(d)->arch.priv; @@ -1264,6 +1267,7 @@ static int ipmmu_reassign_device(struct domain *s, struct domain *t, return 0; } +#endif /* CONFIG_DOMCTL */ static int ipmmu_dt_xlate(struct device *dev, const struct dt_phandle_args *spec) @@ -1367,7 +1371,9 @@ static const struct iommu_ops ipmmu_iommu_ops = .teardown = ipmmu_iommu_domain_teardown, .iotlb_flush = ipmmu_iotlb_flush, .assign_device = ipmmu_assign_device, +#ifdef CONFIG_DOMCTL .reassign_device = ipmmu_reassign_device, +#endif .map_page = arm_iommu_map_page, .unmap_page = arm_iommu_unmap_page, .dt_xlate = ipmmu_dt_xlate, diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c index 5e9e3e048e..d3028d859e 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -2780,6 +2780,7 @@ static int arm_smmu_deassign_dev(struct domain *d, uint8_t devfn, struct device return 0; } +#ifdef CONFIG_DOMCTL static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, u8 devfn, struct device *dev) { @@ -2807,6 +2808,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, return 0; } +#endif /* CONFIG_DOMCTL */ static int arm_smmu_iommu_xen_domain_init(struct domain *d) { @@ -2843,7 +2845,9 @@ static const struct iommu_ops arm_smmu_iommu_ops = { .teardown = arm_smmu_iommu_xen_domain_teardown, .iotlb_flush = arm_smmu_iotlb_flush, .assign_device = arm_smmu_assign_dev, +#ifdef CONFIG_DOMCTL .reassign_device = arm_smmu_reassign_dev, +#endif .map_page = arm_iommu_map_page, .unmap_page = arm_iommu_unmap_page, .dt_xlate = arm_smmu_dt_xlate, diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 22d306d0cb..f1d85ae91f 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2891,6 +2891,7 @@ static int arm_smmu_deassign_dev(struct domain *d, uint8_t devfn, return 0; } +#ifdef CONFIG_DOMCTL static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, u8 devfn, struct device *dev) { @@ -2918,6 +2919,7 @@ static int arm_smmu_reassign_dev(struct domain *s, struct domain *t, return 0; } +#endif /* CONFIG_DOMCTL */ static int arm_smmu_iommu_domain_init(struct domain *d) { @@ -2956,7 +2958,9 @@ static const struct iommu_ops arm_smmu_iommu_ops = { .teardown = arm_smmu_iommu_domain_teardown, .iotlb_flush = arm_smmu_iotlb_flush, .assign_device = arm_smmu_assign_dev, +#ifdef CONFIG_DOMCTL .reassign_device = arm_smmu_reassign_dev, +#endif .map_page = arm_iommu_map_page, .unmap_page = arm_iommu_unmap_page, .dt_xlate = arm_smmu_dt_xlate_generic, diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index 704910de3d..225aae2f29 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -59,6 +59,7 @@ fail: return rc; } +#ifdef CONFIG_DOMCTL int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev) { const struct domain_iommu *hd = dom_iommu(d); @@ -86,6 +87,7 @@ fail: return rc; } +#endif /* CONFIG_DOMCTL */ static bool iommu_dt_device_is_assigned_locked(const struct dt_device_node *dev) { @@ -320,6 +322,7 @@ int iommu_add_dt_device(struct dt_device_node *np) return rc; } +#ifdef CONFIG_DOMCTL int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) { @@ -431,3 +434,4 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d, return ret; } +#endif /* CONFIG_DOMCTL */ diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index c9425d6971..5035eb6e53 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -625,6 +625,7 @@ void iommu_resume(void) iommu_vcall(iommu_get_ops(), resume); } +#ifdef CONFIG_DOMCTL int iommu_do_domctl( struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) @@ -645,6 +646,7 @@ int iommu_do_domctl( return ret; } +#endif /* CONFIG_DOMCTL */ void iommu_crash_shutdown(void) { diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 41638b71d6..176c7502d6 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -877,6 +877,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn) return ret; } +#ifdef CONFIG_DOMCTL /* Caller should hold the pcidevs_lock */ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus, uint8_t devfn) @@ -945,7 +946,6 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus, return ret; } -#ifdef CONFIG_DOMCTL int pci_release_devices(struct domain *d) { int combined_ret; @@ -1483,6 +1483,7 @@ static int iommu_remove_device(struct pci_dev *pdev) return iommu_call(hd->platform_ops, remove_device, devfn, pci_to_dev(pdev)); } +#ifdef CONFIG_DOMCTL static int device_assigned(u16 seg, u8 bus, u8 devfn) { struct pci_dev *pdev; @@ -1646,6 +1647,7 @@ static int iommu_get_device_group( return i; } +#endif /* CONFIG_DOMCTL */ void iommu_dev_iotlb_flush_timeout(struct domain *d, struct pci_dev *pdev) { @@ -1671,6 +1673,7 @@ void iommu_dev_iotlb_flush_timeout(struct domain *d, struct pci_dev *pdev) pcidevs_unlock(); } +#ifdef CONFIG_DOMCTL int iommu_do_pci_domctl( struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) @@ -1804,6 +1807,7 @@ int iommu_do_pci_domctl( return ret; } +#endif /* CONFIG_DOMCTL */ struct segment_iter { int (*handler)(struct pci_dev *pdev, void *arg); diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index c55f02c97e..e9c074a649 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2731,6 +2731,7 @@ static int __init cf_check vtd_setup(void) return ret; } +#ifdef CONFIG_DOMCTL static int cf_check reassign_device_ownership( struct domain *source, struct domain *target, @@ -2926,6 +2927,7 @@ static int cf_check intel_iommu_group_id(u16 seg, u8 bus, u8 devfn) return PCI_BDF(bus, devfn); } +#endif /* CONFIG_DOMCTL */ static int __must_check cf_check vtd_suspend(void) { @@ -3234,14 +3236,18 @@ static const struct iommu_ops __initconst_cf_clobber vtd_ops = { .add_device = intel_iommu_add_device, .enable_device = intel_iommu_enable_device, .remove_device = intel_iommu_remove_device, +#ifdef CONFIG_DOMCTL .assign_device = intel_iommu_assign_device, +#endif .teardown = iommu_domain_teardown, .clear_root_pgtable = iommu_clear_root_pgtable, .map_page = intel_iommu_map_page, .unmap_page = intel_iommu_unmap_page, .lookup_page = intel_iommu_lookup_page, +#ifdef CONFIG_DOMCTL .reassign_device = reassign_device_ownership, .get_device_group_id = intel_iommu_group_id, +#endif .enable_x2apic = intel_iommu_enable_eim, .disable_x2apic = intel_iommu_disable_eim, .update_ire_from_apic = io_apic_write_remap_rte, diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index db98496869..6bbf3df702 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -127,13 +127,13 @@ struct xsm_ops { int (*pci_config_permission)(struct domain *d, uint32_t machine_bdf, uint16_t start, uint16_t end, uint8_t access); -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) && defined(CONFIG_DOMCTL) int (*get_device_group)(uint32_t machine_bdf); int (*assign_device)(struct domain *d, uint32_t machine_bdf); int (*deassign_device)(struct domain *d, uint32_t machine_bdf); #endif -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) && defined(CONFIG_DOMCTL) int (*assign_dtdevice)(struct domain *d, const char *dtpath); int (*deassign_dtdevice)(struct domain *d, const char *dtpath); #endif @@ -548,7 +548,7 @@ static inline int xsm_pci_config_permission( return alternative_call(xsm_ops.pci_config_permission, d, machine_bdf, start, end, access); } -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) && defined(CONFIG_DOMCTL) static inline int xsm_get_device_group(xsm_default_t def, uint32_t machine_bdf) { return alternative_call(xsm_ops.get_device_group, machine_bdf); @@ -565,9 +565,9 @@ static inline int xsm_deassign_device( { return alternative_call(xsm_ops.deassign_device, d, machine_bdf); } -#endif /* HAS_PASSTHROUGH && HAS_PCI) */ +#endif /* HAS_PASSTHROUGH && HAS_PCI && DOMCTL */ -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) && defined(CONFIG_DOMCTL) static inline int xsm_assign_dtdevice( xsm_default_t def, struct domain *d, const char *dtpath) { @@ -580,7 +580,7 @@ static inline int xsm_deassign_dtdevice( return alternative_call(xsm_ops.deassign_dtdevice, d, dtpath); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY && DOMCTL */ static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machine_bdf) { diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index b7eb061e9b..b5174e610b 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -85,13 +85,13 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .pci_config_permission = xsm_pci_config_permission, .get_vnumainfo = xsm_get_vnumainfo, -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) && defined(CONFIG_DOMCTL) .get_device_group = xsm_get_device_group, .assign_device = xsm_assign_device, .deassign_device = xsm_deassign_device, #endif -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) && defined(CONFIG_DOMCTL) .assign_dtdevice = xsm_assign_dtdevice, .deassign_dtdevice = xsm_deassign_dtdevice, #endif diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 9f829aa53b..254e1323e5 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1397,7 +1397,7 @@ static int cf_check flask_mem_sharing(struct domain *d) } #endif -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) && defined(CONFIG_DOMCTL) static int cf_check flask_get_device_group(uint32_t machine_bdf) { uint32_t rsid; @@ -1468,9 +1468,9 @@ static int cf_check flask_deassign_device( return avc_current_has_perm(rsid, SECCLASS_RESOURCE, RESOURCE__REMOVE_DEVICE, NULL); } -#endif /* HAS_PASSTHROUGH && HAS_PCI */ +#endif /* HAS_PASSTHROUGH && HAS_PCI && DOMCTL */ -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) && defined(CONFIG_DOMCTL) static int flask_test_assign_dtdevice(const char *dtpath) { uint32_t rsid; @@ -1531,7 +1531,7 @@ static int cf_check flask_deassign_dtdevice( return avc_current_has_perm(rsid, SECCLASS_RESOURCE, RESOURCE__REMOVE_DEVICE, NULL); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY && DOMCTL */ static int cf_check flask_platform_op(uint32_t op) { @@ -2003,13 +2003,13 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .remove_from_physmap = flask_remove_from_physmap, .map_gmfn_foreign = flask_map_gmfn_foreign, -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) && defined(CONFIG_DOMCTL) .get_device_group = flask_get_device_group, .assign_device = flask_assign_device, .deassign_device = flask_deassign_device, #endif -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY) && defined(CONFIG_DOMCTL) .assign_dtdevice = flask_assign_dtdevice, .deassign_dtdevice = flask_deassign_dtdevice, #endif -- 2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |