public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dong, Eric" <eric.dong@intel.com>
To: "Wang, Jian J" <jian.j.wang@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>,
	Laszlo Ersek <lersek@redhat.com>
Subject: Re: [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers
Date: Tue, 16 Jan 2018 14:02:12 +0000	[thread overview]
Message-ID: <ED077930C258884BBCB450DB737E66224AA8AEBD@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20180115085433.25008-3-jian.j.wang@intel.com>

Reviewed-by: Eric Dong <eric.dong@intel.com>

> -----Original Message-----
> From: Wang, Jian J
> Sent: Monday, January 15, 2018 4:54 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Dong, Eric <eric.dong@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code
> memory for exception handlers
> 
> If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
> of EfiBootServicesData, EfiConventionalMemory, the BIOS will reset after
> timer initialized and started.
> 
> The root cause is that the memory used to hold the exception and interrupt
> 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.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
> ---
>  .../Library/CpuExceptionHandlerLib/DxeException.c      | 18
> ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> 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 <Library/DebugLib.h>
>  #include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> 
>  CONST UINTN    mDoFarReturnFlag  = 0;
> 
> @@ -106,8 +107,12 @@ InitializeCpuInterruptHandlers (
>    RESERVED_VECTORS_DATA              *ReservedVectors;
>    EFI_CPU_INTERRUPT_HANDLER          *ExternalInterruptHandler;
> 
> -  ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) *
> CPU_INTERRUPT_NUM);
> -  ASSERT (ReservedVectors != NULL);
> +  Status = gBS->AllocatePool (
> +                  EfiBootServicesCode,
> +                  sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM,
> +                  (VOID **)&ReservedVectors
> +                  );
> +  ASSERT (!EFI_ERROR (Status) && ReservedVectors != NULL);
>    SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) *
> CPU_INTERRUPT_NUM, 0xff);
>    if (VectorInfo != NULL) {
>      Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors,
> CPU_INTERRUPT_NUM); @@ -137,8 +142,13 @@
> InitializeCpuInterruptHandlers (
> 
>    AsmGetTemplateAddressMap (&TemplateMap);
>    ASSERT (TemplateMap.ExceptionStubHeaderSize <=
> HOOKAFTER_STUB_SIZE);
> -  InterruptEntryCode = AllocatePool
> (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM);
> -  ASSERT (InterruptEntryCode != NULL);
> +
> +  Status = gBS->AllocatePool (
> +                  EfiBootServicesCode,
> +                  TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM,
> +                  (VOID **)&InterruptEntryCode
> +                  );
> +  ASSERT (!EFI_ERROR (Status) && InterruptEntryCode != NULL);
> 
>    InterruptEntry = (UINTN) InterruptEntryCode;
>    for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) {
> --
> 2.15.1.windows.2



  reply	other threads:[~2018-01-16 13:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  8:54 [PATCH 0/6] Fix issues caused by NX memory protection Jian J Wang
2018-01-15  8:54 ` [PATCH 1/6] UefiCpuPkg/MpInitLib: split wake up buffer into two parts Jian J Wang
2018-01-18  6:53   ` Dong, Eric
2018-01-27 16:17   ` Laszlo Ersek
2018-01-28 21:43     ` Laszlo Ersek
2018-01-29  1:06       ` Wang, Jian J
2018-01-29 15:50         ` Laszlo Ersek
2018-01-15  8:54 ` [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers Jian J Wang
2018-01-16 14:02   ` Dong, Eric [this message]
2018-01-15  8:54 ` [PATCH 3/6] UefiCpuPkg/CpuDxe: clear NX attr for page directory Jian J Wang
2018-01-16 14:02   ` Dong, Eric
2018-01-15  8:54 ` [PATCH 4/6] UefiCpuPkg/PiSmmCpuDxeSmm: Enable NXE if it's supported Jian J Wang
2018-01-16 14:02   ` Dong, Eric
2018-01-28 22:46   ` Laszlo Ersek
2018-01-29  9:02     ` Wang, Jian J
2018-01-29 19:48       ` Laszlo Ersek
2018-01-30 13:09         ` Laszlo Ersek
2018-02-01  1:08         ` Wang, Jian J
2018-01-15  8:54 ` [PATCH 5/6] MdeModulePkg/PiSmmCore: remove NX attr for SMM RAM Jian J Wang
2018-01-15 10:18   ` Zeng, Star
2018-01-15  8:54 ` [PATCH 6/6] MdeModulePkg/BootScriptExecutorDxe: remove NX attr for FfsBuffer Jian J Wang
2018-01-15 10:18   ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ED077930C258884BBCB450DB737E66224AA8AEBD@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox