From patchwork Tue Jun 26 17:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10489629 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 4779C60386 for ; Tue, 26 Jun 2018 17:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34591203B9 for ; Tue, 26 Jun 2018 17:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2821628236; Tue, 26 Jun 2018 17:04:03 +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=ham 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 887242894D for ; Tue, 26 Jun 2018 17:02:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D0D36B0286; Tue, 26 Jun 2018 13:02:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 680156B0287; Tue, 26 Jun 2018 13:02:53 -0400 (EDT) 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 4FC116B0288; Tue, 26 Jun 2018 13:02:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot0-f197.google.com (mail-ot0-f197.google.com [74.125.82.197]) by kanga.kvack.org (Postfix) with ESMTP id 1BF6D6B0286 for ; Tue, 26 Jun 2018 13:02:53 -0400 (EDT) Received: by mail-ot0-f197.google.com with SMTP id p13-v6so8452647otl.23 for ; Tue, 26 Jun 2018 10:02:53 -0700 (PDT) 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; bh=Q6uQrGACkUoyvkLY5oDxOMmTtzQry4xQlgtwDFSDwNM=; b=BPqMoJzRDsBvazUFZGJqON5hxsKpuLhocVCnWASDV8iZhR0AB+9dVKOFKz9K5D5Vgk VEIkNAfXl9m6sPsnKMANpinn4KEpe0Uz2Zb1ggwXKVLg9PwlURiSKv3NWzPTulXkFETx LdUzIwXICx+vZhAsLmAGF8hvrx6Mjv8R6HnAUUGtGq039D5vifrNWtpF6dAk/185Ubud FFRR/wI7gYYdyOOJ3xeHyPw6qjzy3o68/oQQ6zGx0Ld3EBqy6YLfUIPaIi1CrCBFHv3A S2DoQ04uMWxGntHdAcOfhQB7Omj2BD42ui8H9/4AyuoH85asPGRJmSBZuwII2Rwetfbl tW5Q== 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: APt69E032JlQWi9vJf3pGQjUczrHnY22cuzLdYd8KU9n2LRYvM+8GhJN 6hKVbasZmKLcHWfPGSVNj4s3knr1prQSl1hB4BkgAg8tk2nm0mUAGwmTLDGUYF+ooazovSDqQXD LBC2ujhqkjlOAjbHeT9VlqlPabE9Mny/56QMPHSn8GYA2kl+3P3g5SKmBVR2PthoB0g== X-Received: by 2002:a9d:368a:: with SMTP id h10-v6mr1259115otc.19.1530032572895; Tue, 26 Jun 2018 10:02:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfSYd0Ahslmvm8NSLXXxGIRrucgu/U4wzYB+aqbX2OFz1NLQw/6LWsvT2V+zw1OTHhffYuX X-Received: by 2002:a9d:368a:: with SMTP id h10-v6mr1259060otc.19.1530032572002; Tue, 26 Jun 2018 10:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530032571; cv=none; d=google.com; s=arc-20160816; b=QfdimnDZbdqUe4WErEzP3izdAK03uov7fwYA3ycRSIJatdSdWi/WWm1n03xZJ1wH2u 5UfWrGIPXm/Ag3RLBmPyGc75OuESM3dQJCy9CdQGLQAzULopEDqGkTinEtIAyIvdYmrP L0E7WVyQfMLgYKm4obyY339QoydVosmfKhqmr/37uVzlgw+ISL4E60NqCVLbRixAscwf TS6ykfjdGzPpwhnkWRC8vDtHdtpw+9JCmqM6zdacqTc2ykBUZwGRl4h0GPz+ifCbJDYn prNMLqhk56cM23OCs81OEaY0paqRTGZp6AJPbLhs/B68KvVTTQvQx4oIML2wIHOs8fZL OqqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Q6uQrGACkUoyvkLY5oDxOMmTtzQry4xQlgtwDFSDwNM=; b=MjYdW4bThT2W6Jkk/ajAgCUnmE3gII962RRIlo8OarE3uzKpVTZwexZBGcf3whDEtP KF071yVjCokjWruHUaPEnqK5nnxGppyWZkGfCBaI6RunxQyVHfgd7GPcYVAhuPohvVff AkpFPSXSXWhWaH04iLGgqnynr3vdaGWhJDhcb8JszxqE02IjFkk08XuAUi7gdllcTETm 0tDD+d15NqXUmL+h6Qdv6VtYTXYJUYs/RfE3wmBUiSgzjKkntl9xplKSUbHmFLCB/mL2 l67FmHnygKrS6H0En8Po6i4wYYMk3Z1/xObPxxfi7+PC3CP9ED8K6CqGoAFGLkldkbHR X3kw== 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 (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id n11-v6si613140otl.127.2018.06.26.10.02.51 for ; Tue, 26 Jun 2018 10:02:51 -0700 (PDT) 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 8C48E7A9; Tue, 26 Jun 2018 10:02:51 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.206.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6461A3F318; Tue, 26 Jun 2018 10:02:48 -0700 (PDT) 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 , Tyler Baicar , Dongjiu Geng , Xie XiuQi , Punit Agrawal , jonathan.zhang@cavium.com, James Morse Subject: [PATCH v5 15/20] ACPI / APEI: Only use queued estatus entry during _in_nmi_notify_one() Date: Tue, 26 Jun 2018 18:01:11 +0100 Message-Id: <20180626170116.25825-16-james.morse@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626170116.25825-1-james.morse@arm.com> References: <20180626170116.25825-1-james.morse@arm.com> 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() 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 1d59d85b38d2..f196f8797fc1 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -713,40 +713,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) { + int sev, rc = 0; u32 len, node_len; + phys_addr_t buf_paddr; 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; - phys_addr_t 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); @@ -755,13 +747,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,