On Thu, Apr 02, 2020 at 12:20:54 +0200, Ard Biesheuvel wrote:
> On 4/2/20 12:16 PM, Leif Lindholm via groups.io wrote:
> > On Sat, Mar 28, 2020 at 11:43:17 +0100, Ard Biesheuvel wrote:
> > > Before getting rid of GetRootTranslationTableInfo() and the related
> > > LookupAddresstoRootTable() in AARCH64's version of ArmMmuLib, add a
> > > version of the former to CpuDxe, which will be its only remaining
> > > user. While at it, simplify it a bit, since in the CpuDxe cases,
> > > both OUT arguments are always provided.
> > > 
> > > Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
> > > ---
> > >   ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 15 +++++++++++++++
> > >   ArmPkg/Drivers/CpuDxe/CpuDxe.h      |  7 -------
> > >   2 files changed, 15 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c 
> > > b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > > index 3b6c5e733709..24eb1c4221e3 100644
> > > --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > > +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> > > @@ -15,6 +15,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > >   #define TT_ATTR_INDX_INVALID    ((UINT32)~0)
> > > +#define MIN_T0SZ        16
> > > +#define BITS_PER_LEVEL  9
> > > +
> > > +STATIC
> > > +VOID
> > > +GetRootTranslationTableInfo (
> > > +  IN  UINTN     T0SZ,
> > > +  OUT UINTN     *RootTableLevel,
> > > +  OUT UINTN     *RootTableEntryCount
> > > +  )
> > > +{
> > > +  *RootTableLevel       = (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL;
> > > +  *RootTableEntryCount  = TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % 
> > > BITS_PER_LEVEL;
> > > +}
> > > +
> > >   STATIC
> > >   UINT64
> > >   GetFirstPageAttribute (
> > > diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.h 
> > > b/ArmPkg/Drivers/CpuDxe/CpuDxe.h
> > > index b627c3c50ff8..3fe5c24d5e5b 100644
> > > --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.h
> > > +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.h
> > > @@ -134,13 +134,6 @@ GetMemoryRegion (
> > >     OUT    UINTN                   *RegionAttributes
> > >     );
> > > -VOID
> > > -GetRootTranslationTableInfo (
> > 
> > So, this may be super picky, but:
> > Deleting the prototype without making the definition also STATIC would
> > cause build errors with -Wmissing-prototypes (which someone might be
> > enabling explicitly or implicitly if say doing some code hardening on
> > the side).
> > 
> > Now, it's a valid point to say that -Wmissing-prototypes isn't in our
> > current CFLAGS, but I think it would be a good habit to get into.
> > So you get a:
> > 
> > Reviewed-by: Leif Lindholm <l...@nuviainc.com>
> > 
> > regardless, but I'd appreciate if you could sling a STATIC into
> > ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c as well before
> > pushing.
> > 
> 
> Well, while I see your point, please note that the prototype only exists in
> a local header file that only gets included by CpuDxe, and not by any of the
> other consumers of ArmMmuLib.

What I'm saying is that with -Wmissing-prototypes added, building
after applying this patch (but before applying the one that deletes
the function) gives:

"aarch64-linux-gnu-gcc"   -g -fshort-wchar -fno-builtin -fno-strict-aliasing 
-Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include 
AutoGen.h -fno-common -DSTRING_ARRAY_NAME=ArmMmuBaseLibStrings -g -Os 
-fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds 
-include AutoGen.h -fno-common -mlittle-endian -fno-short-enums -fverbose-asm 
-funsigned-char -ffunction-sections -fdata-sections -Wno-address 
-fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie 
-ffixed-x18 -mcmodel=small -flto -Wno-unused-but-set-variable 
-Wno-unused-const-variable -DMDEPKG_NDEBUG -DDISABLE_NEW_DEPRECATED_INTERFACES 
-mstrict-align -mgeneral-regs-only -c -o 
/work/git/tianocore/Build/ArmVirtQemu-AARCH64/RELEASE_GCC5/AARCH64/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib/OUTPUT/AArch64/ArmMmuLibCore.obj
 -I/work/git/edk2/ArmPkg/Library/ArmMmuLib/AArch64 
-I/work/git/edk2/ArmPkg/Library/ArmMmuLib 
-I/work/git/tianocore/Build/ArmVirtQemu-AARCH64/RELEASE_GCC5/AARCH64/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib/DEBUG
 -I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include 
-I/work/git/edk2/EmbeddedPkg -I/work/git/edk2/EmbeddedPkg/Include 
-I/work/git/edk2/MdePkg -I/work/git/edk2/MdePkg/Include 
-I/work/git/edk2/MdePkg/Include/AArch64 
/work/git/edk2/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
leif@vanye:/work/git/tianocore$ "aarch64-linux-gnu-gcc"   -g -fshort-wchar 
-fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds 
-ffunction-sections -fdata-sections -include AutoGen.h -fno-common 
-DSTRING_ARRAY_NAME=ArmMmuBaseLibStrings -g -Os -fshort-wchar -fno-builtin 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
-fno-common -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char 
-ffunction-sections -fdata-sections -Wno-address 
-fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie 
-ffixed-x18 -mcmodel=small -flto -Wno-unused-but-set-variable 
-Wno-unused-const-variable -DMDEPKG_NDEBUG -DDISABLE_NEW_DEPRECATED_INTERFACES 
-mstrict-align -mgeneral-regs-only -c -o 
/work/git/tianocore/Build/ArmVirtQemu-AARCH64/RELEASE_GCC5/AARCH64/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib/OUTPUT/AArch64/ArmMmuLibCore.obj
 -I/work/git/edk2/ArmPkg/Library/ArmMmuLib/AArch64 
-I/work/git/edk2/ArmPkg/Library/ArmMmuLib 
-I/work/git/tianocore/Build/ArmVirtQemu-AARCH64/RELEASE_GCC5/AARCH64/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib/DEBUG
 -I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include 
-I/work/git/edk2/EmbeddedPkg -I/work/git/edk2/EmbeddedPkg/Include 
-I/work/git/edk2/MdePkg -I/work/git/edk2/MdePkg/Include 
-I/work/git/edk2/MdePkg/Include/AArch64 
/work/git/edk2/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c 
-Wmissing-prototypes
/work/git/edk2/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c:109:1: error: 
no previous prototype for ‘GetRootTranslationTableInfo’ 
[-Werror=missing-prototypes]
 GetRootTranslationTableInfo (
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

So it breaks bisect if you're experimenting with hardening.

As I said, I don't insist, but I want to be sure you realise that bit
before you decide.

/
    Leif

> 
> 
> > > -  IN  UINTN    T0SZ,
> > > -  OUT UINTN   *TableLevel,
> > > -  OUT UINTN   *TableEntryCount
> > > -  );
> > > -
> > >   EFI_STATUS
> > >   SetGcdMemorySpaceAttributes (
> > >     IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR    *MemorySpaceMap,
> > > -- 
> > > 2.17.1
> > > 
> > 
> > 
> > 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56895): https://edk2.groups.io/g/devel/message/56895
Mute This Topic: https://groups.io/mt/72606847/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to