From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 246F281DBF for ; Wed, 16 Nov 2016 18:54:13 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 16 Nov 2016 18:54:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,651,1473145200"; d="scan'208";a="1060472814" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 16 Nov 2016 18:54:17 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Nov 2016 18:54:17 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Thu, 17 Nov 2016 10:54:14 +0800 From: "Fan, Jeff" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Tian, Feng" Thread-Topic: [PATCH 2/2] MdeModulePkg/PiSmmCpuDxeSmm: Check RegisterCpuInterruptHandler status Thread-Index: AQHSQCaAoJJjcbzeqE2OnH60BN4zJ6Dcaijw Date: Thu, 17 Nov 2016 02:54:13 +0000 Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4A2E0088@shsmsx102.ccr.corp.intel.com> References: <20161116143343.15432-1-jeff.fan@intel.com> <20161116143343.15432-3-jeff.fan@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTkxYzA2MTUtNjVmZi00OWZmLWJjY2ItOWI2YWI2Nzk3ZDk2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IityUjJUVkwrMGo0TzdnXC94bmhtS09QUmt5S0tnU2ptXC9idng1T1g4QWJRWT0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/2] MdeModulePkg/PiSmmCpuDxeSmm: Check RegisterCpuInterruptHandler status 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: Thu, 17 Nov 2016 02:54:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Mike, I think it's not necessary to move ASSERT() to SmmRegisterExceptionHandler(= ) implementation. Because PiSmmCpuDxeSmm will invoke SmmRegisterExceptionHandler() at module = entry point function as my patch showed, it could make sure PiSmmCpuDxeSmm = choose the correct instance.=20 Other module invoke may check SmmRegisterExceptionHandler the return status= for other choice per design. For example: =20 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handl= er for InterruptType was previously installed. Thanks! Jeff -----Original Message----- From: Kinney, Michael D=20 Sent: Thursday, November 17, 2016 12:29 AM To: Fan, Jeff; edk2-devel@lists.01.org; Kinney, Michael D Cc: Tian, Feng Subject: RE: [PATCH 2/2] MdeModulePkg/PiSmmCpuDxeSmm: Check RegisterCpuInte= rruptHandler status Jeff, Shouldn't this ASSERT() be moved into the implementation of SmmRegisterExce= ptionHandler()? This will make sure the PiSmmCpuDxeSmm driver uses the rig= ht lib instance for exceptions that module registers and for exceptions oth= er SMM modules register through the EFI_SMM_CPU_SERVICE_PROTOCOL. Mike > -----Original Message----- > From: Fan, Jeff > Sent: Wednesday, November 16, 2016 6:34 AM > To: edk2-devel@lists.01.org > Cc: Tian, Feng ; Kinney, Michael D=20 > > Subject: [PATCH 2/2] MdeModulePkg/PiSmmCpuDxeSmm: Check=20 > RegisterCpuInterruptHandler status >=20 > Once platform selects the incorrect instance, the caller could know it=20 > from return status and ASSERT(). >=20 > Cc: Feng Tian > Cc: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Fan > --- > UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 4 +++- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 5 ++++- > UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 4 +++- > 3 files changed, 10 insertions(+), 3 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c > index a871bef..f2e2ceb 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c > @@ -27,6 +27,7 @@ SmmInitPageTable ( > { > UINTN PageFaultHandlerHookAddress; > IA32_IDT_GATE_DESCRIPTOR *IdtEntry; > + EFI_STATUS Status; >=20 > // > // Initialize spin lock > @@ -49,7 +50,8 @@ SmmInitPageTable ( > // > // Register SMM Page Fault Handler > // > - SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_PAGE_FAULT= , > SmiPFHandler); > + Status =3D SmmRegisterExceptionHandler (&mSmmCpuService,=20 > + EXCEPT_IA32_PAGE_FAULT, > SmiPFHandler); > + ASSERT_EFI_ERROR (Status); > } >=20 > // > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c > index 329574e..350a6a2 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c > @@ -1384,5 +1384,8 @@ InitIdtr ( > VOID > ) > { > - SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_DEBUG,=20 > DebugExceptionHandler); > + EFI_STATUS Status; > + > + Status =3D SmmRegisterExceptionHandler (&mSmmCpuService,=20 > + EXCEPT_IA32_DEBUG, > DebugExceptionHandler); > + ASSERT_EFI_ERROR (Status); > } > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > index 9cee784..c49fb26 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > @@ -102,6 +102,7 @@ SmmInitPageTable ( > UINTN Index; > UINTN PageFaultHandlerHookAddress; > IA32_IDT_GATE_DESCRIPTOR *IdtEntry; > + EFI_STATUS Status; >=20 > // > // Initialize spin lock > @@ -160,7 +161,8 @@ SmmInitPageTable ( > // > // Register Smm Page Fault Handler > // > - SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_PAGE_FAULT= , > SmiPFHandler); > + Status =3D SmmRegisterExceptionHandler (&mSmmCpuService,=20 > + EXCEPT_IA32_PAGE_FAULT, > SmiPFHandler); > + ASSERT_EFI_ERROR (Status); > } >=20 > // > -- > 2.9.3.windows.2