From patchwork Mon Dec 19 18:30:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 707184 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tj8sN1XP4z9tkk for ; Tue, 20 Dec 2016 05:42:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A6PNOQDv"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tj8sN0TNfzDxJ8 for ; Tue, 20 Dec 2016 05:42:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A6PNOQDv"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tj8cH5xrdzDwNl for ; Tue, 20 Dec 2016 05:30:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A6PNOQDv"; dkim-atps=neutral Received: by mail-pg0-x244.google.com with SMTP id g1so7405229pgn.0 for ; Mon, 19 Dec 2016 10:30:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dzrGwgfbiV6aZ2Hzd+Q++UVw23nJJsoGOaGZfEiKsso=; b=A6PNOQDv1XBsE9QvUamHaOffa1Aird2ziFUroITXmbAnzRiE1zNS15QXHZXguQZk8n 0prjBl7/RfXwvV+wpRF3GRwuNvFwSxqXHE/6G+hn/9ozs85PFrWjoxbtFD0hPQEQNT3a OAhXQfLDjLo8rDdg5UaaaMk68iAmLIoVjNtIhOBKu3K4qwgavxWksD2I4N+JTRy/gHA3 S1O5B4ptMjaYj9mWehhzM3h4K1FGArwZuShdPx0WxCNVa5eO5aILb1ItAxNj5u2NJMB6 d/yXvG7/d4jxVH6tdjB4YGlsIT7bNGxMonvPWch7KE3t+5GVYZgKhv7MrVK+RGOn4pU+ rLgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dzrGwgfbiV6aZ2Hzd+Q++UVw23nJJsoGOaGZfEiKsso=; b=s9rJrkXOTvEpt8nHkMzA3ebP6Z5OpZamdjnOvyFDzwmKmjSQgeupJ844sfeEE6CN1h d/8B6MmeQhfM+IF7Z83xLKk9rL+NtJzYDR7UygDbrkaXrZ7MqDUVYNJ11TUKHeWUJfc+ getptUO0tSJhgSuvZSLVx4ncn8I71wdlDYNJRYSe/op4VVX5yD7BTJJj5HmnpbaiUxnG L3AH7ZVolF2PutFLYjy7PDPvxm0tPtIVZFKXd0iQfTJWUF6yCQzCRg9w62nK3DNzapMW sI9cCcRjZK3MV5GTswgQwd6xq6Ri60GVjeEG+jOsC0qgHKOKmS+6zUR2S4FAzrQSb6Jt PQog== X-Gm-Message-State: AKaTC01XqcmpJqjJ/BzMLCDhi11Dx4xGiDGRTnP1btj1P+NWfcImzPuQNAQzmoFUaRQgEQ== X-Received: by 10.99.113.87 with SMTP id b23mr30914873pgn.41.1482172238217; Mon, 19 Dec 2016 10:30:38 -0800 (PST) Received: from roar.au.ibm.com ([61.68.124.232]) by smtp.gmail.com with ESMTPSA id g27sm33135147pfk.58.2016.12.19.10.30.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 10:30:37 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 06/10] powerpc: nmi_enter for system reset Date: Tue, 20 Dec 2016 04:30:07 +1000 Message-Id: <20161219183011.28310-7-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161219183011.28310-1-npiggin@gmail.com> References: <20161219183011.28310-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" System reset is a non-maskable interrupt from Linux's point of view (occurs under local_irq_disable()), so it should use nmi_enter/exit. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/traps.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 802aa6bbe97b..c65c88fb6482 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -278,6 +278,14 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) void system_reset_exception(struct pt_regs *regs) { + /* + * Avoid crashes in case of nested NMI exceptions. Recoverability + * is determined by RI and in_nmi + */ + bool nested = in_nmi(); + if (!nested) + nmi_enter(); + /* See if any machine dependent calls */ if (ppc_md.system_reset_exception) { if (ppc_md.system_reset_exception(regs)) @@ -296,6 +304,9 @@ void system_reset_exception(struct pt_regs *regs) if (!(regs->msr & MSR_RI)) panic("Unrecoverable System Reset"); + if (!nested) + nmi_exit(); + /* What should we do here? We could issue a shutdown or hard reset. */ }