From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mx.groups.io with SMTP id smtpd.web10.103310.1674830026408550909 for ; Fri, 27 Jan 2023 06:33:46 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TfjaVCoo; spf=pass (domain: gmail.com, ip: 209.85.216.54, mailfrom: pedro.falcato@gmail.com) Received: by mail-pj1-f54.google.com with SMTP id h5-20020a17090a9c0500b0022bb85eb35dso5005204pjp.3 for ; Fri, 27 Jan 2023 06:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5onjRPVkK0tN4xi2HTmUSSIQvOYJ211jO5EpVMBTYGY=; b=TfjaVCooNDlSW2ntGHoIpPl388LMad2F33h+j9zmndlVcdCYkOTxcA4C2esJahaLpu zXuiZDohtCUhp8ktllTX/2j/9xzU8gOttm+441OTB48KGMzxZ8/kLh6R5nlKLQPjA2gM VV4OJp6XgG6iA9hIcsT/N6KzK/7gAENUswsy43w4aGZ15COHP0rsyJSJmxW5E5M3UDGP /Nj6PEskn7fjo3N5DC+1AiMJ9HmFtqKbvAj+ZPkYWuYxsD3v/gXYjaMXCWrwheLLvBWQ 48b+pT3b8TABplz9LjG3ihLB2uoaktimtb7XZ4Y+jMduMRKEUS+4mlwDRNtnDSj/3XPg vj3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5onjRPVkK0tN4xi2HTmUSSIQvOYJ211jO5EpVMBTYGY=; b=fOr4nZO58i2JFbIAC5dvS4UGy2IgCLc4GMWoI7ZhaDuyVzUBoiagXNL0DS4HQuiRyA UGBWBwkOO7OYzxbsGBbZ5MuACgraBriiK2LsDUKEo1FnCYHushfndn2sEeg0QjHUl/hx g4xg+uubdnRCR2S7YGuKFw5uj/nIvTbq/W3jCmhjVvi2i4ae8lmfCb7JesrSWJOym6tb G3U6edC1S5tDeTyOxMvXYvc3yd684wkQeeNxcPA+1h7pMGsXidQGzujhlIRWGuJw60Nh 0XBAnED8w+BFushf8vtH7KvwLGz7zIk7zYNgzxB4n6S0kxd/oEegN1G7Vm6KiF1qYmFw 3Dlg== X-Gm-Message-State: AO0yUKVWsRhtuZhCNYwwnAOB6CdxChRXgvK2lm0JetCRv/VQaYSsA6qw xl/bLFu9MwhYTKrQh0u+Ti73XVpWl8CrrPXMCaM= X-Google-Smtp-Source: AK7set+KaEWkNopb5XA/dJRqG2Ac89nVsQ9KJrzvPZuPG/iNsYxjFq0JKBHG27tVLTUbnfsPxM/8wEcP68XB3JistLA= X-Received: by 2002:a17:90a:4897:b0:22c:13f5:3345 with SMTP id b23-20020a17090a489700b0022c13f53345mr1245742pjh.37.1674830025765; Fri, 27 Jan 2023 06:33:45 -0800 (PST) MIME-Version: 1.0 References: <20230127092945.94389-1-savvamtr@gmail.com> <20230127092945.94389-11-savvamtr@gmail.com> In-Reply-To: <20230127092945.94389-11-savvamtr@gmail.com> From: "Pedro Falcato" Date: Fri, 27 Jan 2023 14:33:34 +0000 Message-ID: Subject: Re: [edk2-platforms][PATCH v3 10/11] Ext4Pkg: Fixes build on MSVC To: Savva Mitrofanov Cc: devel@edk2.groups.io, =?UTF-8?Q?Marvin_H=C3=A4user?= , Vitaly Cheptsov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 27, 2023 at 9:29 AM Savva Mitrofanov wrote= : > > Accessing array using index of uint64 type makes MSVC compiler to > include `__allmul` function in NOOPT which is not referenced in IA32. > So we null-terminates string using ReadSize, which should be equal to > SymlinkSizeTmp after correct reading. Also adds missing MultU64x32 > in Ext4Read. > > Cc: Marvin H=C3=A4user > Cc: Pedro Falcato > Cc: Vitaly Cheptsov > Fixes: 7c46116b0e18 ("Ext4Pkg: Add ext2/3 support") > Fixes: e81432fbacb7 ("Ext4Pkg: Add symbolic links support") > Signed-off-by: Savva Mitrofanov > --- > Features/Ext4Pkg/Ext4Dxe/Inode.c | 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 > index 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 file holes, = except they have > // blocks already allocated to them. > - HoleLen =3D (Ext4GetExtentLength (&Extent) * Partition->BlockSiz= e) - HoleOff; > + HoleLen =3D MultU64x32 (Ext4GetExtentLength (&Extent), Partition= ->BlockSize) - HoleOff; > } > > WasRead =3D HoleLen > RemainingRead ? RemainingRead : (UINTN)HoleL= en; > @@ -166,7 +166,7 @@ Ext4Read ( > Partition->BlockSize > ); > ExtentLengthBytes =3D Extent.ee_len * Partition->BlockSize; > - ExtentLogicalBytes =3D (UINT64)Extent.ee_block * Partition->BlockS= ize; > + ExtentLogicalBytes =3D MultU64x32 ((UINT64)Extent.ee_block, Partit= ion->BlockSize); > ExtentOffset =3D CurrentSeek - ExtentLogicalBytes; > ExtentMayRead =3D (UINTN)(ExtentLengthBytes - ExtentOffset); > > diff --git a/Features/Ext4Pkg/Ext4Dxe/Symlink.c b/Features/Ext4Pkg/Ext4Dx= e/Symlink.c > index 19b357ac6ba0..8b1511a38b55 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Symlink.c > +++ b/Features/Ext4Pkg/Ext4Dxe/Symlink.c > @@ -1,7 +1,7 @@ > /** @file > Symbolic links routines > > - Copyright (c) 2022 Savva Mitrofanov All rights reserved. > + 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 @@ Ext4ReadSlowSymlink ( > return EFI_VOLUME_CORRUPTED; > } > > + // > + // Add null-terminator > + // Sidenote: please don't use this comment style, I know it's prevalent in EDK2 and EDK2 platforms but Ext4Pkg just does: // Comment Also, why are you bringing this null-termination down here? > + SymlinkTmp[ReadSize] =3D '\0'; > + > *AsciiSymlinkSize =3D SymlinkAllocateSize; > *AsciiSymlink =3D SymlinkTmp; > > -- > 2.39.0 > --=20 Pedro