* [PATCH v2] MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun
@ 2018-03-03 5:10 Ruiyu Ni
2018-03-03 5:20 ` Gao, Liming
0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-03-03 5:10 UTC (permalink / raw)
To: edk2-devel; +Cc: Jie Lin, Liming Gao, Yonghong Zhu
Per UEFI spec, iSCSI.Lun is a 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.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jie Lin <jie.lin@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
---
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index c66b77ba6c..35a73e83ff 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2542,6 +2542,7 @@ DevPathFromTextiSCSI (
CHAR16 *ProtocolStr;
CHAR8 *AsciiStr;
ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
+ UINT64 Lun;
NameStr = GetNextParamStr (&TextDeviceNode);
PortalGroupStr = GetNextParamStr (&TextDeviceNode);
@@ -2560,7 +2561,8 @@ DevPathFromTextiSCSI (
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) {
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun
2018-03-03 5:10 [PATCH v2] MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun Ruiyu Ni
@ 2018-03-03 5:20 ` Gao, Liming
0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-03-03 5:20 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Lin, Jie, Zhu, Yonghong
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Saturday, March 3, 2018 1:11 PM
> To: edk2-devel@lists.01.org
> Cc: Lin, Jie <jie.lin@intel.com>; Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> Subject: [PATCH v2] MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun
>
> Per UEFI spec, iSCSI.Lun is a 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.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jie Lin <jie.lin@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
> MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> index c66b77ba6c..35a73e83ff 100644
> --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> @@ -2542,6 +2542,7 @@ DevPathFromTextiSCSI (
> CHAR16 *ProtocolStr;
> CHAR8 *AsciiStr;
> ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
> + UINT64 Lun;
>
> NameStr = GetNextParamStr (&TextDeviceNode);
> PortalGroupStr = GetNextParamStr (&TextDeviceNode);
> @@ -2560,7 +2561,8 @@ DevPathFromTextiSCSI (
> 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) {
> --
> 2.16.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-03 5:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-03 5:10 [PATCH v2] MdePkg/DevicePathFromText: Fix byte orders of iSCSI.Lun Ruiyu Ni
2018-03-03 5:20 ` Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox