From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Morse Subject: [PATCH v8 24/26] arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work Date: Tue, 29 Jan 2019 18:49:00 +0000 Message-ID: <20190129184902.102850-25-james.morse@arm.com> References: <20190129184902.102850-1-james.morse@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190129184902.102850-1-james.morse@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu To: linux-acpi@vger.kernel.org Cc: Rafael Wysocki , Tony Luck , Marc Zyngier , Catalin Marinas , Will Deacon , Dongjiu Geng , linux-mm@kvack.org, Borislav Petkov , Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown List-Id: linux-acpi@vger.kernel.org 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 Acked-by: Catalin Marinas CC: Xie XiuQi CC: gengdongjiu --- Changes since v7: * Added Catalin's ack, then: * Added __irq_enter()/exit() calls so if we interrupted preemptible code, the preempt count matches what other irq-work expects. * Changed the 'if (!arch_irqs_disabled_flags(interrupted_flags))' test to be safe before/after Julien's PMR series. 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 | 23 +++++++++++++++++++++++ arch/arm64/mm/fault.c | 9 ++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 803f0494dd3e..8288ae0c8f3b 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,12 +269,17 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) int apei_claim_sea(struct pt_regs *regs) { int err = -ENOENT; + bool return_to_irqs_enabled; unsigned long current_flags; if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) return err; current_flags = arch_local_save_flags(); + return_to_irqs_enabled = !irqs_disabled_flags(current_flags); + + if (regs) + return_to_irqs_enabled = interrupts_enabled(regs); /* * SEA can interrupt SError, mask it and describe this as an NMI so @@ -283,6 +289,23 @@ 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 (return_to_irqs_enabled) { + local_daif_restore(DAIF_PROCCTX_NOIRQ); + __irq_enter(); + irq_work_run(); + __irq_exit(); + } 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 e1c84c2e1cab..1611714f8333 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -642,11 +642,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; -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12B4DC169C4 for ; Tue, 29 Jan 2019 18:50:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C770C20844 for ; Tue, 29 Jan 2019 18:50:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C770C20844 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF7ED8E0007; Tue, 29 Jan 2019 13:50:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE1E48E0015; Tue, 29 Jan 2019 13:50:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF86F8E0007; Tue, 29 Jan 2019 13:50:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 7620A8E0015 for ; Tue, 29 Jan 2019 13:50:51 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id x15so8358993edd.2 for ; Tue, 29 Jan 2019 10:50:51 -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=WyX6PHLBF1pqpUWRcbcBKvnw8cl/d1twUs4/cn2oYq0=; b=Q0cJ68zVFZc5FIEdSvC/eFOzO1gCdRyFyq/sqLa3BY6NQlZ+EW9vObpSlNmVtJ6x0L 0IohyGmy8f81IC08nf7QsD0eVksAmZmo57Pwvfciihr2ASNXYnht4W2LsEkEozKPeUbF xicPLWKQeIIoDWgyErsL8mYmiANZHAUiXZKU14z7F/JjPbEYNbSfa9Qsx20gCRm/R5br mrDpNdw7Wvk7/G/eQkLy2BtXhXUSti+yBs/iwXnZfcz6L06jTSHI0Z6/lcde41lS6MXT o7mG4WNtAu7G0GelN+XmqAoN+OIBFv1JeZvY1qDrJNS/zpPxqqbNLHWB/RH8wPK9r62K rVvQ== 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: AJcUukfhYCQ6G6qvnDINMFsSdEvXHKypYFteespaSGyDATTJKNq24v3L tIzRFdlkuOBj9a4LyE0tWU6ejgvWLei3CGy3KDH7bV2IURSAThmtG2q9ijE0Ma2TcD1vtLj1yvg me5xurqKQxW3ghiv8J1vX3PK6KW0g9ES8Wa9KdxBT+yHUDBuRPdrIUV1nDDNt3eTdWg== X-Received: by 2002:a50:b1af:: with SMTP id m44mr26266492edd.47.1548787850949; Tue, 29 Jan 2019 10:50:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN46GU/dcpHLMCmO+QPwYLfcJUv7gDmnQuxZmito0SsRQ6M5NR1PdsX8x2r3mf4+77bz0Ib2 X-Received: by 2002:a50:b1af:: with SMTP id m44mr26266435edd.47.1548787849916; Tue, 29 Jan 2019 10:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548787849; cv=none; d=google.com; s=arc-20160816; b=RZ9O9Ogt8S7HPs6yFShkyKu9jMROiJrWqjM7IYpafq+/aD/+7SZZgYTwSqc8FgcOFR I5weUreNn8zf29HF+pkBipikJpOAIQPRTht/toG1ZjDDeCA1VjljlE/VrsjpqqbU2aTs ruLBBNMozE03IVOIxyixA+SS+vjgiFaLKrfeRkxPLdm06KHCp5VX2+fCIeZ7lKQqWfVd YmoLP7AyQ13L+N+j2fHZxg4QtyOY4j0E24WCBV0xy8SNPdgabbnARNwBNXKJwKE88N6I 6QK7Z9Hb/WlyaMsx7PW/2xUhBr+oq/RTaeiJjFP5aXHqYPQssj/Uqt+mAI2SGIRxL85E 2c9g== 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=WyX6PHLBF1pqpUWRcbcBKvnw8cl/d1twUs4/cn2oYq0=; b=r+zkVu/7rQYMNqMJsVZNQXwFtb+gADBSu2Nf001+37pqJKej4qhAOT7SNWl8ajGJYd HGcHY/9Jn5qjRj8hGttyLN8cGsocyY88WMyR457Kl/36hhM9n8HerhLxqhjZcaHMZ9W4 MW1C0c35GdFWzNQjhgbFdBgKItXDzMoWNI4DgPMPzWPYXbrJykVUzQeTmocliTudYm1E TR6+B8Ekkr3HFFWKd58zWyIEQZL+VfCLX+u56lfcxI8m0O71oDUWleBunhHIfpxDqgQn f9UPu3n+TpoxxL7XUuBxRm251ivDsRXa6ozaUT9/949XR6Jw/r9ndBZgGLZfep67qhvU 3ERg== 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 j30si2157551edc.365.2019.01.29.10.50.49 for ; Tue, 29 Jan 2019 10:50:49 -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 D427E1650; Tue, 29 Jan 2019 10:50:48 -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 327F33F557; Tue, 29 Jan 2019 10:50:46 -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 , james.morse@arm.com Subject: [PATCH v8 24/26] arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work Date: Tue, 29 Jan 2019 18:49:00 +0000 Message-Id: <20190129184902.102850-25-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129184902.102850-1-james.morse@arm.com> References: <20190129184902.102850-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 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 Acked-by: Catalin Marinas CC: Xie XiuQi CC: gengdongjiu --- Changes since v7: * Added Catalin's ack, then: * Added __irq_enter()/exit() calls so if we interrupted preemptible code, the preempt count matches what other irq-work expects. * Changed the 'if (!arch_irqs_disabled_flags(interrupted_flags))' test to be safe before/after Julien's PMR series. 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 | 23 +++++++++++++++++++++++ arch/arm64/mm/fault.c | 9 ++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 803f0494dd3e..8288ae0c8f3b 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,12 +269,17 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) int apei_claim_sea(struct pt_regs *regs) { int err = -ENOENT; + bool return_to_irqs_enabled; unsigned long current_flags; if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) return err; current_flags = arch_local_save_flags(); + return_to_irqs_enabled = !irqs_disabled_flags(current_flags); + + if (regs) + return_to_irqs_enabled = interrupts_enabled(regs); /* * SEA can interrupt SError, mask it and describe this as an NMI so @@ -283,6 +289,23 @@ 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 (return_to_irqs_enabled) { + local_daif_restore(DAIF_PROCCTX_NOIRQ); + __irq_enter(); + irq_work_run(); + __irq_exit(); + } 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 e1c84c2e1cab..1611714f8333 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -642,11 +642,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; -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5614BC282C7 for ; Tue, 29 Jan 2019 19:11:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2760F214DA for ; Tue, 29 Jan 2019 19:11:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HwlyVFci"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AjE3RAk4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2760F214DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NsEZpLyfgqJ5WNmkH8w4bvXqMQXcSu/81U3ZAKo4SgA=; b=HwlyVFciEvoP5K a9nRSGOTBRgTr51ULFhIjwMv2Pp9jt/kKgcYLYTVoNQ9jYzKTHsVuuyZAib6tVJ14jiGAhhlO8llq gCPFA9CO7pxbv3g8GTLUV0Tkjt9hkLyqjEs6h0spvdu8DC0exzaqx7WIlru4hr8lxH/D8Cg0K1MlI Q6ZU4ImzEp/5tPIiDa7kG5Ynv/lkG9BOSFE3qfu7VmDMHxfTrBjvo+9AdpBaAc/CTov1OZEJZNr8h GtH5vpWexIJOS4djSjtlMR6GZjWesX4u2tctXCFRsX4zUwIBSV0DKhvLsZLXNCV+xDMZxPa3iG2N0 7Eljc8/X0h8xsgHSmQdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goYnG-0005QM-M3; Tue, 29 Jan 2019 19:11:34 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goYmW-0004kD-9W for linux-arm-kernel@bombadil.infradead.org; Tue, 29 Jan 2019 19:10:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WyX6PHLBF1pqpUWRcbcBKvnw8cl/d1twUs4/cn2oYq0=; b=AjE3RAk4nzminuEa0XjwnYmV+A xDDUw4/bURE9ms/ZoalgDI0fjUKFGaiPOerUeS7PParX1Y1JSGC0Ri52cpO8h7znGcWs7/1rFsw37 hEClbc+RgaL4pcwnj0LEyTmBhm8akILUCHYQz8pV+SlgCBlzFWiLpisC/IE8O35qkAXKCN2PKn/D5 dbOKV1cB03DTKuGHErTWpYSWiJOhs+d1lqK3tHNdzRvoLi1KlMyCuNqE1lWtx4PRqZ4lvEJHYjzvJ 0IOjPP1b7kEPyhV+jN+7DaqDGCUCLGcQSDqL8aAJ1+gQqHISHJVacDGl6zU4CsxUyEAdHlO8pOHzh 8+Rr92+w==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goYTB-0005aU-1r for linux-arm-kernel@lists.infradead.org; Tue, 29 Jan 2019 18:50:50 +0000 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 D427E1650; Tue, 29 Jan 2019 10:50:48 -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 327F33F557; Tue, 29 Jan 2019 10:50:46 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Subject: [PATCH v8 24/26] arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work Date: Tue, 29 Jan 2019 18:49:00 +0000 Message-Id: <20190129184902.102850-25-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129184902.102850-1-james.morse@arm.com> References: <20190129184902.102850-1-james.morse@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_135049_334298_2F097576 X-CRM114-Status: GOOD ( 21.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rafael Wysocki , Tony Luck , Xie XiuQi , Marc Zyngier , Catalin Marinas , Will Deacon , Christoffer Dall , Dongjiu Geng , linux-mm@kvack.org, Borislav Petkov , james.morse@arm.com, Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Catalin Marinas CC: Xie XiuQi CC: gengdongjiu --- Changes since v7: * Added Catalin's ack, then: * Added __irq_enter()/exit() calls so if we interrupted preemptible code, the preempt count matches what other irq-work expects. * Changed the 'if (!arch_irqs_disabled_flags(interrupted_flags))' test to be safe before/after Julien's PMR series. 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 | 23 +++++++++++++++++++++++ arch/arm64/mm/fault.c | 9 ++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 803f0494dd3e..8288ae0c8f3b 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,12 +269,17 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) int apei_claim_sea(struct pt_regs *regs) { int err = -ENOENT; + bool return_to_irqs_enabled; unsigned long current_flags; if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) return err; current_flags = arch_local_save_flags(); + return_to_irqs_enabled = !irqs_disabled_flags(current_flags); + + if (regs) + return_to_irqs_enabled = interrupts_enabled(regs); /* * SEA can interrupt SError, mask it and describe this as an NMI so @@ -283,6 +289,23 @@ 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 (return_to_irqs_enabled) { + local_daif_restore(DAIF_PROCCTX_NOIRQ); + __irq_enter(); + irq_work_run(); + __irq_exit(); + } 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 e1c84c2e1cab..1611714f8333 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -642,11 +642,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; -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel