From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::141; helo=mail-it1-x141.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 2584C211B76AE for ; Tue, 15 Jan 2019 03:14:36 -0800 (PST) Received: by mail-it1-x141.google.com with SMTP id i145so4381039ita.4 for ; Tue, 15 Jan 2019 03:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XLvh4kNoFPTOIUBhOJLS0zwdfnVlWKTifJeOG6TQ+JE=; b=A+b68s1MV47AXsul/2TSzokKTp9Hhts01PX89d5Jb9/2ins/YbPq6dgqSuH7uS17ZZ m3k84aEYplX1+TlcTUjrH2j9CmjtbWsdf7WCas9H8qlhPXMISpGL0MsI7xeJqRzf67lQ fHaN59Iz6QoPwJKdlfAIflt0B/1THRNS8wpO4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XLvh4kNoFPTOIUBhOJLS0zwdfnVlWKTifJeOG6TQ+JE=; b=mz3xgxRDvmc34DFFeirmoeYLO/KH5TD4XIt249RWwwMArz+CMpm4yAXDm9wr3tyMdz yeqzEBCr/wmmAdZeyuVh2PhmPl8Suut5BOLr9AOaWuLsVxdJ7aEwFjV0OS9i2ybKljr/ GLThx4LH3Fccci6tZBUpkELd0TAVeJrUu/NeKXnmys/B5TCaftkzgym5RoH4b1Po2Jau YFrzFtrSZ01nPz3WD5blE/JnRbGfz8tpPq/N+d8ENwoWH6qp/kLZ8fpP3LvkO0FlXEsO Uh47FGUpU/HTbXm0oCwsuXSUxJp6Hx9pAwYiYaXTvt2Vuxkg21EqLd1QVGSR3xD0UISS VDpQ== X-Gm-Message-State: AJcUukdDnNq19aQVwn5PdYWoG4205SJf+KO6fXJkB5KrkiSS61KJhJ6M NV4SfR0WYLa0Vgv20Hcdz+6oNxRNHiPwJ/f7x/IHuQ== X-Google-Smtp-Source: ALg8bN5hbuDmdtmMP4mLHzfwM5+/wJ4k+05P3PXUfh75wR/bxM9I2EMr8nbW5uWlJ8nhbIzNV8H5BYiEiu150K+7g2w= X-Received: by 2002:a24:710:: with SMTP id f16mr1898859itf.121.1547550875761; Tue, 15 Jan 2019 03:14:35 -0800 (PST) MIME-Version: 1.0 References: <20190115082345.3711-1-ard.biesheuvel@linaro.org> <20190115082345.3711-6-ard.biesheuvel@linaro.org> <76d33f86-fa11-dac2-8975-2cc2691f32f1@redhat.com> In-Reply-To: <76d33f86-fa11-dac2-8975-2cc2691f32f1@redhat.com> From: Ard Biesheuvel Date: Tue, 15 Jan 2019 12:14:24 +0100 Message-ID: To: Laszlo Ersek Cc: "edk2-devel@lists.01.org" , Leif Lindholm Subject: Re: [PATCH v2 5/5] ArmPkg/DefaultExceptionHandlerLib: use console if available X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2019 11:14:37 -0000 Content-Type: text/plain; charset="UTF-8" On Tue, 15 Jan 2019 at 11:09, Laszlo Ersek wrote: > > On 01/15/19 09:23, Ard Biesheuvel wrote: > > Print the minimal 'exception occurred' message to the console instead > > of straight to the serial port if the console is available. This makes > > such messages visible on systems where the console is graphical and > > the serial is not connected. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Ard Biesheuvel > > Reviewed-by: Leif Lindholm > > --- > > ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 12 ++++++++++-- > > ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c | 7 ++++++- > > ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf | 1 + > > 3 files changed, 17 insertions(+), 3 deletions(-) > > Please consider updating the following, before pushing the patch: > > > diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c > > index 1024bf48c63d..362acd5ba6d2 100644 > > --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c > > +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c > > @@ -22,6 +22,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -159,14 +160,21 @@ DefaultExceptionHandler ( > > INT32 Offset; > > > > if (mRecursiveException) { > > - CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception occurred while dumping the CPU state\n"); > > - SerialPortWrite ((UINT8 *) Buffer, CharCount); > > + STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n"; > > + > > + SerialPortWrite ((UINT8 *)Message, AsciiStrLen (Message)); > > (1) A micro-optimization could be (sizeof Message - 1) rather than > AsciiStrLen (Message), but it's mostly irrelevant. > OK > > + if (gST->ConOut != NULL) { > > + AsciiPrint (Message); > > + } > > 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); > > + if (gST->ConOut != NULL) { > > + AsciiPrint (Buffer); > > + } > > > > DEBUG_CODE_BEGIN (); > > CHAR8 *Pdb, *PrevPdb; > > diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c > > index cc79cb2fa301..a79f73725aed 100644 > > --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c > > +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > > > @@ -194,7 +195,11 @@ DefaultExceptionHandler ( > > > > CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ", > > gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR); > > - SerialPortWrite ((UINT8 *) Buffer, CharCount); > > + if (gST->ConOut != NULL) { > > + AsciiPrint (Buffer); > > + } else { > > + SerialPortWrite ((UINT8 *)Buffer, CharCount); > > + } > > (2) I think the "serial PLUS console" reporting applies to the 32-bit > lib instance as well, so I assume not updating this from v1 was an > oversight. > Yes it was. Thanks for spotting that. > > > > DEBUG_CODE_BEGIN (); > > CHAR8 *Pdb; > > diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf > > index 7609f82d89a1..6bc48714c9dc 100644 > > --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf > > +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf > > @@ -42,6 +42,7 @@ [LibraryClasses] > > PeCoffGetEntryPointLib > > ArmDisassemblerLib > > SerialPortLib > > + UefiBootServicesTableLib > > > > [Guids] > > gEfiDebugImageInfoTableGuid > > > > With (2) updated, and regardless of (1): > > Acked-by: Laszlo Ersek > > Thanks! > Laszlo