|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V2] x86/AMD-Vi: Add additional check for invalid special->handle
From: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
This patch add an additional logic to check for the often case when the
special->handle is not initialized due to firmware bugs.
but the special->usedid is correct. If users overide this using the
command line option ivrs_ioapic, then it should use the value instead.
---
This patch is supposed to follow the patches:
[Xen-devel] [PATCH RFC 2/2] AMD IOMMU: allow command line overrides for broken
IVRS tables
Changes in V2:
- Fix logic to match the special->used_id with the value provided by
users.
xen/drivers/passthrough/amd/iommu_acpi.c | 55 ++++++++++++++++++++----------
1 file changed, 37 insertions(+), 18 deletions(-)
diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c
b/xen/drivers/passthrough/amd/iommu_acpi.c
index 89b359c..8b14112 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -698,14 +698,16 @@ static u16 __init parse_ivhd_device_special(
return 0;
}
- AMD_IOMMU_DEBUG("IVHD Special: %04x:%02x:%02x.%u variety %#x handle %#x\n",
+ AMD_IOMMU_DEBUG("IVHD Special: %04x:%02x:%02x.%u variety %#x handle %#x
used_id %#x\n",
seg, PCI_BUS(bdf), PCI_SLOT(bdf), PCI_FUNC(bdf),
- special->variety, special->handle);
+ special->variety, special->handle, special->used_id);
add_ivrs_mapping_entry(bdf, bdf, special->header.data_setting, iommu);
switch ( special->variety )
{
case ACPI_IVHD_IOAPIC:
+ {
+ unsigned int apic_id = 0;
if ( !iommu_intremap )
break;
/*
@@ -715,29 +717,45 @@ static u16 __init parse_ivhd_device_special(
*/
for ( apic = 0; apic < nr_ioapics; apic++ )
{
- if ( IO_APIC_ID(apic) != special->handle )
- continue;
+ apic_id = special->handle;
- if ( special->handle >= ARRAY_SIZE(ioapic_sbdf) )
+ if ( IO_APIC_ID(apic) != apic_id )
+ {
+ /* Some BIOSes have invalid value in the special->handle,
+ * but the special->used_id is correct. Here we check to see
if
+ * the user is overiding the special->handle from commandline
+ */
+ if ( (ioapic_sbdf[IO_APIC_ID(apic)].bdf == special->used_id) &&
+ (test_bit(IO_APIC_ID(apic), ioapic_cmdline)) )
+ {
+ apic_id = IO_APIC_ID(apic);
+ AMD_IOMMU_DEBUG ("IVHD Special: Usinging command override "
+ "value for IO-APIC %#x, bdf=%#x\n",
+ apic_id, ioapic_sbdf[apic_id].bdf);
+ }
+ else
+ continue;
+ }
+
+ if ( apic_id >= ARRAY_SIZE(ioapic_sbdf) )
{
printk(XENLOG_ERR "IVHD Error: IO-APIC %#x entry beyond
bounds\n",
- special->handle);
+ apic_id);
return 0;
}
- if ( test_bit(special->handle, ioapic_cmdline) )
- AMD_IOMMU_DEBUG("IVHD: Command line override present for
IO-APIC %#x\n",
- special->handle);
- else if ( ioapic_sbdf[special->handle].pin_2_idx )
+ if ( test_bit(apic_id, ioapic_cmdline) )
+ break;
+ else if ( ioapic_sbdf[apic_id].pin_2_idx )
{
- if ( ioapic_sbdf[special->handle].bdf == bdf &&
- ioapic_sbdf[special->handle].seg == seg )
+ if ( ioapic_sbdf[apic_id].bdf == bdf &&
+ ioapic_sbdf[apic_id].seg == seg )
AMD_IOMMU_DEBUG("IVHD Warning: Duplicate IO-APIC %#x
entries\n",
- special->handle);
+ apic_id);
else
{
printk(XENLOG_ERR "IVHD Error: Conflicting IO-APIC %#x
entries\n",
- special->handle);
+ apic_id);
if ( amd_iommu_perdev_intremap )
return 0;
}
@@ -745,10 +763,10 @@ static u16 __init parse_ivhd_device_special(
else
{
/* set device id of ioapic */
- ioapic_sbdf[special->handle].bdf = bdf;
- ioapic_sbdf[special->handle].seg = seg;
+ ioapic_sbdf[apic_id].bdf = bdf;
+ ioapic_sbdf[apic_id].seg = seg;
- ioapic_sbdf[special->handle].pin_2_idx = xmalloc_array(
+ ioapic_sbdf[apic_id].pin_2_idx = xmalloc_array(
u16, nr_ioapic_entries[apic]);
if ( nr_ioapic_entries[apic] &&
!ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
@@ -765,10 +783,11 @@ static u16 __init parse_ivhd_device_special(
if ( apic == nr_ioapics )
{
printk(XENLOG_ERR "IVHD Error: Invalid IO-APIC %#x\n",
- special->handle);
+ apic_id);
return 0;
}
break;
+ }
case ACPI_IVHD_HPET:
/* set device id of hpet */
if ( hpet_sbdf.iommu ||
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |