From nobody Sat Nov 2 12:16:17 2024 Delivered-To: importer@patchew.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; Authentication-Results: mx.zoho.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 1491053152303278.63086257254815; Sat, 1 Apr 2017 06:25:52 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C58F0219392FE; Sat, 1 Apr 2017 06:25:40 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 29B3C219392F0 for ; Sat, 1 Apr 2017 06:25:40 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 01 Apr 2017 06:25:40 -0700 Received: from jfan12-desk.ccr.corp.intel.com ([10.239.158.57]) by fmsmga004.fm.intel.com with ESMTP; 01 Apr 2017 06:25:38 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,257,1486454400"; d="scan'208";a="242806000" From: Jeff Fan To: edk2-devel@lists.01.org Date: Sat, 1 Apr 2017 21:25:27 +0800 Message-Id: <20170401132530.8340-7-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20170401132530.8340-1-jeff.fan@intel.com> References: <20170401132530.8340-1-jeff.fan@intel.com> Subject: [edk2] [PATCH 6/9] UefiCpuPkg/CpuExceptionHandlerLib: Display PF Excption Data bit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , Feng Tian , Jiewen Yao 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" Page-fault exception data bit displaying is very useful. Cc: Jiewen Yao Cc: Michael Kinney Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- .../CpuExceptionHandlerLib/CpuExceptionCommon.h | 11 +++++++++ .../Ia32/ArchExceptionHandler.c | 26 ++++++++++++++++--= ---- .../X64/ArchExceptionHandler.c | 26 ++++++++++++++++--= ---- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h index 5b3a9b9..e66a5df 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h @@ -30,6 +30,17 @@ #define CPU_INTERRUPT_NUM 256 #define HOOKAFTER_STUB_SIZE 16 =20 +// +// Exception Error Code of Page-Fault Exception +// +#define IA32_PF_EC_P BIT0 +#define IA32_PF_EC_WR BIT1 +#define IA32_PF_EC_US BIT2 +#define IA32_PF_EC_RSVD BIT3 +#define IA32_PF_EC_ID BIT4 +#define IA32_PF_EC_PK BIT5 +#define IA32_PF_EC_SGX BIT15 + #include "ArchInterruptDefs.h" =20 #define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \ diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHa= ndler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandl= er.c index 59ed058..013e19b 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c @@ -126,19 +126,31 @@ DumpCpuContext ( GetExceptionNameStr (ExceptionType), GetApicId () ); - + if ((mErrorCodeFlag & (1 << ExceptionType)) !=3D 0) { + InternalPrintMessage ( + "ExceptionData - %08x", + SystemContext.SystemContextIa32->ExceptionData + ); + if (ExceptionType =3D=3D EXCEPT_IA32_PAGE_FAULT) { + InternalPrintMessage ( + " I:%x R:%x U:%x W:%x P:%x PK:%x S:%x", + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) = !=3D 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_RSVD)= !=3D 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_US) = !=3D 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_WR) = !=3D 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_P) = !=3D 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_PK) = !=3D 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_SGX) = !=3D 0 + ); + } + InternalPrintMessage ("\n"); + } InternalPrintMessage ( "EIP - %08x, CS - %08x, EFLAGS - %08x\n", SystemContext.SystemContextIa32->Eip, SystemContext.SystemContextIa32->Cs, SystemContext.SystemContextIa32->Eflags ); - if ((mErrorCodeFlag & (1 << ExceptionType)) !=3D 0) { - InternalPrintMessage ( - "ExceptionData - %08x\n", - SystemContext.SystemContextIa32->ExceptionData - ); - } InternalPrintMessage ( "EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x\n", SystemContext.SystemContextIa32->Eax, diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHan= dler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler= .c index 5199559..98a776f 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -131,19 +131,31 @@ DumpCpuContext ( GetExceptionNameStr (ExceptionType), GetApicId () ); - + if ((mErrorCodeFlag & (1 << ExceptionType)) !=3D 0) { + InternalPrintMessage ( + "ExceptionData - %016lx", + SystemContext.SystemContextX64->ExceptionData + ); + if (ExceptionType =3D=3D EXCEPT_IA32_PAGE_FAULT) { + InternalPrintMessage ( + " I:%x R:%x U:%x W:%x P:%x PK:%x S:%x", + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) = !=3D 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_RSVD) = !=3D 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_US) = !=3D 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_WR) = !=3D 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_P) = !=3D 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_PK) = !=3D 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_SGX) = !=3D 0 + ); + } + InternalPrintMessage ("\n"); + } InternalPrintMessage ( "RIP - %016lx, CS - %016lx, RFLAGS - %016lx\n", SystemContext.SystemContextX64->Rip, SystemContext.SystemContextX64->Cs, SystemContext.SystemContextX64->Rflags ); - if (mErrorCodeFlag & (1 << ExceptionType)) { - InternalPrintMessage ( - "ExceptionData - %016lx\n", - SystemContext.SystemContextX64->ExceptionData - ); - } InternalPrintMessage ( "RAX - %016lx, RCX - %016lx, RDX - %016lx\n", SystemContext.SystemContextX64->Rax, --=20 2.9.3.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel