diff mbox

[1/4] dmi: dmicheck: check pci(e) slot and segment, bus and dev/func

Message ID 1494554782-20436-1-git-send-email-alex.hung@canonical.com
State Accepted
Headers show

Commit Message

Alex Hung May 12, 2017, 2:06 a.m. UTC
Slot types in type 9 other than PCI, AGP, PCI-X, or PCI-Express
should have segment, bus and dev/func to set to 0xff.

Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/dmi/dmicheck/dmicheck.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Colin Ian King May 12, 2017, 12:56 p.m. UTC | #1
On 12/05/17 03:06, Alex Hung wrote:
> Slot types in type 9 other than PCI, AGP, PCI-X, or PCI-Express
> should have segment, bus and dev/func to set to 0xff.
> 
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/dmi/dmicheck/dmicheck.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
> index e8e8f13..5a09ea4 100644
> --- a/src/dmi/dmicheck/dmicheck.c
> +++ b/src/dmi/dmicheck/dmicheck.c
> @@ -1304,6 +1304,31 @@ static void dmicheck_entry(fwts_framework *fw,
>  					"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
>  					data[0xc],
>  					table, addr, "Slot Characteristics 2", 0xc);
> +			if (hdr->length < 0x11)
> +				break;
> +			if (!((data[0x5] == 0x06) ||
> +			      ((data[0x5] >= 0x0e) && (data[0x5] <= 0x23)) ||
> +			      ((data[0x5] >= 0xa0) && (data[0x5] <= 0xb6)))) {
> +				if (GET_UINT16(data + 0xd) != 0xffff)
> +					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
> +						"Invalid value 0x%4.4" PRIx16 " was used and 0xffff"
> +						"should be used for non-PCI(e) while accessing entry '%s' @ "
> +						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
> +						GET_UINT16(data + 0x0d), table, addr, "Segment Group Number", 0xd);
> +				if (data[0xf] != 0xff)
> +					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
> +						"Invalid value 0x%2.2" PRIx8 " was used and 0xff"
> +						"should be used for non-PCI(e) while accessing entry '%s' @ "
> +						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
> +						data[0xf], table, addr, "Bus Number", 0xf);
> +				if (data[0x10] != 0xff)
> +					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
> +						"Invalid value 0x%2.2" PRIx8 " was used and 0xff"
> +						"should be used for non-PCI(e) while accessing entry '%s' @ "
> +						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
> +						data[0x10], table, addr, "Device/Function Number", 0x10);
> +			}
> +
>  			break;
>  
>  		case 10: /* 7.11 (Type 10 is obsolete) */
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Ivan Hu May 23, 2017, 7:42 a.m. UTC | #2
On 05/12/2017 10:06 AM, Alex Hung wrote:
> Slot types in type 9 other than PCI, AGP, PCI-X, or PCI-Express
> should have segment, bus and dev/func to set to 0xff.
>
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>   src/dmi/dmicheck/dmicheck.c | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
>
> diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
> index e8e8f13..5a09ea4 100644
> --- a/src/dmi/dmicheck/dmicheck.c
> +++ b/src/dmi/dmicheck/dmicheck.c
> @@ -1304,6 +1304,31 @@ static void dmicheck_entry(fwts_framework *fw,
>   					"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
>   					data[0xc],
>   					table, addr, "Slot Characteristics 2", 0xc);
> +			if (hdr->length < 0x11)
> +				break;
> +			if (!((data[0x5] == 0x06) ||
> +			      ((data[0x5] >= 0x0e) && (data[0x5] <= 0x23)) ||
> +			      ((data[0x5] >= 0xa0) && (data[0x5] <= 0xb6)))) {
> +				if (GET_UINT16(data + 0xd) != 0xffff)
> +					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
> +						"Invalid value 0x%4.4" PRIx16 " was used and 0xffff"
> +						"should be used for non-PCI(e) while accessing entry '%s' @ "
> +						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
> +						GET_UINT16(data + 0x0d), table, addr, "Segment Group Number", 0xd);
> +				if (data[0xf] != 0xff)
> +					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
> +						"Invalid value 0x%2.2" PRIx8 " was used and 0xff"
> +						"should be used for non-PCI(e) while accessing entry '%s' @ "
> +						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
> +						data[0xf], table, addr, "Bus Number", 0xf);
> +				if (data[0x10] != 0xff)
> +					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
> +						"Invalid value 0x%2.2" PRIx8 " was used and 0xff"
> +						"should be used for non-PCI(e) while accessing entry '%s' @ "
> +						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
> +						data[0x10], table, addr, "Device/Function Number", 0x10);
> +			}
> +
>   			break;
>   
>   		case 10: /* 7.11 (Type 10 is obsolete) */


Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
index e8e8f13..5a09ea4 100644
--- a/src/dmi/dmicheck/dmicheck.c
+++ b/src/dmi/dmicheck/dmicheck.c
@@ -1304,6 +1304,31 @@  static void dmicheck_entry(fwts_framework *fw,
 					"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
 					data[0xc],
 					table, addr, "Slot Characteristics 2", 0xc);
+			if (hdr->length < 0x11)
+				break;
+			if (!((data[0x5] == 0x06) ||
+			      ((data[0x5] >= 0x0e) && (data[0x5] <= 0x23)) ||
+			      ((data[0x5] >= 0xa0) && (data[0x5] <= 0xb6)))) {
+				if (GET_UINT16(data + 0xd) != 0xffff)
+					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
+						"Invalid value 0x%4.4" PRIx16 " was used and 0xffff"
+						"should be used for non-PCI(e) while accessing entry '%s' @ "
+						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
+						GET_UINT16(data + 0x0d), table, addr, "Segment Group Number", 0xd);
+				if (data[0xf] != 0xff)
+					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
+						"Invalid value 0x%2.2" PRIx8 " was used and 0xff"
+						"should be used for non-PCI(e) while accessing entry '%s' @ "
+						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
+						data[0xf], table, addr, "Bus Number", 0xf);
+				if (data[0x10] != 0xff)
+					fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_VALUE_OUT_OF_RANGE,
+						"Invalid value 0x%2.2" PRIx8 " was used and 0xff"
+						"should be used for non-PCI(e) while accessing entry '%s' @ "
+						"0x%8.8" PRIx32 ", field '%s', offset 0x%2.2x",
+						data[0x10], table, addr, "Device/Function Number", 0x10);
+			}
+
 			break;
 
 		case 10: /* 7.11 (Type 10 is obsolete) */