* [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled
@ 2009-10-28 16:31 Wei Wang2
2009-10-28 17:30 ` Keir Fraser
0 siblings, 1 reply; 5+ messages in thread
From: Wei Wang2 @ 2009-10-28 16:31 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 537 bytes --]
This patch moves IVRS table parsing functions into an early position, which
prevent iommu_enabled from being disabled by failure dmar table detection.
Thanks,
Wei
Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
AMD GmbH, Germany
Operating System Research Center
Legal Information:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34
85609 Dornach b. München
Geschäftsführer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht München, HRB Nr. 43632
[-- Attachment #2: fix-ivrs.patch --]
[-- Type: text/x-diff, Size: 4352 bytes --]
diff -r 42e9682e4b61 xen/arch/x86/acpi/boot.c
--- a/xen/arch/x86/acpi/boot.c Mon Oct 26 13:33:38 2009 +0000
+++ b/xen/arch/x86/acpi/boot.c Wed Oct 28 11:58:31 2009 +0100
@@ -936,6 +936,8 @@ int __init acpi_boot_init(void)
acpi_dmar_init();
+ acpi_ivrs_init();
+
acpi_mmcfg_init();
return 0;
diff -r 42e9682e4b61 xen/drivers/passthrough/amd/iommu_acpi.c
--- a/xen/drivers/passthrough/amd/iommu_acpi.c Mon Oct 26 13:33:38 2009 +0000
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c Wed Oct 28 11:58:31 2009 +0100
@@ -863,6 +863,7 @@ static int __init detect_iommu_acpi(stru
return -ENODEV;
}
+ INIT_LIST_HEAD(&amd_iommu_head);
while ( table->length > (length + sizeof(*ivrs_block)) )
{
ivrs_block = (struct acpi_ivrs_block_header *) ((u8 *)table + length);
@@ -972,9 +973,23 @@ static int __init get_last_bdf_acpi(stru
return 0;
}
-int __init amd_iommu_detect_acpi(void)
-{
- return acpi_table_parse(AMD_IOMMU_ACPI_IVRS_SIG, detect_iommu_acpi);
+int __init acpi_ivrs_init(void)
+{
+ int rt;
+
+ /* to make sure this flag has not been cleared after vtd detection */
+ iommu_enabled = 1;
+
+ rt = acpi_table_parse(AMD_IOMMU_ACPI_IVRS_SIG, detect_iommu_acpi);
+
+ if ( (rt != 0) || (iommu_found() == 0) )
+ {
+ printk("AMD-Vi: IOMMU not found!\n");
+ iommu_enabled = 0;
+ return -ENODEV;
+ }
+
+ return 0;
}
int __init amd_iommu_get_ivrs_dev_entries(void)
diff -r 42e9682e4b61 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c Mon Oct 26 13:33:38 2009 +0000
+++ b/xen/drivers/passthrough/amd/iommu_init.c Wed Oct 28 11:58:31 2009 +0100
@@ -628,7 +628,7 @@ error_out:
return -ENODEV;
}
-static void __init amd_iommu_init_cleanup(void)
+void __init amd_iommu_init_cleanup(void)
{
struct amd_iommu *iommu, *next;
int bdf;
@@ -718,7 +718,7 @@ static int __init amd_iommu_setup_device
int sys_mgt, dev_ex, lint1_pass, lint0_pass,
nmi_pass, ext_int_pass, init_pass;
- BUG_ON( (ivrs_bdf_entries == 0) || (iommu_enabled) );
+ BUG_ON( (ivrs_bdf_entries == 0) );
/* allocate 'device table' on a 4K boundary */
device_table.alloc_size = PAGE_SIZE <<
@@ -805,6 +805,7 @@ int __init amd_iommu_init(void)
error_out:
amd_iommu_init_cleanup();
+ printk("AMD-Vi: Error initialization!\n");
return -ENODEV;
}
diff -r 42e9682e4b61 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Oct 26 13:33:38 2009 +0000
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Oct 28 11:58:31 2009 +0100
@@ -158,24 +158,6 @@ static void amd_iommu_setup_dom0_devices
spin_unlock(&pcidevs_lock);
}
-int amd_iov_detect(void)
-{
- INIT_LIST_HEAD(&amd_iommu_head);
-
- if ( (amd_iommu_detect_acpi() !=0) || (iommu_found() == 0) )
- {
- printk("AMD-Vi: IOMMU not found!\n");
- return -ENODEV;
- }
-
- if ( amd_iommu_init() != 0 )
- {
- printk("Error initialization\n");
- return -ENODEV;
- }
- return 0;
-}
-
static int allocate_domain_resources(struct hvm_iommu *hd)
{
/* allocate root table */
diff -r 42e9682e4b61 xen/include/asm-x86/acpi.h
--- a/xen/include/asm-x86/acpi.h Mon Oct 26 13:33:38 2009 +0000
+++ b/xen/include/asm-x86/acpi.h Wed Oct 28 11:58:31 2009 +0100
@@ -154,6 +154,7 @@ extern u8 x86_acpiid_to_apicid[];
#define MAX_LOCAL_APIC 256
int acpi_dmar_init(void);
+int acpi_ivrs_init(void);
void acpi_mmcfg_init(void);
/* Incremented whenever we transition through S3. Value is 1 during boot. */
diff -r 42e9682e4b61 xen/include/asm-x86/hvm/iommu.h
--- a/xen/include/asm-x86/hvm/iommu.h Mon Oct 26 13:33:38 2009 +0000
+++ b/xen/include/asm-x86/hvm/iommu.h Wed Oct 28 11:58:31 2009 +0100
@@ -5,7 +5,7 @@ extern struct iommu_ops intel_iommu_ops;
extern struct iommu_ops intel_iommu_ops;
extern struct iommu_ops amd_iommu_ops;
extern int intel_vtd_setup(void);
-extern int amd_iov_detect(void);
+extern int amd_iommu_init(void);
static inline struct iommu_ops *iommu_get_ops(void)
{
@@ -29,7 +29,7 @@ static inline int iommu_hardware_setup(v
case X86_VENDOR_INTEL:
return intel_vtd_setup();
case X86_VENDOR_AMD:
- return amd_iov_detect();
+ return amd_iommu_init();
default:
BUG();
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled
2009-10-28 16:31 [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled Wei Wang2
@ 2009-10-28 17:30 ` Keir Fraser
2009-10-28 17:46 ` Wei Wang2
0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2009-10-28 17:30 UTC (permalink / raw)
To: Wei Wang2, xen-devel
On 28/10/2009 16:31, "Wei Wang2" <wei.wang2@amd.com> wrote:
> This patch moves IVRS table parsing functions into an early position, which
> prevent iommu_enabled from being disabled by failure dmar table detection.
Not nice. See if c/s 20381 fixes your problem. It's justa cleanup of some
VT-d code which should avoid the problem altogether.
-- Keir
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled
2009-10-28 17:30 ` Keir Fraser
@ 2009-10-28 17:46 ` Wei Wang2
2009-10-28 18:03 ` Keir Fraser
0 siblings, 1 reply; 5+ messages in thread
From: Wei Wang2 @ 2009-10-28 17:46 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
On Wednesday 28 October 2009 18:30:31 Keir Fraser wrote:
> On 28/10/2009 16:31, "Wei Wang2" <wei.wang2@amd.com> wrote:
> > This patch moves IVRS table parsing functions into an early position,
> > which prevent iommu_enabled from being disabled by failure dmar table
> > detection.
>
> Not nice. See if c/s 20381 fixes your problem. It's justa cleanup of some
> VT-d code which should avoid the problem altogether.
>
> -- Keir
Thanks, I have not checked 20381 while creating this patch. I will test it
again and send something new if necessary.
-Wei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled
2009-10-28 17:46 ` Wei Wang2
@ 2009-10-28 18:03 ` Keir Fraser
2009-10-29 13:51 ` Wei Wang2
0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2009-10-28 18:03 UTC (permalink / raw)
To: Wei Wang2; +Cc: xen-devel
On 28/10/2009 17:46, "Wei Wang2" <wei.wang2@amd.com> wrote:
>> Not nice. See if c/s 20381 fixes your problem. It's justa cleanup of some
>> VT-d code which should avoid the problem altogether.
>>
>> -- Keir
>
> Thanks, I have not checked 20381 while creating this patch.
That's because I created it in response to your patch! :-)
K.
> I will test it again and send something new if necessary.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled
2009-10-28 18:03 ` Keir Fraser
@ 2009-10-29 13:51 ` Wei Wang2
0 siblings, 0 replies; 5+ messages in thread
From: Wei Wang2 @ 2009-10-29 13:51 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
[-- Attachment #1: Type: text/plain, Size: 970 bytes --]
On Wednesday 28 October 2009 19:03:17 Keir Fraser wrote:
> On 28/10/2009 17:46, "Wei Wang2" <wei.wang2@amd.com> wrote:
> >> Not nice. See if c/s 20381 fixes your problem. It's justa cleanup of
> >> some VT-d code which should avoid the problem altogether.
> >>
> >> -- Keir
> >
> > Thanks, I have not checked 20381 while creating this patch.
>
> That's because I created it in response to your patch! :-)
>
> K.
>
> > I will test it again and send something new if necessary.
Keir,
Attached patch removes a BUG_ON condition, to boot amd iommu system correctly.
Thanks,
Wei
Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
AMD GmbH, Germany
Operating System Research Center
Legal Information:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34
85609 Dornach b. München
Geschäftsführer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht München, HRB Nr. 43632
[-- Attachment #2: fix-bug-on.patch --]
[-- Type: text/x-diff, Size: 571 bytes --]
diff -r c1f2b68b6dca xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c Wed Oct 28 17:27:47 2009 +0000
+++ b/xen/drivers/passthrough/amd/iommu_init.c Thu Oct 29 12:46:00 2009 +0100
@@ -719,7 +719,7 @@ static int __init amd_iommu_setup_device
int sys_mgt, dev_ex, lint1_pass, lint0_pass,
nmi_pass, ext_int_pass, init_pass;
- BUG_ON( (ivrs_bdf_entries == 0) || (iommu_enabled) );
+ BUG_ON( (ivrs_bdf_entries == 0) );
/* allocate 'device table' on a 4K boundary */
device_table.alloc_size = PAGE_SIZE <<
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-10-29 13:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-28 16:31 [PATCH] AMD IOMMU: Parse IVRS table early to prevent iommu_enabled from being disabled Wei Wang2
2009-10-28 17:30 ` Keir Fraser
2009-10-28 17:46 ` Wei Wang2
2009-10-28 18:03 ` Keir Fraser
2009-10-29 13:51 ` Wei Wang2
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.