From patchwork Fri Sep 21 22:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10611113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EE2514DA for ; Fri, 21 Sep 2018 22:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C212D796 for ; Fri, 21 Sep 2018 22:35:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E18362D79F; Fri, 21 Sep 2018 22:35:19 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 651862D796 for ; Fri, 21 Sep 2018 22:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mFRzP+O/KyMUG3riL5WgVnZBN4COM26JPNBtPc6XLYM=; b=mG/8WNLyI+yBQ3 UJA9xT9crAGCn2p06ot2IfNEaITscbjKicK0FEiwgVacze5Fckn62KvKpL18EQhitGPzqpi2giVrJ Sgpin2lxPh1BXmBc0VsoCrZtgPRUkpdTip5xxyPK2/IDuZXGa5eA8U2psoKyHAp3Kkpy/fcHje7hZ HmPSq6v1jUvYrsGXU/yiypjNR3w7f9QrQ/VoDdHUOmwakeCFL9+wiP9HQOl+w1PND1vA5tJXcEdkS RZXw6Z16PydMNd336xcfg6UpPMkkqoALGwbi4kHCP1F9LmEVezOtNVsjQ8NEiLYuBWsl0W1ngAMnx 4KkdX0D4RRYUT+jzIvyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3U11-0005uq-Hk; Fri, 21 Sep 2018 22:35:11 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3Tzp-0004vp-2E for linux-arm-kernel@bombadil.infradead.org; Fri, 21 Sep 2018 22:33:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NlHipBD85WpKIhfoKQJofToLO84wEXj65vQgfTlE2IY=; b=QKVdeHJ1LXXalotFHj4MP8019u t5CHqc8AlxDpQy2fxrHkwo4Wb72OFNLrC8K9jFJHPAkX/BVK6EnEMKrLSzPy37dzGB+w9ZRDqEx2S cAUGfG1Cm9/nt0R1yGrc5QDqhh1Sqlj5e5WoqeqfhwlJYd5WTh8XyvtxZ1k7tWeR9RjJgwWTYHYIy bygrGka044PKME2UT8mzumX4q5okV5DahFBMpPnIpNpcQyISlHQK+cXxcF4ZoDfXFMlJgEFGgnjxH TNEBFeX0r7azrrbkj/WbaR/GIevQE+qJEYGxVZ9x1tq3Bq+beB79B+6YE2dWDb8tZr/zUeZXhpwri LwDr62MA==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3TlS-0003yO-1Y for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2018 22:19:09 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4347D15BE; Fri, 21 Sep 2018 15:18:55 -0700 (PDT) Received: from melchizedek.Emea.Arm.com (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2DB4A3F557; Fri, 21 Sep 2018 15:18:52 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Subject: [PATCH v6 15/18] ACPI / APEI: Only use queued estatus entry during _in_nmi_notify_one() Date: Fri, 21 Sep 2018 23:17:02 +0100 Message-Id: <20180921221705.6478-16-james.morse@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180921221705.6478-1-james.morse@arm.com> References: <20180921221705.6478-1-james.morse@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_231906_424132_6887D1A1 X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jonathan.zhang@cavium.com, Rafael Wysocki , Tony Luck , Punit Agrawal , Xie XiuQi , Marc Zyngier , Catalin Marinas , Tyler Baicar , Will Deacon , Christoffer Dall , Dongjiu Geng , linux-mm@kvack.org, Borislav Petkov , James Morse , Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Each struct ghes has an worst-case sized buffer for storing the estatus. If an error is being processed by ghes_proc() in process context this buffer will be in use. If the error source then triggers an NMI-like notification, the same buffer will be used by _in_nmi_notify_one() to stage the estatus data, before __process_error() copys it into a queued estatus entry. Merge __process_error()s work into _in_nmi_notify_one() so that the queued estatus entry is used from the beginning. Use the ghes_peek_estatus() so we know how much memory to allocate from the ghes_estatus_pool before we read the records. Reported-by: Borislav Petkov Signed-off-by: James Morse --- drivers/acpi/apei/ghes.c | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 055176ed68ac..a0c10b60ad44 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -722,40 +722,32 @@ static void ghes_print_queued_estatus(void) } } -/* Save estatus for further processing in IRQ context */ -static void __process_error(struct ghes *ghes, - struct acpi_hest_generic_status *ghes_estatus) +static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) { + u64 buf_paddr; + int sev, rc = 0; u32 len, node_len; struct ghes_estatus_node *estatus_node; struct acpi_hest_generic_status *estatus; - if (ghes_estatus_cached(ghes_estatus)) - return; + rc = ghes_peek_estatus(ghes, fixmap_idx, &buf_paddr, &len); + if (rc) + return rc; - len = cper_estatus_len(ghes_estatus); node_len = GHES_ESTATUS_NODE_LEN(len); estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool, node_len); if (!estatus_node) - return; + return -ENOMEM; estatus_node->ghes = ghes; estatus_node->generic = ghes->generic; estatus = GHES_ESTATUS_FROM_NODE(estatus_node); - memcpy(estatus, ghes_estatus, len); - llist_add(&estatus_node->llnode, &ghes_estatus_llist); -} - -static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) -{ - int sev; - u64 buf_paddr; - struct acpi_hest_generic_status *estatus = ghes->estatus; - if (ghes_read_estatus(ghes, estatus, &buf_paddr, fixmap_idx)) { + if (__ghes_read_estatus(estatus, buf_paddr, len, fixmap_idx)) { ghes_clear_estatus(estatus, buf_paddr, fixmap_idx); - return -ENOENT; + rc = -ENOENT; + goto no_work; } sev = ghes_severity(estatus->error_severity); @@ -764,13 +756,20 @@ static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) __ghes_panic(ghes, estatus); } - if (!buf_paddr) - return 0; - - __process_error(ghes, estatus); ghes_clear_estatus(estatus, buf_paddr, fixmap_idx); - return 0; + if (!buf_paddr || ghes_estatus_cached(estatus)) + goto no_work; + + llist_add(&estatus_node->llnode, &ghes_estatus_llist); + + return rc; + +no_work: + gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node, + node_len); + + return rc; } static int ghes_estatus_queue_notified(struct list_head *rcu_list,