From patchwork Tue Sep 5 18:22:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111707 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp3193293qge; Tue, 5 Sep 2017 11:23:00 -0700 (PDT) X-Received: by 10.84.235.71 with SMTP id g7mr5158183plt.86.1504635780851; Tue, 05 Sep 2017 11:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504635780; cv=none; d=google.com; s=arc-20160816; b=rq6MFonwXXOENEAoOrRH15bqniHaGKNYlOGInoiS4TU695PgvCsD17cS8kRcaBrZ2o VDQJVQnIWhFYUDtW/l/jILcerIJ4HhnUGx/SAJFZJUKXA5Y0FDOZiANenRYmoyk5p//R Mohu2LcjFJcHD7d5/+boHV6GRqgH8yeSurJE+Zhv3NAqUPODEt0POe2qdAAsTd7SIFBl 1hWtlB9hz/uuYniOPas5Uv57119e0TSOp9K9jXT6+HlKVhEqLFRDk4MU95mL7eUwn3PK 0bQ1uSUitzBhpzHxqXAZogXWbChmpUWoGASSfd4AlyGNsdzbewjrfIIa2VZPVHEAsJpA elfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=vH6WJ8XRydAr1nwvpDSxO4M0jpTwHzimbrGJE16wvy0=; b=tnxAqORbdpvMwcDaCHxLU3VMXdYJjtZ+gk9X9j/l9d6vNSAMzy2wz7W4cJqcjr4YSY Y0JeGtX1beKvfs6EIZqRMtsGflLc+7+uTONi60fMMaIqSyCkWO0hgcSn6OFgf3hb5CJ6 5lMTvDAjxhllycklohQM2JjUVqAAC5Tad3vRSfkgv2hpmTqGnLHb9/88BmBhBu+ccsiW 9cc3RL3LIqN1TkfjYeiGtt41Vu29wQ65l/8ZOhM3UZOs0BvmL3g6r/UoUtmblSMjTjI+ 0jttdSpv1HkVuyKLxI6g9QhdT1T8Ttsxv2UuGRrvwW0BlpGtekWuqpOpb/xHAHj8GYxw Qkcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=J2Y2hLBg; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id b3si687738plb.691.2017.09.05.11.23.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 11:23:00 -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 header.s=google header.b=J2Y2hLBg; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7148221E2BE22; Tue, 5 Sep 2017 11:20:10 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (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 9AD112095BB67 for ; Tue, 5 Sep 2017 11:20:08 -0700 (PDT) Received: by mail-wm0-x22c.google.com with SMTP id u26so22657715wma.0 for ; Tue, 05 Sep 2017 11:22:57 -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; bh=gdAOOrRGo5hExX6okl1XEHec5WQyhXEhqMNs9NyfE1o=; b=J2Y2hLBgW2RYAUxPIos7KVOUYRgxI1tO0v1RRHla+UlLi6l0U8WIfJM7JeCGRcm3hh Cb4Bgx5qUbxX1Ww4WqskFMEZUjzUQRZQfHdznjhPvrpA2ZHvYBwxnTHKnUp3J1HTGVBc GaPZILKAXPyhEF253D69OUYFrEMhmefhpg638= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gdAOOrRGo5hExX6okl1XEHec5WQyhXEhqMNs9NyfE1o=; b=mcG70d17iWS8U3tOJWe6E2bfgTzho7+wUD0OsKYjdMCSLqXMQU2hqPXK4XhsvFZ/AU lVuXzan8W5j48WwNrQTio0kBbXY4SBfRttP1DX82ohjRRUzUq2DQgcuGtbEKzgitzxrR AQ2fjzHhX6yIHzD/Pfv9SZigOSMKYU01ksI4s+xpTXSiNcc861sU6uCfZO1MVEC3fkEM 7TFewE5PSUGbWFHdHNh7ek5Fsoked61UqJrhaT3x0kycz63S8SnBMlLxgMVkXyNG5SjR aOaSQfgMk00pnyqe0rggZTSMqUgZEtbRRDqwcc6yC+leiaUlcJ4mP0qXPAPsQJKgnQN0 E58A== X-Gm-Message-State: AHPjjUjR9eH6DyXMjOjh0w4qoIULgciLwVKF1g2jZocy+r9D2unfxLA8 cDb/gMm/wlonDjN1QcAOxg== X-Google-Smtp-Source: ADKCNb5xqK1wsgfWVDMf7lQVfAWrA9kUv/c9mVUWg2kkOV6DXenNmUMHoitPZCXJQS+xuFDxGBuAZQ== X-Received: by 10.28.183.5 with SMTP id h5mr2633386wmf.60.1504635776232; Tue, 05 Sep 2017 11:22:56 -0700 (PDT) Received: from localhost.localdomain ([154.151.223.220]) by smtp.gmail.com with ESMTPSA id f188sm1384605wme.21.2017.09.05.11.22.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 11:22:54 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Tue, 5 Sep 2017 19:22:49 +0100 Message-Id: <20170905182249.1230-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] ArmPkg: add ArmCrashDumpDxe driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Even though RELEASE builds produce some diagnostics when a crash occurs, they can be rather unhelpful: Synchronous Exception at 0x0000000000000000 and sometimes, it would be useful to get a full register dump from a production machine without having to modify the firmware. This can be achieved very easily by incorporating a DEBUG build of ARM's DefaultExceptionHandlerLib into a DXE driver, and registering its DefaultExceptionHandler entry point as the synchronous exception handler, overriding the default one. If we then build this driver using the UefiDebugLibConOut DebugLib implementation, we end up with a module than can simply be loaded via the Shell on any system. Shell> load fs0:ArmCrashDumpDxe.efi As a bonus, the crash dump will also appear on the graphical display, not only on the serial port. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.c | 38 +++++++++++++ ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc | 56 ++++++++++++++++++++ ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf | 40 ++++++++++++++ 3 files changed, 134 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.c b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.c new file mode 100644 index 000000000000..221798a26b22 --- /dev/null +++ b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.c @@ -0,0 +1,38 @@ +/** @file + + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include + +STATIC EFI_CPU_ARCH_PROTOCOL *mCpu; + +EFI_STATUS +EFIAPI +ArmCrashDumpDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu); + ASSERT_EFI_ERROR(Status); + + return mCpu->RegisterInterruptHandler (mCpu, + EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS, + &DefaultExceptionHandler); +} diff --git a/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc new file mode 100644 index 000000000000..5bb27da14bd4 --- /dev/null +++ b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc @@ -0,0 +1,56 @@ +#/** @file +# +# Copyright (c) 2017, Linaro Ltd. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + PLATFORM_NAME = ArmCrashDumpDxe + PLATFORM_GUID = 8dc3c2f8-988e-4e32-8fb7-0df43f6d0d8a + PLATFORM_VERSION = 0.1 + DSC_SPECIFICATION = 0x00010019 + OUTPUT_DIRECTORY = Build/ArmCrashDumpDxe + SUPPORTED_ARCHITECTURES = AARCH64 + BUILD_TARGETS = DEBUG + SKUID_IDENTIFIER = DEFAULT + +[PcdsFixedAtBuild] + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x27 + +[LibraryClasses] + ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf + +[Components.common] + ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf diff --git a/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf new file mode 100644 index 000000000000..828b23924920 --- /dev/null +++ b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf @@ -0,0 +1,40 @@ +#/** @file +# +# Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x00010018 + BASE_NAME = ArmCrashDumpDxe + FILE_GUID = 0bda00b0-05d6-4bb8-bfc7-058ad13615cf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = ArmCrashDumpDxeInitialize + +[Sources] + ArmCrashDumpDxe.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + DefaultExceptionHandlerLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiCpuArchProtocolGuid + +[Depex] + gEfiCpuArchProtocolGuid