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.web09.26058.1652685263921678640 for ; Mon, 16 May 2022 00:14:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bI+fP6cB; 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=1652685266; x=1684221266; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/2w4XBfukLZ7TVeSv9MqmfJClcL7mZXR1WIhCkktGB8=; b=bI+fP6cBO2ljoFebR1Ewuge1jJQhHVhZUbVCacP002AnxC5I6dCuKu2T 3wLRJY/ir9pC0ouSMF1Pl6dAPEinDy/Ve2eOP9kk2WHPd0J971fCtKwxu UIiEFNEGtJskhZEnjv+aJjRfX6sSyXDlSAdSaIzmVmm5QYi8DsN19Z43Z McXoXfgiIm2Z+c1TCfpNmfRbkaHu1fd3ptRb65a57BqiQyc5fzXE/bkso QBh3jBZ5vBcatswaJZrlrILJX7dGXm96VN1TAxTqKKcVGuGu19N929dnR cEXgavp4O2jNbeylyRdU2Ih4HxUUkYXKX0vgBY+G6RRkNoxmIbLv+eG7c g==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270451768" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270451768" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2022 00:14:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="555129003" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.183.102]) by orsmga002.jf.intel.com with ESMTP; 16 May 2022 00:14:19 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong Subject: [PATCH v3 1/5] MpInitLib: Allocate code buffer for PEI phase Date: Mon, 16 May 2022 15:14:08 +0800 Message-Id: <20220516071412.359-2-ray.ni@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220516071412.359-1-ray.ni@intel.com> References: <20220516071412.359-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 4a73787ee4..d761bdc487 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1056,7 +1056,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.35.1.windows.2