From patchwork Tue Jun 26 17:01:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10489671 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 DF262604D3 for ; Tue, 26 Jun 2018 17:04:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC37B20950 for ; Tue, 26 Jun 2018 17:04:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C03F725F3E; Tue, 26 Jun 2018 17:04:06 +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 9756E28609 for ; Tue, 26 Jun 2018 17:02:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A043D6B0280; Tue, 26 Jun 2018 13:02:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9B5836B0281; Tue, 26 Jun 2018 13:02:42 -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 8A3D06B0282; Tue, 26 Jun 2018 13:02:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id 5D8976B0280 for ; Tue, 26 Jun 2018 13:02:42 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id v71-v6so12348063oie.20 for ; Tue, 26 Jun 2018 10:02:42 -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=5KizE+e1E0FwMRMD9es80nYrJ7vBkTUzy97ueQgtCf4=; b=UWpbBkgrjCTFAsxnknceDFupZIj6a3gH3PGkApe+wyiRTK5BLXJO5nKhXH6F3rwErQ QhLNgvU4K4Z5f19vNre4rX8+lYUvGf2J0QNvENNopvGyclDbnePr1h0QtT6DGKtOLfa5 kttUlG02f+QT7yvHVD8VFKkKzQIwuWufghYNOQdvb1HC6hL3Z1AAw2hxX+c7M2p4mWPn wW/+aKq8bGTaD64/7CM18sbL6Kdl5V+fAgIgRJOt6IehYMZ+rhLF7ltewrdd/jJqTwZd c1rIm37U59WvRs/slvnd/wq4Zw4Y2Qt1hMnkKEbxW+7AgzanzeZ+vQqcVLRFsyfTRHHo UtDQ== 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: APt69E3dledd2Q53TxSsdp8/JKhxnC0tBCVHlzonV+JJr87Lx1otQd0z JLRkum40gTaj7f+qbU8k+Uq7+Q9uIEJouiKL6oEjJ/nAkwOxVBI37TiQ3f98NVyuCG7ONJWbj9l eERmLlgNHr8nNtiq9qinYFuWScr1F8360yaexF409kyfUmHrQUE0eCu43b4jgPHMylg== X-Received: by 2002:aca:f40b:: with SMTP id s11-v6mr1214309oih.143.1530032562171; Tue, 26 Jun 2018 10:02:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd5q5PqPpn9wlLdAD9VpR64YKGOmKlWx9GhE2K9h+182L5bhn0Wn7fYnn2iHDJzTf7cNglV X-Received: by 2002:aca:f40b:: with SMTP id s11-v6mr1214193oih.143.1530032559855; Tue, 26 Jun 2018 10:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530032559; cv=none; d=google.com; s=arc-20160816; b=qP8yXW5IyFUddo8vSCXTkjWRbcqpxx6r5aKZWBajT4jialVoLI6qpD7qROp/S2X3uZ cteKUV8LBQ4upPkYVHi/ULIgcLQJArKdDceVobMk5chYG7WPNDCETKZXdB/HspdFVUXu VW9WufYw4NPFQPlCJ6vQtBjqWKEGKAHY9+vC25DuwytffgUTrMZ0ARoWfba6VeVnellX mj6LeNzw7iKkFyPBArBGuUxEHpAKnk75wwQxzSoLefJU+3/UDl2mPRTfiP94S3os1Tnd vNZ/qr5IN44o9Q1gFZq7LqcoIGs7860MIJVhNCHOSqPjOdHHdRv2HKcPVojt2D+AUw/o g69A== 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=5KizE+e1E0FwMRMD9es80nYrJ7vBkTUzy97ueQgtCf4=; b=PET6ZQoECRYdB+WiTezRFUxHVHqOJ3iXOo4Pi+x6n0Xv9+Me2E/O6nhrK9sJugHVln e4Qxq5k+1zhcjGgw7JJDWkQqi3HKf7bw48FNgtxTNx/wVm1XZ3uI343UhJpjgr/0Wonn IBJ9FeZIzuLZK/ayNG7s74/KVT9fOtaLAO9NCW6PaF8XQqERFKt3eFVQ+IQcmZneirqj 19xGOLRvco+ynpBO4vTKUL0M27vZgXeunYkD1ThNGpKH7HGwM9rU9Dm/pWcWVEcszSaA YLqnRDPh3KbQpiq/eBRprmTG9fDJLy/Oh4QjRhfCM7BNG7iOuJ16kBP8VPWdjUVCfAbl aOZw== 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 p185-v6si641267oig.311.2018.06.26.10.02.39 for ; Tue, 26 Jun 2018 10:02:39 -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 779A722C7; Tue, 26 Jun 2018 10:02:39 -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 25DAD3F318; Tue, 26 Jun 2018 10:02:36 -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 12/20] ACPI / APEI: Don't store CPER records physical address in struct ghes Date: Tue, 26 Jun 2018 18:01:08 +0100 Message-Id: <20180626170116.25825-13-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 When CPER records are found the address of the records is stashed in the struct ghes. Once the records have been processed, this address is overwritten with zero so that it won't be processed again without being re-populated by firmware. This goes wrong if a struct ghes can be processed concurrently, as can happen at probe time when an NMI occurs. Avoid this stashing by letting the caller hold the address. A later patch will do away with the use of ghes->flags in the read/clear code too. Signed-off-by: James Morse --- drivers/acpi/apei/ghes.c | 30 +++++++++++++++--------------- include/acpi/ghes.h | 1 - 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 7b412508b3ea..b0054dfad9cc 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -266,7 +266,7 @@ static inline int ghes_severity(int severity) } } -static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len, +static void ghes_copy_tofrom_phys(void *buffer, phys_addr_t paddr, u32 len, int from_phys, int fixmap_idx) { void __iomem *vaddr; @@ -291,14 +291,13 @@ static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len, static int ghes_read_estatus(struct ghes *ghes, struct acpi_hest_generic_status *estatus, - int fixmap_idx) + phys_addr_t *buf_paddr, int fixmap_idx) { struct acpi_hest_generic *g = ghes->generic; - u64 buf_paddr; u32 len; int rc; - rc = apei_read(&buf_paddr, &g->error_status_address); + rc = apei_read(buf_paddr, &g->error_status_address); if (rc) { if (printk_ratelimit()) pr_warning(FW_WARN GHES_PFX @@ -306,15 +305,14 @@ static int ghes_read_estatus(struct ghes *ghes, g->header.source_id); return -EIO; } - if (!buf_paddr) + if (!*buf_paddr) return -ENOENT; - ghes_copy_tofrom_phys(estatus, buf_paddr, + ghes_copy_tofrom_phys(estatus, *buf_paddr, sizeof(*estatus), 1, fixmap_idx); if (!estatus->block_status) return -ENOENT; - ghes->buffer_paddr = buf_paddr; ghes->flags |= GHES_TO_CLEAR; rc = -EIO; @@ -326,7 +324,7 @@ static int ghes_read_estatus(struct ghes *ghes, if (cper_estatus_check_header(estatus)) goto err_read_block; ghes_copy_tofrom_phys(estatus + 1, - buf_paddr + sizeof(*estatus), + *buf_paddr + sizeof(*estatus), len - sizeof(*estatus), 1, fixmap_idx); if (cper_estatus_check(estatus)) goto err_read_block; @@ -341,12 +339,12 @@ static int ghes_read_estatus(struct ghes *ghes, static void ghes_clear_estatus(struct ghes *ghes, struct acpi_hest_generic_status *estatus, - int fixmap_idx) + phys_addr_t buf_paddr, int fixmap_idx) { estatus->block_status = 0; if (!(ghes->flags & GHES_TO_CLEAR)) return; - ghes_copy_tofrom_phys(estatus, ghes->buffer_paddr, + ghes_copy_tofrom_phys(estatus, buf_paddr, sizeof(estatus->block_status), 0, fixmap_idx); ghes->flags &= ~GHES_TO_CLEAR; } @@ -718,10 +716,11 @@ static void __process_error(struct ghes *ghes, 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, fixmap_idx)) { - ghes_clear_estatus(ghes, estatus, fixmap_idx); + if (ghes_read_estatus(ghes, estatus, &buf_paddr, fixmap_idx)) { + ghes_clear_estatus(ghes, estatus, buf_paddr, fixmap_idx); return -ENOENT; } @@ -735,7 +734,7 @@ static int _in_nmi_notify_one(struct ghes *ghes, int fixmap_idx) return 0; __process_error(ghes, estatus); - ghes_clear_estatus(ghes, estatus, fixmap_idx); + ghes_clear_estatus(ghes, estatus, buf_paddr, fixmap_idx); return 0; } @@ -853,11 +852,12 @@ static int ghes_proc(struct ghes *ghes) { int rc; unsigned long flags; + phys_addr_t buf_paddr; struct acpi_hest_generic_status *estatus = ghes->estatus; spin_lock_irqsave(&ghes_notify_lock_irq, flags); - rc = ghes_read_estatus(ghes, estatus, FIX_APEI_GHES_IRQ); + rc = ghes_read_estatus(ghes, estatus, &buf_paddr, FIX_APEI_GHES_IRQ); if (rc) goto out; @@ -871,7 +871,7 @@ static int ghes_proc(struct ghes *ghes) ghes_do_proc(ghes, estatus); out: - ghes_clear_estatus(ghes, estatus, FIX_APEI_GHES_IRQ); + ghes_clear_estatus(ghes, estatus, buf_paddr, FIX_APEI_GHES_IRQ); if (rc == -ENOENT) goto unlock; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 1624e2be485c..3d77452e3a1d 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -22,7 +22,6 @@ struct ghes { struct acpi_hest_generic_v2 *generic_v2; }; struct acpi_hest_generic_status *estatus; - u64 buffer_paddr; unsigned long flags; union { struct list_head list;