Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3982712imu; Mon, 12 Nov 2018 03:59:22 -0800 (PST) X-Google-Smtp-Source: AJdET5ecNpi4OZ5phlr0k8JEiJOuFY4pJnYA0NhTDYtDaFlN627PVoqmaPWvgYLiyX//hZjhJY66 X-Received: by 2002:a65:5387:: with SMTP id x7mr572077pgq.412.1542023962608; Mon, 12 Nov 2018 03:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542023962; cv=none; d=google.com; s=arc-20160816; b=W5RfkZLzgxRg0k34QO3v0bD0N3dnnxH4Fa1derpw8gVzwzgpLko+BWB1YcxHp9vEYl HxrEfG9crXmSRCOC2NyspnO1HvxgBeXsb4lW7JDwFX1aedK77yV5UNPjN7cciiwBDp10 IDEM7Dzc0i92V20HzWuAOFRkTnnk5qMHMgx/TJeNO5cWKJC/X1r0HnA2/vpmB6tMM1v+ rqv+oWdGSFd+4+hvRsXvi8bgEXihTjEK4/uAUFpGkogluYcsmNpfyerJRiM4Xnmx1DVg Q8OjvtSrSCEpXsZaBWP9fQNuSx6h86dnfqrzK50SsW7fS0+WLltaNebHYB+uhV7sr4Gx Go1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=BEqS2iK1VqCFnwzMTzq8iCIygxIXd+MeSifT58/38aI=; b=mN5vD7phZl3kTkX2jIPFpLBOCiSTqjSlfrka8jNDUgf5WNKskmAd0AO7OlxrkRjHvz Mri8314Skywn8FrpQ4fb0EP7uWl0hxQFkiC0rDB9ENpVOdFG/oa6bUJMo4nOw/7Xx3iA +DuLtT8UyrQx6wEJ+9YWJNx6pUEothuYqSquxPuu1wbbRqpSk7C97LssCFO17IYWs0l/ NljzyJJ1YeW9W1du6ES+Mw9ZSCEh6a356/4xw3+R9wVVksR/cZbv9Mef362jWMHM3BRQ RMK6//6Jrp6GRElRdOxZky9/FoG34ee4iMUT1zZzSvlUaAIEgF1wV0gW/1R08G1sDwSv zWKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61-v6si16981153plb.418.2018.11.12.03.59.07; Mon, 12 Nov 2018 03:59:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730091AbeKLVvL (ORCPT + 99 others); Mon, 12 Nov 2018 16:51:11 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34794 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729293AbeKLVvK (ORCPT ); Mon, 12 Nov 2018 16:51:10 -0500 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 EB57615AB; Mon, 12 Nov 2018 03:58:13 -0800 (PST) Received: from e112298-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D89B33F5A0; Mon, 12 Nov 2018 03:58:11 -0800 (PST) From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Thierry , Mark Rutland , Dave Martin Subject: [PATCH v6 21/24] arm64: Handle serror in NMI context Date: Mon, 12 Nov 2018 11:57:12 +0000 Message-Id: <1542023835-21446-22-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> References: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Per definition of the daifflags, Serrors can occur during any interrupt context, that includes NMI contexts. Trying to nmi_enter in an nmi context will crash. Skip nmi_enter/nmi_exit when serror occurred during an NMI. Suggested-by: James Morse Signed-off-by: Julien Thierry Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Dave Martin Cc: James Morse --- arch/arm64/kernel/traps.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 5f4d9ac..66344cd 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -897,13 +897,17 @@ bool arm64_is_fatal_ras_serror(struct pt_regs *regs, unsigned int esr) asmlinkage void do_serror(struct pt_regs *regs, unsigned int esr) { - nmi_enter(); + const bool was_in_nmi = in_nmi(); + + if (!was_in_nmi) + nmi_enter(); /* non-RAS errors are not containable */ if (!arm64_is_ras_serror(esr) || arm64_is_fatal_ras_serror(regs, esr)) arm64_serror_panic(regs, esr); - nmi_exit(); + if (!was_in_nmi) + nmi_exit(); } void __pte_error(const char *file, int line, unsigned long val) -- 1.9.1