From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.10774.1651936399606004842 for ; Sat, 07 May 2022 08:13:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=N67BISXf; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651936399; x=1683472399; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xj5IHkR2M1tn6zCBzv//gNXQ1ViBcO3TmDaD9JaR9/E=; b=N67BISXfLNrXDY91ikp/4dJC1d2TDnsBkUEcnDK3KysRlizdjkvUbuUe bjxjtI+0DL1f3L8+QowR63R8qacTi+TuymMEPg5svTwqRq4ANOzmG8djT 2jzU1XKEaYY0EbniJvH3LXn++9OWKPkmBp/Yp80uWhlezKt+kgeRwVVfG O6+f0AK6nAFnbagSvkefcHMFpODBD7MkQtWre+eO48CvZ3M+E1jOm41IH LQoMA0U9fwpgkgqAr4nO2VP4FA0LZWbNfkHJaB+uReQKG4xJ4G3kPjQSn s81XbUeFWctaQSy+OarBsPRwQLybCQ45YZ/FX78qAKMC5ZJIFJ0vi4oRj w==; X-IronPort-AV: E=McAfee;i="6400,9594,10340"; a="268345239" X-IronPort-AV: E=Sophos;i="5.91,207,1647327600"; d="scan'208";a="268345239" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 08:13:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,207,1647327600"; d="scan'208";a="601004352" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.183.102]) by orsmga001.jf.intel.com with ESMTP; 07 May 2022 08:13:18 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong Subject: [PATCH 1/4] MpInitLib: Allocate code buffer for PEI phase Date: Sat, 7 May 2022 23:13:10 +0800 Message-Id: <20220507151313.115-2-ray.ni@intel.com> X-Mailer: git-send-email 2.32.0.windows.1 In-Reply-To: <20220507151313.115-1-ray.ni@intel.com> References: <20220507151313.115-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Today's implementation assumes PEI phase runs at 32bit so the execution-disable feature is not applicable. It's not always TRUE. The patch allocates 32bit&64bit code buffer for PEI phase as well. Signed-off-by: Ray Ni Cc: Eric Dong --- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 2 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 2 +- UefiCpuPkg/Library/MpInitLib/MpLib.h | 2 +- UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 15 ++++++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/M= pInitLib/DxeMpLib.c index 60d14a5a0e..78cc3e2b93 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -162,7 +162,7 @@ GetWakeupBuffer ( @retval 0 Cannot find free memory below 4GB.=0D **/=0D UINTN=0D -GetModeTransitionBuffer (=0D +AllocateCodeBuffer (=0D IN UINTN BufferSize=0D )=0D {=0D diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 91c7afaeb2..3dc1b9f872 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1058,7 +1058,7 @@ AllocateResetVector ( (CpuMpData->WakeupBuffer +=0D CpuMpData->AddressMap.RendezvousFunnel= Size +=0D CpuMpData->AddressMap.SwitchToRealSize= );=0D - CpuMpData->WakeupBufferHigh =3D GetModeTransitionBuffer (=0D + CpuMpData->WakeupBufferHigh =3D AllocateCodeBuffer (=0D CpuMpData->AddressMap.RendezvousFunnel= Size +=0D CpuMpData->AddressMap.SwitchToRealSize= -=0D CpuMpData->AddressMap.ModeTransitionOf= fset=0D diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpIn= itLib/MpLib.h index f8c52426dd..59ab960897 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -442,7 +442,7 @@ GetWakeupBuffer ( @retval 0 Cannot find free memory below 4GB.=0D **/=0D UINTN=0D -GetModeTransitionBuffer (=0D +AllocateCodeBuffer (=0D IN UINTN BufferSize=0D );=0D =0D diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/M= pInitLib/PeiMpLib.c index efce574727..65400b95a2 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c @@ -299,14 +299,19 @@ GetWakeupBuffer ( @retval 0 Cannot find free memory below 4GB.=0D **/=0D UINTN=0D -GetModeTransitionBuffer (=0D +AllocateCodeBuffer (=0D IN UINTN BufferSize=0D )=0D {=0D - //=0D - // PEI phase doesn't need to do such transition. So simply return 0.=0D - //=0D - return 0;=0D + EFI_STATUS Status;=0D + EFI_PHYSICAL_ADDRESS Address;=0D +=0D + Status =3D PeiServicesAllocatePages (EfiBootServicesCode, EFI_SIZE_TO_PA= GES (BufferSize), &Address);=0D + if (EFI_ERROR (Status)) {=0D + Address =3D 0;=0D + }=0D +=0D + return (UINTN)Address;=0D }=0D =0D /**=0D --=20 2.32.0.windows.1