From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 10229AC1267 for ; Tue, 6 Feb 2024 13:26:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=0fsWn9nx0jp54wj8EQVob9iDsRx7RijK8jKFwysqiCA=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1707225979; v=1; b=fBI93hTIrsze3PPijhrYtCdEiROpWTZm7Lt6BlBAvKDvN2mZE8rZPLfOYHE851fJParkZdWq 2EdAT5Pito99pgrXrm9/vfveX40H7n+9NcRxskvj45rhAsMxc9QUpSrahGyl8HevKFO7trm1Naf 3GMjYfWdNKzXsawZ6IWGPCn4= X-Received: by 127.0.0.2 with SMTP id VsLmYY7687511xRZfuTx6t76; Tue, 06 Feb 2024 05:26:19 -0800 X-Received: from smtp.joursoir.net (smtp.joursoir.net [91.192.102.115]) by mx.groups.io with SMTP id smtpd.web11.21227.1707225979009239734 for ; Tue, 06 Feb 2024 05:26:19 -0800 X-Received: from localhost.localdomain (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.joursoir.net (Postfix) with ESMTPSA id 432D141DD3; Tue, 6 Feb 2024 16:26:13 +0300 (MSK) From: "Joursoir" To: devel@edk2.groups.io Cc: ardb@kernel.org, michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, Alexander Goncharov Subject: [edk2-devel] [PATCH 1/2] MdeModulePkg: Introduce and use PcdMemoryAttributesTableVersion Date: Tue, 6 Feb 2024 16:25:51 +0300 Message-ID: <20240206132552.245545-2-chat@joursoir.net> In-Reply-To: <20240206132552.245545-1-chat@joursoir.net> References: <20240206132552.245545-1-chat@joursoir.net> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,chat@joursoir.net List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: eR2I0x431SAm0EIL7k40X8otx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=fBI93hTI; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- 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/DxeM= ain.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=0D gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable = ## CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress = ## CONSUMES=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableVersion = ## CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType = ## CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask = ## CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath = ## CONSUMES=0D diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModule= Pkg/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 ( //=0D MemoryAttributesTable =3D AllocatePool (sizeof (EFI_MEMORY_ATTRIBUTES_TA= BLE) + DescriptorSize * RuntimeEntryCount);=0D ASSERT (MemoryAttributesTable !=3D NULL);=0D - MemoryAttributesTable->Version =3D EFI_MEMORY_ATTRIBUTES_TABLE_V= ERSION;=0D + MemoryAttributesTable->Version =3D PcdGet32 (PcdMemoryAttributes= TableVersion);=0D MemoryAttributesTable->NumberOfEntries =3D RuntimeEntryCount;=0D MemoryAttributesTable->DescriptorSize =3D (UINT32)DescriptorSize;=0D - if (gMemoryAttributesTableForwardCfi) {=0D + if (MemoryAttributesTable->Version > 0x01 && gMemoryAttributesTableForwa= rdCfi) {=0D MemoryAttributesTable->Flags =3D EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWAR= D_CONTROL_FLOW_GUARD;=0D } else {=0D MemoryAttributesTable->Flags =3D 0;=0D 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.=0D gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x3E|UINT32|0= x0001004c=0D =0D + ## Indicates which Memory Attributes Table version exposed to the OS.=0D + # @Prompt Exposed Memory Attributes Table version.=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableVersion|0x0000000= 2|UINT32|0x12f85350=0D +=0D ## This PCD defines the MAX repair count.=0D # The default value is 0 that means infinite.=0D # @Prompt MAX repair count=0D 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.
\n"=0D = "BIT 5 - EFI_ACPI_TABLE_VERSION_5_0.
"=0D =0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMemoryAttributesTableVersion= _PROMPT #language en-US "Exposed Memory Attributes Table version."=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMemoryAttributesTableVersion= _HELP #language en-US "Indicates which Memory Attributes Table version exp= osed to the OS."=0D +=0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHiiOsRuntimeSupport_PROMPT = #language en-US "Enable export HII data and configuration to be used in OS = runtime."=0D =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHiiOsRuntimeSupport_HELP #l= anguage en-US "Indicates if HII data and configuration has been exported.
\n"=0D --=20 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] -=-=-=-=-=-=-=-=-=-=-=-