From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: ray.ni@intel.com) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by groups.io with SMTP; Fri, 24 May 2019 02:08:25 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2019 02:08:24 -0700 X-ExtLoop1: 1 Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 24 May 2019 02:08:24 -0700 Received: from fmsmsx162.amr.corp.intel.com (10.18.125.71) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 24 May 2019 02:08:24 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx162.amr.corp.intel.com (10.18.125.71) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 24 May 2019 02:08:23 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.33]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.10]) with mapi id 14.03.0415.000; Fri, 24 May 2019 17:08:21 +0800 From: "Ni, Ray" To: "Liu, Zhiguang" , "devel@edk2.groups.io" CC: "Justen, Jordan L" , Andrew Fish Subject: Re: [PATCH] EmulatorPkg: Fix bugs about MiscBootServices Thread-Topic: [PATCH] EmulatorPkg: Fix bugs about MiscBootServices Thread-Index: AQHVEgk8OjMufGjE+kywxItR4/LUaqZ5/B2Q Date: Fri, 24 May 2019 09:08:21 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C15EC73@SHSMSX104.ccr.corp.intel.com> References: <20190524081743.18780-1-zhiguang.liu@intel.com> In-Reply-To: <20190524081743.18780-1-zhiguang.liu@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWYxZmFiN2YtZDUxYS00YTYxLWI1ZjItZTI2MzM3NmFmNTRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZlY0bFhwMHZ1SEdFQUg1NFwvdGEzaUNpNk92MFlYVnNyb252ZTdrc0tURWFXNjFMeG9JaTRCaFhSSEJhN2NOWWgifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Zhiguang, For the first issue, where does the fix come from? Or you did the implementation yourself? I ask this because I want to make sure the code is from an existing tested implementation. Thanks, Ray > -----Original Message----- > From: Liu, Zhiguang > Sent: Friday, May 24, 2019 4:18 PM > To: devel@edk2.groups.io > Cc: Justen, Jordan L ; Andrew Fish > ; Ni, Ray > Subject: [PATCH] EmulatorPkg: Fix bugs about MiscBootServices >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1757 >=20 > This patch fix two issues. > 1. > The previous code "NanoSecondDelay (MicroSeconds * 1000)" > may cause data overflow. > 2. > Delete some code in > /EmulatorPkg/ResetRuntimeDxe/Reset.c > which may cause Tpl problems when invoked by watchdog. > I think it is ok to delete these code, because it will > be more like what NT32 does. >=20 > Signed-off-by: Zhiguang Liu > Cc: Jordan Justen > Cc: Andrew Fish > Cc: Ray Ni > --- > EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c | 14 > +++++++++++++- > EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c | 14 +++++++++++++= - > EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c | 14 +++++++++++++= - > EmulatorPkg/ResetRuntimeDxe/Reset.c | 24 -------------= ----------- > 4 files changed, 39 insertions(+), 27 deletions(-) >=20 > diff --git a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c > b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c > index c331cbba9c..813963de7b 100644 > --- a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c > +++ b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c > @@ -33,7 +33,19 @@ MicroSecondDelay ( > IN UINTN MicroSeconds > ) > { > - return NanoSecondDelay (MicroSeconds * 1000); > + UINTN Remainder; > + UINTN Counter; > + UINTN Index; > + Counter =3D (UINTN) DivU64x32Remainder ( > + MultU64x32 (MicroSeconds, 1000), > + 0xffffffff, > + &Remainder > + ); > + for (Index =3D 0; Index < Counter; Index++) { > + NanoSecondDelay (0xffffffff); > + } > + NanoSecondDelay (Remainder); > + return MicroSeconds; > } >=20 >=20 > diff --git a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c > b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c > index 14cae4214c..590ce55fae 100644 > --- a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c > +++ b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c > @@ -64,7 +64,19 @@ MicroSecondDelay ( > IN UINTN MicroSeconds > ) > { > - return NanoSecondDelay (MicroSeconds * 1000); > + UINTN Remainder; > + UINTN Counter; > + UINTN Index; > + Counter =3D (UINTN) DivU64x32Remainder ( > + MultU64x32 (MicroSeconds, 1000), > + 0xffffffff, > + &Remainder > + ); > + for (Index =3D 0; Index < Counter; Index++) { > + NanoSecondDelay (0xffffffff); > + } > + NanoSecondDelay (Remainder); > + return MicroSeconds; > } >=20 >=20 > diff --git a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c > b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c > index cce46fb366..dcac32a51f 100644 > --- a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c > +++ b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c > @@ -30,7 +30,19 @@ MicroSecondDelay ( > IN UINTN MicroSeconds > ) > { > - return NanoSecondDelay (MicroSeconds * 1000); > + UINTN Remainder; > + UINTN Counter; > + UINTN Index; > + Counter =3D (UINTN) DivU64x32Remainder ( > + MultU64x32 (MicroSeconds, 1000), > + 0xffffffff, > + &Remainder > + ); > + for (Index =3D 0; Index < Counter; Index++) { > + NanoSecondDelay (0xffffffff); > + } > + NanoSecondDelay (Remainder); > + return MicroSeconds; > } >=20 > /** > diff --git a/EmulatorPkg/ResetRuntimeDxe/Reset.c > b/EmulatorPkg/ResetRuntimeDxe/Reset.c > index 19504825c9..9439f9ccff 100644 > --- a/EmulatorPkg/ResetRuntimeDxe/Reset.c > +++ b/EmulatorPkg/ResetRuntimeDxe/Reset.c > @@ -29,30 +29,6 @@ EmuResetSystem ( > IN VOID *ResetData OPTIONAL > ) > { > - EFI_STATUS Status; > - UINTN HandleCount; > - EFI_HANDLE *HandleBuffer; > - UINTN Index; > - > - // > - // Disconnect all > - // > - Status =3D gBS->LocateHandleBuffer ( > - AllHandles, > - NULL, > - NULL, > - &HandleCount, > - &HandleBuffer > - ); > - if (!EFI_ERROR (Status)) { > - for (Index =3D 0; Index < HandleCount; Index++) { > - Status =3D gBS->DisconnectController (HandleBuffer[Index], NULL, N= ULL); > - } > - > - gBS->FreePool (HandleBuffer); > - } > - > - > // > // Discard ResetType, always return 0 as exit code > // > -- > 2.21.0.windows.1