From patchwork Sun May 17 12:57:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 194183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74D5EC433E0 for ; Sun, 17 May 2020 12:58:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52EDB20801 for ; Sun, 17 May 2020 12:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589720321; bh=JFADzI+bFJI+qlwWMdKUY00z9kgPZExBs/0rCBkTIhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yK1bvUgmoE22Le7wzHGBJbmzjLuRvIXJ40e3HAXvIF4hVodwgQkslVMrY7CZHo17D cehU48qEfu/Kl4KeQwv+hyr+TmSmJgodV2DV0/H2xIUsK3dBxePjshKHkL0QtWngFE 7Iz9Mx4Q9gvn4cxVQr4PUmVfBzIh8nPjM9NzxDgw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727928AbgEQM6k (ORCPT ); Sun, 17 May 2020 08:58:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:51584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728019AbgEQM6k (ORCPT ); Sun, 17 May 2020 08:58:40 -0400 Received: from e123331-lin.nice.arm.com (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (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 EF29A207D4; Sun, 17 May 2020 12:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589720319; bh=JFADzI+bFJI+qlwWMdKUY00z9kgPZExBs/0rCBkTIhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ju+Tp6asCB7nzRU2CbbVhiOH+xYnaQJ8GlIfdcUPGOp5blK9vXI6sGf7LIeNv6Rej qkRUsF4rx4kAaU/zBxmBFjuX6YsDM1KiBWh4MjXbllG2haQtcdpC199CjQHANHta8i k7sIEHGMY3XBT93FXDAsKZdRVL2jfyA9rqP/d8Ms= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arvind Sankar , Benjamin Thiel , Borislav Petkov , Dave Young , Heinrich Schuchardt , Javier Martinez Canillas , Jerry Snitselaar , Lenny Szubowicz , linux-acpi@vger.kernel.org, Loic Yhuel , Matthew Garrett , Mike Lothian , Punit Agrawal Subject: [PATCH 2/7] efi/earlycon: Fix early printk for wider fonts Date: Sun, 17 May 2020 14:57:49 +0200 Message-Id: <20200517125754.8934-3-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200517125754.8934-1-ardb@kernel.org> References: <20200517125754.8934-1-ardb@kernel.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Dave Young When I play with terminus fonts I noticed the efi early printk does not work because the earlycon code assumes font width is 8. Here add the code to adapt with larger fonts. Tested with all kinds of kernel built-in fonts on my laptop. Also tested with a local draft patch for 14x28 !bold terminus font. Signed-off-by: Dave Young Link: https://lore.kernel.org/r/20200412024927.GA6884@dhcp-128-65.nay.redhat.com Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/earlycon.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c index 5d4f84781aa0..a52236e11e5f 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h) const u32 color_black = 0x00000000; const u32 color_white = 0x00ffffff; const u8 *src; - u8 s8; - int m; + int m, n, bytes; + u8 x; - src = font->data + c * font->height; - s8 = *(src + h); + bytes = BITS_TO_BYTES(font->width); + src = font->data + c * font->height * bytes + h * bytes; - for (m = 0; m < 8; m++) { - if ((s8 >> (7 - m)) & 1) + for (m = 0; m < font->width; m++) { + n = m % 8; + x = *(src + m / 8); + if ((x >> (7 - n)) & 1) *dst = color_white; else *dst = color_black; From patchwork Sun May 17 12:57:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 194182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42DACC433E0 for ; Sun, 17 May 2020 12:58:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21AAA204EC for ; Sun, 17 May 2020 12:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589720331; bh=afhSt/ziJwuU2iemGe+CpeKSEPCVYGr/02In/Zx/9tM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OZWYRWhRk07bEGTBlBa/e3+5CEhjey2DEUhXiPsWaTn5QLAiJMa0XZzRuczNYXiDt J7Mo1CdleIK/q1nwearLCU2exShl44VSVwIeMlVvqyyOJ0tKphEjS3+YatkeQmZCvP Y05qmg/a/8QtT3L+8YZhK/hXmTaDHikGM3j0GMMc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728055AbgEQM6u (ORCPT ); Sun, 17 May 2020 08:58:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728035AbgEQM6t (ORCPT ); Sun, 17 May 2020 08:58:49 -0400 Received: from e123331-lin.nice.arm.com (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (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 94CCE20735; Sun, 17 May 2020 12:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589720328; bh=afhSt/ziJwuU2iemGe+CpeKSEPCVYGr/02In/Zx/9tM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bkK850ZefEI0HYBud2QUR0yxQ9Ifmjd4631b7ko+it0zcxFdqlTOQz9c6hOhi+rL0 wHxv14ZF1lxvj49dnPqJenY1Eo5rR0zMCasgaduGvzR2CjqfqH+I7KbsmfzgmPxciX Ol0KtI6wRno3BCrykZy+tfLXgDVL82zHLC+gobS8= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arvind Sankar , Benjamin Thiel , Borislav Petkov , Dave Young , Heinrich Schuchardt , Javier Martinez Canillas , Jerry Snitselaar , Lenny Szubowicz , linux-acpi@vger.kernel.org, Loic Yhuel , Matthew Garrett , Mike Lothian , Punit Agrawal Subject: [PATCH 4/7] efi: cper: Add support for printing Firmware Error Record Reference Date: Sun, 17 May 2020 14:57:51 +0200 Message-Id: <20200517125754.8934-5-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200517125754.8934-1-ardb@kernel.org> References: <20200517125754.8934-1-ardb@kernel.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Punit Agrawal 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: Borislav Petkov 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 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() From patchwork Sun May 17 12:57:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 194181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E49EC433E0 for ; Sun, 17 May 2020 12:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A13D20823 for ; Sun, 17 May 2020 12:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589720339; bh=oOhRo7vJXpfA5fYUJ8MfcQCIzfp14pkZq5YYCY2YfQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cjyFSml4Taa+c/wxNXwt4HV+od39gNuW0UfiszR5MyxBqXC/YdvfY9+mGCmQ7Wu/s 6eosRNh4rv2ekbknDkJ+5jcQ2uhcIThzaFO9Yp7dP3bdBr0ma9atAbGlQPmoUYHlyn hjDZc9SreRNQ/MQX7uVSUxKB1dPX7L6oS/5VDeSU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727903AbgEQM66 (ORCPT ); Sun, 17 May 2020 08:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728035AbgEQM65 (ORCPT ); Sun, 17 May 2020 08:58:57 -0400 Received: from e123331-lin.nice.arm.com (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (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 7AB0420825; Sun, 17 May 2020 12:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589720336; bh=oOhRo7vJXpfA5fYUJ8MfcQCIzfp14pkZq5YYCY2YfQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPDf7YbdxbPax5Dz2wQzwEmVSWDMhDPpi8e+2b2+vjC2WaPVeu361iLSqaf3+MzNZ UeD9vAY2NM3XvEVeeyo7SwvFRsAI/c0eMVTQsvSdo4pA7+Vuy3MrbXPenaI79ZB6a1 jokICm1lL/JnreJIIOGfiMOhW/hNlYLBuyc88bXM= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arvind Sankar , Benjamin Thiel , Borislav Petkov , Dave Young , Heinrich Schuchardt , Javier Martinez Canillas , Jerry Snitselaar , Lenny Szubowicz , linux-acpi@vger.kernel.org, Loic Yhuel , Matthew Garrett , Mike Lothian , Punit Agrawal Subject: [PATCH 6/7] efi: Pull up arch-specific prototype efi_systab_show_arch() Date: Sun, 17 May 2020 14:57:53 +0200 Message-Id: <20200517125754.8934-7-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200517125754.8934-1-ardb@kernel.org> References: <20200517125754.8934-1-ardb@kernel.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Benjamin Thiel Pull up arch-specific prototype efi_systab_show_arch() in order to fix a -Wmissing-prototypes warning: arch/x86/platform/efi/efi.c:957:7: warning: no previous prototype for ‘efi_systab_show_arch’ [-Wmissing-prototypes] char *efi_systab_show_arch(char *str) Signed-off-by: Benjamin Thiel Link: https://lore.kernel.org/r/20200516132647.14568-1-b.thiel@posteo.de Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 5 +---- include/linux/efi.h | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 911a2bd0f6b7..4e3055238f31 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -130,11 +130,8 @@ static ssize_t systab_show(struct kobject *kobj, if (efi.smbios != EFI_INVALID_TABLE_ADDR) str += sprintf(str, "SMBIOS=0x%lx\n", efi.smbios); - if (IS_ENABLED(CONFIG_IA64) || IS_ENABLED(CONFIG_X86)) { - extern char *efi_systab_show_arch(char *str); - + if (IS_ENABLED(CONFIG_IA64) || IS_ENABLED(CONFIG_X86)) str = efi_systab_show_arch(str); - } return str - buf; } diff --git a/include/linux/efi.h b/include/linux/efi.h index 251f1f783cdf..9430d01c0c3d 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1245,4 +1245,6 @@ struct linux_efi_memreserve { void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size); +char *efi_systab_show_arch(char *str); + #endif /* _LINUX_EFI_H */