Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp497197ybr; Fri, 22 May 2020 11:32:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxddQTurPGATKfKy4/qltpivF6gr88tsFxr340aIO6+fpwZp6NrSQHkXMmXBD08U/QRIHXs X-Received: by 2002:a50:d513:: with SMTP id u19mr4261406edi.173.1590172343789; Fri, 22 May 2020 11:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590172343; cv=none; d=google.com; s=arc-20160816; b=08S6QsiCrLxGUHfYelLjwJgPK0FsLY5NC9B6GfVCagQWoPD3bRyq807vLwgdC7EO1V NFxpSeSPpdnmNuqh/p6qS8hjy8yEA7RF6PCG5bITU2a0upMoZzxAzQl5ZJx4Rbhetlb6 MtRy7sNBKVmkuiLTEg/uW87O2+yYcfexat322Zwcvg9JHL9iBaeuxZqsoOjKZChw+68k qim1kAzx6to27skl9iw/3QEVf5N/F43WWcUDtX2pd9rL2jR/4EWxz4nXoNg0LmuNvZS2 vWq7h4BkdqCGX+gjPlqQ3u9rIMOzlaX2lYuPNb63JIapOPxuKQ2XJNnyKwn9T6zn/VXT Ijcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=NtmQ2X0hCy21mc1z5zl520F0KhHPNTguyaxASLQ0SDA=; b=XV+jJ8xBiXJxwO59yE9x5CxuzOyR3Zkig7GB8ijQ8hADdkueoLTujFe5GLw70TT1Cp lX4fdih9dFw6QXFTlQgqc6prk7RLB/JvK22joECXKOP1RyVv9bXL6N7lJ3IpG6N0DIH/ agglU0aXhvNZ+MDSdiJzOcm5vh7OzGPDTutUtaCrVd+/EcKGNn5rEIKj2fPKbBVC6JJl STKXWVYBqBLtyF5qMLHcu+h4vRtnJuPGA6VOJCa92m+/Goreb5gjLBuA4Hac9YFfvXpM oko+Tru2r3G53nNnaTJ0fniNl6naA6t7XMBN5xZ8IFwB0/4wd1uaEkBOeRYHFlY8dNSX xUCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si5175096eda.585.2020.05.22.11.32.00; Fri, 22 May 2020 11:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730944AbgEVSaY (ORCPT + 99 others); Fri, 22 May 2020 14:30:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730824AbgEVSaW (ORCPT ); Fri, 22 May 2020 14:30:22 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 494DDC061A0E; Fri, 22 May 2020 11:30:22 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jcCQz-0002l9-2V; Fri, 22 May 2020 20:30:17 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id B327F1C0475; Fri, 22 May 2020 20:30:16 +0200 (CEST) Date: Fri, 22 May 2020 18:30:16 -0000 From: "tip-bot2 for Punit Agrawal" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: efi/urgent] efi: cper: Add support for printing Firmware Error Record Reference Cc: Punit Agrawal , Ard Biesheuvel , "Rafael J. Wysocki" , Borislav Petkov , James Morse , linux-acpi@vger.kernel.org, linux-efi@vger.kernel.org, x86 , LKML In-Reply-To: <20200512045502.3810339-1-punit1.agrawal@toshiba.co.jp> References: <20200512045502.3810339-1-punit1.agrawal@toshiba.co.jp> MIME-Version: 1.0 Message-ID: <159017221661.17951.2040359767337422693.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the efi/urgent branch of tip: Commit-ID: 3d8c11efd528d56972d44ed0de51c4e11a9a4fa9 Gitweb: https://git.kernel.org/tip/3d8c11efd528d56972d44ed0de51c4e11a9a4fa9 Author: Punit Agrawal AuthorDate: Tue, 12 May 2020 13:55:02 +09:00 Committer: Ard Biesheuvel CommitterDate: Thu, 14 May 2020 11:11:20 +02:00 efi: cper: Add support for printing Firmware Error Record Reference While debugging a boot failure, the following unknown error record was seen in the boot logs. <...> BERT: Error records from previous boot: [Hardware Error]: event severity: fatal [Hardware Error]: Error 0, type: fatal [Hardware Error]: section type: unknown, 81212a96-09ed-4996-9471-8d729c8e69ed [Hardware Error]: section length: 0x290 [Hardware Error]: 00000000: 00000001 00000000 00000000 00020002 ................ [Hardware Error]: 00000010: 00020002 0000001f 00000320 00000000 ........ ....... [Hardware Error]: 00000020: 00000000 00000000 00000000 00000000 ................ [Hardware Error]: 00000030: 00000000 00000000 00000000 00000000 ................ <...> On further investigation, it was found that the error record with UUID (81212a96-09ed-4996-9471-8d729c8e69ed) has been defined in the UEFI Specification at least since v2.4 and has recently had additional fields defined in v2.7 Section N.2.10 Firmware Error Record Reference. Add support for parsing and printing the defined fields to give users a chance to figure out what went wrong. Signed-off-by: Punit Agrawal Cc: Ard Biesheuvel Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: James Morse Cc: linux-acpi@vger.kernel.org Cc: linux-efi@vger.kernel.org Link: https://lore.kernel.org/r/20200512045502.3810339-1-punit1.agrawal@toshiba.co.jp Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper.c | 62 ++++++++++++++++++++++++++++++++++++- include/linux/cper.h | 9 +++++- 2 files changed, 71 insertions(+) diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 9d25129..f564e15 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -407,6 +407,58 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, } } +static const char * const fw_err_rec_type_strs[] = { + "IPF SAL Error Record", + "SOC Firmware Error Record Type1 (Legacy CrashLog Support)", + "SOC Firmware Error Record Type2", +}; + +static void cper_print_fw_err(const char *pfx, + struct acpi_hest_generic_data *gdata, + const struct cper_sec_fw_err_rec_ref *fw_err) +{ + void *buf = acpi_hest_get_payload(gdata); + u32 offset, length = gdata->error_data_length; + + printk("%s""Firmware Error Record Type: %s\n", pfx, + fw_err->record_type < ARRAY_SIZE(fw_err_rec_type_strs) ? + fw_err_rec_type_strs[fw_err->record_type] : "unknown"); + printk("%s""Revision: %d\n", pfx, fw_err->revision); + + /* Record Type based on UEFI 2.7 */ + if (fw_err->revision == 0) { + printk("%s""Record Identifier: %08llx\n", pfx, + fw_err->record_identifier); + } else if (fw_err->revision == 2) { + printk("%s""Record Identifier: %pUl\n", pfx, + &fw_err->record_identifier_guid); + } + + /* + * The FW error record may contain trailing data beyond the + * structure defined by the specification. As the fields + * defined (and hence the offset of any trailing data) vary + * with the revision, set the offset to account for this + * variation. + */ + if (fw_err->revision == 0) { + /* record_identifier_guid not defined */ + offset = offsetof(struct cper_sec_fw_err_rec_ref, + record_identifier_guid); + } else if (fw_err->revision == 1) { + /* record_identifier not defined */ + offset = offsetof(struct cper_sec_fw_err_rec_ref, + record_identifier); + } else { + offset = sizeof(*fw_err); + } + + buf += offset; + length -= offset; + + print_hex_dump(pfx, "", DUMP_PREFIX_OFFSET, 16, 4, buf, length, true); +} + static void cper_print_tstamp(const char *pfx, struct acpi_hest_generic_data_v300 *gdata) { @@ -494,6 +546,16 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata else goto err_section_too_small; #endif + } else if (guid_equal(sec_type, &CPER_SEC_FW_ERR_REC_REF)) { + struct cper_sec_fw_err_rec_ref *fw_err = acpi_hest_get_payload(gdata); + + printk("%ssection_type: Firmware Error Record Reference\n", + newpfx); + /* The minimal FW Error Record contains 16 bytes */ + if (gdata->error_data_length >= SZ_16) + cper_print_fw_err(newpfx, gdata, fw_err); + else + goto err_section_too_small; } else { const void *err = acpi_hest_get_payload(gdata); diff --git a/include/linux/cper.h b/include/linux/cper.h index 4f005d9..8537e92 100644 --- a/include/linux/cper.h +++ b/include/linux/cper.h @@ -521,6 +521,15 @@ struct cper_sec_pcie { u8 aer_info[96]; }; +/* Firmware Error Record Reference, UEFI v2.7 sec N.2.10 */ +struct cper_sec_fw_err_rec_ref { + u8 record_type; + u8 revision; + u8 reserved[6]; + u64 record_identifier; + guid_t record_identifier_guid; +}; + /* Reset to default packing */ #pragma pack()