Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2609591ybk; Tue, 12 May 2020 03:50:45 -0700 (PDT) X-Google-Smtp-Source: APiQypK9A3YDrGsU0ZMF7AbxGMkQa/URXXv8TDquvXg8uniIhATNIxx03hQrCmqL3kR+Tm/vjFIU X-Received: by 2002:a50:e8cb:: with SMTP id l11mr18209860edn.174.1589280645210; Tue, 12 May 2020 03:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589280645; cv=none; d=google.com; s=arc-20160816; b=Kh6iKlEvmrFZLK8jtSf3xqjywGF+7+y3rRl0tmth8KjEmU47DO8LBNt1ncZNC1O6K4 Ga/N5KRRE7Q7do/qwQMPWqAQjD8oHsQSHaa9ccb12lAscdFbkNSI3vebM0Ze1PSVI74y VV8UEWQy1aydc7w2yF6tm0RdVkKAbfaySL71IFSnE5ThIcxYk0JbvQ95vf9WeVgkesEd Brf5s2MnvIoBNwg8Lp9MGMMPy1zWxrgmjslYFzODhi29vXvgvAzP8I7IfbndGQiVX59i HguR8Sc772CclMculh5V8pVUB3lw1cUy6H9cAHm7/etmHubBT8WCkW/RtvdS1UWvZT5h npwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fbTpWoT2KD2qdGxmghLtaZFgd8Ys2Pb3+3GrON719lA=; b=bAKvKhYGlE1H/0zzofTcHE+ejWhCOyS3agXgIi10DF3AUQXYZOWPDiNFj1WUY2729l tHZJO111ScJuFnqXp39mcZn1sSizwxBQnqESwdHnsq8OrbtMsGdqwM7s9O93zdu/FgiQ ZP9k/rjHlx6TS+zpnPoXYyB7K2HPr+00yIJqwuZPeUhKFTwIlYdENwVPxw0Eg6Ud+YkK k+Lf3jYeKXbmxt5+snp6RQ568AXt/6AaizDbGeq47e5oqq0yRPPf5jzY362CrI5HLP0B dGMeDi5vgSvOkrBAIKPhRhZwSs50++7HzK5c+PszRj5Xl+RV0WIZYK+vSU9wd9BWgd37 DseA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HwPdPyFu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si7366729eju.4.2020.05.12.03.50.21; Tue, 12 May 2020 03:50:45 -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; dkim=pass header.i=@kernel.org header.s=default header.b=HwPdPyFu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbgELKsN (ORCPT + 99 others); Tue, 12 May 2020 06:48:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729639AbgELKsL (ORCPT ); Tue, 12 May 2020 06:48:11 -0400 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABA5A20731; Tue, 12 May 2020 10:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589280490; bh=ec2u7fiwEX8z3gl7q4XcFA1SD2R8KacLDpSUINJUYBg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HwPdPyFu87aAL4/LLpNjBOyFO7DQ5+aEu5nTHautuwZQLmwEjjfK+lUIvds0KIQZu 0V3BZEU61nKPMMQzPMny0yWfyMqkhjYKPaj6vrd32+gzGZYwDgSn7v7X6arODd221s 8AAn5vWXDVU7J3/wc2QxC2LqbhWlUpF/FcbAxqYE= Received: by mail-io1-f54.google.com with SMTP id e18so499352iog.9; Tue, 12 May 2020 03:48:10 -0700 (PDT) X-Gm-Message-State: AGi0PublluOoGjc+M8zwjad9oOSh0OBOZZAPuwzG19yuXwNk6Gjj8HKF D3UeAJnXb7H5MU6nKe4Z9ooQWOJjNlBA7XmhzKQ= X-Received: by 2002:a02:c6b4:: with SMTP id o20mr7529554jan.134.1589280490038; Tue, 12 May 2020 03:48:10 -0700 (PDT) MIME-Version: 1.0 References: <20200512045502.3810339-1-punit1.agrawal@toshiba.co.jp> In-Reply-To: <20200512045502.3810339-1-punit1.agrawal@toshiba.co.jp> From: Ard Biesheuvel Date: Tue, 12 May 2020 12:47:59 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [Patch v2] efi: cper: Add support for printing Firmware Error Record Reference To: Punit Agrawal Cc: Linux Kernel Mailing List , "Rafael J. Wysocki" , Borislav Petkov , James Morse , ACPI Devel Maling List , linux-efi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 May 2020 at 06:55, Punit Agrawal wrote: > > 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 > --- > Hi Ard, > > I've updated the patch based on your feedback. > > As you noted, some aspects of the spec make it a bit tricky to support > all revisions in a nice way (e.g., size check) but this version should > fix existing issues. > > Thanks, > Punit > > v1[0] -> v2: > * Simplified error record structure definition > * Fixed size check > * Added comment to clarify offset calculation for dumped data > * Style fixes for multiline if blocks > Thanks. I will queue this as a fix. > [0] https://lkml.kernel.org/lkml/20200427085242.2380614-1-punit1.agrawal@toshiba.co.jp/ > --- > 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 9d2512913d25..f564e15fbc7e 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 4f005d95ce88..8537e9282a65 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() > > -- > 2.26.2 >