IOMMU: Add two generic functions to vendor neutral interface
PATCH 1/1 IOMMU: Add two generic functions to vendor neutral interface
Hi,
This patch adds 2 generic functions into the vendor neutral iommu interface, The reason is that from changeset 19732, there is only one global flag "iommu_enabled" that controls iommu enablement for both vtd and amd systems, so we need different code paths for vtd and amd iommu systems if this flag has been turned on. Also, the early checking of "iommu_enabled" in iommu_setup() is removed to prevent iommu functionalities from been disabled on amd systems.
Thanks,
-Wei
--
AMD GmbH, Germany
Operating System Research Center
Legal Information:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34
85609 Dornach b. München
Geschäftsführer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis München Registergericht München, HRB Nr. 43632
xen/arch/x86/msi.c +1 -1
@@ -192,7 +192,7 @@ static void read_msi_msg(struct msi_desc }if ( iommu_enabled ) -msi_msg_read_remap_rte (entry, msg); +iommu_read_msi_from_ire (entry, msg); }static int set_vector_msi (struct msi_desc *entry)
xen/drivers/passthrough/amd/iommu_intr.c +12 -0
@@ -231,6 +231,18 @@ void amd_iommu_msi_msg_update_ire(update_intremap_entry_from_msi_msg (iommu, pdev, msg); } +unsigned int amd_iommu_read_ioapic_from_ire ( +unsigned int apic,unsigned int reg) +{ + *IO_APIC_BASE (apic) = reg; +return *(IO_APIC_BASE (apic)+4 ); +} + +void amd_iommu_read_msi_from_ire ( +struct msi_desc *msi_desc,struct msi_msg *msg) +{ +} +int __init deallocate_intremap_table (void ) {if ( int_remap_table )
xen/drivers/passthrough/amd/pci_amd_iommu.c +2 -0
@@ -439,4 +439,6 @@ struct iommu_ops amd_iommu_ops = { .get_device_group_id = amd_iommu_group_id, .update_ire_from_apic = amd_iommu_ioapic_update_ire, .update_ire_from_msi = amd_iommu_msi_msg_update_ire, + .read_apic_from_ire = amd_iommu_read_ioapic_from_ire, + .read_msi_from_ire = amd_iommu_read_msi_from_ire, };
xen/drivers/passthrough/iommu.c +14 -4
@@ -263,14 +263,10 @@ static int iommu_setup(void) {int rc = -ENODEV ; -if ( !iommu_enabled ) - goto out; - rc =iommu_hardware_setup (); iommu_enabled = (rc ==0 ); - out:if ( force_iommu && !iommu_enabled )panic ("IOMMU setup failed, crash Xen for security purpose!\n" );
@@ -336,6 +332,20 @@ void iommu_update_ire_from_msi(struct iommu_ops *ops =iommu_get_ops (); ops->update_ire_from_msi (msi_desc, msg); } + +void iommu_read_msi_from_ire ( +struct msi_desc *msi_desc,struct msi_msg *msg) +{ +struct iommu_ops *ops =iommu_get_ops (); + ops->read_msi_from_ire (msi_desc, msg); +} + +unsigned int iommu_read_apic_from_ire (unsigned int apic,unsigned int reg) +{ +struct iommu_ops *ops =iommu_get_ops (); +return ops->read_apic_from_ire (apic, reg); +} +/* * Local variables: * mode: C
xen/drivers/passthrough/vtd/iommu.c +2 -0
@@ -1989,6 +1989,8 @@ struct iommu_ops intel_iommu_ops = { .get_device_group_id = intel_iommu_group_id, .update_ire_from_apic = io_apic_write_remap_rte, .update_ire_from_msi = msi_msg_write_remap_rte, + .read_apic_from_ire = io_apic_read_remap_rte, + .read_msi_from_ire = msi_msg_read_remap_rte, };/*
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +4 -0
@@ -87,6 +87,10 @@ void amd_iommu_ioapic_update_ire( unsigned int apic, unsigned int reg, unsigned int value);void amd_iommu_msi_msg_update_ire (struct msi_desc *msi_desc,struct msi_msg *msg); +void amd_iommu_read_msi_from_ire ( +struct msi_desc *msi_desc,struct msi_msg *msg); +unsigned int amd_iommu_read_ioapic_from_ire ( +unsigned int apic,unsigned int reg);static inline u32 get_field_from_reg_u32 (u32 reg_value,u32 mask,u32 shift) {
xen/include/asm-x86/io_apic.h +1 -1
@@ -131,7 +131,7 @@ static inline unsigned int io_apic_read(static inline unsigned int io_apic_read (unsigned int apic,unsigned int reg) {if (ioapic_reg_remapped (reg)) -return io_apic_read_remap_rte (apic, reg); +return iommu_read_apic_from_ire (apic, reg); *IO_APIC_BASE (apic) = reg;return *(IO_APIC_BASE (apic)+4 ); }
xen/include/xen/iommu.h +4 -0
@@ -107,10 +107,14 @@ struct iommu_ops {int (*get_device_group_id)(u8 bus,u8 devfn);void (*update_ire_from_apic)(unsigned int apic,unsigned int reg,unsigned int value);void (*update_ire_from_msi)(struct msi_desc *msi_desc,struct msi_msg *msg); +void (*read_msi_from_ire)(struct msi_desc *msi_desc,struct msi_msg *msg); +unsigned int (*read_apic_from_ire)(unsigned int apic,unsigned int reg); };void iommu_update_ire_from_apic (unsigned int apic,unsigned int reg,unsigned int value);void iommu_update_ire_from_msi (struct msi_desc *msi_desc,struct msi_msg *msg); +void iommu_read_msi_from_ire (struct msi_desc *msi_desc,struct msi_msg *msg); +unsigned int iommu_read_apic_from_ire (unsigned int apic,unsigned int reg);void iommu_suspend (void );void iommu_resume (void );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel