From patchwork Mon Dec 3 18:06: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: 10710291 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 8ECB1109C for ; Mon, 3 Dec 2018 18:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 835D12B47E for ; Mon, 3 Dec 2018 18:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76DFF2B495; Mon, 3 Dec 2018 18:08:22 +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 072ED2B47E for ; Mon, 3 Dec 2018 18:08:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80E126B6A9B; Mon, 3 Dec 2018 13:08:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7BEA06B6A9D; Mon, 3 Dec 2018 13:08:01 -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 65CD16B6A9E; Mon, 3 Dec 2018 13:08:01 -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 11DDC6B6A9B for ; Mon, 3 Dec 2018 13:08:01 -0500 (EST) Received: by mail-ot1-f70.google.com with SMTP id t13so5994522otk.4 for ; Mon, 03 Dec 2018 10:08:01 -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=yYwIdTKWeRNtz5QSmMouRNEU9UwxT/m3QVZga4V1oPc=; b=nvc/28V+zZIoBsAps3y2MZ2H5v4lleva0qK/GQjmXRAwaVIV6xdhrvOtdWNYAJHhlG OSgnGb6BkjKum2UiE4CK1uBXvRvRbYuU0C6FFegARO6bOrojK63+cxAlUucbVLHkQuqJ nyHafLAWhtH+b1s0tahA9XXQiHguXogQP4PHKS4/inK1vVvdoVN50WuoZPbLF3vyGJJn cdw9+Z7H84nU8typkpy1HIo4A/HsvUf7x9ZQkoPmQU6nhUD8qxUjjwL28+HXveUvrZfR AFz3Q9sPDqjbvPb2Mg4K/TPdEXGcUHop2u0Vek40l0B6qpW/fPXBpyDvIPou1XnDf7w+ PXKg== 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+aEWaGUE9CrauAtH1575rxMdIZROVxeelVgbpvEKHFOSak2tgG4dgj nxuKb3k6tM6ic2s+hN6TJyBy6lQFbUC1RgZDEgNk9EPboLVT1IWjFMCFdgOGRgjvpHObrjWsXip Oypwv9tsOyuwXZE/NNxqPKjRqi5pwsBV78R0byUGN3bqaScQN+S3My+w83gMsUJXpFA== X-Received: by 2002:aca:4506:: with SMTP id s6mr9836447oia.115.1543860480793; Mon, 03 Dec 2018 10:08:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/VP1KvKpqhkH9Kyoi7YBNu1QUp4rOu5T2iSVAjQPruO5gMu5+fmc16A6M53HWgTWBRF2d09 X-Received: by 2002:aca:4506:: with SMTP id s6mr9836396oia.115.1543860479542; Mon, 03 Dec 2018 10:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860479; cv=none; d=google.com; s=arc-20160816; b=kxTfgKFGfOv61s4YrbdkTjoKkNdad3o2mug7s4AdtFoFgOQiq9aSIMg2oxO8rPk+9O wSWysYS/+WnPNjSEzMe3bdHLeD7esbgTTsAYJFP0UrARZ+UhnZZhT9McDGyYtr1cF4YV ZJWr+Mfn7y6aMz3px+DjoMkpbX+yBFfZDpZqyClOHGid6HKT1NuxZnxVLVnBePmaiVf/ 4q3b3WbVOQBgTLJP/CTagQTRXUoAWG7ORjw/2/X9mgOXHG5KfrMAA3MbfFWPYG+vzqMC HvH8eqNSVIm8xoTC3nb8fh/wGwkGGsIMUZ2hIxIwLISZhTA37oIKX7PU2EHugDDp595k 0PQg== 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=yYwIdTKWeRNtz5QSmMouRNEU9UwxT/m3QVZga4V1oPc=; b=sILInYiXiddVEWbzMNFi6XNHxjM0uBWp6Fz8dy7NOMO9ow0yh1souv1/aIxupzEGM7 EHXUspc8R3RhhF+gB8wC22OAm3NItCIbfMszW4Txllmp2Cl/mXDQ2/UYi8H4iURMyjl4 H5klzVn93eNttGSS8czFGvXPjY4d4+HVxyyj50Nm9FB71rYUFJO4LWPWveFEwS5RdTdQ Dm3lcD58ELLJ6O9VzyY3kBuAZraW/dFXdHYickKEhxP1bDl6unia8FLdq4tf9bPAI5o0 MYNDceO1Qz5NkaagVp1TsYocrM2GnKYKWCwGflUvBu6rttpk8di/08Pya4e10VCKKAAQ 34Vw== 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 l78si6508323oih.207.2018.12.03.10.07.59 for ; Mon, 03 Dec 2018 10:07:59 -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 CE757169E; Mon, 3 Dec 2018 10:07:58 -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 0A36C3F59C; Mon, 3 Dec 2018 10:07:55 -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 23/25] arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work Date: Mon, 3 Dec 2018 18:06:11 +0000 Message-Id: <20181203180613.228133-24-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 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 this is not guaranteed to be taken before returning to user-space. Unless the exception interrupted a context with irqs-masked, irq_work_run() can run immediately. Otherwise return -EINPROGRESS to indicate ghes_notify_sea() found some work to do, but it hasn't finished yet. With this apei_claim_sea() returning '0' means 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 Acked-by: Catalin Marinas --- Changes since v6: * Added pr_warn() for the EINPROGRESS case so panic-tracebacks show 'APEI was here'. * Tinkered with the commit message Changes since v2: * Removed IS_ENABLED() check, done by the caller unless we have a dummy definition. --- arch/arm64/kernel/acpi.c | 22 +++++++++++++++++++++- arch/arm64/mm/fault.c | 9 ++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 803f0494dd3e..421331157e8f 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -268,13 +269,17 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) int apei_claim_sea(struct pt_regs *regs) { int err = -ENOENT; - unsigned long current_flags; + unsigned long current_flags, interrupted_flags; if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) return err; current_flags = arch_local_save_flags(); + interrupted_flags = current_flags; + if (regs) + interrupted_flags = regs->pstate; + /* * SEA can interrupt SError, mask it and describe this as an NMI so * that APEI defers the handling. @@ -283,6 +288,21 @@ 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 { + pr_warn("APEI work queued but not completed"); + err = -EINPROGRESS; + } + } + local_daif_restore(current_flags); return err; diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 956afc7d932a..c26ee1f1cc36 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -629,11 +629,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; + } if (esr & ESR_ELx_FnV) siaddr = NULL;