public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/2] BaseTools: Fix bug when converting iSCSI node
@ 2018-03-03  7:35 Yonghong Zhu
  2018-03-03  7:35 ` [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array Yonghong Zhu
  2018-03-03  7:38 ` [Patch 1/2] BaseTools: Fix bug when converting iSCSI node Gao, Liming
  0 siblings, 2 replies; 4+ messages in thread
From: Yonghong Zhu @ 2018-03-03  7:35 UTC (permalink / raw)
  To: edk2-devel

If protocol string is not specified, default TCP(0) should be used.
Today's implementation wrongly sets to 1 for this case.
Copy the fix solution from MdePkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/DevicePath/DevicePathFromText.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
index 776cf05..06482ae 100644
--- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c
+++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
@@ -2424,11 +2424,11 @@ DevPathFromTextiSCSI (
     Options |= 0x1000;
   }
 
   ISCSIDevPath->LoginOption      = (UINT16) Options;
 
-  if (StrCmp (ProtocolStr, L"TCP") == 0) {
+  if (IS_NULL (*ProtocolStr) || (StrCmp (ProtocolStr, L"TCP") == 0)) {
     ISCSIDevPath->NetworkProtocol = 0;
   } else {
     //
     // Undefined and reserved.
     //
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array
  2018-03-03  7:35 [Patch 1/2] BaseTools: Fix bug when converting iSCSI node Yonghong Zhu
@ 2018-03-03  7:35 ` Yonghong Zhu
  2018-03-03  7:47   ` Ni, Ruiyu
  2018-03-03  7:38 ` [Patch 1/2] BaseTools: Fix bug when converting iSCSI node Gao, Liming
  1 sibling, 1 reply; 4+ messages in thread
From: Yonghong Zhu @ 2018-03-03  7:35 UTC (permalink / raw)
  To: edk2-devel

Per UEFI spec, FibreEx.WWN, FibreEx.Lun, SasEx.Address, SasEx.Lun
and iSCSI.Lun are all 8-byte array with byte #0 in the left.
It means "0102030405060708" should be converted to:
    UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08}
or  UINT64 = {0807060504030201}

Today's implementation wrongly uses the reversed order.
The patch fixes this issue by using StrHexToBytes().
Copy this solution from MdePkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/DevicePath/DevicePathFromText.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
index 776cf05..f2c0b3c 100644
--- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c
+++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
@@ -2385,10 +2385,11 @@ DevPathFromTextiSCSI (
   CHAR16                      *DataDigestStr;
   CHAR16                      *AuthenticationStr;
   CHAR16                      *ProtocolStr;
   CHAR8                       *AsciiStr;
   ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
+  UINT64                      Lun;
 
   NameStr           = GetNextParamStr (&TextDeviceNode);
   PortalGroupStr    = GetNextParamStr (&TextDeviceNode);
   LunStr            = GetNextParamStr (&TextDeviceNode);
   HeaderDigestStr   = GetNextParamStr (&TextDeviceNode);
@@ -2403,11 +2404,12 @@ DevPathFromTextiSCSI (
 
   AsciiStr = ISCSIDevPath->TargetName;
   StrToAscii (NameStr, &AsciiStr);
 
   ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);
-  Strtoi64 (LunStr, &ISCSIDevPath->Lun);
+  Strtoi64 (LunStr, &Lun);
+  WriteUnaligned64 ((UINT64 *) &ISCSIDevPath->Lun, SwapBytes64 (Lun));
 
   Options = 0x0000;
   if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {
     Options |= 0x0002;
   }
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Patch 1/2] BaseTools: Fix bug when converting iSCSI node
  2018-03-03  7:35 [Patch 1/2] BaseTools: Fix bug when converting iSCSI node Yonghong Zhu
  2018-03-03  7:35 ` [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array Yonghong Zhu
@ 2018-03-03  7:38 ` Gao, Liming
  1 sibling, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-03-03  7:38 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

Please update commit message with MdePkg Fix hash value.

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
> Sent: Saturday, March 3, 2018 3:36 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch 1/2] BaseTools: Fix bug when converting iSCSI node
> 
> If protocol string is not specified, default TCP(0) should be used.
> Today's implementation wrongly sets to 1 for this case.
> Copy the fix solution from MdePkg.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>  BaseTools/Source/C/DevicePath/DevicePathFromText.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> index 776cf05..06482ae 100644
> --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> @@ -2424,11 +2424,11 @@ DevPathFromTextiSCSI (
>      Options |= 0x1000;
>    }
> 
>    ISCSIDevPath->LoginOption      = (UINT16) Options;
> 
> -  if (StrCmp (ProtocolStr, L"TCP") == 0) {
> +  if (IS_NULL (*ProtocolStr) || (StrCmp (ProtocolStr, L"TCP") == 0)) {
>      ISCSIDevPath->NetworkProtocol = 0;
>    } else {
>      //
>      // Undefined and reserved.
>      //
> --
> 2.6.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array
  2018-03-03  7:35 ` [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array Yonghong Zhu
@ 2018-03-03  7:47   ` Ni, Ruiyu
  0 siblings, 0 replies; 4+ messages in thread
From: Ni, Ruiyu @ 2018-03-03  7:47 UTC (permalink / raw)
  To: edk2-devel

On 3/3/2018 3:35 PM, Yonghong Zhu wrote:
> Per UEFI spec, FibreEx.WWN, FibreEx.Lun, SasEx.Address, SasEx.Lun
The commit message is wrong.

> and iSCSI.Lun are all 8-byte array with byte #0 in the left.
> It means "0102030405060708" should be converted to:
>      UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08}
> or  UINT64 = {0807060504030201}
> 
> Today's implementation wrongly uses the reversed order.
> The patch fixes this issue by using StrHexToBytes().
> Copy this solution from MdePkg.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>   BaseTools/Source/C/DevicePath/DevicePathFromText.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> index 776cf05..f2c0b3c 100644
> --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> @@ -2385,10 +2385,11 @@ DevPathFromTextiSCSI (
>     CHAR16                      *DataDigestStr;
>     CHAR16                      *AuthenticationStr;
>     CHAR16                      *ProtocolStr;
>     CHAR8                       *AsciiStr;
>     ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
> +  UINT64                      Lun;
>   
>     NameStr           = GetNextParamStr (&TextDeviceNode);
>     PortalGroupStr    = GetNextParamStr (&TextDeviceNode);
>     LunStr            = GetNextParamStr (&TextDeviceNode);
>     HeaderDigestStr   = GetNextParamStr (&TextDeviceNode);
> @@ -2403,11 +2404,12 @@ DevPathFromTextiSCSI (
>   
>     AsciiStr = ISCSIDevPath->TargetName;
>     StrToAscii (NameStr, &AsciiStr);
>   
>     ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);
> -  Strtoi64 (LunStr, &ISCSIDevPath->Lun);
> +  Strtoi64 (LunStr, &Lun);
> +  WriteUnaligned64 ((UINT64 *) &ISCSIDevPath->Lun, SwapBytes64 (Lun));
>   
>     Options = 0x0000;
>     if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {
>       Options |= 0x0002;
>     }
> 


-- 
Thanks,
Ray


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-03  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-03  7:35 [Patch 1/2] BaseTools: Fix bug when converting iSCSI node Yonghong Zhu
2018-03-03  7:35 ` [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array Yonghong Zhu
2018-03-03  7:47   ` Ni, Ruiyu
2018-03-03  7:38 ` [Patch 1/2] BaseTools: Fix bug when converting iSCSI node Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox