From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 A4B6F221F93C1 for ; Tue, 16 Jan 2018 05:56:56 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2018 06:02:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,368,1511856000"; d="scan'208";a="193743710" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 16 Jan 2018 06:02:15 -0800 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 Jan 2018 06:02:14 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 Jan 2018 06:02:13 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Tue, 16 Jan 2018 22:02:12 +0800 From: "Dong, Eric" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" , "Ni, Ruiyu" , Laszlo Ersek Thread-Topic: [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers Thread-Index: AQHTjd6IqQxDUXLejk611Uu6uc/Yv6N2iV7Q Date: Tue, 16 Jan 2018 14:02:12 +0000 Message-ID: References: <20180115085433.25008-1-jian.j.wang@intel.com> <20180115085433.25008-3-jian.j.wang@intel.com> In-Reply-To: <20180115085433.25008-3-jian.j.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjE0ZGUyODEtMjljZS00MDExLWI0NmMtZGRlOTQ0ODBkYTg0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJXQXBIdVdlXC9xdzJzVEJ0aXE5Z25RVkJoSTVQSGNsUUpMSXVxVlpEVnl5UThNSitKNmErMFZHR3FLZFlZdFUxWiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers 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: , X-List-Received-Date: Tue, 16 Jan 2018 13:56:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: Wang, Jian J > Sent: Monday, January 15, 2018 4:54 PM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen ; Ni, Ruiyu ; > Dong, Eric ; Laszlo Ersek > Subject: [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code > memory for exception handlers >=20 > If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory > of EfiBootServicesData, EfiConventionalMemory, the BIOS will reset after > timer initialized and started. >=20 > The root cause is that the memory used to hold the exception and interrup= t > handler is allocated with type of EfiBootServicesData and marked as non- > executable due to NX feature enabled. This patch fixes it by allocating > EfiBootServicesCode type of memory for those handlers instead. >=20 > Cc: Jiewen Yao > Cc: Ruiyu Ni > Cc: Eric Dong > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > .../Library/CpuExceptionHandlerLib/DxeException.c | 18 > ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > index 9a72b37e77..6d1b54d31d 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > @@ -16,6 +16,7 @@ > #include "CpuExceptionCommon.h" > #include > #include > +#include >=20 > CONST UINTN mDoFarReturnFlag =3D 0; >=20 > @@ -106,8 +107,12 @@ InitializeCpuInterruptHandlers ( > RESERVED_VECTORS_DATA *ReservedVectors; > EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; >=20 > - ReservedVectors =3D AllocatePool (sizeof (RESERVED_VECTORS_DATA) * > CPU_INTERRUPT_NUM); > - ASSERT (ReservedVectors !=3D NULL); > + Status =3D gBS->AllocatePool ( > + EfiBootServicesCode, > + sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM, > + (VOID **)&ReservedVectors > + ); > + ASSERT (!EFI_ERROR (Status) && ReservedVectors !=3D NULL); > SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * > CPU_INTERRUPT_NUM, 0xff); > if (VectorInfo !=3D NULL) { > Status =3D ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, > CPU_INTERRUPT_NUM); @@ -137,8 +142,13 @@ > InitializeCpuInterruptHandlers ( >=20 > AsmGetTemplateAddressMap (&TemplateMap); > ASSERT (TemplateMap.ExceptionStubHeaderSize <=3D > HOOKAFTER_STUB_SIZE); > - InterruptEntryCode =3D AllocatePool > (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM); > - ASSERT (InterruptEntryCode !=3D NULL); > + > + Status =3D gBS->AllocatePool ( > + EfiBootServicesCode, > + TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NU= M, > + (VOID **)&InterruptEntryCode > + ); > + ASSERT (!EFI_ERROR (Status) && InterruptEntryCode !=3D NULL); >=20 > InterruptEntry =3D (UINTN) InterruptEntryCode; > for (Index =3D 0; Index < CPU_INTERRUPT_NUM; Index ++) { > -- > 2.15.1.windows.2