From: <suravee.suthikulpanit@amd.com>
To: JBeulich@suse.com
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
xen-devel@lists.xen.org
Subject: [PATCH 1/1 V3] x86/AMD-Vi: Add additional check for invalid special->handle
Date: Thu, 12 Sep 2013 12:00:40 -0500 [thread overview]
Message-ID: <1379005240-4857-1-git-send-email-suravee.suthikulpanit@amd.com> (raw)
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
This patch handle additional cases for IVRS bugs where special->handle
is not correctly initialized for IOAPIC and HPETS due to firmware bugs.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Provide logic in "is_ioapic_overidden()"
Signed-off-by: Jan Beulich <JBeulich@suse.com>
---
Changes from V2:
- Add logic from Jan
- Also invalid handle for HPET
- Clean up old logics
xen/drivers/passthrough/amd/iommu_acpi.c | 60 +++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 89b359c..0e63e35 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -664,19 +664,46 @@ static void __init parse_ivrs_hpet(char *str)
ASSERT(*s == '[');
id = simple_strtoul(s + 1, &s, 0);
- if ( id != (typeof(hpet_sbdf.id))id || *s != ']' || *++s != '=' )
+ if ( (*s != ']') || (*++s != '=') )
return;
s = parse_pci(s + 1, &seg, &bus, &dev, &func);
if ( !s || *s )
return;
+ hpet_sbdf.id = id;
hpet_sbdf.bdf = PCI_BDF(bus, dev, func);
hpet_sbdf.seg = seg;
hpet_sbdf.cmdline = 1;
}
custom_param("ivrs_hpet[", parse_ivrs_hpet);
+static bool_t is_ioapic_overidden(u16 seg, u16 bdf, u8 handle)
+{
+ bool_t ret = 0;
+ int apic = find_first_bit(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+
+ while ( apic < ARRAY_SIZE(ioapic_sbdf) )
+ {
+ if ( ioapic_sbdf[apic].bdf == bdf &&
+ ioapic_sbdf[apic].seg == seg )
+ break;
+ apic = find_next_bit(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf),
+ apic + 1);
+ }
+
+ if ( apic < ARRAY_SIZE(ioapic_sbdf) )
+ {
+ AMD_IOMMU_DEBUG("IVHD: Command line override present for IO-APIC %#x "
+ "(IVRS: %#x devID %04x:%02x:%02x.%u)\n",
+ apic, handle, seg, PCI_BUS(bdf),
+ PCI_SLOT(bdf), PCI_FUNC(bdf));
+ ret = 1;
+ }
+
+ return ret;
+}
+
static u16 __init parse_ivhd_device_special(
const struct acpi_ivrs_device8c *special, u16 seg,
u16 header_length, u16 block_length, struct amd_iommu *iommu)
@@ -698,16 +725,18 @@ 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:
- if ( !iommu_intremap )
+ if ( !iommu_intremap ||
+ is_ioapic_overidden(seg, bdf, special->handle) )
break;
+
/*
* Some BIOSes have IOAPIC broken entries so we check for IVRS
* consistency here --- whether entry's IOAPIC ID is valid and
@@ -725,10 +754,7 @@ static u16 __init parse_ivhd_device_special(
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 ( ioapic_sbdf[special->handle].pin_2_idx )
{
if ( ioapic_sbdf[special->handle].bdf == bdf &&
ioapic_sbdf[special->handle].seg == seg )
@@ -770,6 +796,16 @@ static u16 __init parse_ivhd_device_special(
}
break;
case ACPI_IVHD_HPET:
+ if ( hpet_sbdf.cmdline )
+ {
+ AMD_IOMMU_DEBUG("IVHD: Command line override present for HPET %#x "
+ "(IVRS: %#x devID %04x:%02x:%02x.%u)\n",
+ hpet_sbdf.id, special->handle, seg, PCI_BUS(bdf),
+ PCI_SLOT(bdf), PCI_FUNC(bdf));
+ hpet_sbdf.iommu = iommu;
+ break;
+ }
+
/* set device id of hpet */
if ( hpet_sbdf.iommu ||
(hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) )
@@ -777,12 +813,10 @@ static u16 __init parse_ivhd_device_special(
printk(XENLOG_WARNING "Only one IVHD HPET entry is supported\n");
break;
}
+
hpet_sbdf.id = special->handle;
- if ( !hpet_sbdf.cmdline )
- {
- hpet_sbdf.bdf = bdf;
- hpet_sbdf.seg = seg;
- }
+ hpet_sbdf.bdf = bdf;
+ hpet_sbdf.seg = seg;
hpet_sbdf.iommu = iommu;
break;
default:
--
1.8.1.2
next reply other threads:[~2013-09-12 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 17:00 suravee.suthikulpanit [this message]
2013-09-13 9:24 ` [PATCH 1/1 V3] x86/AMD-Vi: Add additional check for invalid special->handle Jan Beulich
2013-09-13 22:48 ` Suravee Suthikulpanit
2013-09-13 23:31 ` Suravee Suthikulpanit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379005240-4857-1-git-send-email-suravee.suthikulpanit@amd.com \
--to=suravee.suthikulpanit@amd.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).