[VTD] check BIOS settings before enabling interrupt remapping or x2apic

Check flags field in ACPI DMAR structure before enabling interrupt
remapping or x2apic.  This allows platform vendors to disable
interrupt remapping or x2apic features if on board BIOS does not
support them.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
This commit is contained in:
Allen Kay committed 2011-04-02 15:49:25 +01:00
1 parent 9da48f2428
commit 0be477c900
7 files changed
+49 -9

No files matched your search

+3 -3
View File
@@ -516,7 +516,7 @@ static void resume_x2apic(void)
mask_8259A();
mask_IO_APIC_setup(ioapic_entries);
iommu_enable_IR();
iommu_enable_x2apic_IR();
__enable_x2apic();
restore_IO_APIC_setup(ioapic_entries);
@@ -735,7 +735,7 @@ int lapic_suspend(void)
local_irq_save(flags);
disable_local_APIC();
iommu_disable_IR();
iommu_disable_x2apic_IR();
local_irq_restore(flags);
return 0;
}
@@ -958,7 +958,7 @@ void __init x2apic_bsp_setup(void)
mask_8259A();
mask_IO_APIC_setup(ioapic_entries);
if ( iommu_enable_IR() )
if ( iommu_enable_x2apic_IR() )
{
if ( x2apic_enabled )
panic("Interrupt remapping could not be enabled while "
+24
View File
@@ -47,6 +47,7 @@ static LIST_HEAD_READ_MOSTLY(acpi_atsr_units);
static LIST_HEAD_READ_MOSTLY(acpi_rhsa_units);
static struct acpi_table_header *__read_mostly dmar_table;
static int __read_mostly dmar_flags;
static u64 __read_mostly igd_drhd_address;
static void __init dmar_scope_add_buses(struct dmar_scope *scope, u16 sec_bus,
@@ -761,7 +762,11 @@ out:
int __init acpi_dmar_init(void)
{
struct acpi_table_dmar *dmar;
acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_table);
dmar = (struct acpi_table_dmar *) dmar_table;
dmar_flags = dmar->flags;
return parse_dmar_table(acpi_parse_dmar);
}
@@ -781,3 +786,22 @@ void acpi_dmar_zap(void)
dmar_table->signature[0] = 'X';
dmar_table->checksum -= 'X'-'D';
}
int __init platform_supports_intremap(void)
{
unsigned int flags = 0;
flags = DMAR_INTR_REMAP;
return ((dmar_flags & flags) == DMAR_INTR_REMAP);
}
int __init platform_supports_x2apic(void)
{
unsigned int flags = 0;
if (!cpu_has_x2apic)
return 0;
flags = DMAR_INTR_REMAP | DMAR_X2APIC_OPT_OUT;
return ((dmar_flags & flags) == DMAR_INTR_REMAP);
}
+2
View File
@@ -119,5 +119,7 @@ void vtd_ops_preamble_quirk(struct iommu* iommu);
void vtd_ops_postamble_quirk(struct iommu* iommu);
void me_wifi_quirk(struct domain *domain, u8 bus, u8 devfn, int map);
void pci_vtd_quirk(struct pci_dev *pdev);
int __init platform_supports_intremap(void);
int __init platform_supports_x2apic(void);
#endif // _VTD_EXTERN_H_
+13 -3
View File
@@ -735,6 +735,13 @@ int enable_intremap(struct iommu *iommu, int eim)
ASSERT(ecap_intr_remap(iommu->ecap) && iommu_intremap);
if ( !platform_supports_intremap() )
{
dprintk(XENLOG_ERR VTDPREFIX,
"Platform firmware does not support interrupt remapping\n");
return -EINVAL;
}
ir_ctrl = iommu_ir_ctrl(iommu);
sts = dmar_readl(iommu->reg, DMAR_GSTS_REG);
@@ -821,10 +828,10 @@ out:
}
/*
* This function is used to enable Interrutp remapping when
* This function is used to enable Interrupt remapping when
* enable x2apic
*/
int iommu_enable_IR(void)
int iommu_enable_x2apic_IR(void)
{
struct acpi_drhd_unit *drhd;
struct iommu *iommu;
@@ -832,6 +839,9 @@ int iommu_enable_IR(void)
if ( !iommu_supports_eim() )
return -1;
if ( !platform_supports_x2apic() )
return -1;
for_each_drhd_unit ( drhd )
{
struct qi_ctrl *qi_ctrl = NULL;
@@ -881,7 +891,7 @@ int iommu_enable_IR(void)
* This function is used to disable Interrutp remapping when
* suspend local apic
*/
void iommu_disable_IR(void)
void iommu_disable_x2apic_IR(void)
{
struct acpi_drhd_unit *drhd;
+1 -1
View File
@@ -2014,7 +2014,7 @@ static int init_vtd_hw(void)
if ( enable_intremap(iommu, 0) != 0 )
{
dprintk(XENLOG_WARNING VTDPREFIX,
"Failed to enable Interrupt Remapping!\n");
"Interrupt Remapping not enabled\n");
break;
}
}
+4
View File
@@ -22,6 +22,10 @@
#include <xen/types.h>
/* DMAR Flags bits */
#define DMAR_INTR_REMAP 0x1
#define DMAR_X2APIC_OPT_OUT 0x2
/*
* Intel IOMMU register specification per version 1.0 public spec.
*/
+2 -2
View File
@@ -63,8 +63,8 @@ struct iommu {
int iommu_setup(void);
int iommu_supports_eim(void);
int iommu_enable_IR(void);
void iommu_disable_IR(void);
int iommu_enable_x2apic_IR(void);
void iommu_disable_x2apic_IR(void);
int iommu_add_device(struct pci_dev *pdev);
int iommu_remove_device(struct pci_dev *pdev);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.