From patchwork Fri May 12 21:42:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Luck X-Patchwork-Id: 9724889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23567601E7 for ; Fri, 12 May 2017 21:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15B3728892 for ; Fri, 12 May 2017 21:43:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A70B28893; Fri, 12 May 2017 21:43:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77F7928896 for ; Fri, 12 May 2017 21:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758757AbdELVnT (ORCPT ); Fri, 12 May 2017 17:43:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:65355 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756114AbdELVnS (ORCPT ); Fri, 12 May 2017 17:43:18 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2017 14:43:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,332,1491289200"; d="scan'208";a="86919741" Received: from agluck-desk.sc.intel.com ([10.3.52.160]) by orsmga004.jf.intel.com with ESMTP; 12 May 2017 14:43:17 -0700 From: "Luck, Tony" To: "Rafael J. Wysocki" Cc: Tony Luck , Len Brown , Huang Ying , Borislav Petkov , Tomasz Nowicki , Jonathan Zhang , Tyler Baicar , linux-acpi@vger.kernel.org Subject: [PATCH v2 1/2] ACPI / APEI: Boot Error Record Table processing was needlessly complicated Date: Fri, 12 May 2017 14:42:11 -0700 Message-Id: <78b9b4db53afcaec6bd5b6b95480d64ef6874450.1494624795.git.tony.luck@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: <20170512120118.zwhgtcbf4u4zshbn@pd.tnic> In-Reply-To: References: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tony Luck Quoting version 6.1 of the ACPI specification. Section 18.3.1 "Boot Error Source" says: The Boot Error Region is a range of addressable memory OSPM can access during initialization to determine if an unhandled error condition occurred. System firmware must report this memory range as firmware reserved. The format of the Boot Error Region follow that of an Error Status Block, this is defined in Section 18.3.2.7. The format of the error status block is described by Table 18-342. This clarifies some points that were obfuscated in earlier versions. E.g. there is no longer a separate table to describe the format of the "Boot Error Region" (which was identical to the "Error Status Block"). Also saying "follow that of *an* Error Status Block" makes it clear that there is just one block (which can still contain multiple "Generic Error Data Entry structures"). The loop inside bert_print_all() is unnecessary (but probably harmless as the "while (remain > sizeof(struct acpi_bert_region))" loop should terminate after we skipped over the first entry. We can drop the "bert_print_all()" function and just move the four relevant lines inline in "bert_init()". Cc: Len Brown Cc: Huang Ying Cc: Borislav Petkov Cc: Tomasz Nowicki Cc: Jonathan (Zhixiong) Zhang Cc: Tyler Baicar Cc: linux-acpi@vger.kernel.org Reviewed-by: Borislav Petkov Signed-off-by: Tony Luck --- drivers/acpi/apei/bert.c | 54 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/drivers/acpi/apei/bert.c b/drivers/acpi/apei/bert.c index 12771fcf0417..b28e1573d4cf 100644 --- a/drivers/acpi/apei/bert.c +++ b/drivers/acpi/apei/bert.c @@ -34,50 +34,6 @@ static int bert_disable; -static void __init bert_print_all(struct acpi_bert_region *region, - unsigned int region_len) -{ - struct acpi_hest_generic_status *estatus = - (struct acpi_hest_generic_status *)region; - int remain = region_len; - u32 estatus_len; - - if (!estatus->block_status) - return; - - while (remain > sizeof(struct acpi_bert_region)) { - if (cper_estatus_check(estatus)) { - pr_err(FW_BUG "Invalid error record.\n"); - return; - } - - estatus_len = cper_estatus_len(estatus); - if (remain < estatus_len) { - pr_err(FW_BUG "Truncated status block (length: %u).\n", - estatus_len); - return; - } - - pr_info_once("Error records from previous boot:\n"); - - cper_estatus_print(KERN_INFO HW_ERR, estatus); - - /* - * Because the boot error source is "one-time polled" type, - * clear Block Status of current Generic Error Status Block, - * once it's printed. - */ - estatus->block_status = 0; - - estatus = (void *)estatus + estatus_len; - /* No more error records. */ - if (!estatus->block_status) - return; - - remain -= estatus_len; - } -} - static int __init setup_bert_disable(char *str) { bert_disable = 1; @@ -89,7 +45,7 @@ __setup("bert_disable", setup_bert_disable); static int __init bert_check_table(struct acpi_table_bert *bert_tab) { if (bert_tab->header.length < sizeof(struct acpi_table_bert) || - bert_tab->region_length < sizeof(struct acpi_bert_region)) + bert_tab->region_length < sizeof(struct acpi_hest_generic_status)) return -EINVAL; return 0; @@ -98,7 +54,7 @@ static int __init bert_check_table(struct acpi_table_bert *bert_tab) static int __init bert_init(void) { struct apei_resources bert_resources; - struct acpi_bert_region *boot_error_region; + struct acpi_hest_generic_status *boot_error_region; struct acpi_table_bert *bert_tab; unsigned int region_len; acpi_status status; @@ -138,7 +94,11 @@ static int __init bert_init(void) goto out_fini; boot_error_region = ioremap_cache(bert_tab->address, region_len); if (boot_error_region) { - bert_print_all(boot_error_region, region_len); + if (boot_error_region->block_status) { + pr_info("Error records from previous boot:\n"); + cper_estatus_print(KERN_INFO HW_ERR, boot_error_region); + boot_error_region->block_status = 0; + } iounmap(boot_error_region); } else { rc = -ENOMEM;