Skip to contentSkip to conversation

VTD: Remove the check for reserved device scope type

PATCH Superseded Yang Zhang 4 participants 7 messages Apr 16, 2013 – Aug 15, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yang Zhang

author
#0 lore raw

PATCH 1/1 VTD: Remove the check for reserved device scope type

From: Yang Zhang <[email protected]>

Though we only have four valid types now, the new type may be added in future. It's better to remove the check and only deal with the type that we can recognize.

---
 xen/drivers/passthrough/vtd/dmar.c |    7 +++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 5 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/dmar.c +5 -2
index 370d5d6..eda04a3 100644
@@ -283,8 +283,7 @@ static int __init scope_device_count(const void *start, const void *end)
     while ( start < end )
     {
         scope = start;
-        if ( (scope->length < MIN_SCOPE_LEN) ||
-             (scope->entry_type >= ACPI_DMAR_SCOPE_TYPE_RESERVED) )
+        if ( scope->length < MIN_SCOPE_LEN )
         {
             dprintk(XENLOG_WARNING VTDPREFIX, "Invalid device scope.\n");
             return -EINVAL;
@@ -409,6 +408,10 @@ static int __init acpi_parse_dev_scope(
             }
 
             break;
+
+        default:
+            start += acpi_scope->length;
+            continue;
         }
         scope->devices[didx++] = PCI_BDF(bus, path->dev, path->fn);
         start += acpi_scope->length;
xen/include/acpi/actbl2.h +0 -1
index a28226a..87bc6b3 100644
@@ -303,7 +303,6 @@ enum acpi_dmar_scope_type {
 	ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2,
 	ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3,
 	ACPI_DMAR_SCOPE_TYPE_HPET = 4,
-	ACPI_DMAR_SCOPE_TYPE_RESERVED = 5	/* 5 and greater are reserved */
 };
 
 struct acpi_dmar_pci_path {
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Yang Zhang

From: Yang Zhang <[email protected]>

Though we only have four valid types now, the new type may be added in future. It's better to remove the check and only deal with the type that we can recognize.

Quoted 44 lines
---
 xen/drivers/passthrough/vtd/dmar.c |    7 +++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 5 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/dmar.c +1 -2
index 370d5d6..eda04a3 100644
@@ -283,8 +283,7 @@ static int __init scope_device_count(const void *start,
 const void *end)
     while ( start < end )
     {
         scope = start;
-        if ( (scope->length < MIN_SCOPE_LEN) ||
-             (scope->entry_type >= ACPI_DMAR_SCOPE_TYPE_RESERVED) )
+        if ( scope->length < MIN_SCOPE_LEN )
         {
             dprintk(XENLOG_WARNING VTDPREFIX, "Invalid device scope.\n");
             return -EINVAL;
xen/drivers/passthrough/vtd/dmar.c +4 -0
@@ -409,6 +408,10 @@ static int __init acpi_parse_dev_scope(
             }
 
             break;
+
+        default:
+            start += acpi_scope->length;
+            continue;
         }
         scope->devices[didx++] = PCI_BDF(bus, path->dev, path->fn);
         start += acpi_scope->length;
xen/include/acpi/actbl2.h +0 -1
index a28226a..87bc6b3 100644
@@ -303,7 +303,6 @@ enum acpi_dmar_scope_type {
 ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2,
 ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3,
 ACPI_DMAR_SCOPE_TYPE_HPET = 4,
- ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */
 };
 
 struct acpi_dmar_pci_path {
#2 lore raw
In reply to Yang Zhang
Quoted 28 lines · Yang Zhang

From: Yang Zhang <[email protected]>

Though we only have four valid types now, the new type may be added in future. It's better to remove the check and only deal with the type that we can recognize.

---
 xen/drivers/passthrough/vtd/dmar.c |    7 +++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 5 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/dmar.c +1 -2
index 370d5d6..eda04a3 100644
@@ -283,8 +283,7 @@ static int __init scope_device_count(const void *start, const void *end)
     while ( start < end )
     {
         scope = start;
-        if ( (scope->length < MIN_SCOPE_LEN) ||
-             (scope->entry_type >= ACPI_DMAR_SCOPE_TYPE_RESERVED) )
+        if ( scope->length < MIN_SCOPE_LEN )
         {
             dprintk(XENLOG_WARNING VTDPREFIX, "Invalid device scope.\n");
             return -EINVAL;

xen/drivers/passthrough/vtd/dmar.c static int __init acpi_parse_dev_scope( · line 412

Quoted 5 lines
xen/drivers/passthrough/vtd/dmar.c +2 -0
@@ -409,6 +408,10 @@ static int __init acpi_parse_dev_scope(
             }
 
             break;
+
+        default:

Worth a log message? At least if iommu_verbose?

Quoted 17 lines
xen/drivers/passthrough/vtd/dmar.c +2 -0
+            start += acpi_scope->length;
+            continue;
         }
         scope->devices[didx++] = PCI_BDF(bus, path->dev, path->fn);
         start += acpi_scope->length;
xen/include/acpi/actbl2.h +0 -1
index a28226a..87bc6b3 100644
@@ -303,7 +303,6 @@ enum acpi_dmar_scope_type {
 	ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2,
 	ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3,
 	ACPI_DMAR_SCOPE_TYPE_HPET = 4,
-	ACPI_DMAR_SCOPE_TYPE_RESERVED = 5	/* 5 and greater are reserved */
 };
 
 struct acpi_dmar_pci_path {
#3 lore raw

Ian Campbell wrote on 2013-04-16:

Quoted 30 lines · Yang Zhang
Quoted 12 lines

From: Yang Zhang <[email protected]>

Though we only have four valid types now, the new type may be added in future. It's better to remove the check and only deal with the type that we can recognize.

---
 xen/drivers/passthrough/vtd/dmar.c |    7 +++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 5 insertions(+), 3 deletions(-)
Quoted 5 lines
(quoted diff) +0 -0

b/xen/drivers/passthrough/vtd/dmar.c index 370d5d6..eda04a3 100644 --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -283,8 +283,7 @@ static int __init scope_device_count(const void *start,

const void *end)

Quoted 11 lines
     while ( start < end )
     {
         scope = start;
-        if ( (scope->length < MIN_SCOPE_LEN) || -            
(scope->entry_type >= ACPI_DMAR_SCOPE_TYPE_RESERVED) ) +        if (
scope->length < MIN_SCOPE_LEN )
         {
             dprintk(XENLOG_WARNING VTDPREFIX, "Invalid device
             scope.\n"); return -EINVAL; @@ -409,6 +408,10 @@ static
             int __init acpi_parse_dev_scope( }
Quoted 5 lines

xen/drivers/passthrough/vtd/dmar.c static int __init acpi_parse_dev_scope( · line 412

Quoted 3 lines
             break;
xen/drivers/passthrough/vtd/dmar.c +2 -0
+
+        default:

Worth a log message? At least if iommu_verbose?

Sure.

Quoted 20 lines
Quoted 11 lines
xen/drivers/passthrough/vtd/dmar.c +2 -0
+            start += acpi_scope->length;
+            continue;
         }
         scope->devices[didx++] = PCI_BDF(bus, path->dev, path->fn);
         start += acpi_scope->length;
xen/include/acpi/actbl2.h +0 -0
index a28226a..87bc6b3 100644

xen/include/acpi/actbl2.h enum acpi_dmar_scope_type { · line 306

Quoted 4 lines
xen/include/acpi/actbl2.h +0 -1
@@ -303,7 +303,6 @@ enum acpi_dmar_scope_type {
 	ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2,
 	ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3,
 	ACPI_DMAR_SCOPE_TYPE_HPET = 4,
-	ACPI_DMAR_SCOPE_TYPE_RESERVED = 5	/* 5 and greater are reserved

*/

Quoted 3 lines
xen/include/acpi/actbl2.h +0 -0
 };
 
 struct acpi_dmar_pci_path {

Best regards,
Yang

#4 lore raw
In reply to Yang Zhang

Zhang, Yang Z wrote on 2013-04-16:

Quoted 48 lines

From: Yang Zhang <[email protected]>

Though we only have four valid types now, the new type may be added in future. It's better to remove the check and only deal with the type that we can recognize.

---
 xen/drivers/passthrough/vtd/dmar.c |    7 +++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 5 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/xen/drivers/passthrough/vtd/dmar.c index 370d5d6..eda04a3 100644 --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -283,8 +283,7 @@ static int __init scope_device_count(const void *start, const void *end)

     while ( start < end )
     {
         scope = start;
(quoted diff) +0 -2
-        if ( (scope->length < MIN_SCOPE_LEN) ||
-             (scope->entry_type >=

ACPI_DMAR_SCOPE_TYPE_RESERVED) )

xen/drivers/passthrough/vtd/dmar.c +5 -0
+        if ( scope->length < MIN_SCOPE_LEN )
         {
             dprintk(XENLOG_WARNING VTDPREFIX, "Invalid device
             scope.\n"); return -EINVAL; @@ -409,6 +408,10 @@ static int
             __init acpi_parse_dev_scope( }
 
             break;
+
+        default:
+            start += acpi_scope->length;
+            continue;
         }
         scope->devices[didx++] = PCI_BDF(bus, path->dev, path->fn);
         start += acpi_scope->length;
xen/include/acpi/actbl2.h index renamed from xen/include/acpi/actbl2.h +0 -0

a28226a..87bc6b3 100644 --- a/xen/include/acpi/actbl2.h +++ b/xen/include/acpi/actbl2.h @@ -303,7 +303,6 @@ enum acpi_dmar_scope_type {

xen/include/acpi/actbl2.h index renamed from xen/include/acpi/actbl2.h +0 -1
 	ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2,
 	ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3,
 	ACPI_DMAR_SCOPE_TYPE_HPET = 4,
-	ACPI_DMAR_SCOPE_TYPE_RESERVED = 5	/* 5 and greater are reserved

*/
};

Quoted 1 line

struct acpi_dmar_pci_path {

Please help to back port this patch to Xen 4.2 and Xen 4.1. Currently , we found the old Xen cannot use VT-d in some special platform without this patch. Thanks.

Best regards,
Yang

#5 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Yang Z

Please help to back port this patch to Xen 4.2 and Xen 4.1. Currently , we found the old Xen cannot use VT-d in some special platform without this patch.

Done for 4.2; the patch doesn't apply as-is to 4.1, so please provide a backported version if you think it really is relevant for this soon to be closed tree (and depending on timing, we may close the tree before that backport becomes ready for it).

Jan

#6 lore raw

Jan Beulich wrote on 2013-08-15:

Quoted 11 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Yang Z

Please help to back port this patch to Xen 4.2 and Xen 4.1. Currently , we found the old Xen cannot use VT-d in some special platform without this

patch.

Done for 4.2; the patch doesn't apply as-is to 4.1, so please provide a backported version if you think it really is relevant for this soon to be closed tree (and depending on timing, we may close the tree before that backport becomes ready for it).
Jan

Thanks. It's not so urgent. I will send out a 4.1 compatible patch later.

Best regards,
Yang