From nobody Mon May 6 12:35:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41321+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41321+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558685886; cv=none; d=zoho.com; s=zohoarc; b=UOUOXZonqoc3ul0CMd57SnKyL3D12q9sM7o2tqJmDBv1fOWX7BfaXDMBKNIfMkk9gcezxgJe+k+qRtJrRRVWUgxCMF4fbc69zcNP23ECoO9LLw4akISl/pHAnN9RhaWrt/WTnLGmt6s4lpr1fxSQotoW0RArLTJF8EsQ9Nl56ZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558685886; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=5bWPB20iXrxJbcRmXrx5sqwFLUXPiiNRx6Nj4di1PV4=; b=O44x9fY99+Q4ngGQpRQl2+22ckBiiIw6jqrh1bQAc/eFqGs9gen+7DNQER6eCfhqJqGHe+h+wNgIrjLFQBtmwHYQTlp3e6YixHIU1aJG1Gap7jTSbcteORIBmMUfARwGR/vNCwDwbkARLYyjpcu4ZE48rkY0yIt89fKwStkYRGg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41321+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558685886320237.8137330632867; Fri, 24 May 2019 01:18:06 -0700 (PDT) Return-Path: X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Fri, 24 May 2019 01:18:05 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2019 01:18:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,506,1549958400"; d="scan'208";a="177351861" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.157.133]) by fmsmga002.fm.intel.com with ESMTP; 24 May 2019 01:18:03 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Jordan Justen , Andrew Fish , Ray Ni Subject: [edk2-devel] [PATCH] EmulatorPkg: Fix bugs about MiscBootServices Date: Fri, 24 May 2019 16:17:43 +0800 Message-Id: <20190524081743.18780-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558685885; bh=l3AzPwySAWwArbLz/nNGPnrK9gZkidtjguWWNpfDZ9c=; h=Cc:Date:From:Reply-To:Subject:To; b=JbPncj4wDVOCOKqIuJ9G9TJJbjVjalTCRZMh2BAWKY+BjMo1buXuPxVG8LA6lfdtJZw McDME+xZCBkNuhg99n2sgKugrxH+7VVv6BIZ3iojyVRGJBXJteO3X8YIeerY4z7vHLe3C SqQN/+RM1/Dr9tcOu1bD2HC87CX/3NYXUbs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1757 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. 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(-) diff --git a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c b/Emulat= orPkg/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/Li= brary/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/Li= brary/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/ResetRuntime= Dxe/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, NUL= L); - } - - gBS->FreePool (HandleBuffer); - } - - // // Discard ResetType, always return 0 as exit code // --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41321): https://edk2.groups.io/g/devel/message/41321 Mute This Topic: https://groups.io/mt/31742582/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-