Skip to contentSkip to conversation

EDD: Check for correct EDD 3.0 length

PATCH In review Hannes Reinecke 2 participants 2 messages May 16, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 EDD: Check for correct EDD 3.0 length

There are two competing EDD 3.0 specifications, the original one from Phoenix
<http://mbldr.sourceforge.net/specsedd30.pdf>
and the T-13 approved one
<http://www.t13.org/documents/UploadedDocuments/docs2004/d1572r3-EDD3.pdf>

They differ in the length of the device_path field, which is one quad word for the Phoenix spec and two quad words for the T-13 spec. So we need to test for both lengths and blank out the second quad word when a Phoenix version is detected.

Cc Gleb Natapov <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Alan Cox <[email protected]>
drivers/firmware/edd.c +13 -2
index e229576..beedf4c 100644
@@ -192,6 +192,13 @@ edd_show_interface(struct edd_device *edev, char *buf)
 			p += scnprintf(p, left, " ");
 		}
 	}
+	/*
+	 * Phoenix EDD 3.0 reserves only one quad word for the
+	 * device path, so blank out the second quad word.
+	 */
+	if (info->params.device_path_info_length == 36)
+		info->params.device_path.unknown.reserved2 = 0;
+
 	if (!strncmp(info->params.interface_type, "ATAPI", 5)) {
 		p += scnprintf(p, left, "\tdevice: %u  lun: %u\n",
 			     info->params.device_path.atapi.device,
@@ -545,8 +552,12 @@ edd_has_edd30(struct edd_device *edev)
 	}
 
 
-	/* We support only T13 spec */
-	if (info->params.device_path_info_length != 44)
+	/*
+	 * Phoenix EDD 3.0 specifies this to be 36,
+	 * T-13 EDD 3.0 uses 44. So check for both.
+	 */
+	if (info->params.device_path_info_length != 36 &&
+	    info->params.device_path_info_length != 44)
 		return 0;
 
 	for (i = 30; i < info->params.device_path_info_length + 30; i++)
#1 lore raw
Quoted 6 lines · Hannes Reinecke

There are two competing EDD 3.0 specifications, the original one from Phoenix
<http://mbldr.sourceforge.net/specsedd30.pdf>
and the T-13 approved one
<http://www.t13.org/documents/UploadedDocuments/docs2004/d1572r3-EDD3.pdf>

Quoted 6 lines

They differ in the length of the device_path field, which is one quad word for the Phoenix spec and two quad words for the T-13 spec. So we need to test for both lengths and blank out the second quad word when a Phoenix version is detected.

Can you please clarify what practical problem are you seeing that you are trying to fix with this patch?

Quoted 10 lines
Cc Gleb Natapov <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Alan Cox <[email protected]>
drivers/firmware/edd.c +0 -0
index e229576..beedf4c 100644

drivers/firmware/edd.c edd_show_interface(struct edd_device *edev, char *buf) · line 201

Quoted 10 lines
drivers/firmware/edd.c +7 -0
@@ -192,6 +192,13 @@ edd_show_interface(struct edd_device *edev, char *buf)
 			p += scnprintf(p, left, " ");
 		}
 	}
+	/*
+	 * Phoenix EDD 3.0 reserves only one quad word for the
+	 * device path, so blank out the second quad word.
+	 */
+	if (info->params.device_path_info_length == 36)
+		info->params.device_path.unknown.reserved2 = 0;
+

You overwrite checksum here. Hope it will not be checked after that point. This will work for all interface types defined by Phoenix spec except SCSI as far as I see. In Phoenix spec SCSI interface is one byte LUN, in T13 it is changed to be: word SCSI ID, qword LUN.

Quoted 8 lines
drivers/firmware/edd.c +0 -1
 	if (!strncmp(info->params.interface_type, "ATAPI", 5)) {
 		p += scnprintf(p, left, "\tdevice: %u  lun: %u\n",
 			     info->params.device_path.atapi.device,
@@ -545,8 +552,12 @@ edd_has_edd30(struct edd_device *edev)
 	}
 
 
-	/* We support only T13 spec */

drivers/firmware/edd.c edd_has_edd30(struct edd_device *edev) · line 563

Quoted 10 lines
drivers/firmware/edd.c +6 -1
-	if (info->params.device_path_info_length != 44)
+	/*
+	 * Phoenix EDD 3.0 specifies this to be 36,
+	 * T-13 EDD 3.0 uses 44. So check for both.
+	 */
+	if (info->params.device_path_info_length != 36 &&
+	    info->params.device_path_info_length != 44)
 		return 0;
 
 	for (i = 30; i < info->params.device_path_info_length + 30; i++)

--
Gleb.