From nobody Mon Sep 16 19:33:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+105308+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+105308+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1685025084; cv=none; d=zohomail.com; s=zohoarc; b=Db7hzSP4Ff9Hvs3lFedafML7/CH9g9Tr/Eq6r5DAkYlEilEIRPhMPuKno9I2CHBfGqyBTeuyNDyUoggWiTdg1RbvzrGY5/Mvosg2ANFgJ7GancBI1v6nOY544ecwqa62dWIkp3lvpZgQT8dCj8tzSDva6WEuhK9VWKtoQtE+Hfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685025084; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=LaysgQ9UTPCE6qcEBUm+f3mhHOQpX4AipNWwff6sJEk=; b=TkHkPytupanFi8UZkHZ6l4ekyw82FB9qlWrm3/rpQ4nMziRUu/MvoLCq9wJoNm08aImeQUXnF8yCMEEhy1ncKoLpd4me143WaQZQII4OEP8K18AJ/e54fl2WPQVHyBos4Mq4zE4Vytq1Fdip3ZP2jeWULKXOZfDEJI/53VWZXYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+105308+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1685025084097124.24235031895546; Thu, 25 May 2023 07:31:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bTR0YY1788612xRz0v4iyyzY; Thu, 25 May 2023 07:31:23 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.13543.1685025083096221352 for ; Thu, 25 May 2023 07:31:23 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1745645F3; Thu, 25 May 2023 14:31:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85DF0C433A1; Thu, 25 May 2023 14:31:19 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Ray Ni , Jiewen Yao , Gerd Hoffmann , Taylor Beebe , Oliver Smith-Denny , Dandan Bi , Liming Gao , "Kinney, Michael D" , Leif Lindholm , Sunil V L , Andrei Warkentin Subject: [edk2-devel] [RFC PATCH 08/10] MdeModulePkg/DxeIpl: Merge EBC, RISCV64 and LOONGARCH code Date: Thu, 25 May 2023 16:30:39 +0200 Message-Id: <20230525143041.1172989-9-ardb@kernel.org> In-Reply-To: <20230525143041.1172989-1-ardb@kernel.org> References: <20230525143041.1172989-1-ardb@kernel.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org X-Gm-Message-State: eOo6AEZGnuWoViPL05TrsxbYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1685025083; bh=WD+W68DVwKd31ccl/To9VLK3KCiEfr04HhHbK1Tk2uo=; h=Cc:Date:From:Reply-To:Subject:To; b=WR4mzNPn5qf2HP58+uYhx113faaH/PHZRVWIs+lPlMvdPsPIM1FX6qST6BlzMFYt61g +LDm8ihBeX1+hmkE2a1O9lEjoxZjyaSTeHoU9tQw6AlKw3fSvn/oLMPWhXO4rCVP7j2ks dUUnFeuc/pfxPTRTl3IwrK1OqlWjm8g4xWo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1685025085883100001 Content-Type: text/plain; charset="utf-8" The Risc-V and LoongArch specific versions of the DXE core handoff code in DxeIpl are essentially copies of the EBC version (modulo the copyright in the header and some debug prints in the code). In preparation for introducing a generic PPI based method to implement the non-executable stack, let's merge these versions, so we only need to add this logic once. Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/DxeIplPeim/{Ebc/DxeLoadFunc.c =3D> DxeHandoff.c} | 2 +- MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 10 +-- MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c | 63 ----= ------------ MdeModulePkg/Core/DxeIplPeim/RiscV64/DxeLoadFunc.c | 75 ----= ---------------- 4 files changed, 3 insertions(+), 147 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/Ebc/DxeLoadFunc.c b/MdeModulePkg/= Core/DxeIplPeim/DxeHandoff.c similarity index 92% rename from MdeModulePkg/Core/DxeIplPeim/Ebc/DxeLoadFunc.c rename to MdeModulePkg/Core/DxeIplPeim/DxeHandoff.c index c1a16b602452218e..a0f85ebea56e6cba 100644 --- a/MdeModulePkg/Core/DxeIplPeim/Ebc/DxeLoadFunc.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeHandoff.c @@ -1,5 +1,5 @@ /** @file - EBC-specific functionality for DxeLoad. + Generic version of arch-specific functionality for DxeLoad. =20 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/Dx= eIplPeim/DxeIpl.inf index 052ea0ec1a6f2771..60c998be6c1bad01 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -45,17 +45,11 @@ [Sources.X64] X64/VirtualMemory.c X64/DxeLoadFunc.c =20 -[Sources.EBC] - Ebc/DxeLoadFunc.c - [Sources.ARM, Sources.AARCH64] Arm/DxeLoadFunc.c =20 -[Sources.RISCV64] - RiscV64/DxeLoadFunc.c - -[Sources.LOONGARCH64] - LoongArch64/DxeLoadFunc.c +[Sources.LOONGARCH64,Sources.RISCV64,Sources.EBC] + DxeHandoff.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c b/MdeMo= dulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c deleted file mode 100644 index 95d3af19ea4c9f00..0000000000000000 --- a/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c +++ /dev/null @@ -1,63 +0,0 @@ -/** @file - LoongArch specifc functionality for DxeLoad. - - Copyright (c) 2022, Loongson Technology Corporation Limited. All rights = reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "DxeIpl.h" - -/** - Transfers control to DxeCore. - - This function performs a CPU architecture specific operations to execute - the entry point of DxeCore with the parameters of HobList. - It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. - - @param[in] DxeCoreEntryPoint The entry point of DxeCore. - @param[in] HobList The start of HobList passed to Dxe= Core. - -**/ -VOID -HandOffToDxeCore ( - IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, - IN EFI_PEI_HOB_POINTERS HobList - ) -{ - VOID *BaseOfStack; - VOID *TopOfStack; - EFI_STATUS Status; - - // - // Allocate 128KB for the Stack - // - BaseOfStack =3D AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE)); - ASSERT (BaseOfStack !=3D NULL); - - // - // Compute the top of the stack we were allocated. Pre-allocate a UINTN - // for safety. - // - TopOfStack =3D (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SI= ZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT); - TopOfStack =3D ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); - - // - // End of PEI phase signal - // - Status =3D PeiServicesInstallPpi (&gEndOfPeiSignalPpi); - ASSERT_EFI_ERROR (Status); - - // - // Update the contents of BSP stack HOB to reflect the real stack info p= assed to DxeCore. - // - UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE); - - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, - HobList.Raw, - NULL, - TopOfStack - ); -} diff --git a/MdeModulePkg/Core/DxeIplPeim/RiscV64/DxeLoadFunc.c b/MdeModule= Pkg/Core/DxeIplPeim/RiscV64/DxeLoadFunc.c deleted file mode 100644 index b3567d88f73467e7..0000000000000000 --- a/MdeModulePkg/Core/DxeIplPeim/RiscV64/DxeLoadFunc.c +++ /dev/null @@ -1,75 +0,0 @@ -/** @file - RISC-V specific functionality for DxeLoad. - - Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "DxeIpl.h" - -/** - Transfers control to DxeCore. - - This function performs a CPU architecture specific operations to execute - the entry point of DxeCore with the parameters of HobList. - It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. - - @param DxeCoreEntryPoint The entry point of DxeCore. - @param HobList The start of HobList passed to DxeCore. - -**/ -VOID -HandOffToDxeCore ( - IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, - IN EFI_PEI_HOB_POINTERS HobList - ) -{ - VOID *BaseOfStack; - VOID *TopOfStack; - EFI_STATUS Status; - - // - // - // Allocate 128KB for the Stack - // - BaseOfStack =3D AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE)); - if (BaseOfStack =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a: Can't allocate memory for stack.", __func__)= ); - ASSERT (FALSE); - } - - // - // Compute the top of the stack we were allocated. Pre-allocate a UINTN - // for safety. - // - TopOfStack =3D (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SI= ZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT); - TopOfStack =3D ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); - - // - // End of PEI phase signal - // - Status =3D PeiServicesInstallPpi (&gEndOfPeiSignalPpi); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: Fail to signal End of PEI event.", __func__)= ); - ASSERT (FALSE); - } - - // - // Update the contents of BSP stack HOB to reflect the real stack info p= assed to DxeCore. - // - UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE); - - DEBUG ((DEBUG_INFO, "DXE Core new stack at %x, stack pointer at %x\n", B= aseOfStack, TopOfStack)); - - // - // Transfer the control to the entry point of DxeCore. - // - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, - HobList.Raw, - NULL, - TopOfStack - ); -} --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105308): https://edk2.groups.io/g/devel/message/105308 Mute This Topic: https://groups.io/mt/99131195/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-