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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 7A2332250EDFD for ; Fri, 2 Mar 2018 23:41:15 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 23:47:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,416,1515484800"; d="scan'208";a="24816666" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.44]) ([10.239.9.44]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2018 23:47:25 -0800 To: edk2-devel@lists.01.org References: <1520062536-14244-1-git-send-email-yonghong.zhu@intel.com> <1520062536-14244-2-git-send-email-yonghong.zhu@intel.com> From: "Ni, Ruiyu" Message-ID: <853c4e80-392d-5558-a0b3-d9bb6fd45c7e@Intel.com> Date: Sat, 3 Mar 2018 15:47:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1520062536-14244-2-git-send-email-yonghong.zhu@intel.com> Subject: Re: [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:41:15 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 > --- > 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