From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 23BCB81EF7 for ; Tue, 29 Nov 2016 23:22:49 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 29 Nov 2016 23:22:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,720,1473145200"; d="scan'208";a="792464400" Received: from jfan12-desk.ccr.corp.intel.com ([10.239.9.5]) by FMSMGA003.fm.intel.com with ESMTP; 29 Nov 2016 23:22:47 -0800 From: Jeff Fan To: edk2-devel@lists.01.org Cc: Feng Tian , Jiewen Yao , Michael D Kinney Date: Wed, 30 Nov 2016 15:22:42 +0800 Message-Id: <20161130072243.35268-3-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20161130072243.35268-1-jeff.fan@intel.com> References: <20161130072243.35268-1-jeff.fan@intel.com> Subject: [PATCH 2/3] UefiCpuPkg: Add ExceptionHandlerData for ArchRestoreExceptionContext() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Nov 2016 07:22:49 -0000 mReservedVectors is not set, we could add parameter ExceptionHandlerData for ArchRestoreExceptionContext() that could use it instead of mReservedVectors. Cc: Feng Tian Cc: Jiewen Yao Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- .../CpuExceptionHandlerLib/CpuExceptionCommon.h | 11 +++++----- .../Ia32/ArchExceptionHandler.c | 21 +++++++++++------- .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c | 2 +- .../X64/ArchExceptionHandler.c | 25 +++++++++++++--------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h index dc5d941..f2e4692 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h @@ -211,14 +211,15 @@ ArchSaveExceptionContext ( /** Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. **/ VOID ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData ); /** diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c index b96636b..7ab2438 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c @@ -87,19 +87,24 @@ ArchSaveExceptionContext ( /** Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. **/ VOID ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData ) { - SystemContext.SystemContextIa32->Eflags = mReservedVectors[ExceptionType].OldFlags; - SystemContext.SystemContextIa32->Cs = mReservedVectors[ExceptionType].OldCs; - SystemContext.SystemContextIa32->Eip = mReservedVectors[ExceptionType].OldIp; - SystemContext.SystemContextIa32->ExceptionData = mReservedVectors[ExceptionType].ExceptionData; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + SystemContext.SystemContextIa32->Eflags = ReservedVectors[ExceptionType].OldFlags; + SystemContext.SystemContextIa32->Cs = ReservedVectors[ExceptionType].OldCs; + SystemContext.SystemContextIa32->Eip = ReservedVectors[ExceptionType].OldIp; + SystemContext.SystemContextIa32->ExceptionData = ReservedVectors[ExceptionType].ExceptionData; } /** diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c index 483a417..c0fc9a6 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c @@ -68,7 +68,7 @@ CommonExceptionHandlerWorker ( // Old IDT handler has been executed, then restore CPU exception content to // run new exception handler. // - ArchRestoreExceptionContext (ExceptionType, SystemContext); + ArchRestoreExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData); // // Rlease spin lock for ApicId // diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c index f84b1a8..7495b14 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -90,21 +90,26 @@ ArchSaveExceptionContext ( /** Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. **/ VOID ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData ) { - SystemContext.SystemContextX64->Ss = mReservedVectors[ExceptionType].OldSs; - SystemContext.SystemContextX64->Rsp = mReservedVectors[ExceptionType].OldSp; - SystemContext.SystemContextX64->Rflags = mReservedVectors[ExceptionType].OldFlags; - SystemContext.SystemContextX64->Cs = mReservedVectors[ExceptionType].OldCs; - SystemContext.SystemContextX64->Rip = mReservedVectors[ExceptionType].OldIp; - SystemContext.SystemContextX64->ExceptionData = mReservedVectors[ExceptionType].ExceptionData; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + SystemContext.SystemContextX64->Ss = ReservedVectors[ExceptionType].OldSs; + SystemContext.SystemContextX64->Rsp = ReservedVectors[ExceptionType].OldSp; + SystemContext.SystemContextX64->Rflags = ReservedVectors[ExceptionType].OldFlags; + SystemContext.SystemContextX64->Cs = ReservedVectors[ExceptionType].OldCs; + SystemContext.SystemContextX64->Rip = ReservedVectors[ExceptionType].OldIp; + SystemContext.SystemContextX64->ExceptionData = ReservedVectors[ExceptionType].ExceptionData; } /** -- 2.9.3.windows.2