From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=34.238.86.106; helo=mail.paulo.ac; envelope-from=paulo@paulo.ac; receiver=edk2-devel@lists.01.org Received: from mail.paulo.ac (mail.paulo.ac [34.238.86.106]) (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 5F638222DDBEF for ; Sun, 14 Jan 2018 16:18:55 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.paulo.ac (Postfix) with ESMTP id 7B66DC08890; Mon, 15 Jan 2018 00:24:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at paulo.ac X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=6.31 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: mail.paulo.ac (amavisd-new); dkim=pass (1024-bit key) header.d=paulo.ac Received: from mail.paulo.ac ([127.0.0.1]) by localhost (mail.paulo.ac [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id di0REKi9cHnS; Mon, 15 Jan 2018 00:24:11 +0000 (UTC) Received: from thor.domain.name (177.204.15.215.dynamic.adsl.gvt.net.br [177.204.15.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.paulo.ac (Postfix) with ESMTPSA id B81F6C78F41; Mon, 15 Jan 2018 00:24:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.paulo.ac B81F6C78F41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=paulo.ac; s=default; t=1515975848; bh=P3yNyXi4SecmzornniLLT/wG3+E0RVMUEbdorzmZqPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=UjYWL7xbPtogQlRYOhdkN8oFSirPGwe0OWORBV2lT+iYUnDngujL8ScHSOnYVKmJ1 eMYF5Q5ccwCtZ3S0OZlfEe/bUuWeIIGVC7oxvNltbh6V6PzmHp7o0JwaIu1y3CF6xC sm0yJQYyuhQiYF4V1UZg11UiqPNZ8I9wuXgTbFQk= From: Paulo Alcantara To: edk2-devel@lists.01.org Cc: Paulo Alcantara , Eric Dong , Laszlo Ersek Date: Sun, 14 Jan 2018 22:23:36 -0200 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Subject: [RFC v5 8/8] UefiCpuPkg/CpuExceptionHandlerLib: Add early check in DumpStackContents X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 00:18:55 -0000 Add an early check in DumpStackContens() to abort in case of no unwound stacks. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Eric Dong Cc: Laszlo Ersek Signed-off-by: Paulo Alcantara --- UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c | 7 +++++++ UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c index 31fbd4a164..ac3801f704 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c @@ -805,6 +805,13 @@ DumpStackContents ( { UINT32 CurrentEsp; + // + // Do nothing in case there wasn't any unwound stack. + // + if (UnwoundStacksCount == 0) { + return; + } + // // Get current stack pointer // diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c index 4d8c9b0a89..6c3bad01a6 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -418,6 +418,13 @@ DumpStackContents ( UINTN RspAddressStart; UINTN RspAddressEnd; + // + // Do nothing in case there wasn't any unwound stack. + // + if (UnwoundStacksCount == 0) { + return; + } + // // Get current stack pointer // -- 2.14.3