From nobody Fri Nov 1 10:36:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151675974850554.7831611345124; Tue, 23 Jan 2018 18:09:08 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5A12D22333776; Tue, 23 Jan 2018 18:03:39 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7A95C21E48F50 for ; Tue, 23 Jan 2018 18:03:37 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2018 18:09:04 -0800 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.239]) by orsmga003.jf.intel.com with ESMTP; 23 Jan 2018 18:08:47 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,404,1511856000"; d="scan'208";a="21843087" From: Jian J Wang To: edk2-devel@lists.01.org Date: Wed, 24 Jan 2018 10:08:45 +0800 Message-Id: <20180124020845.6096-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix issue in wakeup buffer initialization X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Laszlo Ersek , Eric Dong MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To fix an issue in which enabling NX feature will mark the AP wakeup buffer as non-executable and fail the AP init, the buffer was split into two part: the lower part in memory within 1MB and the higher part within allocated executable memory (EfiBootServicesCode). But the address of higher part memory was stored in lower part memory, which is actually shared with legacy components and will be overwritten by LegacyBiosDxe driver if CSM is enabled. This patch fixes this issue by storing the address of higher part memory in CpuMpData instead of ExchangeInfo. Cc: Ruiyu Ni Cc: Eric Dong Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 20 ++++++++++---------- UefiCpuPkg/Library/MpInitLib/MpLib.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 6231968c74..42011d6231 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -823,19 +823,20 @@ FillExchangeInfoData ( // Copy all 32-bit code and 64-bit code into memory with type of // EfiBootServicesCode to avoid page fault if NX memory protection is en= abled. // - if (ExchangeInfo->ModeTransitionMemory !=3D 0) { + if (CpuMpData->WakeupBufferHigh !=3D 0) { Size =3D CpuMpData->AddressMap.RendezvousFunnelSize - CpuMpData->AddressMap.ModeTransitionOffset; CopyMem ( - (VOID *)(UINTN)ExchangeInfo->ModeTransitionMemory, + (VOID *)CpuMpData->WakeupBufferHigh, CpuMpData->AddressMap.RendezvousFunnelAddress + CpuMpData->AddressMap.ModeTransitionOffset, Size ); =20 - ExchangeInfo->ModeHighMemory =3D ExchangeInfo->ModeTransitionMemory; - ExchangeInfo->ModeHighMemory +=3D (UINT32)ExchangeInfo->ModeOffset - - (UINT32)CpuMpData->AddressMap.ModeTransitionOffset; + ExchangeInfo->ModeTransitionMemory =3D (UINT32)CpuMpData->WakeupBuffer= High; + ExchangeInfo->ModeHighMemory =3D (UINT32)CpuMpData->WakeupBufferHigh + + (UINT32)ExchangeInfo->ModeOffset - + (UINT32)CpuMpData->AddressMap.ModeTrans= itionOffset; ExchangeInfo->ModeHighSegment =3D (UINT16)ExchangeInfo->CodeSegment; } else { ExchangeInfo->ModeTransitionMemory =3D (UINT32) @@ -916,11 +917,10 @@ AllocateResetVector ( CpuMpData->WakeupBuffer =3D GetWakeupBuffer (ApResetVectorSize); CpuMpData->MpCpuExchangeInfo =3D (MP_CPU_EXCHANGE_INFO *) (UINTN) (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.Rende= zvousFunnelSize); - CpuMpData->MpCpuExchangeInfo->ModeTransitionMemory =3D (UINT32) - GetModeTransitionBuffer ( - CpuMpData->AddressMap.RendezvousFunnelSize - - CpuMpData->AddressMap.ModeTransitionOffset - ); + CpuMpData->WakeupBufferHigh =3D GetModeTransitionBuffer ( + CpuMpData->AddressMap.RendezvousFunnel= Size - + CpuMpData->AddressMap.ModeTransitionOf= fset + ); } BackupAndPrepareWakeupBuffer (CpuMpData); } diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpIn= itLib/MpLib.h index 0232fe896a..e7f9a4de0a 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -208,6 +208,7 @@ struct _CPU_MP_DATA { UINTN CpuApStackSize; MP_ASSEMBLY_ADDRESS_MAP AddressMap; UINTN WakeupBuffer; + UINTN WakeupBufferHigh; UINTN BackupBuffer; UINTN BackupBufferSize; =20 --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel