From: "Bret Barkelew" <bret@corthon.com>
To: Leif Lindholm <leif@nuviainc.com>
Cc: devel@edk2.groups.io, Ard Biesheuvel <ardb+tianocore@kernel.org>,
Sean Brogan <sean.brogan@microsoft.com>
Subject: Re: [PATCH v1 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon
Date: Tue, 2 Nov 2021 12:51:12 -0700 [thread overview]
Message-ID: <CAGTkKaj8-bKiKvY2pAg0QLyE3TuDuFgf=fjWQwVh6dpuzDsAmA@mail.gmail.com> (raw)
In-Reply-To: <20211102095716.ucmiocmes3fsylge@leviathan>
[-- Attachment #1: Type: text/plain, Size: 6341 bytes --]
Will address.
On Tue, Nov 2, 2021 at 2:57 AM Leif Lindholm <leif@nuviainc.com> wrote:
>
> On Mon, Nov 01, 2021 at 12:56:43 -0700, brbarkel@microsoft.com wrote:
> > From: Sean Brogan <sean.brogan@microsoft.com>
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651
>
> Some description please.
>
> > Cc: Leif Lindholm <leif@nuviainc.com>
> > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> > ---
> > ArmPkg/Library/MmuLib/MmuLib.c | 120 ++++++++++++++++++++
> > ArmPkg/ArmPkg.dsc | 1 +
> > ArmPkg/Library/MmuLib/BaseMmuLib.inf | 30 +++++
> > 3 files changed, 151 insertions(+)
> >
> > diff --git a/ArmPkg/Library/MmuLib/MmuLib.c
> b/ArmPkg/Library/MmuLib/MmuLib.c
> > new file mode 100644
> > index 000000000000..7a6ba1f81819
> > --- /dev/null
> > +++ b/ArmPkg/Library/MmuLib/MmuLib.c
> > @@ -0,0 +1,120 @@
> > +/** @file
> > +This library instance implements a very limited MMU Lib instance
> > +for the ARM/AARCH64 architectures. This library shims a common library
> > +interface to the ArmPkg defined ArmMmuLib.ib.
>
> - ib. ?
>
> > +
> > +Copyright (c) Microsoft Corporation.
> > +SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include <Library/MmuLib.h>
> > +#include <Library/ArmMmuLib.h>
> > +#include <Library/DebugLib.h>
>
> Please sort alphabetically.
>
> /
> Leif
>
> > +
> > +/**
> > + Bitwise sets the memory attributes on a range of memory based on an
> attributes mask.
> > +
> > + @param BaseAddress The start of the range for which to set
> attributes.
> > + @param Length The length of the range.
> > + @param Attributes A bitmask of the attributes to set. See
> "Physical memory
> > + protection attributes" in UefiSpec.h
> > +
> > + @return EFI_SUCCESS
> > + @return Others
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +MmuSetAttributes (
> > + IN EFI_PHYSICAL_ADDRESS BaseAddress,
> > + IN UINT64 Length,
> > + IN UINT64 Attributes
> > + )
> > + {
> > + EFI_STATUS Status;
> > +
> > + Status = EFI_UNSUPPORTED;
> > +
> > + if (Attributes & EFI_MEMORY_XP) {
> > + Status = ArmSetMemoryRegionNoExec (BaseAddress, Length);
> > + if (EFI_ERROR(Status)) {
> > + DEBUG((DEBUG_ERROR, "%a - Failed to set NX. Status = %r\n",
> __FUNCTION__, Status));
> > + }
> > + }
> > +
> > + ASSERT_EFI_ERROR(Status);
> > + return Status;
> > + }
> > +
> > +
> > +/**
> > + Bitwise clears the memory attributes on a range of memory based on an
> attributes mask.
> > +
> > + @param BaseAddress The start of the range for which to
> clear attributes.
> > + @param Length The length of the range.
> > + @param Attributes A bitmask of the attributes to clear.
> See "Physical memory
> > + protection attributes" in UefiSpec.h
> > +
> > + @return EFI_SUCCESS
> > + @return Others
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +MmuClearAttributes (
> > + IN EFI_PHYSICAL_ADDRESS BaseAddress,
> > + IN UINT64 Length,
> > + IN UINT64 Attributes
> > + )
> > + {
> > + EFI_STATUS Status;
> > +
> > + Status = EFI_UNSUPPORTED;
> > +
> > + if (Attributes & EFI_MEMORY_XP) {
> > + Status = ArmClearMemoryRegionNoExec (BaseAddress, Length);
> > + if (EFI_ERROR(Status)) {
> > + DEBUG((DEBUG_ERROR, "%a - Failed to clear NX. Status = %r\n",
> __FUNCTION__, Status));
> > + }
> > + }
> > +
> > + if (Attributes & EFI_MEMORY_RO) {
> > + Status = ArmClearMemoryRegionReadOnly(BaseAddress, Length);
> > + if (EFI_ERROR(Status)) {
> > + DEBUG((DEBUG_ERROR, "%a - Failed to clear RO. Status = %r\n",
> __FUNCTION__, Status));
> > + }
> > + }
> > +
> > + ASSERT_EFI_ERROR(Status);
> > + return Status;
> > + }
> > +
> > +
> > +/**
> > + Returns the memory attributes on a range of memory.
> > +
> > + @param BaseAddress The start of the range for which to set
> attributes.
> > + @param Attributes A return pointer for the attributes.
> > +
> > + @return EFI_SUCCESS
> > + @return EFI_INVALID_PARAMETER A return pointer is NULL.
> > + @return Others
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +MmuGetAttributes (
> > + IN EFI_PHYSICAL_ADDRESS BaseAddress,
> > + OUT UINT64 *Attributes
> > + )
> > + {
> > + EFI_STATUS Status;
> > +
> > + Status = EFI_UNSUPPORTED;
> > +
> > + DEBUG ((DEBUG_ERROR, "%a() API not implemented\n", __FUNCTION__));
> > +
> > + ASSERT_EFI_ERROR(Status);
> > + return Status;
> > + }
> > diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> > index 06ede068f99d..cbc67daa7696 100644
> > --- a/ArmPkg/ArmPkg.dsc
> > +++ b/ArmPkg/ArmPkg.dsc
> > @@ -165,3 +165,4 @@ [Components.AARCH64]
> >
> > [Components.AARCH64, Components.ARM]
> > ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> > + ArmPkg/Library/MmuLib/BaseMmuLib.inf
> > diff --git a/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> > new file mode 100644
> > index 000000000000..15095abee9c3
> > --- /dev/null
> > +++ b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> > @@ -0,0 +1,30 @@
> > +## @file
> > +# This library instance implements a very limited MMU Lib instance
> > +# for the ARM/AARCH64 architectures. This library shims a common
> library
> > +# interface to the ArmPkg defined ArmMmuLib.
> > +#
> > +# Copyright (c) Microsoft Corporation.
> > +#
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent
> > +#
> > +##
> > +
> > +[Defines]
> > + INF_VERSION = 0x00010005
> > + BASE_NAME = MmuLib
> > + FILE_GUID = 6f2ee9a4-79b3-4b77-9a47-e2bd4b917b75
> > + MODULE_TYPE = BASE
> > + VERSION_STRING = 1.0
> > + LIBRARY_CLASS = MmuLib
> > +
> > +[Sources]
> > + MmuLib.c
> > +
> > +[Packages]
> > + MdePkg/MdePkg.dec
> > + MdeModulePkg/MdeModulePkg.dec
> > + ArmPkg/ArmPkg.dec
> > +
> > +[LibraryClasses]
> > + DebugLib
> > + ArmMmuLib
> > --
> > 2.31.1.windows.1
> >
>
[-- Attachment #2: Type: text/html, Size: 8735 bytes --]
next prev parent reply other threads:[~2021-11-02 19:51 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 19:56 [PATCH v1 00/16] Un-siloing Arm common code Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM Bret Barkelew
2021-11-02 8:43 ` Leif Lindholm
2021-11-02 8:50 ` [edk2-devel] " ryan.harkin
2021-11-02 9:03 ` Leif Lindholm
2021-11-02 9:26 ` Leif Lindholm
2021-11-01 19:56 ` [PATCH v1 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib Bret Barkelew
2021-11-02 9:34 ` Leif Lindholm
2021-11-02 9:39 ` Leif Lindholm
2021-11-01 19:56 ` [PATCH v1 03/16] ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 04/16] ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib Bret Barkelew
2021-11-02 9:39 ` Leif Lindholm
2021-11-01 19:56 ` [PATCH v1 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg Bret Barkelew
2021-11-02 9:50 ` Leif Lindholm
2021-11-02 19:44 ` [EXTERNAL] Re: [edk2-devel] " Bret Barkelew
2021-11-04 6:23 ` 回复: " gaoliming
2021-11-04 6:24 ` Andrew Fish
2021-11-04 17:23 ` Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools Bret Barkelew
2021-11-02 9:55 ` Leif Lindholm
2021-11-02 19:45 ` [EXTERNAL] Re: [edk2-devel] " Bret Barkelew
2021-11-02 23:34 ` [EXTERNAL] " Andrew Fish
2021-11-03 11:03 ` Leif Lindholm
2021-11-03 15:35 ` Bob Feng
2021-11-03 16:08 ` Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg Bret Barkelew
2021-11-02 1:52 ` 回复: " gaoliming
2021-11-02 9:24 ` Leif Lindholm
2021-11-02 19:48 ` Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 08/16] MdePkg: Create the MMU access lib to abstract memory protection settings Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 09/16] MdeModulePkg: Swap to MmuLib instead of Arm-specific lib Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction Bret Barkelew
2021-11-02 0:25 ` [edk2-devel] " Yao, Jiewen
2021-11-01 19:56 ` [PATCH v1 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon Bret Barkelew
2021-11-02 9:57 ` Leif Lindholm
2021-11-02 19:51 ` Bret Barkelew [this message]
2021-11-01 19:56 ` [PATCH v1 12/16] ArmPkg: Move the StandaloneMmCpu driver to ArmPkg Bret Barkelew
2021-11-02 10:00 ` Leif Lindholm
2021-11-02 19:53 ` Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 13/16] ArmPkg: Move the StandaloneMmCoreEntryPoint lib " Bret Barkelew
2021-11-02 10:00 ` Leif Lindholm
2021-11-01 19:56 ` [PATCH v1 14/16] ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only Bret Barkelew
2021-11-02 10:05 ` Leif Lindholm
2021-11-01 19:56 ` [PATCH v1 15/16] ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves Bret Barkelew
2021-11-01 19:56 ` [PATCH v1 16/16] ArmPlatformPkg/ArmPlatformPkg.dsc: " Bret Barkelew
2021-11-02 0:26 ` [edk2-devel] [PATCH v1 00/16] Un-siloing Arm common code Yao, Jiewen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGTkKaj8-bKiKvY2pAg0QLyE3TuDuFgf=fjWQwVh6dpuzDsAmA@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox