From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web10.36451.1675067718594543356 for ; Mon, 30 Jan 2023 00:35:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=DcuDEvbm; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BF798240149 for ; Mon, 30 Jan 2023 09:35:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1675067716; bh=j6ppzPi6a5IxtOmaFd4QCvCCiCjQ/pZzUlObnf8fiM4=; h=From:Subject:Date:Cc:To:From; b=DcuDEvbm3k0z//CeF3e8O4id8UYCBI3D63NN2UC3KD1a7DOHB7khVx1h3bloworwC JKXg/mwXLaI8RDnAtMTNYB7Otbo6WyuprzPeQr3gtKscmmFWLhb6hNStf0lrSfoUV6 Y10NBLttqUKLQAKoI4VddwnWMjavXhJuIPbzVWe+JflXNjjpHuAEoAE1gMQorOzzSm cIez6wADAJS12rG86jaXVJahOt6PnKIn8OgfU8sNXb7C5mOR/zwg2NIh3gTzqkw2Kq ej8ItyfT9eTh2zFvwEPPMD55nFueOnqW3EGpZRN0ndGgF0OwOo6RV8WifNmx3b7Wfz /Kg5yi7vPtWaw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4P51hg486zz9rxG; Mon, 30 Jan 2023 09:35:15 +0100 (CET) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= Mime-Version: 1.0 (1.0) Subject: Re: [edk2-platforms][PATCH v3 10/11] Ext4Pkg: Fixes build on MSVC Date: Mon, 30 Jan 2023 08:35:15 +0000 Message-Id: <90232C61-45AC-41C3-B1DA-9ACE10FCFBF4@posteo.de> References: Cc: Savva Mitrofanov , devel@edk2.groups.io, Vitaly Cheptsov In-Reply-To: To: Pedro Falcato Content-Type: multipart/alternative; boundary=Apple-Mail-04C0C262-176C-4153-9853-B51F37E7A9F5 Content-Transfer-Encoding: 7bit --Apple-Mail-04C0C262-176C-4153-9853-B51F37E7A9F5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
As d= iscussion got stuck,

Review= ed-by: Marvin H=C3=A4user <mhaeuser@posteo.de>
<= br>
On 27. Jan 2023, at 15:36, Marvin H=C3=A4user &= lt;mhaeuser@posteo.de> wrote:

=EF=BB=BFOn 27. Jan 2023, at 15:33, Pedro Falcato <pe= dro.falcato@gmail.com> wrote:

On Fri, Jan 27, 2023 at 9:29 A= M Savva Mitrofanov <savvamtr@gmail.com> wrote:

Ac= cessing array using index of uint64 type makes MSVC compiler to
include `= __allmul` function in NOOPT which is not referenced in IA32.
So we null-t= erminates string using ReadSize, which should be equal to
SymlinkSizeTmp a= fter correct reading. Also adds missing MultU64x32
in Ext4Read.

Cc= : Marvin H=C3=A4user <mhaeuser@posteo.de>
Cc: Pedro Falcato <ped= ro.falcato@gmail.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com&g= t;
Fixes: 7c46116b0e18 ("Ext4Pkg: Add ext2/3 support")
Fixes: e81432fb= acb7 ("Ext4Pkg: Add symbolic links support")
Signed-off-by: Savva Mitrofa= nov <savvamtr@gmail.com>
---
Features/Ext4Pkg/Ext4Dxe/Inode.c &n= bsp; |  4 ++--
Features/Ext4Pkg/Ext4Dxe/Symlink.c | 12 ++++++--= ----
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a= /Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/Inode.c
inde= x 90e3eb88f523..8db051d3c444 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Inode.= c
+++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c
@@ -152,7 +152,7 @@ Ext4Read (=
      } else {
    =     // Uninitialized extents behave exactly the same as f= ile holes, except they have
       &nb= sp;// blocks already allocated to them.
-      &= nbsp; HoleLen =3D (Ext4GetExtentLength (&Extent) * Partition->Bl= ockSize) - HoleOff;
+        HoleLen =3D= MultU64x32 (Ext4GetExtentLength (&Extent), Partition->BlockSize) - H= oleOff;
      }

   &n= bsp;  WasRead =3D HoleLen > RemainingRead ? RemainingRead : (UI= NTN)HoleLen;
@@ -166,7 +166,7 @@ Ext4Read (
    &n= bsp;            =           Partition->Bl= ockSize
           = ;            &nb= sp;   );
      ExtentLengthB= ytes  =3D Extent.ee_len * Partition->BlockSize;
-   &nb= sp;  ExtentLogicalBytes =3D (UINT64)Extent.ee_block * Partition-&g= t;BlockSize;
+      ExtentLogicalBytes =3D MultU= 64x32 ((UINT64)Extent.ee_block, Partition->BlockSize);
  &nb= sp;   ExtentOffset       =3D Cu= rrentSeek - ExtentLogicalBytes;
      Exten= tMayRead      =3D (UINTN)(ExtentLengthBytes - Exten= tOffset);

diff --git a/Features/Ext4Pkg/Ext4Dxe/Symlink.c b/Features/= Ext4Pkg/Ext4Dxe/Symlink.c
index 19b357ac6ba0..8b1511a38b55 100644
--- a= /Features/Ext4Pkg/Ext4Dxe/Symlink.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Symlin= k.c
@@ -1,7 +1,7 @@
/** @file
  Symbolic links routines
-  Copyright (c) 2022 Savva Mitrofanov All rights reserved.
+ &= nbsp;Copyright (c) 2022-2023 Savva Mitrofanov All rights reserved.
 =  SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -155,11 += 155,6 @@ Ext4ReadSlowSymlink (
    return Status;
=   }

-  //
-  // Add null-terminator
-  = ;//
-  SymlinkTmp[SymlinkSizeTmp] =3D '\0';
-
  if (= SymlinkSizeTmp !=3D ReadSize) {
    DEBUG ((
 = ;     DEBUG_FS,
@@ -168,6 +163,11 @@ Ext4ReadSlo= wSymlink (
    return EFI_VOLUME_CORRUPTED;
 =  }

+  //
+  // Add null-terminator
+  //
in EDK2 and EDK2 platforms but Ext4Pkg just does:
// C= omment

Also, why are you bringing this n= ull-termination down here?

I don't think there's a strong functional reason, but it ad= heres to the principle of not touching malformed data if at all possible. No= t sure it needs to be part of this particular commit, but why not, it causes= less noise this way.

+  Symli= nkTmp[ReadSize] =3D '\0';
+
  *AsciiSymlinkSize =3D SymlinkA= llocateSize;
  *AsciiSymlink     =3D Symlin= kTmp;

--
2.39.0



-- 
Pedro=

= --Apple-Mail-04C0C262-176C-4153-9853-B51F37E7A9F5--