From patchwork Mon Dec 3 18:06:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10710277 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 471EF1057 for ; Mon, 3 Dec 2018 18:08:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C9172B47E for ; Mon, 3 Dec 2018 18:08:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30A102B49D; Mon, 3 Dec 2018 18:08:02 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF0992B47E for ; Mon, 3 Dec 2018 18:08:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB3616B6A8A; Mon, 3 Dec 2018 13:07:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D8ED96B6A8B; Mon, 3 Dec 2018 13:07:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C553F6B6A8C; Mon, 3 Dec 2018 13:07:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by kanga.kvack.org (Postfix) with ESMTP id 92B036B6A8A for ; Mon, 3 Dec 2018 13:07:46 -0500 (EST) Received: by mail-ot1-f70.google.com with SMTP id w6so5968783otb.6 for ; Mon, 03 Dec 2018 10:07:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=h30DZ5QsoanOwOfyV3bhyCWkTrBNg0fy/1dD74I5bNY=; b=jBQROFopR33yR97qHJggnph1K/mKXojksm9tEWvre4CMMAgDN+utBeI4JQ9UKXNGvx udwG4HVemZbWCZm7te0rl7ZdYMOZ7h/55cLaeF78AU/HImYF3NDYhFqEl1sWYtH3hwIt rwwKxOBQJGm1MkgWG2XsZmhj8cxq6yp7ZcqD7UTs0AkgR5NPmQIGfA6SeNelgMs2aTaE Wc6mMgkaYEAN/Hgvy91npDGl7Jta9/DGBwVAH5PRjGVfBKa5dh/2InjJtHdLHv0KY3Cm ylCppNDymfxvVpoXj7UKd6W+dgQG0ALqZSNH2t3gxRp3VaI3B4psR8nUXomt1DmXKFFa docw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: AA+aEWYPwrIfftbgjJgmYSvEn26QjKNOG5Zp4DLNoGJydAEwo5egN5iZ UlNajYvQPWQoP64cxODT6RFuanOQohdQKKO8//vHOL6nyPlYsG2GeRPGNo6TdP7XBQdcW+Dha2q wUkxsUw3JJczXo1afJTE/gGsW/vGiObQUvgm/k2RogadLlXVBBZGkw7jqkeiHiBEuVw== X-Received: by 2002:aca:e84d:: with SMTP id f74mr11089357oih.34.1543860466369; Mon, 03 Dec 2018 10:07:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/U/fMjqSQmZE3yd1rEdwxEwTUEuW9EREuQHO+IbiMGAJFrDfPkWUK9QYGeAxbXzZVD5glXz X-Received: by 2002:aca:e84d:: with SMTP id f74mr11089312oih.34.1543860465442; Mon, 03 Dec 2018 10:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860465; cv=none; d=google.com; s=arc-20160816; b=eAcYy26QQXwWQzbD6XElwm7PklyzqiMsyFPT2lJ5MjBfHhQM9MoKpbY7kcYreiQtxe yQELzjhVU21h8R0mASuQ3Ime+ay40rHzgSpBjn02o/pWaf519Z9Jeaje3mQxPJR1sV/y noq0+qQllpD/PrWMHbS0plobfM1vVgmuCMWflVucA5xcdk08MhKPwNPi2oNFP+8KS94c Ufj4SFm290JNsNCaFweO95L0JIoWSp5EwfeyA9dleep0ghzp+6CkfZ9NDgI7fRWec2NY R7Y8OWQj9gzhyrGHtHCZl5o5QMvp5RqRkcgrh0YcMdEALvynfLhu+1PE6DF44iXWussg f9PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=h30DZ5QsoanOwOfyV3bhyCWkTrBNg0fy/1dD74I5bNY=; b=FYdOqptfI1C2EQcF/R0avvXBOz9cERPwVx2QXEkKrA6wiiWSbpp7o3gnObdIxB0Q68 d9IlGiMS7H4z5No0KWTYXTft5njXQUbGRvZHwpdQ39WpdmQvYqpEzC3/iVWrYe6KLmtN JgXg/3VS7VDtbv9AWULVh8OG0hqI7jYxuKVDZ/Bjrzg3zWsS4Db9WOFbjHUp11R73CES RdV6gpSdie069TdWQHAWsOpcLGLcvYgVJ7x2t5UkzSyamxEKW1v7HFEtmCJpGHIcSWXe itfR/kCj0b0Nf1CrPFmJJ1LrkyzrDLvyme71dgeEByf0XmlJqCFn2+agG8v2X5Vi3nH+ aHmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id 97si6695626otb.98.2018.12.03.10.07.45 for ; Mon, 03 Dec 2018 10:07:45 -0800 (PST) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com 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 CE3DD1713; Mon, 3 Dec 2018 10:07:44 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09A853F59C; Mon, 3 Dec 2018 10:07:41 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Dongjiu Geng , Xie XiuQi , Fan Wu , James Morse Subject: [PATCH v7 19/25] ACPI / APEI: Only use queued estatus entry during _in_nmi_notify_one() Date: Mon, 3 Dec 2018 18:06:07 +0000 Message-Id: <20181203180613.228133-20-james.morse@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181203180613.228133-1-james.morse@arm.com> References: <20181203180613.228133-1-james.morse@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 new ghes_peek_estatus() to know how much memory to allocate from the ghes_estatus_pool before reading the records. Reported-by: Borislav Petkov Signed-off-by: James Morse Change since v6: * Added a comment explaining the 'ack-error, then goto no_work'. * Added missing esatus-clearing, which is necessary after reading the GAS, Reviewed-by: Borislav Petkov --- drivers/acpi/apei/ghes.c | 59 ++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 07a12aac4c1a..849da0d43a21 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -856,43 +856,43 @@ 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 *src_estatus) +static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) { - u32 len, node_len; + struct acpi_hest_generic_status *estatus, tmp_header; struct ghes_estatus_node *estatus_node; - struct acpi_hest_generic_status *estatus; + u32 len, node_len; + u64 buf_paddr; + int sev, rc; if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG)) - return; + return -EOPNOTSUPP; - if (ghes_estatus_cached(src_estatus)) - return; + rc = __ghes_peek_estatus(ghes, fixmap_idx, &tmp_header, &buf_paddr); + if (rc) { + ghes_clear_estatus(&tmp_header, buf_paddr, fixmap_idx); + return rc; + } - len = cper_estatus_len(src_estatus); - node_len = GHES_ESTATUS_NODE_LEN(len); + rc = __ghes_check_estatus(ghes, &tmp_header); + if (rc) { + ghes_clear_estatus(&tmp_header, buf_paddr, fixmap_idx); + return rc; + } + len = cper_estatus_len(&tmp_header); + 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, src_estatus, len); - llist_add(&estatus_node->llnode, &ghes_estatus_llist); -} - -static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) -{ - struct acpi_hest_generic_status *estatus = ghes->estatus; - u64 buf_paddr; - int sev; - 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); @@ -901,14 +901,25 @@ static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) __ghes_panic(ghes, estatus); } - __process_error(ghes, estatus); ghes_clear_estatus(estatus, buf_paddr, fixmap_idx); if (is_hest_type_generic_v2(ghes) && ghes_ack_error(ghes->generic_v2)) pr_warn_ratelimited(FW_WARN GHES_PFX "Failed to ack error status block!\n"); - return 0; + /* This error has been reported before, don't process it again. */ + if (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,