From patchwork Fri Sep 21 22:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10611077 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 DC0B25A4 for ; Fri, 21 Sep 2018 22:19:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8B22DDD2 for ; Fri, 21 Sep 2018 22:19:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B94D82DDDF; Fri, 21 Sep 2018 22:19:12 +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 451D22DDD2 for ; Fri, 21 Sep 2018 22:19:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBACA8E0023; Fri, 21 Sep 2018 18:19:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D6B198E0001; Fri, 21 Sep 2018 18:19:10 -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 C5B598E0023; Fri, 21 Sep 2018 18:19:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by kanga.kvack.org (Postfix) with ESMTP id 9A3418E0001 for ; Fri, 21 Sep 2018 18:19:10 -0400 (EDT) Received: by mail-ot1-f71.google.com with SMTP id n12-v6so1993313otk.22 for ; Fri, 21 Sep 2018 15:19:10 -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=Jk9gZco1Cu30m5Tw/JSrvCazhgDfTTXWmpc9MnvC4ws=; b=CjZTJmtds3aGkNBy3KbnFRHFWc0ht5LCGYm+dce9Lsc/rdu+5ZIfE9yP6EHNPVDC4G 5mrdiSQkVYr1HT1l4x7GS/fGCBlBjyVcMV+g7hIEgkMMF+Ewi8GjZq42nRZaeShIeCFz xL26PcDdTCztAVQkyEwIYErXfEyM8pNoxskvwzkj5jaq17sBc6gZ10URAGY0+yJUBBvu KXyNG9jeICMTTPne3z9XQrzWvoIwznV4EkYYbBpo4BVszciE47RWmp+YobnZiX8oykVw rXJhS+Gao03cw7Y+r6+9/qJKLfqHP4IN9EARzJuNBNABk08HrBUeSrEimorzY3VyCIGx QxtQ== 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: APzg51BzArT2GVp9K57LU0cagQK0Qwcrp+iNk1TL2sUMgaNYeHymTq3+ k6g6d3bGRGgPujQlorGCe6mZzMXV+onyLQgVCq7OSObHZg6PHiFfU1rb05DP5DVJ91TelGtcOnT Xi6k2OrTwDhPa/GxUZ7roJOz6uVL2M3C8WbbncklEzc4lhhhEQtkydSHbeHk/lp1xqg== X-Received: by 2002:a9d:541c:: with SMTP id j28-v6mr27838747oth.134.1537568350372; Fri, 21 Sep 2018 15:19:10 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbq7LaN3f1I/Psz6RR6JXcymV3rcO8c+gjY4lDTH4RkjLgkRxW14/pHAqa2/U4Hxg1sAMx9 X-Received: by 2002:a9d:541c:: with SMTP id j28-v6mr27838714oth.134.1537568349443; Fri, 21 Sep 2018 15:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537568349; cv=none; d=google.com; s=arc-20160816; b=tt9VUf68mVEyvyQIyOhPunoEgskF1EX4ZqfwZiQJQjJHXZIbUNNTsA3a1/7t1aSb8J VXfizojfvPHWqJL8YIDxUsXHVX//zBCNrSNxfakqOwHrqW2Kc87lFnD1RQqkCAiXm5Y8 e9xwljZQVqvBksOedoF7mVrv8rbue9T0CA2Ey9m8IFhq2XhlfEgIDrTnPDxuLBmtUyfT /bTKeX1Mu6xa5sfVOh4ubDakbk1IDk01pe3l+8DZw+jokcyJdT03ns7YLkiaKEEKyvt4 vBbCxwvUaGsl5gv8NC5hnPwtl3fOUBhO9U2LzRAASjwlHezKbf9KScpxeq2eefRPqsq5 j0gw== 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=Jk9gZco1Cu30m5Tw/JSrvCazhgDfTTXWmpc9MnvC4ws=; b=aM1LaLtkpEsq6knVVKoakzQZ5Pu6ygx5t7J8UP9d4N10RBPHtQPCsqrNZDZ2Y0mtn9 sna7WXa7Zl2IFo5T9ieJaAqd0mL4AhkixjHJUNkQHgbpHug2WgfsYAlg4TZ6OVClaMgV 6T15A2HxbMxMNy51rQ01XdFm8o33CvEKljui6bphpSgMuH8ZHoxlWkRG2+tPleATL/jc lDz2GNQtB8wQqWOUUCtfT3+Enjj+CPts9xUoHfPE0bcJ8qThaXiw79XTT9HlmsWQFhe5 OwIKHbIXZwvwAgbl7VEIc4TrXBt7TZfMGBNdeCWShu9ylL3DOfJ7P11N/8ObWg+6sYFy I79A== 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 r17-v6si11765982oic.35.2018.09.21.15.19.09 for ; Fri, 21 Sep 2018 15:19:09 -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 E085518A; Fri, 21 Sep 2018 15:19:08 -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 CB4903F557; Fri, 21 Sep 2018 15:19:05 -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 18/18] arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work Date: Fri, 21 Sep 2018 23:17:05 +0100 Message-Id: <20180921221705.6478-19-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 APEI is unable to do all of its error handling work in nmi-context, so it defers non-fatal work onto the irq_work queue. arch_irq_work_raise() sends an IPI to the calling cpu, but we can't guarantee this will be taken before we return. Unless we interrupted a context with irqs-masked, we can call irq_work_run() to do the work now. Otherwise return -EINPROGRESS to indicate ghes_notify_sea() found some work to do, but it hasn't finished yet. With this we can take apei_claim_sea() returning '0' to mean this external-abort was also notification of a firmware-first RAS error, and that APEI has processed the CPER records. Signed-off-by: James Morse Reviewed-by: Punit Agrawal Tested-by: Tyler Baicar CC: Xie XiuQi CC: gengdongjiu --- Changes since v2: * Removed IS_ENABLED() check, done by the caller unless we have a dummy definition. --- arch/arm64/kernel/acpi.c | 19 +++++++++++++++++++ arch/arm64/mm/fault.c | 9 ++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index a9b8bba014b5..09744e2d15a0 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -270,10 +271,14 @@ int apei_claim_sea(struct pt_regs *regs) { int err = -ENOENT; unsigned long current_flags = arch_local_save_flags(); + unsigned long interrupted_flags = current_flags; if (!IS_ENABLED(CONFIG_ACPI_APEI_SEA)) return err; + if (regs) + interrupted_flags = regs->pstate; + /* * SEA can interrupt SError, mask it and describe this as an NMI so * that APEI defers the handling. @@ -282,6 +287,20 @@ int apei_claim_sea(struct pt_regs *regs) nmi_enter(); err = ghes_notify_sea(); nmi_exit(); + + /* + * APEI NMI-like notifications are deferred to irq_work. Unless + * we interrupted irqs-masked code, we can do that now. + */ + if (!err) { + if (!arch_irqs_disabled_flags(interrupted_flags)) { + local_daif_restore(DAIF_PROCCTX_NOIRQ); + irq_work_run(); + } else { + err = -EINPROGRESS; + } + } + local_daif_restore(current_flags); return err; diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 2c38776bb71f..97036e01522a 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -630,11 +630,10 @@ static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs) inf = esr_to_fault_info(esr); - /* - * Return value ignored as we rely on signal merging. - * Future patches will make this more robust. - */ - apei_claim_sea(regs); + if (apei_claim_sea(regs) == 0) { + /* APEI claimed this as a firmware-first notification */ + return 0; + } clear_siginfo(&info); info.si_signo = inf->sig;