public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: Chao Li <lichao@loongson.cn>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: "Kumar, Rahul R" <rahul.r.kumar@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Sunil V L <sunilvl@ventanamicro.com>,
	"Warkentin, Andrei" <andrei.warkentin@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 07/13] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg
Date: Mon, 25 Mar 2024 02:29:36 +0000	[thread overview]
Message-ID: <MN6PR11MB8244CF91FF08CA66533ABD678C362@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240320084319.276603-1-lichao@loongson.cn>

[-- Attachment #1: Type: text/plain, Size: 5312 bytes --]

2 comments:

  1.
Atrributes is type of UINTN but Mask is type of UINT64. Should they follow the same UINT64 type?
  2.
The header file does not define the meaning of each bit. As a reference, MdeModulePkg/Include/Ppi/MemoryAttribute.h defines 3 bits can be used for memory permission setting.


@Ard Biesheuvel<mailto:ardb+tianocore@kernel.org>,
Do you think that MdeModulePkg/Include/Ppi/MemoryAttribute.h misses a capability to return the attributes of a given range of memory address?
For your reference, Chao defined a lib API as below to serve the same request:
/**
  Finds the first of the length and memory properties of the memory region corresponding
  to the specified base address.
  @param[in]       BaseAddress       To find the base address of the memory region.
  @param[in, out]  RegionLength      Pointer holding:
                                      - At entry, the length of the memory region
                                        expected to be found.
                                      - At exit, the length of the memory region found.
  @param[out]      RegionAttributes  Properties of the memory region found.
  @retval  EFI_SUCCESS    The corresponding memory area was successfully found
           EFI_NOT_FOUND    No memory area found
**/
EFI_STATUS
EFIAPI
GetMemoryRegionAttributes (
  IN     UINTN  BaseAddress,
  IN OUT UINTN  *RegionLength,
  OUT    UINTN  *RegionAttributes
  );

I hope we can align the lib API and PPI definition to one so that the lib API can be dropped in future (not in this round of patch).

Thanks,
Ray
________________________________
From: Chao Li <lichao@loongson.cn>
Sent: Wednesday, March 20, 2024 16:43
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; Leif Lindholm <quic_llindhol@quicinc.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Sami Mujawar <sami.mujawar@arm.com>; Sunil V L <sunilvl@ventanamicro.com>; Warkentin, Andrei <andrei.warkentin@intel.com>
Subject: [PATCH v2 07/13] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

Add a new header file CpuMmuLib.h, whitch is referenced from
ArmPkg/Include/Library/ArmMmuLib.h. Currently, only support for
LoongArch64 is added, and more architectures can be accommodated in the
future.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4734

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/Include/Library/CpuMmuLib.h | 55 ++++++++++++++++++++++++++
 UefiCpuPkg/UefiCpuPkg.dec              |  4 ++
 2 files changed, 59 insertions(+)
 create mode 100644 UefiCpuPkg/Include/Library/CpuMmuLib.h

diff --git a/UefiCpuPkg/Include/Library/CpuMmuLib.h b/UefiCpuPkg/Include/Library/CpuMmuLib.h
new file mode 100644
index 0000000000..26d2d65524
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/CpuMmuLib.h
@@ -0,0 +1,33 @@
+/** @file
+
+  Copyright (c) 2024 Loongson Technology Corporation Limited. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_MMU_LIB_H_
+#define CPU_MMU_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+/**
+  Sets the Attributes  of the specified memory region.
+
+  @param[in]  BaseAddress    The base address of the memory region to set the Attributes.
+  @param[in]  Length         The length of the memory region to set the Attributes.
+  @param[in]  Attributes     The Attributes to be set.
+  @param[in]  AttributeMask  Mask of memory attributes to take into account.
+
+  @retval  EFI_SUCCESS    The Attributes was set successfully
+**/
+EFI_STATUS
+EFIAPI
+SetMemoryRegionAttributes (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINTN                 Length,
+  IN UINTN                 Attributes,
+  IN UINT64                AttributeMask
+  );
+
+#endif // CPU_MMU_LIB_H_
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 571b59b36f..ca744fab55 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -72,6 +72,10 @@ [LibraryClasses.RISCV64]
   ##
   RiscVMmuLib|Include/Library/BaseRiscVMmuLib.h

+[LibraryClasses.LoongArch64]
+  ##  @libraryclass  Provides functions for the memory management unit.
+  CpuMmuLib|Include/Library/CpuMmuLib.h
+
 [Guids]
   gUefiCpuPkgTokenSpaceGuid      = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
   gMsegSmramGuid                 = { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
--
2.27.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117074): https://edk2.groups.io/g/devel/message/117074
Mute This Topic: https://groups.io/mt/105041094/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 13969 bytes --]

  reply	other threads:[~2024-03-25  2:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  8:41 [edk2-devel] [PATCH v2 00/13] Part 2 patch set to add LoongArch support into UefiCpuPkg Chao Li
2024-03-20  8:42 ` [edk2-devel] [PATCH v2 01/13] UefiCpuPkg/CpuTimerLib: Reorder the INF file alphabetically Chao Li
2024-03-22  1:15   ` Ni, Ray
2024-03-20  8:42 ` [edk2-devel] [PATCH v2 02/13] UefiCpuPkg/CpuExceptionHandlerLib: Reorder the INF files alphabetically Chao Li
2024-03-22  1:21   ` Ni, Ray
2024-03-20  8:42 ` [edk2-devel] [PATCH v2 03/13] UefiCpuPkg/MpInitLib: " Chao Li
2024-03-20  8:42 ` [edk2-devel] [PATCH v2 04/13] UefiCpuPkg/CpuDxe: Reorder the INF file alphabetically Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 05/13] UefiCpuPkg: Add LoongArch64 CPU Timer instance Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 06/13] UefiCpuPkg: Add CPU exception library for LoongArch Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 07/13] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg Chao Li
2024-03-25  2:29   ` Ni, Ray [this message]
2024-03-25  2:31   ` Ni, Ray
2024-03-25  2:52     ` Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 08/13] UefiCpuPkg: Added a new PCD named PcdCpuExceptionVectorBaseAddress Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 09/13] UefiCpuPkg: Add CpuMmuLib to UefiCpuPkg Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 10/13] UefiCpuPkg: Add CpuMmuInitLib.h " Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 11/13] UefiCpuPkg: Add CpuMmuInitLib " Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 12/13] UefiCpuPkg: Add multiprocessor library for LoongArch64 Chao Li
2024-03-20  8:43 ` [edk2-devel] [PATCH v2 13/13] UefiCpuPkg: Add CpuDxe driver " Chao Li
2024-03-25  2:35   ` Ni, Ray
2024-03-22 12:39 ` [edk2-devel] [PATCH v2 00/13] Part 2 patch set to add LoongArch support into UefiCpuPkg Gerd Hoffmann
2024-03-25  2:46   ` Ni, Ray
2024-03-25  3:10     ` Chao Li
     [not found]     ` <17BFE34457098413.21233@groups.io>
2024-03-26  1:32       ` Chao Li
     [not found]       ` <17C02C7EE39BF604.20354@groups.io>
2024-03-29  1:28         ` Chao Li
2024-04-09  2:06           ` Ni, Ray
2024-04-09  4:29             ` Chao Li
2024-04-09  5:27               ` Ni, Ray
2024-04-09  6:21                 ` Chao Li
     [not found]         ` <17C1180424B48FA9.19344@groups.io>
2024-04-03  1:21           ` Chao Li

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=MN6PR11MB8244CF91FF08CA66533ABD678C362@MN6PR11MB8244.namprd11.prod.outlook.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