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 910A274003C for ; Fri, 1 Mar 2024 06:04:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=fD6DLRINL8n8s/YJ8tLQrPXS0RAIPP7EWZfKx0Zvwvc=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID: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=1709273049; v=1; b=NqnYL0KHfkfK/haE4Fb+HVpBa1EXduXEW7qeRFAszNbT73B35VTAEeIMdOBPTRKfz+4YKPDT wO+kFkh8dgabVDQF7Uw2koE9gE1D+nUZ5wsrkTjJM/S6e0ZSw3tAN+3Wzxzqq3+QS8BYo/XWV/P aytgxQvZ/RGxgYYSsjCPV0Rw= X-Received: by 127.0.0.2 with SMTP id oFgwYY7687511xBQIsOGLVk9; Thu, 29 Feb 2024 22:04:09 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.16423.1709273048256700864 for ; Thu, 29 Feb 2024 22:04:08 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="14362732" X-IronPort-AV: E=Sophos;i="6.06,195,1705392000"; d="scan'208";a="14362732" X-Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 22:04:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,195,1705392000"; d="scan'208";a="12768887" X-Received: from shpfwdbuild004.ccr.corp.intel.com ([10.239.56.152]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 22:04:06 -0800 From: "Aaron Li" To: devel@edk2.groups.io Cc: Zhiguang Liu , Dandan Bi , Liming Gao , Liu Yun Subject: [edk2-devel] [PATCH v1 1/1] MdeModulePkg/AcpiTableDxe: Select ACPI memory type by PCD Date: Fri, 1 Mar 2024 14:03:30 +0800 Message-ID: <20240301060330.996-1-aaron.li@intel.com> 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,aaron.li@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: jCRDTw6UwNJ7soHXRtGLd97hx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=NqnYL0KH; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=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 UEFI spec defined ACPI Tables at boot time can be contained in memory of type EfiACPIReclaimMemory or EfiAcpiMemoryNVS, although InstallAcpiTable with AcpiTableProtocol will only allocate memory with type EfiACPIReclaimMemory (Except FACS). This patch provides an optional method controlled by PCD to switch all ACPI allocated memory from EfiACPIReclaimMemory to EfiAcpiMemoryNVS. If the PcdAcpiMemoryUseNvs is set to TRUE, all ACPI allocated memory will using EfiAcpiMemoryNVS. Cc: Zhiguang Liu Cc: Dandan Bi Cc: Liming Gao Cc: Liu Yun Signed-off-by: Aaron Li --- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 37 +++++++++++++++----- MdeModulePkg/MdeModulePkg.dec | 6 ++++ MdeModulePkg/MdeModulePkg.uni | 7 ++++ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 1 + 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index e09bc9b704f5..6c3dbad90345 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -340,6 +340,7 @@ ReallocateAcpiTableBuffer ( EFI_ACPI_TABLE_INSTANCE TempPrivateData; EFI_STATUS Status; UINT64 CurrentData; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; CopyMem (&TempPrivateData, AcpiTableInstance, sizeof (EFI_ACPI_TABLE_INSTANCE)); // @@ -359,6 +360,12 @@ ReallocateAcpiTableBuffer ( NewMaxTableNumber * sizeof (UINT32); } + if (PcdGetBool (PcdAcpiMemoryUseNvs)) { + AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { + AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + if (mAcpiTableAllocType != AllocateAnyPages) { // // Allocate memory in the lower 32 bit of address range for @@ -372,13 +379,13 @@ ReallocateAcpiTableBuffer ( PageAddress = 0xFFFFFFFF; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (TotalSize), &PageAddress ); } else { Status = gBS->AllocatePool ( - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, TotalSize, (VOID **)&Pointer ); @@ -512,6 +519,7 @@ AddTableToList ( EFI_PHYSICAL_ADDRESS AllocPhysAddress; UINT64 Buffer64; BOOLEAN AddToRsdt; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; // // Check for invalid input parameters @@ -550,6 +558,12 @@ AddTableToList ( CurrentTableList->TableSize = CurrentTableSize; CurrentTableList->PoolAllocation = FALSE; + if (PcdGetBool (PcdAcpiMemoryUseNvs)) { + AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { + AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + // // Allocation memory type depends on the type of the table // @@ -585,7 +599,7 @@ AddTableToList ( // such as AArch64 that allocate multiples of 64 KB // Status = gBS->AllocatePool ( - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, CurrentTableList->TableSize, (VOID **)&CurrentTableList->Table ); @@ -596,7 +610,7 @@ AddTableToList ( // Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (CurrentTableList->TableSize), &AllocPhysAddress ); @@ -1944,6 +1958,7 @@ AcpiTableAcpiTableConstructor ( UINTN RsdpTableSize; UINT8 *Pointer; EFI_PHYSICAL_ADDRESS PageAddress; + EFI_MEMORY_TYPE AcpiAllocateMemoryType; // // Check for invalid input parameters @@ -1978,17 +1993,23 @@ AcpiTableAcpiTableConstructor ( RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER); } + if (PcdGetBool (PcdAcpiMemoryUseNvs)) { + AcpiAllocateMemoryType = EfiACPIMemoryNVS; + } else { + AcpiAllocateMemoryType = EfiACPIReclaimMemory; + } + if (mAcpiTableAllocType != AllocateAnyPages) { PageAddress = 0xFFFFFFFF; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (RsdpTableSize), &PageAddress ); } else { Status = gBS->AllocatePool ( - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, RsdpTableSize, (VOID **)&Pointer ); @@ -2037,13 +2058,13 @@ AcpiTableAcpiTableConstructor ( PageAddress = 0xFFFFFFFF; Status = gBS->AllocatePages ( mAcpiTableAllocType, - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, EFI_SIZE_TO_PAGES (TotalSize), &PageAddress ); } else { Status = gBS->AllocatePool ( - EfiACPIReclaimMemory, + AcpiAllocateMemoryType, TotalSize, (VOID **)&Pointer ); diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index a2cd83345f5b..324fb5e69ae6 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1523,6 +1523,12 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Prompt Exposed ACPI table versions. gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x3E|UINT32|0x0001004c + ## Indicates whether ACPI memory is using NVS + # Default is FALSE that means ACPI memory is using EfiACPIReclaimMemory type + # If it is set to TRUE that means ACPI memory is using EfiACPIMemoryNVS type + # @Prompt ACPI memory is using NVS. + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiMemoryUseNvs|FALSE|BOOLEAN|0x0001008b + ## 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 a17d34d60b21..a2c10774bb54 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -955,6 +955,13 @@ "BIT 4 - EFI_ACPI_TABLE_VERSION_4_0.
\n" "BIT 5 - EFI_ACPI_TABLE_VERSION_5_0.
" +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiMemoryUseNvs_PROMPT #language en-US "ACPI memory is using NVS." + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiMemoryUseNvs_HELP #language en-US "Indicates whether ACPI memory is using NVS\n" + "Default is FALSE that means ACPI memory is using EfiACPIReclaimMemory type\n" + "If it is set to TRUE that means ACPI memory is using EfiACPIMemoryNVS type" + + #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.

\n" diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf index 86dea43e27e4..38d64913a28c 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf @@ -68,6 +68,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiMemoryUseNvs ## CONSUMES [Protocols] gEfiAcpiTableProtocolGuid ## PRODUCES -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116210): https://edk2.groups.io/g/devel/message/116210 Mute This Topic: https://groups.io/mt/104659443/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-