From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4C2F721F6A6FD for ; Fri, 2 Mar 2018 23:29:31 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 23:35:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,416,1515484800"; d="scan'208";a="34319489" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by fmsmga004.fm.intel.com with ESMTP; 02 Mar 2018 23:35:41 -0800 From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Sat, 3 Mar 2018 15:35:36 +0800 Message-Id: <1520062536-14244-2-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1520062536-14244-1-git-send-email-yonghong.zhu@intel.com> References: <1520062536-14244-1-git-send-email-yonghong.zhu@intel.com> Subject: [Patch 2/2] BaseTools: Fix byte orders when handling 8-byte array X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2018 07:29:31 -0000 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 --- 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