From: "Dong, Eric" <eric.dong@intel.com>
To: edk2-devel <edk2-devel-bounces@lists.01.org>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
"Yao, Jiewen" <jiewen.yao@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH 2/4] UefiCpuPkg/CpuExceptionHandlerLib: support stack switch for PEI exceptions
Date: Thu, 6 Sep 2018 01:38:17 +0000 [thread overview]
Message-ID: <ED077930C258884BBCB450DB737E66224AC99446@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20180903031550.4440-3-jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org]
> Sent: Monday, September 3, 2018 11:16 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Dong, Eric <eric.dong@intel.com>; Yao,
> Jiewen <jiewen.yao@intel.com>; Laszlo Ersek <lersek@redhat.com>; Zeng,
> Star <star.zeng@intel.com>
> Subject: [edk2] [PATCH 2/4] UefiCpuPkg/CpuExceptionHandlerLib: support
> stack switch for PEI exceptions
>
> Stack Guard needs to setup stack switch capability to allow exception handler
> to be called with good stack if stack overflow is detected.
> This patch update InitializeCpuExceptionHandlersEx() to allow pass extra
> initialization data used to setup exception stack switch for specified
> exceptions.
>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: "Ware, Ryan R" <ryan.r.ware@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
> ---
> .../CpuExceptionHandlerLib/PeiCpuException.c | 27
> +++++++++++++++++++++-
> .../PeiCpuExceptionHandlerLib.inf | 4 ++++
> 2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> index 6f271983f2..5687c98c0d 100644
> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> @@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> #include <Library/DebugLib.h>
> #include <Library/HobLib.h>
> #include <Library/MemoryAllocationLib.h>
> +#include <Library/PcdLib.h>
>
> CONST UINTN mDoFarReturnFlag = 0;
>
> @@ -208,5 +209,29 @@ InitializeCpuExceptionHandlersEx (
> IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL
> )
> {
> - return InitializeCpuExceptionHandlers (VectorInfo);
> + EFI_STATUS Status;
> +
> + //
> + // To avoid repeat initialization of default handlers, the caller
> + should pass // an extended init data with InitDefaultHandlers set to
> + FALSE. There's no // need to call this method to just initialize
> + default handlers. Call non-ex // version instead; or this method must
> + be implemented as a simple wrapper of // non-ex version of it, if this
> version has to be called.
> + //
> + if (InitData == NULL || InitData->Ia32.InitDefaultHandlers) {
> + Status = InitializeCpuExceptionHandlers (VectorInfo); } else {
> + Status = EFI_SUCCESS;
> + }
> +
> + if (!EFI_ERROR (Status)) {
> + //
> + // Initializing stack switch is only necessary for Stack Guard functionality.
> + //
> + if (PcdGetBool (PcdCpuStackGuard) && InitData != NULL) {
> + Status = ArchSetupExcpetionStack (InitData);
> + }
> + }
> +
> + return Status;
> }
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i
> nf
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i
> nf
> index 783260e39a..0ea44b3052 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i
> nf
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLi
> +++ b.inf
> @@ -60,3 +60,7 @@
> HobLib
> MemoryAllocationLib
> SynchronizationLib
> +
> +[Pcd]
> + gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard
> +
> --
> 2.16.2.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2018-09-06 1:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 3:15 [PATCH 0/4] Add PEI Stack Guard feature Jian J Wang
2018-09-03 3:15 ` [PATCH 1/4] MdeModulePkg/DxeIpl: disable paging before creating new page table Jian J Wang
2018-09-03 3:15 ` [PATCH 2/4] UefiCpuPkg/CpuExceptionHandlerLib: support stack switch for PEI exceptions Jian J Wang
2018-09-06 1:38 ` Dong, Eric [this message]
2018-09-03 3:15 ` [PATCH 3/4] UefiCpuPkg/MpInitLib: fix register restore issue in AP wakeup Jian J Wang
2018-09-05 5:29 ` Dong, Eric
2018-09-03 3:15 ` [PATCH 4/4] UefiCpuPkg/CpuMpPei: support stack guard feature Jian J Wang
2018-09-06 1:45 ` Dong, Eric
2018-09-06 2:42 ` Wang, Jian J
2018-09-03 4:14 ` [PATCH 0/4] Add PEI Stack Guard feature Yao, Jiewen
2018-09-03 4:56 ` Wang, Jian J
2018-09-03 14:52 ` Laszlo Ersek
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=ED077930C258884BBCB450DB737E66224AC99446@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