Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3533396imu; Mon, 10 Dec 2018 03:55:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vl2jAc9+6UBI2nHVIITWV4RQeNXYdegk28jayQPK5JrDGNADgLQoEzUoCcyV3iANDyN7IY X-Received: by 2002:a63:9d05:: with SMTP id i5mr9796213pgd.98.1544442928294; Mon, 10 Dec 2018 03:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544442928; cv=none; d=google.com; s=arc-20160816; b=j6BZv42lc9WykweTLmCTIrhQpmO6RgP6CtToJi9KRLZ0Avdx42exw1ZgLM/Meh5ZyR cq9bdIROSg12miew4TOU8l1L0gbxU9K+zWNvYJCae9sQcUXY33WKwVGUcEk07AZ8xKVy gw+6XbcwjBZe5Z6astz00B7N2jqkcFJf0KWVM0sCrb8N8gVfrW4WEID5gqGTT8kIs9HD MVIQ5MQVnu+b8q0QeItQKYVdWOjyqc+utvFUNq4J1Pm+j/T0pArb+TbHa4CHU3gmwgiH LV4SB9bKaeXs7cvnDRWKyXg9KbDP7ZjxarCqlze9TswiWmoS9NcBVcRqn9+ldP7PVEfc qaOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id; bh=OBQYjLD52Fxz2Q4amH0vQVV3jBlw9THA8CY7z/V9fTI=; b=tMUcU31Y3tkFBqSaChcGGB7u6caxw+ikauiLoRBKDnEagAsm/vn5a4w0EUUx1TT4Kv QT76ulnuofHpr+9lxHDRt/prLjcCpG4p8a0FYNF6UKbAEx+Gi5HkBdsU7UX3Ncle37o7 wj+juw7++udamVGD1UTFYz9ydToYjyvZlML6U+zfAeI4/48Ms4qnpFJgSu2mzKLCs2hZ f6UgkTmqJBEyOC3bo/I1tb2/+hfQOEAJ6i3OLViSq5Vjxwz6X1gujOeMXtDhDLCrEyM8 2fr2oRa/dgfWcO+8Si80stJJj1oELkKyX14SQlhix2ZzK1bnCEKSejT3QUJGj64vOwhp AI8g== 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 a193si11066734pfa.214.2018.12.10.03.55.13; Mon, 10 Dec 2018 03:55:28 -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 S1727396AbeLJLlc (ORCPT + 99 others); Mon, 10 Dec 2018 06:41:32 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:58666 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbeLJLlb (ORCPT ); Mon, 10 Dec 2018 06:41:31 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43D1PP4NhCz9tylK; Mon, 10 Dec 2018 12:41:29 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id RLSczNLKkF5q; Mon, 10 Dec 2018 12:41:29 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43D1PP3VQ7z9tylJ; Mon, 10 Dec 2018 12:41:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 000878B7A9; Mon, 10 Dec 2018 12:41:29 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id gTaV2tp9ZEjP; Mon, 10 Dec 2018 12:41:29 +0100 (CET) Received: from po14163vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CBDCC8B74C; Mon, 10 Dec 2018 12:41:29 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id A857D716EF; Mon, 10 Dec 2018 11:41:29 +0000 (UTC) Message-Id: <33dbb34cea199dc003cf5b7581faf905d546e0cf.1544441989.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] powerpc/83xx: handle machine check caused by watchdog timer To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 10 Dec 2018 11:41:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the watchdog timer is set in interrupt mode, it causes a machine check when it times out. The purpose of this mode is to ease debugging, not to crash the kernel and reboot the machine. This patch implements a special handling for that, in order to not crash the kernel if the watchdog times out while in interrupt or within the idle task. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/cputable.h | 1 + arch/powerpc/include/asm/reg.h | 2 ++ arch/powerpc/kernel/cputable.c | 10 ++++++---- arch/powerpc/platforms/83xx/misc.c | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index a0395ccbbe9e..d05f0c28e515 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -44,6 +44,7 @@ extern int machine_check_e500(struct pt_regs *regs); extern int machine_check_e200(struct pt_regs *regs); extern int machine_check_47x(struct pt_regs *regs); int machine_check_8xx(struct pt_regs *regs); +int machine_check_83xx(struct pt_regs *regs); extern void cpu_down_flush_e500v2(void); extern void cpu_down_flush_e500mc(void); diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index 0d2139a0d5b9..1c98ef1f2d5b 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -769,6 +769,8 @@ #define SRR1_PROGTRAP 0x00020000 /* Trap */ #define SRR1_PROGADDR 0x00010000 /* SRR0 contains subsequent addr */ +#define SRR1_MCE_MCP 0x00080000 /* Machine check signal caused interrupt */ + #define SPRN_HSRR0 0x13A /* Save/Restore Register 0 */ #define SPRN_HSRR1 0x13B /* Save/Restore Register 1 */ #define HSRR1_DENORM 0x00100000 /* Denorm exception */ diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 2da01340c84c..1eab54bc6ee9 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -1141,6 +1141,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .machine_check = machine_check_generic, .platform = "ppc603", }, +#ifdef CONFIG_PPC_83xx { /* e300c1 (a 603e core, plus some) on 83xx */ .pvr_mask = 0x7fff0000, .pvr_value = 0x00830000, @@ -1151,7 +1152,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .icache_bsize = 32, .dcache_bsize = 32, .cpu_setup = __setup_cpu_603, - .machine_check = machine_check_generic, + .machine_check = machine_check_83xx, .platform = "ppc603", }, { /* e300c2 (an e300c1 core, plus some, minus FPU) on 83xx */ @@ -1165,7 +1166,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .icache_bsize = 32, .dcache_bsize = 32, .cpu_setup = __setup_cpu_603, - .machine_check = machine_check_generic, + .machine_check = machine_check_83xx, .platform = "ppc603", }, { /* e300c3 (e300c1, plus one IU, half cache size) on 83xx */ @@ -1179,7 +1180,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .icache_bsize = 32, .dcache_bsize = 32, .cpu_setup = __setup_cpu_603, - .machine_check = machine_check_generic, + .machine_check = machine_check_83xx, .num_pmcs = 4, .oprofile_cpu_type = "ppc/e300", .oprofile_type = PPC_OPROFILE_FSL_EMB, @@ -1196,12 +1197,13 @@ static struct cpu_spec __initdata cpu_specs[] = { .icache_bsize = 32, .dcache_bsize = 32, .cpu_setup = __setup_cpu_603, - .machine_check = machine_check_generic, + .machine_check = machine_check_83xx, .num_pmcs = 4, .oprofile_cpu_type = "ppc/e300", .oprofile_type = PPC_OPROFILE_FSL_EMB, .platform = "ppc603", }, +#endif { /* default match, we assume split I/D cache & TB (non-601)... */ .pvr_mask = 0x00000000, .pvr_value = 0x00000000, diff --git a/arch/powerpc/platforms/83xx/misc.c b/arch/powerpc/platforms/83xx/misc.c index d75c9816a5c9..3e591d159413 100644 --- a/arch/powerpc/platforms/83xx/misc.c +++ b/arch/powerpc/platforms/83xx/misc.c @@ -150,3 +150,19 @@ void __init mpc83xx_setup_arch(void) mpc83xx_setup_pci(); } + +int machine_check_83xx(struct pt_regs *regs) +{ + u32 mask = 1 << (31 - IPIC_MCP_WDT); + + if (!(regs->msr & SRR1_MCE_MCP) || !(ipic_get_mcp_status() & mask)) + return machine_check_generic(regs); + ipic_clear_mcp_status(mask); + + if (debugger_fault_handler(regs)) + return 1; + + die("Watchdog NMI Reset", regs, 0); + + return 1; +} -- 2.13.3