From patchwork Wed Jan 16 20:22:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155749 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096517jaa; Wed, 16 Jan 2019 12:22:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VuaWV8eEIoPwOH+qOoIOJPs4QZ4snlmPmIIrxOD6hE1y377FRAO3tWdivLN6p+PSUNeun X-Received: by 2002:a63:5b1f:: with SMTP id p31mr10504622pgb.56.1547670169302; Wed, 16 Jan 2019 12:22:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670169; cv=none; d=google.com; s=arc-20160816; b=BKyMEOhHEndjOo5UvN4yRHKisDf9jriYznSnUSuTrChhwGDmb/Gith6gKxk55DMKL5 CBzZRT+a7KTdesZDE4XdMAii/o9ynBmwCYHxn0VuAwNfktqi2uG9DHHAxRU/nmOn0k2n HySzLnipEmoON79mP9o+0NlQ80qLdbjrcE2yRo90O7jstItPa/HxNDr5UoDh2HcdR+32 sREINP2/dAfQPoccAnzEJgVJeSgTvi8EEchljRLbb+GeyvnIcUj0xWo3Ni45O1q4SVMq bQvy7K2XuD8//fV5bmIu67VeHM1BmQzTRO+gFP7J6U+dgd65SThpIfwM189G5lGMjcyS dp+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=dvSUMfK1tivctpywTCwSARsNLq86FouRDZwaussRSjY=; b=xupKll9fQIJofMQKpsF6q4XJIWqVBudtK/lDRL0PRkctfhbnxSGCWmwsdSOC2XX168 YBXBuhDxkzd1tH5eMDrm64e8TwMMxjvhj5a76KpGoeqHMr6FjrxP2F7pMnfSSxt/nuLf UPCUIt9n7PMYzXFREakq6bftkLyM7MSzPBmEB/VBZseu9Cbho3REIET04NDn1IJj9uzr Pdtg9hX5Yp29yKp5I8b0M9zbfM9lx7cOghxDoCGMp77+/jyqKYlZCHlzehF8OtqUglkr E8AhqrD7SMzI5oPi4FX0bPDqSWbn4c+nDoUlCp0sYQlGbDQagJXgg64oAwEpqK/guo3B 3W5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a6VWKBYS; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id m30si7750187pff.158.2019.01.16.12.22.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a6VWKBYS; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 83F67211B818F; Wed, 16 Jan 2019 12:22:47 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::441; helo=mail-wr1-x441.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 536F7211A759E for ; Wed, 16 Jan 2019 12:22:46 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id s12so8486395wrt.4 for ; Wed, 16 Jan 2019 12:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YPnadlKxkbPc9ckGKEUcfDoL7OUUtibGPEGlvYq7IMw=; b=a6VWKBYSeVEbxhCp7eloj5ShndQvBbNxSavJsJStHdHTrvUCFxFMJclz/+9XsH1yyn pj0gpIPrwKPPgFlyIt1v9qiYFum5rx89V1X15JYKk6lPKYMXWmTuoplwSLFAEKL6X3Z6 9O3ogYmGbdC524rfnaSbAiDV9FRCLxKBK3tjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YPnadlKxkbPc9ckGKEUcfDoL7OUUtibGPEGlvYq7IMw=; b=jqE7WbBsf/qIL7hZbIAt+eQb5DN0ettX+CEtc+qF/TNFXcSHeXJr3maG9FCS4jHFnM qxdOS5KV0phMFFvCr98l0ma1xpCenPppU9Ob7XGQBaIA2Ql/e5xJ3f9469JzgKQ2fUrX 2bE8vCSllaXgtEvmpPCjmwzQwHYlgcDXyrGVw5vMdM14u1czJk7lCigfxVil3LU3Gd6n AaaBxclV0ArtBJl5ohgqqNdJyfnkB8DIpa1U2d+vMcl0tCu1tfXhOspKmvyP2S/iqRk2 ymDIdOovWypAwLJHzSmdTx+X4Ujlk0E2Z8xUq1ERkyMXw8fKbbNmqsn0OgYWLuRl8l7Y 6Uzw== X-Gm-Message-State: AJcUukegPfU9sJlNvD4kc8kGQnWZvxzLmOJPqeac20zUGwbjcldlFEa2 VswWXapfIJqeAh1DbhSwdbZXOMY/ecrPtg== X-Received: by 2002:adf:fc89:: with SMTP id g9mr8774400wrr.96.1547670163937; Wed, 16 Jan 2019 12:22:43 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:42 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:26 +0100 Message-Id: <20190116202236.6977-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 01/11] StandaloneMmPkg: add HobLib implementation for MM_STANDALONE modules X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This HobLib code is based on the staging implementation of StandaloneMmPkg, with the following changes: - drop the unused AArch64/StandaloneMmCoreHobLibInternal.c source file - remove hack from HobLibConstructor() - update code comments referring the MM core Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c | 649 ++++++++++++++++++++ StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf | 45 ++ 2 files changed, 694 insertions(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: jiewen.yao@intel.com diff --git a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c new file mode 100644 index 000000000000..cc1a08166470 --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c @@ -0,0 +1,649 @@ +/** @file + HOB Library implementation for Standalone MM Core. + +Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include + +// +// Cache copy of HobList pointer. +// +STATIC VOID *gHobList = NULL; + +/** + The constructor function caches the pointer to HOB list. + + The constructor function gets the start address of HOB list from system configuration table. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the image. + @param MmSystemTable A pointer to the MM System Table. + + @retval EFI_SUCCESS The constructor successfully gets HobList. + @retval Other value The constructor can't get HobList. + +**/ +EFI_STATUS +EFIAPI +HobLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *MmSystemTable + ) +{ + UINTN Index; + + for (Index = 0; Index < gMmst->NumberOfTableEntries; Index++) { + if (CompareGuid (&gEfiHobListGuid, &gMmst->MmConfigurationTable[Index].VendorGuid)) { + gHobList = gMmst->MmConfigurationTable[Index].VendorTable; + break; + } + } + return EFI_SUCCESS; +} + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + If the pointer to the HOB list is NULL, then ASSERT(). + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + UINTN Index; + + if (gHobList == NULL) { + for (Index = 0; Index < gMmst->NumberOfTableEntries; Index++) { + if (CompareGuid (&gEfiHobListGuid, &gMmst->MmConfigurationTable[Index].VendorGuid)) { + gHobList = gMmst->MmConfigurationTable[Index].VendorTable; + break; + } + } + } + ASSERT (gHobList != NULL); + return gHobList; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + ASSERT (HobStart != NULL); + + Hob.Raw = (UINT8 *) HobStart; + // + // Parse the HOB list until end of list or matching type is found. + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == Type) { + return Hob.Raw; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + If the pointer to the HOB list is NULL, then ASSERT(). + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextHob (Type, HobList); +} + +/** + Returns the next instance of the matched GUID HOB from the starting HOB. + + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION, and its GUID Name equals to the input Guid. + If such a HOB from the starting HOB pointer does not exist, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size information, respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS GuidHob; + + GuidHob.Raw = (UINT8 *) HobStart; + while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) { + if (CompareGuid (Guid, &GuidHob.Guid->Name)) { + break; + } + GuidHob.Raw = GET_NEXT_HOB (GuidHob); + } + return GuidHob.Raw; +} + +/** + Returns the first instance of the matched GUID HOB among the whole HOB list. + + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If such a HOB from the starting HOB pointer does not exist, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size information, respectively. + + If the pointer to the HOB list is NULL, then ASSERT(). + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextGuidHob (Guid, HobList); +} + +/** + Get the system boot mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + If the pointer to the HOB list is NULL, then ASSERT(). + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +{ + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; + + HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList (); + + return HandOffHob->BootMode; +} + +VOID * +CreateHob ( + IN UINT16 HobType, + IN UINT16 HobLength + ) +{ + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; + EFI_HOB_GENERIC_HEADER *HobEnd; + EFI_PHYSICAL_ADDRESS FreeMemory; + VOID *Hob; + + HandOffHob = GetHobList (); + + HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); + + FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom; + + if (FreeMemory < HobLength) { + return NULL; + } + + Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList; + ((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType; + ((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength; + ((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0; + + HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength); + HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; + + HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST; + HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER); + HobEnd->Reserved = 0; + HobEnd++; + HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; + + return Hob; +} + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module entry point. + +**/ +VOID +EFIAPI +BuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +{ + EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob; + + ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) && + ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)); + + Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE)); + + CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid); + Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; + Hob->MemoryAllocationHeader.MemoryLength = ModuleLength; + Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved)); + + CopyGuid (&Hob->ModuleName, ModuleName); + Hob->EntryPoint = EntryPoint; +} + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +{ + EFI_HOB_RESOURCE_DESCRIPTOR *Hob; + + Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); + ASSERT(Hob != NULL); + + Hob->ResourceType = ResourceType; + Hob->ResourceAttribute = ResourceAttribute; + Hob->PhysicalStart = PhysicalStart; + Hob->ResourceLength = NumberOfBytes; +} + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +{ + EFI_HOB_GUID_TYPE *Hob; + + // + // Make sure that data length is not too long. + // + ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE))); + + Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength)); + CopyGuid (&Hob->Name, Guid); + return Hob + 1; +} + + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +{ + VOID *HobData; + + ASSERT (Data != NULL || DataLength == 0); + + HobData = BuildGuidHob (Guid, DataLength); + + return CopyMem (HobData, Data, DataLength); +} + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_FIRMWARE_VOLUME *Hob; + + Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME)); + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; +} + + +/** + Builds a EFI_HOB_TYPE_FV2 HOB. + + This function builds a EFI_HOB_TYPE_FV2 HOB. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + @param FvName The name of the Firmware Volume. + @param FileName The name of the file. + +**/ +VOID +EFIAPI +BuildFv2Hob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN CONST EFI_GUID *FvName, + IN CONST EFI_GUID *FileName + ) +{ + EFI_HOB_FIRMWARE_VOLUME2 *Hob; + + Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2)); + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; + CopyGuid (&Hob->FvName, FvName); + CopyGuid (&Hob->FileName, FileName); +} + + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +{ + EFI_HOB_CPU *Hob; + + Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU)); + + Hob->SizeOfMemorySpace = SizeOfMemorySpace; + Hob->SizeOfIoSpace = SizeOfIoSpace; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); +} + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + EFI_HOB_MEMORY_ALLOCATION *Hob; + + ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) && + ((Length & (EFI_PAGE_SIZE - 1)) == 0)); + + Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION)); + + ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} + +/** + Builds a HOB that describes a chunk of system memory with Owner GUID. + + This function builds a HOB that describes a chunk of system memory. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + @param OwnerGUID GUID for the owner of this resource. + +**/ +VOID +EFIAPI +BuildResourceDescriptorWithOwnerHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes, + IN EFI_GUID *OwnerGUID + ) +{ + ASSERT (FALSE); +} + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + If the platform does not support Capsule Volume HOBs, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + ASSERT (FALSE); +} + + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + ASSERT (FALSE); +} + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + ASSERT (FALSE); +} diff --git a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf new file mode 100644 index 000000000000..542a19cc4bec --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf @@ -0,0 +1,45 @@ +## @file +# Instance of HOB Library for Standalone MM modules. +# +# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = HobLib + FILE_GUID = 8262551B-AB2D-4E76-99FC-5EBB83F4988E + MODULE_TYPE = MM_STANDALONE + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x00010032 + LIBRARY_CLASS = HobLib|MM_STANDALONE + CONSTRUCTOR = HobLibConstructor + +# +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 +# + +[Sources] + StandaloneMmHobLib.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + MmServicesTableLib + +[Guids] + gEfiHobListGuid ## CONSUMES ## SystemTable + gEfiHobMemoryAllocModuleGuid ## CONSUMES From patchwork Wed Jan 16 20:22:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155750 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096572jaa; Wed, 16 Jan 2019 12:22:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN4cLKm+vSaPtYwkJYi3ebJ1SheIOJHGi02BhcASXLfccpL6ihd49gRm2IbOG3EeTecGK8Sj X-Received: by 2002:a65:6215:: with SMTP id d21mr10545440pgv.289.1547670172143; Wed, 16 Jan 2019 12:22:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670172; cv=none; d=google.com; s=arc-20160816; b=gkExWsJ9Cj3gyKjvBmToD+IuP5BymSwIyZb2uwu27C4Yk9QlaVUg16wNIIspDDpPYr jIWY2hZbDx9mlx9q2806AC4x4mgDboJVP++MwR1LfFO6oIxC96K/5E+Gcsdv8BXrYz6/ iOh7gvqCPjc5oRiR9rAh4CEUw+DztjYRQdN5ux+3rF9rPh+YnnKuSPVX6HZ4RtJaOXyS IlixOUKDZzKg/v28yI4As91h9dyCZUbi2saz5er77p9zAmlJZLkt2BIYkI5D9VSAknRb fyxF/t/k7syBr+5Fe0xB266k9qqgHqAvjWrEtxn1UhMwprCZtQPZfQPaUah8qvxsFH5s R5KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=BNJdNTTWT1xu2aCFDipDfqD8sGKs5y1pb92LBags/98=; b=rKRo50a6nzoXhGzATENaNmIEdMGi0980dDEYzKgF6SFc6pCwIQWIZXBL5bLNnuWXej rRAbGY+6dT+kAUWFfhYYt5aC2oiA3YLW/yTxoDVjobzdg5YQiO+b4jcbqtWMqa4DTSBs IKV0yatc5BC05m1LvteoEDAkr3qTtviSvuOhPRg0eH6fVY+0ynujVDFoRGyMnR+ybW8n LmSBwZQAxIxE/HLhvvkSndOR3+A4W3V6c69m4I5UZlszCOvT65uUVdIRmvJy9p3sSZgB ueKG1kz0LriIyX5omU2i2cojf7+UK7ZT8Nc09OITD7QgokXhw0Yas67NWax/Vz3OE2F8 Im8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dt06RXne; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id m8si5233378pls.400.2019.01.16.12.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dt06RXne; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B20B1211B8199; Wed, 16 Jan 2019 12:22:49 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 299F2211B76AA for ; Wed, 16 Jan 2019 12:22:48 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id b11so3458060wmj.1 for ; Wed, 16 Jan 2019 12:22:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dMgFd+B/b3ecsxP2le2rClh9lvDaOEHIxgh4qPul3FA=; b=dt06RXne60a9ad9brQQJ96rFtoz5iey+beAonq/DUXo+TEdF1dOX2kMboh+XDZIgyB 8cY+t8tPQGIV3175uLb1BYYbafvX2MFeCToAZKN97JdYH1iO5V50JuUHRHWkai3pNeYc dt0hm/TA30vd0Qkext4EJJGjjo8bU+lq208wE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dMgFd+B/b3ecsxP2le2rClh9lvDaOEHIxgh4qPul3FA=; b=tEhOACcleAMYJY86ZW2JAQEqodH8KUu0/nj9uyLtpUlsU8UOS8ypgCj+7FMSnSaGiB lGeoltr7tCT1rbm0FX5PpUV3/lPveexH0a9CSaH/mJPwGUUCSgyaOTFAmqBzp04EkSVd C47eEEelq7RJNE8s4cXH/k7LB58GLlqyF8ZJu+AnjmscNLsbrvI2d032ytneWAncLcnr 5Us4dmYkDCQOhlrKLQwyF3hpTAZv4S9xKc6a9eivqwtHEQmkW6/dl9PlvL71klkpiz99 v/3zzAU8GR7f/HRjNHw1DWR2jwkUaNXkK/QvUkLRiI7fOgjWoQbo2rT4Pv2awml4/dl6 j/Lg== X-Gm-Message-State: AJcUukdGAhMAcsMSgwUGv8/P4hLZsjZQYuUjZUZDlb5d1QOMk5Dv5dvi menUfsSqVNkdLM4Uh0mNecbaAQeEUPrEhw== X-Received: by 2002:a1c:ac42:: with SMTP id v63mr8630637wme.119.1547670165378; Wed, 16 Jan 2019 12:22:45 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:44 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:27 +0100 Message-Id: <20190116202236.6977-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 02/11] StandaloneMmPkg: add MM_STANDALONE MemoryAllocationLib implementation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This MemoryAllocationLib code is based on the staging implementation of StandaloneMmPkg, with the following changes: - use correct MODULE_TYPE - include MmServicesTableLib instead of declaring gMmst directly - update code comments referring to the MM core Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c | 822 ++++++++++++++++++++ StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf | 42 + 2 files changed, 864 insertions(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: jiewen.yao@intel.com diff --git a/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c new file mode 100644 index 000000000000..c7c1282babff --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c @@ -0,0 +1,822 @@ +/** @file + Support routines for memory allocation routines based on Standalone MM Core internal functions. + + Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include + +/** + Allocates one or more 4KB pages of a certain memory type. + + Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated + buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. + If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + + if (Pages == 0) { + return NULL; + } + + Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + return (VOID *)(UINTN)Memory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocatePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiRuntimeServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiRuntimeServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ) +{ + return NULL; +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. If it is not possible to free allocated pages, then this function will + perform no actions. + + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreePages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + + ASSERT (Pages != 0); + Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN)Buffer, Pages); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates one or more 4KB pages of a certain memory type at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment + specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. + If there is not enough memory at the specified alignment remaining to satisfy the request, then + NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN UINTN Alignment + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + UINTN AlignedMemory; + UINTN AlignmentMask; + UINTN UnalignedPages; + UINTN RealPages; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Pages == 0) { + return NULL; + } + if (Alignment > EFI_PAGE_SIZE) { + // + // Calculate the total number of pages since alignment is larger than page size. + // + AlignmentMask = Alignment - 1; + RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment); + // + // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. + // + ASSERT (RealPages > Pages); + + Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask; + UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory); + if (UnalignedPages > 0) { + // + // Free first unaligned page(s). + // + Status = gMmst->MmFreePages (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); + UnalignedPages = RealPages - Pages - UnalignedPages; + if (UnalignedPages > 0) { + // + // Free last unaligned page(s). + // + Status = gMmst->MmFreePages (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + } else { + // + // Do not over-allocate pages in this case. + // + Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = (UINTN) Memory; + } + return (VOID *) AlignedMemory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return NULL; +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. If it is not possible to free allocated pages, then this function will + perform no actions. + + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + + ASSERT (Pages != 0); + Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates a buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePool ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN AllocationSize + ) +{ + EFI_STATUS Status; + VOID *Memory; + + Memory = NULL; + + Status = gMmst->MmAllocatePool (MemoryType, AllocationSize, &Memory); + if (EFI_ERROR (Status)) { + Memory = NULL; + } + return Memory; +} + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocatePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ) +{ + return NULL; +} + +/** + Allocates and zeros a buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer + with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, + then NULL is returned. + + @param PoolType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ) +{ + return NULL; +} + +/** + Copies a buffer to an allocated buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return NULL; +} + +/** + Reallocates a buffer of a specified memory type. + + Allocates and zeros the number bytes specified by NewSize from memory of the type + specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and + NewSize bytes are copied from OldBuffer to the newly allocated buffer, and + OldBuffer is freed. A pointer to the newly allocated buffer is returned. + If NewSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory remaining to satisfy the request, then NULL is returned. + + If the allocation of the new buffer is successful and the smaller of NewSize and OldSize + is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). + + @param PoolType The type of pool to allocate. + @param OldSize The size, in bytes, of OldBuffer. + @param NewSize The size, in bytes, of the buffer to reallocate. + @param OldBuffer The buffer to copy to the allocated buffer. This is an optional + parameter that may be NULL. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalReallocatePool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldBuffer OPTIONAL + ) +{ + VOID *NewBuffer; + + NewBuffer = InternalAllocateZeroPool (PoolType, NewSize); + if (NewBuffer != NULL && OldBuffer != NULL) { + CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize)); + FreePool (OldBuffer); + } + return NewBuffer; +} + +/** + Reallocates a buffer of type EfiBootServicesData. + + Allocates and zeros the number bytes specified by NewSize from memory of type + EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and + NewSize bytes are copied from OldBuffer to the newly allocated buffer, and + OldBuffer is freed. A pointer to the newly allocated buffer is returned. + If NewSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory remaining to satisfy the request, then NULL is returned. + + If the allocation of the new buffer is successful and the smaller of NewSize and OldSize + is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). + + @param OldSize The size, in bytes, of OldBuffer. + @param NewSize The size, in bytes, of the buffer to reallocate. + @param OldBuffer The buffer to copy to the allocated buffer. This is an optional + parameter that may be NULL. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +ReallocatePool ( + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldBuffer OPTIONAL + ) +{ + return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer); +} + +/** + Reallocates a buffer of type EfiRuntimeServicesData. + + Allocates and zeros the number bytes specified by NewSize from memory of type + EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and + NewSize bytes are copied from OldBuffer to the newly allocated buffer, and + OldBuffer is freed. A pointer to the newly allocated buffer is returned. + If NewSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory remaining to satisfy the request, then NULL is returned. + + If the allocation of the new buffer is successful and the smaller of NewSize and OldSize + is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). + + @param OldSize The size, in bytes, of OldBuffer. + @param NewSize The size, in bytes, of the buffer to reallocate. + @param OldBuffer The buffer to copy to the allocated buffer. This is an optional + parameter that may be NULL. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +ReallocateRuntimePool ( + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldBuffer OPTIONAL + ) +{ + return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer); +} + +/** + Reallocates a buffer of type EfiReservedMemoryType. + + Allocates and zeros the number bytes specified by NewSize from memory of type + EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and + NewSize bytes are copied from OldBuffer to the newly allocated buffer, and + OldBuffer is freed. A pointer to the newly allocated buffer is returned. + If NewSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory remaining to satisfy the request, then NULL is returned. + + If the allocation of the new buffer is successful and the smaller of NewSize and OldSize + is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). + + @param OldSize The size, in bytes, of OldBuffer. + @param NewSize The size, in bytes, of the buffer to reallocate. + @param OldBuffer The buffer to copy to the allocated buffer. This is an optional + parameter that may be NULL. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +ReallocateReservedPool ( + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldBuffer OPTIONAL + ) +{ + return NULL; +} + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. If it is not possible to free pool + resources, then this function will perform no actions. + + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreePool ( + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + + Status = gMmst->MmFreePool (Buffer); + ASSERT_EFI_ERROR (Status); +} + diff --git a/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf new file mode 100644 index 000000000000..8776e34e7c06 --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf @@ -0,0 +1,42 @@ +## @file +# Memory Allocation Library instance standalone MM modules. +# +# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = MemoryAllocationLib + FILE_GUID = 54646378-A9DC-473F-9BE1-BD027C4C76DE + MODULE_TYPE = MM_STANDALONE + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x00010032 + LIBRARY_CLASS = MemoryAllocationLib|MM_STANDALONE + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 +# + +[Sources] + StandaloneMmMemoryAllocationLib.c + +[Packages] + MdePkg/MdePkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + MmServicesTableLib From patchwork Wed Jan 16 20:22:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155751 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096640jaa; Wed, 16 Jan 2019 12:22:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN7hCzflJhKFrmY18JLwJD1ec8jaYbwvEgdv1nSAulgL5s2lZ9782QZjQrKvF3jhVI3py/L8 X-Received: by 2002:a62:528e:: with SMTP id g136mr12110950pfb.111.1547670175650; Wed, 16 Jan 2019 12:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670175; cv=none; d=google.com; s=arc-20160816; b=FE5Sl92YkdAL9nTkt8wkUNinNyqX8dOXFBS/CLqBAL1WwK/HiaazZxKqkJX0t5fuPY qu4Tya6Gn7hVS5S/6M/8Ig2t1XRks+5mgmrpt/Wje/EO2BcpfAgKo6aOEEbeHYZYDjyY i8G8X9LHQWtDrg9jB/obqKtfP+MUdJz4e00GJgBwMOyUn1s0jGeJH2fJSnIeZlHi1+SA WXcNVqlcj/Rxq1S6uILGVxOFoVvYQZ/lTuO9O8liBilr3KjJveUg8IEFoKEgyWoQxigB +LspD2CleEqggNhQ0oTIb6RmDEyKfy9eriZAAvA4zDYEWsQFrVlMZRO/IRfEpvHwDDVd pkyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=PFVLYl2hdOeeRR/yTg+cZbEdVX5p/+FKE6fC9PBe+QA=; b=uqaN0agkH/4fufq0II3cgVidsahK45BrspP6Gak9z3LY7KrrGJmF2x0W8drP8wqUEq Q49T4KoqlzS4gSUgwyfUzgT9t5Ow/hsc7RBV8weMxM4oXDmjrMkGnO01bIG53pIglAA/ znl0bf0pGMUWYWMXi/7xASmGhbVcYwajq83p55suainNq3ixKB7absL1GNfFZ2GaDJps AJh/fP5LPyOUW/zH+0YmtmBL7rKgh/rUvaaNMLwCHYngCeZzcv0RFCchv9afghCgPFED H2ZMNfSWQOLI2V/6muTBefFmqZt2evr+yLSsSa2tr1T8JdexBJxybinpI2HvUYG+VvTX CEiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FUp6DMaw; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id d34si7515592pla.80.2019.01.16.12.22.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FUp6DMaw; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DFBCA211B819E; Wed, 16 Jan 2019 12:22:49 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::344; helo=mail-wm1-x344.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D1DA7211B76AA for ; Wed, 16 Jan 2019 12:22:48 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id b11so3458095wmj.1 for ; Wed, 16 Jan 2019 12:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K3AS8wZmW7gmPg5p7BnpIDhWtxvaqsZ9hbA0Q5Uh7LE=; b=FUp6DMawwYANisIgCrkZ83vzTStUnLlvk62d7NtvC14IVHcQphymUnEbITiJJEJE+W 6+hx4Tdf8LRbzWoWTGhNJ0Y+LSUT6pUEhbTFNRdjdw8UI9BglmtL0Wj5SYJ8PdNAyCnO mTwET9EDlJiPRY7Aw7oUK+jsMavljyGvH7Gg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K3AS8wZmW7gmPg5p7BnpIDhWtxvaqsZ9hbA0Q5Uh7LE=; b=nW3rl8Fg3VVc0f34cJhPBqu48yuRzf53Y3IeCWSBfr+6oyc9VDCALC5ycM/gBgInKa vSEmGHVLXnC55lqKLVSjCAG2giIGUKsQl8FEufIpw2oND4bq7aIjvhLuH8O6qh2miFhf JtLh80gRKTxqQ05EtqT2sb8uhWOpy+PsgOUoG6Pt+iZ3LFRtcghYhMk8Bt+XK7WsQRqg sMSKoYroQ/CszOm9E8N6Ps3Nn1OIN9FHlP2SAlQb3wluMmUDV5vT0rGLQAFASwzv2HZ5 YlUmXfKDRpUVYkxzfsg2es92dhng4PWk9O2SmNy0sPUi7sU9uqw0IOCn/zy7MaNS2txo oK3w== X-Gm-Message-State: AJcUukfe9DnPHzeK7PCa9ED/qSTzdiQAw0IXPZBOSX38VaqxoiB6nsp2 Q78afwGqTI6jD2XJOGpvJgo5Jms9nPabmw== X-Received: by 2002:a1c:1b8d:: with SMTP id b135mr3354135wmb.115.1547670167057; Wed, 16 Jan 2019 12:22:47 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:45 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:28 +0100 Message-Id: <20190116202236.6977-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 03/11] StandaloneMmPkg/StandaloneMmCoreHobLib: restrict to MM_CORE_STANDALONE X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Remove MM_STANDALONE from the list of permitted modules for this library. It should only be used by the standalone MM core. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: jiewen.yao@intel.com diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf index db19d3c926e8..ac036e31cf5e 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf @@ -24,7 +24,7 @@ [Defines] MODULE_TYPE = MM_CORE_STANDALONE VERSION_STRING = 1.0 PI_SPECIFICATION_VERSION = 0x00010032 - LIBRARY_CLASS = HobLib|MM_CORE_STANDALONE MM_STANDALONE + LIBRARY_CLASS = HobLib|MM_CORE_STANDALONE # # VALID_ARCHITECTURES = AARCH64 From patchwork Wed Jan 16 20:22:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155752 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096734jaa; Wed, 16 Jan 2019 12:22:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xy6tMRShuUXCwArXMISOQtVMEswaKQJz0vzZixoo7Mbju/qUDK/teYocfBYlqNPW3pOkH X-Received: by 2002:a62:3541:: with SMTP id c62mr11600124pfa.19.1547670179400; Wed, 16 Jan 2019 12:22:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670179; cv=none; d=google.com; s=arc-20160816; b=owfwLZKKTySLJmVhS7r7RlqErOCg8c524rb0d28o/LX87cQeA03LOOpli+gGSikbYH Cl6Q2vnTbLXLb1QqBcwKHOeRn+e5ezNhIrjgalWEnXEUXnwl9mDXQOKqTh1YNNYSBV/m F6GfRJA1uySVZodZxfKl3z4fH3k49lRtP0JB2ZcuRwaj6gaG3b5FL4uefu/DtLU+SUdD tE5hbH3vx5wM+ozca4VW4a5JUAbBul8Gm9ChTtvowWv2Wf7KiU/+TpN3kbSMFEYis2lz tiyzXctWkw8AU+lvKvxocKOLPGyGvBMX0m5FhjbotnHuyEiAJBa3hXByWJQdWgaXw72/ I6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=ovHhHZHanB581pfN83KoptBLkfZP311lBBbcEFIb8Ts=; b=wYlGXlfYB9NagyarF7HZViZJ6JgIiUzajJAoRt4go415wrmN1NxzhJfvGo1hNY8x4w HBdvCvzbqQyc2LQ4UN1daPmR705KMD1yoOAtNg/rVH8pf5SoDHmnB0RqT+Jg18sBWUWz XMfb9ZnVrfTQLpEvdyNQBvSO/+rdvfQt0/MGHaZebBx7COVvi020qkxCWRLHteEpWVTf PQ5OYE1+sP9tcNbcOmpyS8Fi0K4shxeAVbMgwgRyG7H4JIE+GsyE2HfFSOPrUPDbhV2L 1hN8AUxGb4Dvuv4kdhs2BKmd1PJg1VYtLEAr7H1evOesp09z7PkftUfrHze1UMyVTY7y yXFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OxoG5cqI; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id m33si6601326pgl.379.2019.01.16.12.22.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OxoG5cqI; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1A71D211B81A3; Wed, 16 Jan 2019 12:22:52 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::342; helo=mail-wm1-x342.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 85D2921CAD9B2 for ; Wed, 16 Jan 2019 12:22:50 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id a62so3445229wmh.4 for ; Wed, 16 Jan 2019 12:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jl/FlFCahcN8wqk9alo6HvXlgW1kKXM7FityXdAUMQs=; b=OxoG5cqI9i44VARoR6KnDjZaHC61F0H7OcA8tPZ88Z7LlT9pOZuxa362+Y1eVRp+tr n8lbFjGPKieKl3Jaz44SzAHWg+faxsrk1IRVES7cayfNHvxEPg2h7nKKlxK+gpeduTVv 61B/OeqQoGCrjIymQZnmH/wzyDz//gllP92/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Jl/FlFCahcN8wqk9alo6HvXlgW1kKXM7FityXdAUMQs=; b=H1QqumYXUSihYUfTelLIb2Lgs9nRP5P4Owl8w8gHR2as1juIDemMBKHqfdOUtF4GqU o31SKHYH8PpEpyhMuMT9i7xRy5cPSQUHlY8aIXkuaXwdqpddueLms+YH1R46pDcrnyuL Q7RpYrKGmLs4cSQ5THTTdmH3YUSOuKxnCzIMkCFrqBRgEvcocUZmmf4SIVwqSP+L31M3 aSug3l/SezLIdeztmS5mKok69M+G5jmmcd2+4civw2nadWW+AzTTlJQ0W/aUwT8Ozz1A HzncvJEzqJaAdbtde0PgSbyjV/odPI3ckD28an0Ovl9qRd7t3KvJO/ZapsViqoSB692m fFbQ== X-Gm-Message-State: AJcUukcEzhgugAr6HmkjOM4vRflm+0XbdX8KcsrOu8TRKxsrxRil/6L7 G1OW2UAK4/85YMFe9tReMH8bAaD7/DEqCA== X-Received: by 2002:a1c:2501:: with SMTP id l1mr9303502wml.102.1547670168678; Wed, 16 Jan 2019 12:22:48 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:47 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:29 +0100 Message-Id: <20190116202236.6977-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 04/11] StandaloneMmPkg/StandaloneMmCpu: fix typo Standlone -> Standalone X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Fix a couple of occurrences of typo Standlone -> Standalone Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Supreeth Venkatesh --- StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c | 2 +- StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c | 6 +++--- StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h | 8 +------- StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf | 4 ++-- 4 files changed, 7 insertions(+), 13 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c index 2814577b3fcc..25114821448a 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c @@ -65,7 +65,7 @@ EFI_MM_CONFIGURATION_PROTOCOL mMmConfig = { STATIC EFI_MM_ENTRY_POINT mMmEntryPoint = NULL; EFI_STATUS -PiMmStandloneArmTfCpuDriverEntry ( +PiMmStandaloneArmTfCpuDriverEntry ( IN UINTN EventId, IN UINTN CpuNumber, IN UINTN NsCommBufferAddr diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c index 85a9c108aea4..203a32baaaf9 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c @@ -74,7 +74,7 @@ GetGuidedHobData ( } EFI_STATUS -StandloneMmCpuInitialize ( +StandaloneMmCpuInitialize ( IN EFI_HANDLE ImageHandle, // not actual imagehandle IN EFI_MM_SYSTEM_TABLE *SystemTable // not actual systemtable ) @@ -147,8 +147,8 @@ StandloneMmCpuInitialize ( // Share the entry point of the CPU driver DEBUG ((DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx = 0x%lx\n", (UINT64) CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr, - (UINT64) PiMmStandloneArmTfCpuDriverEntry)); - *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandloneArmTfCpuDriverEntry; + (UINT64) PiMmStandaloneArmTfCpuDriverEntry)); + *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandaloneArmTfCpuDriverEntry; // Find the descriptor that contains the whereabouts of the buffer for // communication with the Normal world. diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h index 7b38b65e1242..543467f67576 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h @@ -40,7 +40,7 @@ extern MP_INFORMATION_HOB_DATA *mMpInformationHobData; extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig; EFI_STATUS -PiMmStandloneArmTfCpuDriverEntry ( +PiMmStandaloneArmTfCpuDriverEntry ( IN UINTN EventId, IN UINTN CpuNumber, IN UINTN NsCommBufferAddr @@ -55,10 +55,4 @@ PiMmCpuTpFwRootMmiHandler ( IN OUT UINTN *CommBufferSize OPTIONAL ); -EFI_STATUS _PiMmStandloneArmTfCpuDriverEntry ( - IN UINTN EventId, - IN UINTN CpuNumber, - IN UINTN NsCommBufferAddr - ); - #endif diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf index 9e6bbabdb103..d261e51ebc75 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.inf @@ -18,12 +18,12 @@ [Defines] INF_VERSION = 0x0001001A - BASE_NAME = StandloneMmCpu + BASE_NAME = StandaloneMmCpu FILE_GUID = 58F7A62B-6280-42A7-BC38-10535A64A92C MODULE_TYPE = MM_STANDALONE VERSION_STRING = 1.0 PI_SPECIFICATION_VERSION = 0x00010032 - ENTRY_POINT = StandloneMmCpuInitialize + ENTRY_POINT = StandaloneMmCpuInitialize [Sources] StandaloneMmCpu.c From patchwork Wed Jan 16 20:22:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155753 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096793jaa; Wed, 16 Jan 2019 12:23:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN5wiLYPyLSb7kD5DlqYKncD4oqQJFyMiKgGHvamClp94h2aoOR4gzGFbrePkc4vFGDMsdYu X-Received: by 2002:a62:cd1:: with SMTP id 78mr11641885pfm.219.1547670182925; Wed, 16 Jan 2019 12:23:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670182; cv=none; d=google.com; s=arc-20160816; b=se/QgEGkJpMl3Xuvdtz2YhHSyAG+oJaCYQPDiudnsczxhlzLLkMaXZswtbW1PbicdA YBW2IzTejQGN9omCDZJnnN177EzABqR+lSTcNf8NYg4ieUe4fB4JqVjyr52lSO+Gm6Gn coS75+ndr/bhspnk/ZJnNlHmQyr+w/YIZTHe4f0l5Y0bI0RSnHtPICtjggcAvQQQBSBy UaCod5m4Mn3Z+wIu7HpOPfV3yFMpf3bJwLKzeMVplSV1/zPOeEy6mJeVjbGcnIYqkbeA H8dYfIVk0bY/eRtMRGd/SqM/TZEum2PKSRGb3V/jhodX7sMLvGuU/TiJrotDynHY1tla B9IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=MKdMD1+uNsBsbeLpZYBkIGuZ8NzKNcokJC8JPdHrQ1s=; b=ydUd3T6d64XoN/SNXwR68s97zLkGJrkAJm2TJdBX0VFKnCDwmvRHS38vVU3K4qp05K wmWtuybJT15iiIm+cQrhX9Z6nRn9ZdQ+rpplPXEyhgvJyMYSL+U9BTCGQrKLB7xidHuI 7ssx9t8Ls5Va6BLViF2LXL1xK6Vgvs4lTcnyREYFF1w+32mZMQBeNSExcL9xM1mzI8tm XGitn4P85/plbm4tbLjrA958eNig9XMPSbjxOFc8aM+tp/RVvdlcWa4BjYoaAAnf16Pw mHuCYVaui05Vo49CCzQRR3AxefCCEEQXIKcPHOwRHF9evn+ggnxdcAIWt52IFfqYdDOY FoAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XdxnXFEH; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id bh5si7002024plb.42.2019.01.16.12.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XdxnXFEH; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 529CD211B81A6; Wed, 16 Jan 2019 12:22:53 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::32f; helo=mail-wm1-x32f.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D61EF211AF9E8 for ; Wed, 16 Jan 2019 12:22:51 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id m1so3457219wml.2 for ; Wed, 16 Jan 2019 12:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NO4R12nkrb9A+iGMEceCHH46ajRX+Qlrv3yufHJs4mU=; b=XdxnXFEHwVRXVb0IcfhS4CRPo40Kx8c7Z8tDdP8R2yZbN7V+YzdKU9WFfhSMA8lza6 Cgm8ZRHpCodoe5zbk//K//CXI8kLzIykxTBxNH2e9JtjvtnoIU3kxn4WHHYaXCJuqq8S sBpeFFNmkJeewmw65BA26YqCSn2JKnxJ0Jy0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NO4R12nkrb9A+iGMEceCHH46ajRX+Qlrv3yufHJs4mU=; b=MN2nOCjpf+dl0PdtkBbVsAdmyLZcwljCOKQR7AaBg1X2X+RzS26IYZtphV8lzP1pn1 /+p0/Q6icSD1+LzS7uhBOqHpUv0dxBNlOdQj+VlfAa3x/kVsrSQabYQBzG+M+fn/TcpK 5uxyPvfAJli7OsDvcuasR9Edtdh3RSFOvfSo272f8PwUNJb/2IWuax5Hvo9WCwWXfBPN lZMEuwQ1dUFD5xS5BKB7/CczjHFuf8G5xhItkIokq8krWCAZH7pnT+rBJMNuJTiX/Ji2 +6IDfd3STM2rwIyvF1ZoESezgm1j4m4yRa63aT4WvCUati1R4LW6qFaJUb/s3lovyuX3 CL6A== X-Gm-Message-State: AJcUukcmDoLmUfqYBp6jHiqvXZiGWc2Xayh7L3RGtfVQezX5wY/MMq1F KlJeGJh0/8Efk9bFtBzTxfsdIbX2neGiDQ== X-Received: by 2002:a1c:ab87:: with SMTP id u129mr8960905wme.104.1547670170045; Wed, 16 Jan 2019 12:22:50 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:49 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:30 +0100 Message-Id: <20190116202236.6977-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 05/11] StandaloneMmPkg/StandaloneMmCoreEntryPoint: add missing SerialPortLib ref X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" StandaloneMmCoreEntryPoint calls SerialPortInitialize() explicitly, so add SerialPortLib to its list of LibraryClasses. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Supreeth Venkatesh --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf index 3222cd359f3e..769eaeeefbea 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf @@ -43,6 +43,7 @@ [Packages.AARCH64] [LibraryClasses] BaseLib DebugLib + SerialPortLib [LibraryClasses.AARCH64] StandaloneMmMmuLib From patchwork Wed Jan 16 20:22:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155754 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096860jaa; Wed, 16 Jan 2019 12:23:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7YcigMb/ZE6+Qj6CROEVWn4ep+3povGarWFoPwt3T9RDPVIvQe8IJEM7WVo9LYEIP46qR7 X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr11859609plb.55.1547670186679; Wed, 16 Jan 2019 12:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670186; cv=none; d=google.com; s=arc-20160816; b=W5z36HUbb9XA9BZEApKtzLe3aquJmwevKsd3Hd1+F+77tY6BdDksGBlOdsZh+G21Gc n7bKRAcHNllbOimv/uYwUKBJBRJX+9NBIpbtdY8c1ANJiLxxpl5QNIKupRmIlG0ULhVU f+T+ZMQgVSB1XAWAbH4KbVwFIGjaAF/qMAcSbhJNBOEwv/5NBVrdOTXv+xePG0+0QJ0J wbjKw7GTby+2lJmlaEmQ/GIv8JPTAFoPIgKwrTHq6/xccu74ETpcBgOq1rQWIPf/AG+M X0vPFTRb3QqknTm14Cd7Pk5tkGg1/QqmT4PdCZWZyUeaV3BsXPDxj9y+bHP5RH7kFy4M yxPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=UVXecLeS9Jh6+blOKwM6vfXNn2Va2B0x4RngKeh0Gj4=; b=PzpHbTSCvmgZAzbLNdjtLQKco8HI+Oo5gZV1tHxYCJlhj/d47+jdJJONp9DGPjjkQs s60c++eR2F+PMWpGBnrwZbqY5SDu9zbVhqhN7nYjgy/w5uqDwCBHPb6PmkVBStBU5lUi ZATJMTU/lZp9E0b/jKqa5RpcjSTXHXa+zTdEUQUPin1p/teSLDDlogAYYxYzrhsgwc3f m6rU4e8u06O969TkzLyoLycyYedvchuxPYUdf/PdFeJ+0599TEuiZaj9vci52l1oe5TT 5pCtI2OEwNsv+rcVOcAfgLuwBhV4Uj0p3umTCp/DQDiNWY5zpecqVkydWfRpDpC3iKDF xVHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MUqvUz5+; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id gn22si6760830plb.19.2019.01.16.12.23.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MUqvUz5+; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 810A1211B81A9; Wed, 16 Jan 2019 12:22:54 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::444; helo=mail-wr1-x444.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 16801211B76AA for ; Wed, 16 Jan 2019 12:22:52 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id t27so8482971wra.6 for ; Wed, 16 Jan 2019 12:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=X2M7UBPF7Gie++HujcaNxBU7lIsaE0uU6J7TWbQ5/0w=; b=MUqvUz5+c/F8GlV/bOnX6ajXnwO7O4JWoy17QTHdYxp4Lv6wyU+pqCI6ME+dGxxC8Q xwhruEERssxC/ckbQ6dkxIINRfB8ASzTgtY1Q6vVw4ZLHbjGXXE6u7/pFoxPW/C9DJ5B JbQALcNjHuIXYkfP4RY0eTFWBGP02e4amutqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=X2M7UBPF7Gie++HujcaNxBU7lIsaE0uU6J7TWbQ5/0w=; b=Gr/eBII98k99JTFkGM6UUbTfkoMF7PM054YCETxuvNMv6FI75HELq+A4GliXbiwM9H NDhUYG145BTNGDpwoCDNUD8Dg3o68Du1rpKG3FZeR2SwsXyi9lGVeeEz2uG8/pQo9V5L SjQpqLCjggnSBS0DVIPOFqy4iQ+pZwqNE0jR8A5+NeHTbzm5Zg19HUCvWTUevTX4+iYJ 8Xkd5rWsQdUYY1SLlk3jB4bsE9QBTfT2whxBrF7pAgMxxmRHLHTjKIuAnbCG+jWcvd2E pj7GfFlUTx5vhx+vqEjcmvqI7QXMG6MqKWE4x/Uv5aml0YPUdlAVYp+zjwNyVDQ3sz1L qpnA== X-Gm-Message-State: AJcUukennZp0dAYWjsok7O9h51LHINe6pYpNV2T51FTUOvjqYwEeudLz Sf6cESYlz4jlwZeM7k8TcRsqXi+rbFxVGw== X-Received: by 2002:a5d:4250:: with SMTP id s16mr9080749wrr.253.1547670171312; Wed, 16 Jan 2019 12:22:51 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:50 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:31 +0100 Message-Id: <20190116202236.6977-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 06/11] StandaloneMmPkg/StandaloneMmCoreEntryPoint: use %a modifier for ASCII strings X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" PE/COFF section names are ASCII strings so use %a not %s. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Supreeth Venkatesh --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c index 60c1f66b83fa..3ca7f6660f47 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c @@ -78,7 +78,7 @@ UpdateMmFoundationPeCoffPermissions ( "%a: Section %d of image at 0x%lx has 0x%x permissions\n", __FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Characteristics)); DEBUG ((DEBUG_INFO, - "%a: Section %d of image at 0x%lx has %s name\n", + "%a: Section %d of image at 0x%lx has %a name\n", __FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Name)); DEBUG ((DEBUG_INFO, "%a: Section %d of image at 0x%lx has 0x%x address\n", From patchwork Wed Jan 16 20:22:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155755 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1096933jaa; Wed, 16 Jan 2019 12:23:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4SMkZc8trolT4MfVZ3LZ5SdO1dncqq44PMRw9XYbqHTXYGaD1bHEDCDYD9umW9mIQ3Qe9p X-Received: by 2002:a17:902:4523:: with SMTP id m32mr11673093pld.53.1547670190525; Wed, 16 Jan 2019 12:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670190; cv=none; d=google.com; s=arc-20160816; b=z0ncyb8N4bYcDtNdM7FYAJ7MhhZBkt8+gWJtglGx2g9y74hKaZHfik3fhckIdP3vKQ 2+Ccc+VeXM4kmEymQwfSGWLIa1Z/r12RStlJg2HCwC7wVnreHAazn5vJo1PFT87FdXkJ zkK1OzGsOSBGlKlYU8J4eiRDNONN9r0D4gfRQdY5zMuKXi+pAjtsuNHBwAJ1jl0A9gWg ZlUM+pb6Xs9rB5/8C7+STG7pd0XMM7TTWWBLqtBW1DNyPfcmABmXugZBOarcKJ4fEH+B XVL2EVA0JtwF6+C8G0MGmlvHLzkwLTzhUaW7o/boBMCNnv96+R3Fn7skKjl6LcOpB0ki 7Osw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Uh5pexYuDFa4hZC/IlYCsFa/9tRiA5q9PcI2BEHU9J0=; b=ZYgymhsgp3mbP+aSD5BxdIH1FvVUOdgdrY4pn9kkZpvPqwH3vfbyaivm+tmDofqxPz /LsPhAbm9TaqjECXSMRD3FA68jrJY6pWriZyOMyvB9dCOyYP5bmw7LGz5ZSJI2uDS2ZX 4dUnVepbbIqF38CdByH15KxFHMNSk6pviykdEDRm31gC2VBYrDbnuJL0BYG3+JKPXLxh 7/fBQasL2jn+Hk2fWU+lXBXJnj4YlZB73O9xZXWheg1Rru8m/ZTavyYhmtjKnaMsxKzC tK22DBgVnzQb8fkxXuZ0sOyHlwn3sFTxWsTn1p6TTQpx3HRlJaMRNmb0NLksKzR+W76z 9CZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Tbn/qES3"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id h5si7059313pgg.230.2019.01.16.12.23.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Tbn/qES3"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B62FC211B81AB; Wed, 16 Jan 2019 12:22:55 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9BF97211B81AB for ; Wed, 16 Jan 2019 12:22:54 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id f188so3417023wmf.5 for ; Wed, 16 Jan 2019 12:22:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xYvAK108fpARZFq4UbDWU58ZBt2yeCKfLKt/exnNwwE=; b=Tbn/qES3FhGaDAs1jdY8I5RXBaU+dGZQYWK5QI9XelAtKBIRI4fXmTn7fkCERupGfn OzGKENugmDFczl+bid0a+cdA5Jc68DN2u6p5A0oLbOY4w8kcmu28Hyf9QkQSxv5Ix149 GjSywLzDwUyCAxDAg3KDkNdYvRNZO0dd3Vfwo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xYvAK108fpARZFq4UbDWU58ZBt2yeCKfLKt/exnNwwE=; b=D9CF0SUZl+dPi8GZBcBoNjh//KfK+pLfO9aYo+O7knzZWfZUw/zq46smY6swIRCRtv U6AGUW4uzS9yU7Tt/mn/Am4qyc8O8Li/dhU4XC6KyuOYR5KToeorxkGEhjX00duloOk6 xb9WedzXh8pmb1FZHBuAs4qmwPrvJK/ETY8ibRPIr72IDrHGsAsdQz2UC1pG87aOy2V8 Ey2jfnJsb86VJPjSycyWU1eMVfQDd0mf0HtGvu7D0NW3Qc3NBS6Q4tURLn3zztdUE3Wj eXRq0pUzD16krmIdpezpvqgAADBbUjPsM3XjkvGZxWZ36SwiAHD7rDwu5mppmtb6AJ10 XVnw== X-Gm-Message-State: AJcUukfJtx0mPWUDXcYeKwNjxT0apvga/V3Tk2v3zSXPlPid+ZiTSN6Y VfuMrNANwZ9Qx0VwX5uOTz1XZipNvvNNkw== X-Received: by 2002:a1c:dc86:: with SMTP id t128mr9438957wmg.42.1547670172867; Wed, 16 Jan 2019 12:22:52 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:51 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:32 +0100 Message-Id: <20190116202236.6977-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 07/11] StandaloneMmPkg/StandaloneMmCoreEntryPoint: remove bogus ASSERT_EFI_ERROR()s X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" ASSERT_EFI_ERROR (x) is a shorthand for ASSERT(!EFI_ERROR(x)), and so it should only be used with EFI_STATUS type expressions. So drop two instances that operate on other types, since neither looks particularly useful. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Supreeth Venkatesh --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c | 2 -- 1 file changed, 2 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c index 05ed6c8dd0b5..5cca532456fd 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c @@ -295,7 +295,6 @@ _ModuleEntryPoint ( // ProcessModuleEntryPointList (HobStart); - ASSERT_EFI_ERROR (CpuDriverEntryPoint); DEBUG ((DEBUG_INFO, "Shared Cpu Driver EP 0x%lx\n", (UINT64) CpuDriverEntryPoint)); finish: @@ -303,5 +302,4 @@ finish: InitMmFoundationSvcArgs.Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; InitMmFoundationSvcArgs.Arg1 = Status; DelegatedEventLoop (&InitMmFoundationSvcArgs); - ASSERT_EFI_ERROR (0); } From patchwork Wed Jan 16 20:22:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155756 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1097024jaa; Wed, 16 Jan 2019 12:23:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN6BtdLkjbAcZJSIJxIgpChHeHSEuypgxILxtSs7EH5OnRv5gwnWlLtk0n2YTlTIoGXma2zx X-Received: by 2002:a81:ad26:: with SMTP id l38mr9266222ywh.439.1547670194725; Wed, 16 Jan 2019 12:23:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670194; cv=none; d=google.com; s=arc-20160816; b=H3GyCUaVh6cW4sD16OzZQp8HT6ii/TLl+Ynj0qcoH3O/RX+3bNp7jW9aEAvcSpLsft SvzMGYYBZ1rbGurewWgDzschs7U8GiwAP17qtSbY4Z9I+4SV1yWeRAErmwqxgurgFn5H HQJdj3wXiPWZ19zOWlxK8Wp+2aHYgBnOsDiwd/D3YfjLsgBLNXAa7z1rrhA4ZoVB4nox KbhXxwG/RnzhbHfbtTIZzD8ZKZqkaI226QTKrjlFmpCaSoXv9iFlPsAcH2MgiEaUc3BM vCG+uK9D5UCvkBbXh9uTx9QGlQtuPHF8n8s0OME1WgM6oxtkwOf2qyuJWDSEnmZGIkc5 1+mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=D479i1fKXoxmMu7EIVj3i4NBXRk4+jmTiJghqIEEWt8=; b=mR7nKkX62X8WWZj4tc7wIrC1/ysDB5xUffBQdGSIK7RmGbArd50Q/ywD18W3ExOL++ OI+HU/Yc8PFmzq+FQ48SCKDAHqeygChL9vmgHIGUa4TZzM6sYuOA+OY1Fe8i+rNd9/hu omufMrldUySsdjg0AhJq6AC/BhhO6H/+88E53UWKUduNdnpxBUY4sxk9RQcV7GOT3WCK cq7ds5Jo4iTvPM2xuUkzSAYUg1fg/TNikm/8V4d9PRpwp+PTynsybBCY7jWbq0nc8Gj7 DfKCn8m63rPlSLSBki2z35i2ZTfiVHRrMu3G8H3Jn6IdLPSfJEwRTIQUiHYAW0cYhYaz YlkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dZfRJ8W4; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id y6si4888828ywd.262.2019.01.16.12.23.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dZfRJ8W4; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EBAA4211B81AE; Wed, 16 Jan 2019 12:22:56 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::344; helo=mail-wm1-x344.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D24AA211B81AE for ; Wed, 16 Jan 2019 12:22:55 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id t200so3471285wmt.0 for ; Wed, 16 Jan 2019 12:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tRa+/INl89H+E9gOy7jcMxo+5Ay5bnSLAEu/QHG3RP4=; b=dZfRJ8W4jz8HYRY58Kpu6R9d7+LSkn1Cxe79WbJ4llKGlg+93kwV0FJOsCPK3Asq+S b3ih4kPJibCZLtuAo0Y1fktseTRdKc9wPsZyzNzRDw+EVURHGOe+PyG+JrAwDQs2Lv6Y mySqXc6SmH5u+qjdE39pLdvWSzMZ2jJFSt1Bc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tRa+/INl89H+E9gOy7jcMxo+5Ay5bnSLAEu/QHG3RP4=; b=LeFoYG4KM7qWv14ZRxAQmQxALg/2s61c5J1Kc5N4D4D6pgMcgXJLgsrhdaG04gOycv 51EuQHjBY6yXu6IxKQzpiGPsPuFnt2znpadCFo5tJis4txBPrqhd7I3KoG0WQDJVwKeq lXmqm/RowjO+y3Aygsrb+/4xcmztpFPP6k0T+veyGczlzwoSoZu706wWyHi2qSny5hQu qJvlrVcuuIazm2ePYyU388PANu8o0LF3X63WxKK7M6Q1FENE3VztNi0PYsr2k5Ag9bMP nXdz5FdmOloRubbMa/n8TrKonpfYvBLRzebnls493XoCNorTHeWqsBi838lU+8+P5xmN pEFQ== X-Gm-Message-State: AJcUukeLjJhoyOMA+nnWAMLXjS8bTAxv5Df+Pt0+h9c4peJSt03NvriS j0IUeM8NRE1TfAlnq1CSvfTDY1U+SCIsSw== X-Received: by 2002:a1c:ac85:: with SMTP id v127mr8061761wme.62.1547670174196; Wed, 16 Jan 2019 12:22:54 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:53 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:33 +0100 Message-Id: <20190116202236.6977-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 08/11] StandaloneMmPkg/StandaloneMmPeCoffExtraActionLib: ignore runtime attribute X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The special handling of the EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER attribute is only necessary for images that are relocated twice, i.e., in the context of SetVirtualAddressMap (). This does not apply to standalone MM modules, so drop the check. Drop some redundant DEBUG output while at it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c index 1c9fec201916..f6bfcc875751 100644 --- a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c @@ -145,8 +145,7 @@ UpdatePeCoffPermissions ( if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) { - if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) == 0 && - TmpContext.ImageType != EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) { + if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) == 0) { DEBUG ((DEBUG_INFO, "%a: Mapping section %d of image at 0x%lx with RO-XN permissions and size 0x%x\n", @@ -158,14 +157,10 @@ UpdatePeCoffPermissions ( __FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize)); } } else { - DEBUG ((DEBUG_INFO, - "%a: Mapping section %d of image at 0x%lx with RO-XN permissions and size 0x%x\n", - __FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize)); - ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize); - DEBUG ((DEBUG_INFO, "%a: Mapping section %d of image at 0x%lx with RO-X permissions and size 0x%x\n", __FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize)); + ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize); NoExecUpdater (Base, SectionHeader.Misc.VirtualSize); } From patchwork Wed Jan 16 20:22:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155757 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1097118jaa; Wed, 16 Jan 2019 12:23:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN57emUlRfmRcAl8vzdQnQA9PB0vRJnp+M0dcCyaFzK9IQYw/Qszhc3KbAhsrFvbBYONczTx X-Received: by 2002:a17:902:4124:: with SMTP id e33mr11671148pld.236.1547670197584; Wed, 16 Jan 2019 12:23:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670197; cv=none; d=google.com; s=arc-20160816; b=qecc3fhigsrw/yQzNKqVzZwtZqlPMuS3gvlolnG0GypSKi3ue5bt+uMKft6Sg8g8i+ /oVMQv5lQ1+m1mzT7kHfZoIKUuLrrz5VYX4Q1n9UnePWrYxagzS5WMsxKqwXBUiRznVO i1TquBo4cGCjG7H/4F1tI+9j5+fedrBy2mzJBtwQ8lfLnAuLGK3spaAeE04XQeI4DgxD rpob69w7D6cR0xdGXDCBqAnWxCT5UNRHpPFJlowjG4hmuZy5FfcOijBtRtvSeXiPStwK UuACu6XFoGPkMUTtt8Vw8kKanfgwelefbSGmeWkyzVULhq60SLn3B1jpEqA+J8GGsS2b ta0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=tEElhh10QdmMPt/ZNo8gYxyiLCvI4KxTvvTY9qkhCd4=; b=pMcoM2QbwohKzWLWgQS98QfnI/xbIkdMBEJjvU0tuyklDPonGoYectebnbAHVH8Ew5 A48vFynyIjK/m7E5IMgkWgAn3wNURyR+nnPFJg04e2+xY3PWRIukQLZBAJvRDCixxOIS lWLTNILS5xomEw0dbZvjxjAu+vIKsWZpWmbUdsm552nvpb6fAc9e09TPH7kilfN1notS BVw/d0MsvvEjKDTg1EA219VTGOjLOcJYhrmxjJE+RTEizLLbxmJrg7ohtl/hm+nrLPCH bB9TtUDI8FqO/9ZTGeLWlMjKDCD6TfRmR6H149OP5hU0lKg89vJmI7u6GrvczebQkWjd //Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="B3Fb/phZ"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id a16si7117375pls.146.2019.01.16.12.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="B3Fb/phZ"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2705D211B81B2; Wed, 16 Jan 2019 12:22:59 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 32426211A759E for ; Wed, 16 Jan 2019 12:22:57 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id t6so8423557wrr.12 for ; Wed, 16 Jan 2019 12:22:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zrkmfQttdsToZzhBFzUUJUcrvh6u3Vf96lPFkeOEPvg=; b=B3Fb/phZVXEZcHyK7Z4wAwMEmaH92ng8Mlt8ipacyZfWRXBAntyABc2yykcmNns1d8 k0UKpE/QAE8B1FgIis1bahsB6JmwX4pZCzEPLELVG8LiF5sI6GO5RxdWR4kiHjGKeayA rCuUaeJEyJCfRjBFpCTrTu4+SzRS9BVRdkHPE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zrkmfQttdsToZzhBFzUUJUcrvh6u3Vf96lPFkeOEPvg=; b=k9DW0en3Q37w3OU9bWEf76UH07JP14E9L9UKWiOZrUX4dOtbyaFAGsqJUgxI29V5xI SAernXimUj8J+Di4ITSv6cYQQOBRmGkPYjGBEeH574XArU1YelVcN+TBekTsgae03Z0n VCzXYZObhAO57hdRmfzmWJn0w0ZmwBdA2ySKJDiHDFlxlBJtW4MZBUOu4Y13glrnG0Kp aSchRJ3767+PIdaFyNyt7VjCZHwYyrkX+0xdPpqOgXEMykEiiBWzKgPRidO/KTrpXv1A w3YuLxfr6935xrixr841T5r/pH0Y7QskNzXbbebwMbZVwSy+vgSVIEivx5xMDiskMDNE xESQ== X-Gm-Message-State: AJcUukeinnISB6c1RWLeLAG50Ix3p4NGspEfKHDt6V3XxG9F0aHyorhZ oEJVSKyKEvZFMmaWvQfxs/YJ1QWA4XKkdQ== X-Received: by 2002:adf:91c3:: with SMTP id 61mr8679130wri.324.1547670175524; Wed, 16 Jan 2019 12:22:55 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:54 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:34 +0100 Message-Id: <20190116202236.6977-10-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 09/11] StandaloneMmPkg/Core/Dispatcher: don't copy dispatched image twice X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The dispatcher uses the PE/COFF loader to load images into the heap, but only does so after copying the entire image first, leading to two copies being made for no good reason. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Core/Dispatcher.c | 30 +------------------- 1 file changed, 1 insertion(+), 29 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jiewen.yao@intel.com diff --git a/StandaloneMmPkg/Core/Dispatcher.c b/StandaloneMmPkg/Core/Dispatcher.c index 8d009b4f80c1..8a2ad5118d92 100644 --- a/StandaloneMmPkg/Core/Dispatcher.c +++ b/StandaloneMmPkg/Core/Dispatcher.c @@ -294,7 +294,6 @@ MmLoadImage ( IN OUT EFI_MM_DRIVER_ENTRY *DriverEntry ) { - VOID *Buffer; UINTN PageCount; EFI_STATUS Status; EFI_PHYSICAL_ADDRESS DstBuffer; @@ -302,17 +301,12 @@ MmLoadImage ( DEBUG ((DEBUG_INFO, "MmLoadImage - %g\n", &DriverEntry->FileName)); - Buffer = AllocateCopyPool (DriverEntry->Pe32DataSize, DriverEntry->Pe32Data); - if (Buffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - Status = EFI_SUCCESS; // // Initialize ImageContext // - ImageContext.Handle = Buffer; + ImageContext.Handle = DriverEntry->Pe32Data; ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory; // @@ -320,9 +314,6 @@ MmLoadImage ( // Status = PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { - if (Buffer != NULL) { - MmFreePool (Buffer); - } return Status; } @@ -336,9 +327,6 @@ MmLoadImage ( &DstBuffer ); if (EFI_ERROR (Status)) { - if (Buffer != NULL) { - MmFreePool (Buffer); - } return Status; } @@ -355,9 +343,6 @@ MmLoadImage ( // Status = PeCoffLoaderLoadImage (&ImageContext); if (EFI_ERROR (Status)) { - if (Buffer != NULL) { - MmFreePool (Buffer); - } MmFreePages (DstBuffer, PageCount); return Status; } @@ -367,9 +352,6 @@ MmLoadImage ( // Status = PeCoffLoaderRelocateImage (&ImageContext); if (EFI_ERROR (Status)) { - if (Buffer != NULL) { - MmFreePool (Buffer); - } MmFreePages (DstBuffer, PageCount); return Status; } @@ -393,9 +375,6 @@ MmLoadImage ( (VOID **)&DriverEntry->LoadedImage ); if (EFI_ERROR (Status)) { - if (Buffer != NULL) { - MmFreePool (Buffer); - } MmFreePages (DstBuffer, PageCount); return Status; } @@ -482,13 +461,6 @@ MmLoadImage ( DEBUG_CODE_END (); - // - // Free buffer allocated by Fv->ReadSection. - // - // The UEFI Boot Services FreePool() function must be used because Fv->ReadSection - // used the UEFI Boot Services AllocatePool() function - // - MmFreePool (Buffer); return Status; } From patchwork Wed Jan 16 20:22:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155758 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1097226jaa; Wed, 16 Jan 2019 12:23:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Ir79V2dQK5vUcyuPLQPinIXmqnaJQzzz8CGV2GFmAmb1/sPc3BfTukZ1KYsyLUPTJncQu X-Received: by 2002:a81:d84c:: with SMTP id n12mr9491044ywl.280.1547670201911; Wed, 16 Jan 2019 12:23:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670201; cv=none; d=google.com; s=arc-20160816; b=RowhN0zrsM4BR1zon/wW8AW5ICQVTc+sAtm+EtWhfbj8VQI94lsdatEUJ8b2VIrX5/ SC6pZW+pHANSX305Xnp4gaA1WkOtzZP87KsSSsxocOLNHAFBXkrGGogx/pQEc9icYGZP m3T9fK8wnkvVbKLISSs2aFuhCweLPFUHQxHH1haVVYTwt+DmYbAa/Yht/sKzwVjitcjI W7wnTOFHCcJJ47AqTf5MNBK6ZPkx6JLAGFhDYTQGAVfSjSlhvjjRCAjkm4wAmxg1woge Hn6u7B38mO210IcgWRo+ivDIDGYtYuND3o7LzCl2olCGxXkOV9ZoOJnYj4xpzwH9DdtY /m/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Y5bhNZ2NgQRcGPlpYRl7AM9qWtKkWncB1FoAhuEH1HU=; b=xU4ymJy14bphD4vcWXbeoUaqlHnZqMXKQgbzAtrLyqwXF2MmjSoiUbUNv1QO4TvG1t C0CEtTgVfiv5G8p8YvS5+MUPkLVEyw7y8VOsN9qKnwBaQEYY1XR3y01WYKQzTM9XTmgA 4TsNKBYwGkyaIsvT/tDqhOV2f51PlNz7z1E3PnfY/ZbwBSWSx/K8bd2Auf0OIkfN1A3r DSt79kLU2ZkYNXkTSquCcJWk4o2JRlkPanQWvWdBa4x6M6JwnLTHRbIjxgDbOJqQCOCN b5dC91mbe/nNZ87iSR4KD6oWt7IN+VBQxqfr1SCBQTS6aRhcW1Uw2lZKAsfu4nwosbLu rFTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YMA2Ugs+; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id c22si4656100ywc.443.2019.01.16.12.23.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YMA2Ugs+; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 505B8211B81B6; Wed, 16 Jan 2019 12:23:02 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::330; helo=mail-wm1-x330.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 19AD3211A759E for ; Wed, 16 Jan 2019 12:23:00 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id y139so3415642wmc.5 for ; Wed, 16 Jan 2019 12:22:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hli/q0XoE/UtzHjDRSUIMt2BcGy9QJBwUJV8lE4bcak=; b=YMA2Ugs+gZj52zF4jFGrKHBaUMNa+ZpTYxXtc97SkY9HFHIX4mRto2Uv+ZHu+HQMhi psJPkO4gwXdgM5aZiMfnNactIRFnCPeDEcJ5k70htwgpJ9LiUH+kDz0+BpMzikiEMhhR eEzl+TfbAFY8LTDcEX2jgtMb/UJXw3PxxuDz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hli/q0XoE/UtzHjDRSUIMt2BcGy9QJBwUJV8lE4bcak=; b=dwFXQrfiX9vhBTfKK6hYHutcpnoJxHTttnmYa/437JAT3nH8o7rBNWic2NPcbzZcMI 8WLsr4XLVGDBjwvxzbMG8Y9J6BPBhOVxPMSVgxp3mq9KWj50ZuINgPmfRpLzZAeva+R6 BYBzx1iDcYZ7ziOOsIn4vzuai4lB25oTEKTx0QvCFmSIHcmkmQNYQ+HaUjg4fVlCvPOp PBlJcMeKauDK8EZwOZwyr4zUMogAMOAEZzKmhUJeWeaGE537sdQcGWkglhZC8KL9Mga0 bOUalWrh/0iqfo9bDj+wPwsZJ6L8tBvnIKQas1ZkVGWCurkU1ssMLPXF5Bn1D7kLIZhi fQow== X-Gm-Message-State: AJcUukdDNTWutShR7qaSBG0iGnRCXUn7WtEH40gQm9rBqyed6XxUsptU mXFS3pHx9FLSfaySRIC/2GlmPzi+oCX90g== X-Received: by 2002:a7b:c76b:: with SMTP id x11mr8703826wmk.37.1547670176900; Wed, 16 Jan 2019 12:22:56 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:56 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:35 +0100 Message-Id: <20190116202236.6977-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 10/11] StandaloneMmPkg/StandaloneMmCoreEntryPoint: permit the use of TE images X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" TE images take up less space when using 4 KB section alignment, since the FFS/FV generation code optimizes away the redundant, nested padding. This saves 4 KB of space, which is a worthwhile improvement for code that executes in place in secure context. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c | 107 +++++++++----------- 1 file changed, 46 insertions(+), 61 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c index 3ca7f6660f47..90299ebbafb6 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c @@ -143,9 +143,12 @@ LocateStandaloneMmCorePeCoffData ( Status = FfsFindSectionData (EFI_SECTION_PE32, FileHeader, TeData, TeDataSize); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Section data - 0x%x\n", - Status)); - return Status; + Status = FfsFindSectionData (EFI_SECTION_TE, FileHeader, TeData, TeDataSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Section data - %r\n", + Status)); + return Status; + } } DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", *TeData)); @@ -155,10 +158,9 @@ LocateStandaloneMmCorePeCoffData ( STATIC EFI_STATUS GetPeCoffSectionInformation ( - IN CONST PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *TmpContext, - IN OUT UINT32 *SectionHeaderOffset, - IN OUT UINT16 *NumberOfSections + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT UINT32 *SectionHeaderOffset, + OUT UINT16 *NumberOfSections ) { RETURN_STATUS Status; @@ -168,44 +170,29 @@ GetPeCoffSectionInformation ( UINTN ReadSize; ASSERT (ImageContext != NULL); - ASSERT (TmpContext != NULL); ASSERT (SectionHeaderOffset != NULL); ASSERT (NumberOfSections != NULL); - // - // We need to copy ImageContext since PeCoffLoaderGetImageInfo () - // will mangle the ImageAddress field - // - CopyMem (TmpContext, ImageContext, sizeof (*TmpContext)); - - if (TmpContext->PeCoffHeaderOffset == 0) { - Status = PeCoffLoaderGetImageInfo (TmpContext); - if (RETURN_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, - "%a: PeCoffLoaderGetImageInfo () failed (Status = %r)\n", - __FUNCTION__, Status)); - return Status; - } - } - - if (TmpContext->IsTeImage && - TmpContext->ImageAddress == ImageContext->ImageAddress) { - DEBUG ((DEBUG_INFO, "%a: ignoring XIP TE image at 0x%lx\n", __FUNCTION__, - ImageContext->ImageAddress)); - return RETURN_UNSUPPORTED; + Status = PeCoffLoaderGetImageInfo (ImageContext); + if (RETURN_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: PeCoffLoaderGetImageInfo () failed (Status == %r)\n", + __FUNCTION__, Status)); + return Status; } - if (TmpContext->SectionAlignment < EFI_PAGE_SIZE) { + if (ImageContext->SectionAlignment < EFI_PAGE_SIZE) { // // The sections need to be at least 4 KB aligned, since that is the // granularity at which we can tighten permissions. // - if (!TmpContext->IsTeImage) { + if (!ImageContext->IsTeImage) { DEBUG ((DEBUG_WARN, "%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n", - __FUNCTION__, ImageContext->ImageAddress, TmpContext->SectionAlignment)); + __FUNCTION__, ImageContext->ImageAddress, ImageContext->SectionAlignment)); + return RETURN_UNSUPPORTED; } - return RETURN_UNSUPPORTED; + ImageContext->SectionAlignment = EFI_PAGE_SIZE; } // @@ -217,9 +204,9 @@ GetPeCoffSectionInformation ( Hdr.Union = &HdrData; Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION); ReadSize = Size; - Status = TmpContext->ImageRead ( - TmpContext->Handle, - TmpContext->PeCoffHeaderOffset, + Status = ImageContext->ImageRead ( + ImageContext->Handle, + ImageContext->PeCoffHeaderOffset, &Size, Hdr.Pe32 ); @@ -231,23 +218,28 @@ GetPeCoffSectionInformation ( return Status; } - ASSERT (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE); - - *SectionHeaderOffset = TmpContext->PeCoffHeaderOffset + sizeof (UINT32) + - sizeof (EFI_IMAGE_FILE_HEADER); - *NumberOfSections = Hdr.Pe32->FileHeader.NumberOfSections; - - switch (Hdr.Pe32->OptionalHeader.Magic) { - case EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC: - *SectionHeaderOffset += Hdr.Pe32->FileHeader.SizeOfOptionalHeader; - break; - case EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC: - *SectionHeaderOffset += Hdr.Pe32Plus->FileHeader.SizeOfOptionalHeader; - break; - default: - ASSERT (FALSE); + if (!ImageContext->IsTeImage) { + ASSERT (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE); + + *SectionHeaderOffset = ImageContext->PeCoffHeaderOffset + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER); + *NumberOfSections = Hdr.Pe32->FileHeader.NumberOfSections; + + switch (Hdr.Pe32->OptionalHeader.Magic) { + case EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC: + *SectionHeaderOffset += Hdr.Pe32->FileHeader.SizeOfOptionalHeader; + break; + case EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC: + *SectionHeaderOffset += Hdr.Pe32Plus->FileHeader.SizeOfOptionalHeader; + break; + default: + ASSERT (FALSE); + } + } else { + *SectionHeaderOffset = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER)); + *NumberOfSections = Hdr.Te->NumberOfSections; + ImageContext->ImageAddress -= (UINT32)Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER); } - return RETURN_SUCCESS; } @@ -261,7 +253,6 @@ GetStandaloneMmCorePeCoffSections ( ) { EFI_STATUS Status; - PE_COFF_LOADER_IMAGE_CONTEXT TmpContext; // Initialize the Image Context ZeroMem (ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT)); @@ -270,15 +261,9 @@ GetStandaloneMmCorePeCoffSections ( DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", TeData)); - Status = PeCoffLoaderGetImageInfo (ImageContext); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Image information - 0x%x\n", Status)); - return Status; - } - - Status = GetPeCoffSectionInformation (ImageContext, &TmpContext, SectionHeaderOffset, NumberOfSections); + Status = GetPeCoffSectionInformation (ImageContext, SectionHeaderOffset, NumberOfSections); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - 0x%x\n", Status)); + DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - %r\n", Status)); return Status; } From patchwork Wed Jan 16 20:22:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155759 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1097309jaa; Wed, 16 Jan 2019 12:23:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN6IY/1BK5PkslMcRQc0f2fncvzd88p2vBYf88xjhXq9TPALjEe9teJ/jeogycs9U00tj/Nv X-Received: by 2002:a81:f00c:: with SMTP id p12mr9442657ywm.55.1547670205523; Wed, 16 Jan 2019 12:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547670205; cv=none; d=google.com; s=arc-20160816; b=x+hMWZ6R2A5lBV++qdOlHGxMoctWPQ1LKTs9mZxo/cuSgjwqXf/6a59BZ6LXX66rrI w+XEjp5V5yzMsymul3KgNwprFxD6KGQ1AOASdVXwSzAQBsdJ9Aia3pNAWB/0z8MDlEdl 543UHYcHqdlQBgU2976r6FrNO0Rvqqt1PKSYYjRyLMhxxIlBMFjTpJ/DCGbS6VyNMdqc gBX9btML/eDugkmyX7RG4fGgoMZqkIG93eFGv+6t3Zj3AhWQhVb/SWsd1wq55jis00nN 4KI4LxVGeTVievU06wlknw/te+Sz48JNycX99V62cxGeoHjLXoWXVdk5gyIiAVPCSqac 9AAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=XuDfeKsYdyuPf3aaZ9G+nT/P8YWgUS+euUCbPWTXqV8=; b=VmC8w9Piz8QyEqGl5gukMTRmmdJLYFyYuZKTgMO+514QiNcYYE8/3zqgAc2iVqMWLL QCGDzZLWliAUiqIfEl8emQH/84kVDOhISie5G8FD68ZB9S04mg+osEfSPCb7EEEDdA4X Idn5tzO3J0+i0AF785Q3WMnR3IT4BHEOGMha4ZTXgjhPVmVuDd5XfOY0ZVFGgXxr2lJW YSQwMgg9IPdxxbbY9uVN7meyBEvQHODBDlnm2ElBGX8FNdo+ejg9Ij0YVyiQuyZR8xq6 fGc09asdlHQVnibCSuBN1BIkSznwP/WDvQL/XBxtnN6WXOca75b5GPmJr13JCkjXR2rU KjJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Lbe0SkMp; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id q188si4729462ywb.161.2019.01.16.12.23.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:23:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Lbe0SkMp; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7D949211B81B9; Wed, 16 Jan 2019 12:23:02 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::342; helo=mail-wm1-x342.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 83B94211B81B4 for ; Wed, 16 Jan 2019 12:23:00 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id y8so3424040wmi.4 for ; Wed, 16 Jan 2019 12:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NdToInAw2cZXALleMn5c4+Ws8R7KnoGPV8oJYfl2cO8=; b=Lbe0SkMpoEVivzFJIwxMsRucVlAnaaQMRmoz29QqWpvzpGHb6EkHY9TlPFRqSIIyWi MPkqxpvATsXHeUUCsx2v5MK+fKplY0PZ+fmkmi62EljWXNNTf10yjIP5nIpX55CwQECu JmL0lOHbE7VJqqisFauG2lcZoyWMhRcUdi2z4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NdToInAw2cZXALleMn5c4+Ws8R7KnoGPV8oJYfl2cO8=; b=Pl0AoRt1doXKX3G0khQ+5yw4dHg2Um3oxE/DEZAi2KdtwVbdDxDcjy5N6Y6NWsdkfS 0L1Otr3n1wRY1UHPuNd4YdyZn4VPuOltjkJCYeXdYkxu/KxpTA/76/1dDXieIj34N/Bg flcBtBdBBeOnsFeeobeBpJ+S6slSIEgayaw7exWNRt1rW9vlcKkzOMf4TGuxOcBJFIth QLGjytkI8XpmSYTPBdLqC39qRVNh+QQLL7YezUHHET+ZEIXc8PurAjKtYjffqAU3K7a+ WHmvyZLqctAXtQtk7bbqDezEKE1mNKSLr+rplztVlCJm6o2N/NLn9/G6MCZJA8Ibm9cm vgjg== X-Gm-Message-State: AJcUukf5Bbldi5vmSBILZeusI9WMZyhRJ9IzJeQ2E2UnFLpFc7XRYUU4 eGLoMPy4wVFyJshV/RpMV2+CcLQRYyHOcg== X-Received: by 2002:a1c:7511:: with SMTP id o17mr8810843wmc.42.1547670178702; Wed, 16 Jan 2019 12:22:58 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:28df:207d:542c:1451]) by smtp.gmail.com with ESMTPSA id p139sm70901316wmd.31.2019.01.16.12.22.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 12:22:57 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 16 Jan 2019 21:22:36 +0100 Message-Id: <20190116202236.6977-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116202236.6977-1-ard.biesheuvel@linaro.org> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 11/11] StandaloneMmPkg/Core: permit encapsulated firmware volumes X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Standalone MM requires 4 KB section alignment for all images, so that strict permissions can be applied. Unfortunately, this results in a lot of wasted space, which is usually costly in the secure world environment that standalone MM is expected to operate in. So let's permit the standalone MM drivers (but not the core) to be delivered in a compressed firmware volume. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Core/FwVol.c | 99 ++++++++++++++++++-- StandaloneMmPkg/Core/StandaloneMmCore.inf | 1 + StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c | 5 + StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 3 + 4 files changed, 99 insertions(+), 9 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/StandaloneMmPkg/Core/FwVol.c b/StandaloneMmPkg/Core/FwVol.c index 5abf98c24797..8eb827dda5c4 100644 --- a/StandaloneMmPkg/Core/FwVol.c +++ b/StandaloneMmPkg/Core/FwVol.c @@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "StandaloneMmCore.h" #include +#include // // List of file types supported by dispatcher @@ -65,15 +66,25 @@ Returns: --*/ { - EFI_STATUS Status; - EFI_STATUS DepexStatus; - EFI_FFS_FILE_HEADER *FileHeader; - EFI_FV_FILETYPE FileType; - VOID *Pe32Data; - UINTN Pe32DataSize; - VOID *Depex; - UINTN DepexSize; - UINTN Index; + EFI_STATUS Status; + EFI_STATUS DepexStatus; + EFI_FFS_FILE_HEADER *FileHeader; + EFI_FV_FILETYPE FileType; + VOID *Pe32Data; + UINTN Pe32DataSize; + VOID *Depex; + UINTN DepexSize; + UINTN Index; + EFI_COMMON_SECTION_HEADER *Section; + VOID *SectionData; + UINTN SectionDataSize; + UINT32 DstBufferSize; + VOID *ScratchBuffer; + UINT32 ScratchBufferSize; + VOID *DstBuffer; + UINT16 SectionAttribute; + UINT32 AuthenticationStatus; + EFI_FIRMWARE_VOLUME_HEADER *InnerFvHeader; DEBUG ((DEBUG_INFO, "MmCoreFfsFindMmDriver - 0x%x\n", FwVolHeader)); @@ -83,6 +94,71 @@ Returns: FvIsBeingProcesssed (FwVolHeader); + // + // First check for encapsulated compressed firmware volumes + // + FileHeader = NULL; + do { + Status = FfsFindNextFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, + FwVolHeader, &FileHeader); + if (EFI_ERROR (Status)) { + break; + } + Status = FfsFindSectionData (EFI_SECTION_GUID_DEFINED, FileHeader, + &SectionData, &SectionDataSize); + if (EFI_ERROR (Status)) { + break; + } + Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1); + Status = ExtractGuidedSectionGetInfo (Section, &DstBufferSize, + &ScratchBufferSize, &SectionAttribute); + if (EFI_ERROR (Status)) { + break; + } + + // + // Allocate scratch buffer + // + ScratchBuffer = (VOID *)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize)); + if (ScratchBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Allocate destination buffer + // + DstBuffer = (VOID *)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize)); + if (DstBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Call decompress function + // + Status = ExtractGuidedSectionDecode (Section, &DstBuffer, ScratchBuffer, + &AuthenticationStatus); + FreePages (ScratchBuffer, EFI_SIZE_TO_PAGES (ScratchBufferSize)); + if (EFI_ERROR (Status)) { + goto FreeDstBuffer; + } + + DEBUG ((DEBUG_INFO, + "Processing compressed firmware volume (AuthenticationStatus == %x)\n", + AuthenticationStatus)); + + Status = FindFfsSectionInSections (DstBuffer, DstBufferSize, + EFI_SECTION_FIRMWARE_VOLUME_IMAGE, &Section); + if (EFI_ERROR (Status)) { + goto FreeDstBuffer; + } + + InnerFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(Section + 1); + Status = MmCoreFfsFindMmDriver (InnerFvHeader); + if (EFI_ERROR (Status)) { + goto FreeDstBuffer; + } + } while (TRUE); + for (Index = 0; Index < sizeof (mMmFileTypes) / sizeof (mMmFileTypes[0]); Index++) { DEBUG ((DEBUG_INFO, "Check MmFileTypes - 0x%x\n", mMmFileTypes[Index])); FileType = mMmFileTypes[Index]; @@ -100,5 +176,10 @@ Returns: } while (!EFI_ERROR (Status)); } + return EFI_SUCCESS; + +FreeDstBuffer: + FreePages (DstBuffer, EFI_SIZE_TO_PAGES (DstBufferSize)); + return Status; } diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf index ff2b8b9cef03..83d31e2d92c5 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf @@ -49,6 +49,7 @@ [LibraryClasses] BaseMemoryLib CacheMaintenanceLib DebugLib + ExtractGuidedSectionLib FvLib HobLib MemoryAllocationLib diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c index 5cca532456fd..67ff9112d5c0 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c @@ -205,6 +205,8 @@ GetSpmVersion (VOID) return Status; } +STATIC UINT64 mExtractGuidedSectionHandlerInfo[64]; + /** The entry point of Standalone MM Foundation. @@ -285,6 +287,9 @@ _ModuleEntryPoint ( goto finish; } + PcdSet64 (PcdGuidedExtractHandlerTableAddress, + (UINT64)mExtractGuidedSectionHandlerInfo); + // // Create Hoblist based upon boot information passed by privileged software // diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf index 769eaeeefbea..55d769fa77e4 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf @@ -54,3 +54,6 @@ [Guids] gEfiMmPeiMmramMemoryReserveGuid gEfiStandaloneMmNonSecureBufferGuid gEfiArmTfCpuDriverEpDescriptorGuid + +[PatchPcd] + gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress