* [edk2-devel] [PATCH 0/2] Introduce and use PCD for Memory Attributes Table
@ 2024-02-06 13:25 Joursoir
2024-02-06 13:25 ` [edk2-devel] [PATCH 1/2] MdeModulePkg: Introduce and use PcdMemoryAttributesTableVersion Joursoir
2024-02-06 13:25 ` [edk2-devel] [PATCH 2/2] MdePkg: Drop unused EFI_MEMORY_ATTRIBUTES_TABLE_VERSION macro Joursoir
0 siblings, 2 replies; 3+ messages in thread
From: Joursoir @ 2024-02-06 13:25 UTC (permalink / raw)
To: devel; +Cc: ardb, michael.d.kinney, gaoliming, zhiguang.liu,
Alexander Goncharov
This patch-set allows UEFI to choose which version of the memory attributes table to produce.
Alexander Goncharov (2):
MdeModulePkg: Introduce and use PcdMemoryAttributesTableVersion
MdePkg: Drop unused EFI_MEMORY_ATTRIBUTES_TABLE_VERSION macro
MdeModulePkg/Core/Dxe/DxeMain.inf | 1 +
MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 4 ++--
MdeModulePkg/MdeModulePkg.dec | 4 ++++
MdeModulePkg/MdeModulePkg.uni | 4 ++++
MdePkg/Include/Guid/MemoryAttributesTable.h | 2 --
5 files changed, 11 insertions(+), 4 deletions(-)
--
2.43.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115159): https://edk2.groups.io/g/devel/message/115159
Mute This Topic: https://groups.io/mt/104197274/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 3+ messages in thread
* [edk2-devel] [PATCH 1/2] MdeModulePkg: Introduce and use PcdMemoryAttributesTableVersion
2024-02-06 13:25 [edk2-devel] [PATCH 0/2] Introduce and use PCD for Memory Attributes Table Joursoir
@ 2024-02-06 13:25 ` Joursoir
2024-02-06 13:25 ` [edk2-devel] [PATCH 2/2] MdePkg: Drop unused EFI_MEMORY_ATTRIBUTES_TABLE_VERSION macro Joursoir
1 sibling, 0 replies; 3+ messages in thread
From: Joursoir @ 2024-02-06 13:25 UTC (permalink / raw)
To: devel; +Cc: ardb, michael.d.kinney, gaoliming, zhiguang.liu,
Alexander Goncharov
Linux kernel supports the memory attributes table v2 since version 6.2.
However, UEFI can be used with older kernel versions that are still
maintainable. So instead of relying on a macro that defines the memory
attributes table, a corresponding PCD is introduced to decide which
version of the table UEFI should create.
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
---
MdeModulePkg/Core/Dxe/DxeMain.inf | 1 +
MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 4 ++--
MdeModulePkg/MdeModulePkg.dec | 4 ++++
MdeModulePkg/MdeModulePkg.uni | 4 ++++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 090970aec6..a59cd117c5 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -177,6 +177,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressRuntimeCodePageNumber ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableVersion ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
index e9343a2c4e..4df7b140f6 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
@@ -181,10 +181,10 @@ InstallMemoryAttributesTable (
//
MemoryAttributesTable = AllocatePool (sizeof (EFI_MEMORY_ATTRIBUTES_TABLE) + DescriptorSize * RuntimeEntryCount);
ASSERT (MemoryAttributesTable != NULL);
- MemoryAttributesTable->Version = EFI_MEMORY_ATTRIBUTES_TABLE_VERSION;
+ MemoryAttributesTable->Version = PcdGet32 (PcdMemoryAttributesTableVersion);
MemoryAttributesTable->NumberOfEntries = RuntimeEntryCount;
MemoryAttributesTable->DescriptorSize = (UINT32)DescriptorSize;
- if (gMemoryAttributesTableForwardCfi) {
+ if (MemoryAttributesTable->Version > 0x01 && gMemoryAttributesTableForwardCfi) {
MemoryAttributesTable->Flags = EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWARD_CONTROL_FLOW_GUARD;
} else {
MemoryAttributesTable->Flags = 0;
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index a2cd83345f..3ef8e6d3e5 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1523,6 +1523,10 @@
# @Prompt Exposed ACPI table versions.
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x3E|UINT32|0x0001004c
+ ## Indicates which Memory Attributes Table version exposed to the OS.
+ # @Prompt Exposed Memory Attributes Table version.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableVersion|0x00000002|UINT32|0x12f85350
+
## This PCD defines the MAX repair count.
# The default value is 0 that means infinite.
# @Prompt MAX repair count
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index a17d34d60b..b1b8d5f976 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -955,6 +955,10 @@
"BIT 4 - EFI_ACPI_TABLE_VERSION_4_0.<BR>\n"
"BIT 5 - EFI_ACPI_TABLE_VERSION_5_0.<BR>"
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMemoryAttributesTableVersion_PROMPT #language en-US "Exposed Memory Attributes Table version."
+
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMemoryAttributesTableVersion_HELP #language en-US "Indicates which Memory Attributes Table version exposed to the OS."
+
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHiiOsRuntimeSupport_PROMPT #language en-US "Enable export HII data and configuration to be used in OS runtime."
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHiiOsRuntimeSupport_HELP #language en-US "Indicates if HII data and configuration has been exported.<BR><BR>\n"
--
2.43.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115160): https://edk2.groups.io/g/devel/message/115160
Mute This Topic: https://groups.io/mt/104197278/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [edk2-devel] [PATCH 2/2] MdePkg: Drop unused EFI_MEMORY_ATTRIBUTES_TABLE_VERSION macro
2024-02-06 13:25 [edk2-devel] [PATCH 0/2] Introduce and use PCD for Memory Attributes Table Joursoir
2024-02-06 13:25 ` [edk2-devel] [PATCH 1/2] MdeModulePkg: Introduce and use PcdMemoryAttributesTableVersion Joursoir
@ 2024-02-06 13:25 ` Joursoir
1 sibling, 0 replies; 3+ messages in thread
From: Joursoir @ 2024-02-06 13:25 UTC (permalink / raw)
To: devel; +Cc: ardb, michael.d.kinney, gaoliming, zhiguang.liu,
Alexander Goncharov
EFI_MEMORY_ATTRIBUTES_TABLE_VERSION is not used anymore. It was
replaced by PcdMemoryAttributesTableVersion.
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
---
MdePkg/Include/Guid/MemoryAttributesTable.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/MdePkg/Include/Guid/MemoryAttributesTable.h b/MdePkg/Include/Guid/MemoryAttributesTable.h
index 238c14ff92..7e0fda70a2 100644
--- a/MdePkg/Include/Guid/MemoryAttributesTable.h
+++ b/MdePkg/Include/Guid/MemoryAttributesTable.h
@@ -21,8 +21,6 @@ typedef struct {
// EFI_MEMORY_DESCRIPTOR Entry[1];
} EFI_MEMORY_ATTRIBUTES_TABLE;
-#define EFI_MEMORY_ATTRIBUTES_TABLE_VERSION 0x00000002
-
#define EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWARD_CONTROL_FLOW_GUARD 0x1
// BIT0 implies that Runtime code includes the forward control flow guard
// instruction, such as X86 CET-IBT or ARM BTI.
--
2.43.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115161): https://edk2.groups.io/g/devel/message/115161
Mute This Topic: https://groups.io/mt/104197280/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-06 13:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 13:25 [edk2-devel] [PATCH 0/2] Introduce and use PCD for Memory Attributes Table Joursoir
2024-02-06 13:25 ` [edk2-devel] [PATCH 1/2] MdeModulePkg: Introduce and use PcdMemoryAttributesTableVersion Joursoir
2024-02-06 13:25 ` [edk2-devel] [PATCH 2/2] MdePkg: Drop unused EFI_MEMORY_ATTRIBUTES_TABLE_VERSION macro Joursoir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox