ia64/xen-unstable

changeset 19800:78962f85c562

IOMMU: Add two generic functions to vendor neutral interface

Add 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.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 19 08:41:50 2009 +0100 (2009-06-19)
parents dc0d1200e3f3
children c3a94ac4c031
files xen/arch/x86/msi.c xen/drivers/passthrough/amd/iommu_intr.c xen/drivers/passthrough/amd/pci_amd_iommu.c xen/drivers/passthrough/iommu.c xen/drivers/passthrough/vtd/iommu.c xen/include/asm-x86/hvm/svm/amd-iommu-proto.h xen/include/asm-x86/io_apic.h xen/include/xen/iommu.h
line diff
     1.1 --- a/xen/arch/x86/msi.c	Thu Jun 18 15:32:48 2009 +0100
     1.2 +++ b/xen/arch/x86/msi.c	Fri Jun 19 08:41:50 2009 +0100
     1.3 @@ -192,7 +192,7 @@ static void read_msi_msg(struct msi_desc
     1.4      }
     1.5  
     1.6      if ( iommu_enabled )
     1.7 -        msi_msg_read_remap_rte(entry, msg);
     1.8 +        iommu_read_msi_from_ire(entry, msg);
     1.9  }
    1.10  
    1.11  static int set_vector_msi(struct msi_desc *entry)
     2.1 --- a/xen/drivers/passthrough/amd/iommu_intr.c	Thu Jun 18 15:32:48 2009 +0100
     2.2 +++ b/xen/drivers/passthrough/amd/iommu_intr.c	Fri Jun 19 08:41:50 2009 +0100
     2.3 @@ -231,6 +231,18 @@ void amd_iommu_msi_msg_update_ire(
     2.4      update_intremap_entry_from_msi_msg(iommu, pdev, msg);
     2.5  }
     2.6  
     2.7 +unsigned int amd_iommu_read_ioapic_from_ire(
     2.8 +    unsigned int apic, unsigned int reg)
     2.9 +{
    2.10 +    *IO_APIC_BASE(apic) = reg;
    2.11 +    return *(IO_APIC_BASE(apic)+4);
    2.12 +}
    2.13 +
    2.14 +void amd_iommu_read_msi_from_ire(
    2.15 +    struct msi_desc *msi_desc, struct msi_msg *msg)
    2.16 +{
    2.17 +}
    2.18 +
    2.19  int __init deallocate_intremap_table(void)
    2.20  {
    2.21      if ( int_remap_table )
     3.1 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Thu Jun 18 15:32:48 2009 +0100
     3.2 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Fri Jun 19 08:41:50 2009 +0100
     3.3 @@ -439,4 +439,6 @@ struct iommu_ops amd_iommu_ops = {
     3.4      .get_device_group_id = amd_iommu_group_id,
     3.5      .update_ire_from_apic = amd_iommu_ioapic_update_ire,
     3.6      .update_ire_from_msi = amd_iommu_msi_msg_update_ire,
     3.7 +    .read_apic_from_ire = amd_iommu_read_ioapic_from_ire,
     3.8 +    .read_msi_from_ire = amd_iommu_read_msi_from_ire,
     3.9  };
     4.1 --- a/xen/drivers/passthrough/iommu.c	Thu Jun 18 15:32:48 2009 +0100
     4.2 +++ b/xen/drivers/passthrough/iommu.c	Fri Jun 19 08:41:50 2009 +0100
     4.3 @@ -263,14 +263,10 @@ static int iommu_setup(void)
     4.4  {
     4.5      int rc = -ENODEV;
     4.6  
     4.7 -    if ( !iommu_enabled )
     4.8 -        goto out;
     4.9 -
    4.10      rc = iommu_hardware_setup();
    4.11  
    4.12      iommu_enabled = (rc == 0);
    4.13  
    4.14 - out:
    4.15      if ( force_iommu && !iommu_enabled )
    4.16          panic("IOMMU setup failed, crash Xen for security purpose!\n");
    4.17  
    4.18 @@ -336,6 +332,20 @@ void iommu_update_ire_from_msi(
    4.19      struct iommu_ops *ops = iommu_get_ops();
    4.20      ops->update_ire_from_msi(msi_desc, msg);
    4.21  }
    4.22 +
    4.23 +void iommu_read_msi_from_ire(
    4.24 +    struct msi_desc *msi_desc, struct msi_msg *msg)
    4.25 +{
    4.26 +    struct iommu_ops *ops = iommu_get_ops();
    4.27 +    ops->read_msi_from_ire(msi_desc, msg);
    4.28 +}
    4.29 +
    4.30 +unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg)
    4.31 +{
    4.32 +    struct iommu_ops *ops = iommu_get_ops();
    4.33 +    return ops->read_apic_from_ire(apic, reg);
    4.34 +}
    4.35 +
    4.36  /*
    4.37   * Local variables:
    4.38   * mode: C
     5.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Thu Jun 18 15:32:48 2009 +0100
     5.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Fri Jun 19 08:41:50 2009 +0100
     5.3 @@ -1989,6 +1989,8 @@ struct iommu_ops intel_iommu_ops = {
     5.4      .get_device_group_id = intel_iommu_group_id,
     5.5      .update_ire_from_apic = io_apic_write_remap_rte,
     5.6      .update_ire_from_msi = msi_msg_write_remap_rte,
     5.7 +    .read_apic_from_ire = io_apic_read_remap_rte,
     5.8 +    .read_msi_from_ire = msi_msg_read_remap_rte,
     5.9  };
    5.10  
    5.11  /*
     6.1 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Thu Jun 18 15:32:48 2009 +0100
     6.2 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Fri Jun 19 08:41:50 2009 +0100
     6.3 @@ -87,6 +87,10 @@ void amd_iommu_ioapic_update_ire(
     6.4      unsigned int apic, unsigned int reg, unsigned int value);
     6.5  void amd_iommu_msi_msg_update_ire(
     6.6      struct msi_desc *msi_desc, struct msi_msg *msg);
     6.7 +void amd_iommu_read_msi_from_ire(
     6.8 +    struct msi_desc *msi_desc, struct msi_msg *msg);
     6.9 +unsigned int amd_iommu_read_ioapic_from_ire(
    6.10 +    unsigned int apic, unsigned int reg);
    6.11  
    6.12  static inline u32 get_field_from_reg_u32(u32 reg_value, u32 mask, u32 shift)
    6.13  {
     7.1 --- a/xen/include/asm-x86/io_apic.h	Thu Jun 18 15:32:48 2009 +0100
     7.2 +++ b/xen/include/asm-x86/io_apic.h	Fri Jun 19 08:41:50 2009 +0100
     7.3 @@ -131,7 +131,7 @@ extern int mpc_default_type;
     7.4  static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
     7.5  {
     7.6  	if (ioapic_reg_remapped(reg))
     7.7 -		return io_apic_read_remap_rte(apic, reg);
     7.8 +		return iommu_read_apic_from_ire(apic, reg);
     7.9  	*IO_APIC_BASE(apic) = reg;
    7.10  	return *(IO_APIC_BASE(apic)+4);
    7.11  }
     8.1 --- a/xen/include/xen/iommu.h	Thu Jun 18 15:32:48 2009 +0100
     8.2 +++ b/xen/include/xen/iommu.h	Fri Jun 19 08:41:50 2009 +0100
     8.3 @@ -107,10 +107,14 @@ struct iommu_ops {
     8.4      int (*get_device_group_id)(u8 bus, u8 devfn);
     8.5      void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);
     8.6      void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
     8.7 +    void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg);
     8.8 +    unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
     8.9  };
    8.10  
    8.11  void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
    8.12  void iommu_update_ire_from_msi(struct msi_desc *msi_desc, struct msi_msg *msg);
    8.13 +void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg);
    8.14 +unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
    8.15  
    8.16  void iommu_suspend(void);
    8.17  void iommu_resume(void);