From patchwork Mon May 9 14:33:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 67347 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1627483qge; Mon, 9 May 2016 07:33:45 -0700 (PDT) X-Received: by 10.98.18.195 with SMTP id 64mr50862561pfs.152.1462804425543; Mon, 09 May 2016 07:33:45 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id ff7si13362394pab.184.2016.05.09.07.33.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 May 2016 07:33:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 063EF1A1EF4; Mon, 9 May 2016 07:33:45 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x229.google.com (mail-wm0-x229.google.com [IPv6:2a00:1450:400c:c09::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4E2741A1EEB for ; Mon, 9 May 2016 07:33:43 -0700 (PDT) Received: by mail-wm0-x229.google.com with SMTP id n129so140626710wmn.1 for ; Mon, 09 May 2016 07:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fXPJAziOsy8UVwALpOdXAJi8vPhP0xY+BuAoYiLHqog=; b=NJmJmMfM6El7w+Hz4RlaJeXcNZPW6Brxj20loIy34VkybTRPxHE5NCXS6pEY84buEk TK/FTbeKjFfVM7IzwFYwEvG5XIbGZP8uCKTAsIvJpdlbJXzh6xnCMqT6gNODwtz28+Aa QRwNS0Lu0Gw/C4AKWX9Zf2+PCFmoCGAxKl/Vs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fXPJAziOsy8UVwALpOdXAJi8vPhP0xY+BuAoYiLHqog=; b=fyqeNXi1sqT7Vl3BT52JDXqZe30qvHpmvP0cf+pvpElC8Uo3BnOJCUTKEdbvSaQr9f /bquUEPK7RuPaJDgg1cwk7JW4/eWcDzxc7EJdYkvybf9N4RzDeYMBJhbWaI5K7a59ziX IJwe7eyKXUH5lFNw0wdP6GpNek0PpGaqqbQEE30GziJXuy2nb5Wykm55y9jbcajtmTH9 1xyaRP2qkKT22A6BYEQTskDpKfjNJ7JfJzI9aSNBq/a3aM0596Bn+oTclyJkpIIf3VCd 7qgW9ZPlwtvyVBgN//2wHRe4h2GCJRKUuEVeTwwgxvD0CWBf/G7PMEokGv44lk5hGKyZ 38rQ== X-Gm-Message-State: AOPr4FX+eIbmCp1uNWfqh9w9TXTBe+nQTZxsHwuBowbj9WJNKoL8OJppgBChw+v14s3j57bI X-Received: by 10.194.175.70 with SMTP id by6mr33519935wjc.19.1462804421931; Mon, 09 May 2016 07:33:41 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id y70sm24973534wmd.3.2016.05.09.07.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 May 2016 07:33:41 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 9 May 2016 16:33:35 +0200 Message-Id: <1462804415-4007-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462804415-4007-1-git-send-email-ard.biesheuvel@linaro.org> References: <1462804415-4007-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/2] ArmPkg/DefaultExceptionHandlerLib: add stack dump to exception handling code X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This adds a partial stack dump (256 bytes at either side of the stack pointer) to the CPU state dumping routine that is invoked when taking an unexpected exception. Since dereferencing the stack pointer may itself fault, ensure that we don't enter the dumping routine recursively. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 57200ff642c2..a86f4be29931 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -34,6 +34,8 @@ STATIC CHAR8 *gExceptionTypeString[] = { "SError" }; +STATIC BOOLEAN mRecursiveException; + CHAR8 * GetImageName ( IN UINTN FaultAddress, @@ -134,6 +136,14 @@ DefaultExceptionHandler ( { CHAR8 Buffer[100]; UINTN CharCount; + INT32 Offset; + + if (mRecursiveException) { + CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception occurred while dumping the CPU state\n"); + SerialPortWrite ((UINT8 *) Buffer, CharCount); + CpuDeadLoop (); + } + mRecursiveException = TRUE; CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR); SerialPortWrite ((UINT8 *) Buffer, CharCount); @@ -182,5 +192,16 @@ DefaultExceptionHandler ( DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR); + DEBUG ((EFI_D_ERROR, "\nStack dump:\n")); + for (Offset = -256; Offset < 256; Offset += 32) { + DEBUG ((EFI_D_ERROR, "%c %013lx: %016lx %016lx %016lx %016lx\n", + Offset == 0 ? '>' : ' ', + SystemContext.SystemContextAArch64->SP + Offset, + *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset), + *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 8), + *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 16), + *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24))); + } + CpuDeadLoop (); }