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: 10611065 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 3A5AB14BD for ; Fri, 21 Sep 2018 22:18:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DA672DDC8 for ; Fri, 21 Sep 2018 22:18:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214E32DDD4; Fri, 21 Sep 2018 22:18:59 +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 A92A82DDC8 for ; Fri, 21 Sep 2018 22:18:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57D988E0020; Fri, 21 Sep 2018 18:18:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 52D398E0001; Fri, 21 Sep 2018 18:18:57 -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 41EDE8E0020; Fri, 21 Sep 2018 18:18:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by kanga.kvack.org (Postfix) with ESMTP id 17EA88E0001 for ; Fri, 21 Sep 2018 18:18:57 -0400 (EDT) Received: by mail-oi0-f69.google.com with SMTP id x145-v6so13426687oia.10 for ; Fri, 21 Sep 2018 15:18:57 -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:mime-version :content-transfer-encoding; bh=NlHipBD85WpKIhfoKQJofToLO84wEXj65vQgfTlE2IY=; b=nmPx//8+lCDyKjj4S4OZlD91IdlWh0YhFxkw6PghfbBYMZiC1RW1BI/v7teXHPT4YX 6+sBSxqK/tu96zhgUACBQl+FZHyBqSZqXjgZV30wFQ35xYr7XRLKc8xzFc82mi3i6vim l9Ds+H+biY9PxpN7yom17M5wWUQk7bC24+d/xMVy8Uj2w3bq6JJtxTEVB3mdiWzOUW9i dEVALEWuO4Bx17+mz2c9lsymriMzku9M6qKFuCOBKl/RoiLKmoNG0l7RbLhcx2ihAxhy dFUnMWL8HHuF9kCMm55rgNL2tycNbdhyXrwVmsExiJdpvaPG/4MppOAv3QIFd5zu8Rki iz2Q== 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: APzg51C7XcKvXFh84BEMpUmuygUfy8mMaxMFwPnNnpaoeDncvCLs0veB ZTqShM5e7K+IVe6nHCzp4GtxQnc1f41CLr5u9KPSzaucAKUPpAyR47GT7Ssuk7BSFuDcj3AixuE x3DViBQro5Ri2b7G8hzrZ9v+KR2fW4m7a2THgiFnWZtW8TO9c6g8txMfn+Kis+soUpA== X-Received: by 2002:a9d:2c85:: with SMTP id p5-v6mr24739220otb.354.1537568336816; Fri, 21 Sep 2018 15:18:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdazsQpgXmM6txbzK1OgLPN+C1wuiykU+V0ZtxK4kXiJC0cWIXDhdoXCMqQO4mcCWa/g97eN X-Received: by 2002:a9d:2c85:: with SMTP id p5-v6mr24739190otb.354.1537568335810; Fri, 21 Sep 2018 15:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537568335; cv=none; d=google.com; s=arc-20160816; b=k7n78eW3mesfBo4zZXeXBr0pES/KTk3OkH4uwOKQs3ZAqvcZJ9eeXLj2lWlBToj+y1 D2vJJE6ePGt0n6A3lpIpy4nPKcTqT5Q1J+1D1XXPSRjCiCR744q2G9V2+pHv9HPXxzKB iD9cGYLuTOLGGwc5zdKMk5tmcMLYaElJw59ulNwFqLy9auaeeborYnZCeo1Qx1JzgYKk MaXCZ4BILyEdzvXpHg9/2cgTTEHy08rXpLlhI9PLlJ6kR4WXcAFmRw3IA3PD68BL/jZc fyog6VtsM4yI2FTuDuGcX+QlQjcE9Jz02PugeiCv5Q8Sd7S1EDkfm0eBndvT5p328HIQ KrBw== 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=NlHipBD85WpKIhfoKQJofToLO84wEXj65vQgfTlE2IY=; b=qw3Dk3imvvuXugMBA07T2EAMUyX+2GYmITqaD8FgNQJst9YESYogWzzraNPFZhr6ZP SVYWTqR5MPzI2IOjP6FJ2sn5p8KdJbtgrl1qdAAtno8Uh8udMxH5Ki//zm0Z841tS3/7 gpfzQHGwXRIrf/Epav7L+VLwKAdUwqJW9JbJ2jYFgbrnZhuUl3kI6V7m/xPNSXDfYqAt 6w9ecdgCgDbyE/PkLChQ1MacM4ZISYGRtvpXmbD7+eo2slIQYmL9GQt2Fbh2B60tJ+8m 8MeXo7De6Y8y7zFe9vIQAb+Pwkgd1Ktj/gsKMaWhp0WWFESMoZmKaJIKHOB9KA7v7cKr pUOA== 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 k70-v6si10681498otk.129.2018.09.21.15.18.55 for ; Fri, 21 Sep 2018 15:18:55 -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 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 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 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-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 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,