From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: [PATCH] IOMMU: Add two generic functions to vendor neutral interface Date: Thu, 18 Jun 2009 15:27:54 +0200 Message-ID: <200906181527.54979.wei.wang2@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_aDkOKGhqS6Eik/H" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_aDkOKGhqS6Eik/H Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, This patch adds 2 generic functions into the vendor neutral iommu interface= ,=20 The reason is that from changeset 19732, there is only one global=20 flag "iommu_enabled" that controls iommu enablement for both vtd and amd=20 systems, so we need different code paths for vtd and amd iommu systems if t= his=20 flag has been turned on. Also, the early checking of "iommu_enabled" in =20 iommu_setup() is removed to prevent iommu functionalities from been disable= d=20 on amd systems. Thanks, =2DWei Signed-off-by: Wei Wang =2D- AMD GmbH, Germany Operating System Research Center =20 Legal Information: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34 85609 Dornach b. M=FCnchen =20 Gesch=E4ftsf=FChrer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis M=FCnchen Registergericht M=FCnchen, HRB Nr. 43632 --Boundary-00=_aDkOKGhqS6Eik/H Content-Type: text/x-diff; charset="iso-8859-1"; name="fix_global_variable.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix_global_variable.patch" diff -r 64a932c92a7c xen/arch/x86/msi.c --- a/xen/arch/x86/msi.c Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/arch/x86/msi.c Wed Jun 17 18:38:34 2009 +0200 @@ -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) diff -r 64a932c92a7c xen/drivers/passthrough/amd/iommu_intr.c --- a/xen/drivers/passthrough/amd/iommu_intr.c Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/drivers/passthrough/amd/iommu_intr.c Wed Jun 17 18:38:34 2009 +0200 @@ -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 ) diff -r 64a932c92a7c xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Jun 17 18:38:34 2009 +0200 @@ -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, }; diff -r 64a932c92a7c xen/drivers/passthrough/iommu.c --- a/xen/drivers/passthrough/iommu.c Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/drivers/passthrough/iommu.c Wed Jun 17 18:38:34 2009 +0200 @@ -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 diff -r 64a932c92a7c xen/drivers/passthrough/vtd/iommu.c --- a/xen/drivers/passthrough/vtd/iommu.c Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/drivers/passthrough/vtd/iommu.c Wed Jun 17 18:38:34 2009 +0200 @@ -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, }; /* diff -r 64a932c92a7c xen/include/asm-x86/hvm/svm/amd-iommu-proto.h --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Wed Jun 17 18:38:34 2009 +0200 @@ -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) { diff -r 64a932c92a7c xen/include/asm-x86/io_apic.h --- a/xen/include/asm-x86/io_apic.h Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/include/asm-x86/io_apic.h Wed Jun 17 18:38:34 2009 +0200 @@ -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); } diff -r 64a932c92a7c xen/include/xen/iommu.h --- a/xen/include/xen/iommu.h Tue Jun 16 14:19:34 2009 +0100 +++ b/xen/include/xen/iommu.h Wed Jun 17 18:38:34 2009 +0200 @@ -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); --Boundary-00=_aDkOKGhqS6Eik/H Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_aDkOKGhqS6Eik/H--