From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) (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 1800B20958BC0 for ; Wed, 6 Sep 2017 08:31:10 -0700 (PDT) Received: by mail-wr0-x22a.google.com with SMTP id 108so14518590wra.5 for ; Wed, 06 Sep 2017 08:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5yqP4+RRN3VPadq5S0/IGXXwOPgj7delUMBtUaRnUyw=; b=h3xJv8sZKs8xhyZ5ZmdnwGaAmpOTtozRJSD/iQeHQ9SSF+fUttn41sHOr7nj4lSXN7 fUN8y7wZXwN/t247HfCvKI0wCHGT6SQlkC/YXjWr0IHEjXbnVSY3LTBJ7wp6wbXmVd05 iBHA7BMJ2fKARhKq7WMy4A/iFROLK4a33sVgo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5yqP4+RRN3VPadq5S0/IGXXwOPgj7delUMBtUaRnUyw=; b=Zy877TEgTDLjxJ0Mwhw14tesmAh9rv9AL0ENCpZfNgQV5Cyc/Z5XgtwSycKGd3G7j/ cmU/1Ok9xAz3bfRDdniqyG/3ZhElxQ9qZyVfwBkY67Jfj01RTmHG4QUjo/cwx/Y/1jtV qm5DhQuUVmuRUaM+KDPOE4O8qVqcbHU6FsS7i5rNm437IU4r8k6lQpA83JG+8lfS5aSl CqaVQuPsaL0opOzuDMpMMyX7Wj7z2EehzDLJwG12/+ekwVXPn1kUI+27fEASn8qyVa1Q np7DZ2dkBLQZfnAKK6G19FLjUv3e2uRdO0H3LBM1WY2l03ZaOzcTWFzK5yKiMYWuw+/1 eH+A== X-Gm-Message-State: AHPjjUialak6pqd4BUMeJnEUNNmhx3HLoMaO3oSlk7ipXMQvRnGLkLzW Yt8e5f0/kmiDzCDx X-Google-Smtp-Source: ADKCNb4IvVXtQoVglQLPZNP6y7yGLRutC2HjiZ5NbQAz6nwZUZsnjkuMVOL3HSG1jr+GUDHu7DuguQ== X-Received: by 10.223.173.242 with SMTP id w105mr1978257wrc.111.1504712038380; Wed, 06 Sep 2017 08:33:58 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 77sm1409731wmt.16.2017.09.06.08.33.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 08:33:57 -0700 (PDT) Date: Wed, 6 Sep 2017 16:33:55 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org Message-ID: <20170906153355.foh2ccau2yy3lnsh@bivouac.eciton.net> References: <20170905182249.1230-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20170905182249.1230-1-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [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: , X-List-Received-Date: Wed, 06 Sep 2017 15:31:10 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Sep 05, 2017 at 07:22:49PM +0100, Ard Biesheuvel wrote: > 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 Really useful thing. Reviewed-by: Leif Lindholm > --- > ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.c | 38 +++++++++++++ > ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc | 56 ++++++++++++++++++++ > ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf | 40 ++++++++++++++ > 3 files changed, 134 insertions(+) > > 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 > -- > 2.11.0 >