Skip to contentSkip to conversation

VTD: Remove the check for reserved device scope type

PATCH In review Yang Zhang 2 participants 3 messages Apr 17, 2013

lore
Share & tools
lore

Yang Zhang

author
#0 lore raw

PATCH v2 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.

---
v1->v2: Add log message for unknown device type.

 xen/drivers/passthrough/vtd/dmar.c |   10 ++++++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 8 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/dmar.c +8 -2
index 370d5d6..1fb43bc 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,13 @@ static int __init acpi_parse_dev_scope(
             }
 
             break;
+
+        default:
+            if ( iommu_verbose )
+                dprintk(VTDPREFIX, " Unknown device type: 0x%x\n",
+                        acpi_scope->entry_type);
+            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
#1 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · 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 4 lines

---
v1->v2: Add log message for unknown device type.

You apparently didn't notice that this got committed already?

Jan

Quoted 48 lines
 xen/drivers/passthrough/vtd/dmar.c |   10 ++++++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 8 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/dmar.c +1 -2
index 370d5d6..1fb43bc 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 +7 -0
@@ -409,6 +408,13 @@ static int __init acpi_parse_dev_scope(
             }
 
             break;
+
+        default:
+            if ( iommu_verbose )
+                dprintk(VTDPREFIX, " Unknown device type: 0x%x\n",
+                        acpi_scope->entry_type);
+            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
#2 lore raw

Jan Beulich wrote on 2013-04-17:

Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line · 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 6 lines
Quoted 4 lines

---
v1->v2: Add log message for unknown device type.

You apparently didn't notice that this got committed already?

Yes, I see it now.

Quoted 36 lines

Jan

Quoted 34 lines
 xen/drivers/passthrough/vtd/dmar.c |   10 ++++++++--
 xen/include/acpi/actbl2.h          |    1 -
 2 files changed, 8 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/dmar.c +0 -1
index 370d5d6..1fb43bc 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,13 @@ static
             int __init acpi_parse_dev_scope( }
             
             break;
xen/drivers/passthrough/vtd/dmar.c +7 -0
+
+        default:
+            if ( iommu_verbose )
+                dprintk(VTDPREFIX, " Unknown device type: 0x%x\n",
+                        acpi_scope->entry_type);
+            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
Quoted 15 lines

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

Quoted 7 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 5 lines
xen/include/acpi/actbl2.h +0 -1
 };
 
 struct acpi_dmar_pci_path {
--

1.7.1

Best regards,
Yang