From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bRkG+P5+; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) 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) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85DF0C433A1; Thu, 25 May 2023 14:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685025082; bh=P5RpjL2qkclrWO6e0lQXUT9RcEHro88Md4ssCNabnd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRkG+P5+KsINDW05bseh20ubuuxhe+knTGg2BypyxTqI2qcHZ2XJ8zu3I0SKYFkBU 0GsM34W/BInDhKJt5C2UMVaT1eNMkQxnzBeHqXA3ZUZBEj8Y0g8D+sTzES6UXMLREC EXAFgzCUglMnIJnuTs/hlK74oRlqA6sP1cTFK6eH1bVWIOiXTFxFG+vHUwdaYMhfGG ItdwEIykJQuKKe29Kq7+mMY5EgM8hvsKb/s558mjsD4FI2hRuQawr6h3qn+uc1MeG7 +liDJ3pWYPODfoCALkK7Y5n2YkAh1PKVTQNlLOi70eY+szmOmf1TGAhSD0TMaiP/7W SmBYSrAVEHkkg== 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: [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> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525143041.1172989-1-ardb@kernel.org> References: <20230525143041.1172989-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=0D - EBC-specific functionality for DxeLoad.=0D + Generic version of arch-specific functionality for DxeLoad.=0D =0D Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D 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=0D X64/DxeLoadFunc.c=0D =0D -[Sources.EBC]=0D - Ebc/DxeLoadFunc.c=0D -=0D [Sources.ARM, Sources.AARCH64]=0D Arm/DxeLoadFunc.c=0D =0D -[Sources.RISCV64]=0D - RiscV64/DxeLoadFunc.c=0D -=0D -[Sources.LOONGARCH64]=0D - LoongArch64/DxeLoadFunc.c=0D +[Sources.LOONGARCH64,Sources.RISCV64,Sources.EBC]=0D + DxeHandoff.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D 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=0D - LoongArch specifc functionality for DxeLoad.=0D -=0D - Copyright (c) 2022, Loongson Technology Corporation Limited. All rights = reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -=0D -**/=0D -=0D -#include "DxeIpl.h"=0D -=0D -/**=0D - Transfers control to DxeCore.=0D -=0D - This function performs a CPU architecture specific operations to execut= e=0D - the entry point of DxeCore with the parameters of HobList.=0D - It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.=0D -=0D - @param[in] DxeCoreEntryPoint The entry point of DxeCore.=0D - @param[in] HobList The start of HobList passed to Dxe= Core.=0D -=0D -**/=0D -VOID=0D -HandOffToDxeCore (=0D - IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,=0D - IN EFI_PEI_HOB_POINTERS HobList=0D - )=0D -{=0D - VOID *BaseOfStack;=0D - VOID *TopOfStack;=0D - EFI_STATUS Status;=0D -=0D - //=0D - // Allocate 128KB for the Stack=0D - //=0D - BaseOfStack =3D AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));=0D - ASSERT (BaseOfStack !=3D NULL);=0D -=0D - //=0D - // Compute the top of the stack we were allocated. Pre-allocate a UINTN= =0D - // for safety.=0D - //=0D - TopOfStack =3D (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SI= ZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);=0D - TopOfStack =3D ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);=0D -=0D - //=0D - // End of PEI phase signal=0D - //=0D - Status =3D PeiServicesInstallPpi (&gEndOfPeiSignalPpi);=0D - ASSERT_EFI_ERROR (Status);=0D -=0D - //=0D - // Update the contents of BSP stack HOB to reflect the real stack info p= assed to DxeCore.=0D - //=0D - UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);=0D -=0D - SwitchStack (=0D - (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,=0D - HobList.Raw,=0D - NULL,=0D - TopOfStack=0D - );=0D -}=0D 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=0D - RISC-V specific functionality for DxeLoad.=0D -=0D - Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -=0D -**/=0D -=0D -#include "DxeIpl.h"=0D -=0D -/**=0D - Transfers control to DxeCore.=0D -=0D - This function performs a CPU architecture specific operations to execut= e=0D - the entry point of DxeCore with the parameters of HobList.=0D - It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.=0D -=0D - @param DxeCoreEntryPoint The entry point of DxeCore.=0D - @param HobList The start of HobList passed to DxeCore= .=0D -=0D -**/=0D -VOID=0D -HandOffToDxeCore (=0D - IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,=0D - IN EFI_PEI_HOB_POINTERS HobList=0D - )=0D -{=0D - VOID *BaseOfStack;=0D - VOID *TopOfStack;=0D - EFI_STATUS Status;=0D -=0D - //=0D - //=0D - // Allocate 128KB for the Stack=0D - //=0D - BaseOfStack =3D AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));=0D - if (BaseOfStack =3D=3D NULL) {=0D - DEBUG ((DEBUG_ERROR, "%a: Can't allocate memory for stack.", __func__)= );=0D - ASSERT (FALSE);=0D - }=0D -=0D - //=0D - // Compute the top of the stack we were allocated. Pre-allocate a UINTN= =0D - // for safety.=0D - //=0D - TopOfStack =3D (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SI= ZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);=0D - TopOfStack =3D ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);=0D -=0D - //=0D - // End of PEI phase signal=0D - //=0D - Status =3D PeiServicesInstallPpi (&gEndOfPeiSignalPpi);=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "%a: Fail to signal End of PEI event.", __func__)= );=0D - ASSERT (FALSE);=0D - }=0D -=0D - //=0D - // Update the contents of BSP stack HOB to reflect the real stack info p= assed to DxeCore.=0D - //=0D - UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);=0D -=0D - DEBUG ((DEBUG_INFO, "DXE Core new stack at %x, stack pointer at %x\n", B= aseOfStack, TopOfStack));=0D -=0D - //=0D - // Transfer the control to the entry point of DxeCore.=0D - //=0D - SwitchStack (=0D - (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,=0D - HobList.Raw,=0D - NULL,=0D - TopOfStack=0D - );=0D -}=0D --=20 2.39.2