Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp114643pxj; Mon, 17 May 2021 22:34:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSBxyG2I3mlNetkYpCwGPMrEd+w0cZmvStMyXQJzZRfhU8tIIf9xmEQabCECvIF45ndAE1 X-Received: by 2002:a92:db11:: with SMTP id b17mr2881475iln.277.1621316093552; Mon, 17 May 2021 22:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621316093; cv=none; d=google.com; s=arc-20160816; b=U3ad53MsdARdhIj728oGS7PC4wAgVHvWBIbMNeasEuolzMm2nbWO1pa5dlCUQ18nM/ bXxxKwunZXecphusoJHDifX+Vtqz3pi9wAZE94qZ0czcxZxDI7mC//OTvYOFMM0j4Pjt nHtqwz+dcnaT7TjXXMb2PyKIwxHsjTw9EYQ/gjTLFvZHZi6KLiIxgqpc4nJe5AveqgOt S2B23gpySgt0E1aYDE8WBpcIgNf+096Vto3frEPmV/7oCxL8tqqAQSBI/TKccjGhLGuJ rZe+hwKHewDcSSIsn2ore6u7XhPs1Nc9eeEM89ZBknF4oyGDy/W/a6dGRXZDG5ykEVkL g77g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CKOJ3t6QYB6CAsnBNqfvgRe3rfsc1p02DseKtLMefgE=; b=yNtQ0XKS6mfyqUFvhbe2yzmq4SwIabWvvEpxMZPqN7DKt35fa15K1XUf8pr2wTdUTZ VMCf4TTX3whTt5vy+oo87aHdN29nZu1646+A8atEKl5IBeOdWQSv/BOGRl76nIH04CI0 cWvn2ViXM2GlNbS3sBoq71vjWFN971rQvSDPq0aUIV6F3s3qZFS8ByHJplexWBunEKpn SN8wilhon3Kdz09SsPtuvToUr8V1l+BSCx5qLBWcobObcWO5q9r+YAeZZ6tqwMKSSxMP andy9pd+S0vvua7L2Y9qQ+3KDKSAAukMxLc1Rp37vANnx9dm5JYihmpKzy3z3Jl4MYds 7R5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EmfwDxfl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si20405905ila.81.2021.05.17.22.34.40; Mon, 17 May 2021 22:34:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EmfwDxfl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240925AbhEQOql (ORCPT + 99 others); Mon, 17 May 2021 10:46:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:60372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240583AbhEQOiu (ORCPT ); Mon, 17 May 2021 10:38:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3CCD061934; Mon, 17 May 2021 14:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261095; bh=bQWRWZNSZrHFi+hejWxx4tlj/NoZ3bkrVH/8nEnLuNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmfwDxflDRQ8JpE7nnNo1gM/gXjNzzrxO+e0hqaMN7WHbCEfEK+KO3UmxBMAMwtNx S8MZrmnX3Cf1n7U0NG+3cI3aImLjisnFN7li6kWt4Qth6hu6MU91LtaRTfUZ92y3H3 0tvMzXoQKawHMp0BSqG9GqtlZcE0mCR6V2NIk8aw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Nicholas Piggin , Michael Ellerman , Sasha Levin Subject: [PATCH 5.12 305/363] powerpc/64s: Make NMI record implicitly soft-masked code as irqs disabled Date: Mon, 17 May 2021 16:02:51 +0200 Message-Id: <20210517140312.907247622@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Piggin [ Upstream commit 4ec5feec1ad029bdf7d49bc50ccc0c195eeabe93 ] scv support introduced the notion of code that implicitly soft-masks irqs due to the instruction addresses. This is required because scv enters the kernel with MSR[EE]=1. If a NMI (including soft-NMI) interrupt hits when we are implicitly soft-masked then its regs->softe does not reflect this because it is derived from the explicit soft mask state (paca->irq_soft_mask). This makes arch_irq_disabled_regs(regs) return false. This can trigger a warning in the soft-NMI watchdog code (shown below). Fix it by having NMI interrupts set regs->softe to disabled in case of interrupting an implicit soft-masked region. ------------[ cut here ]------------ WARNING: CPU: 41 PID: 1103 at arch/powerpc/kernel/watchdog.c:259 soft_nmi_interrupt+0x3e4/0x5f0 CPU: 41 PID: 1103 Comm: (spawn) Not tainted NIP: c000000000039534 LR: c000000000039234 CTR: c000000000009a00 REGS: c000007fffbcf940 TRAP: 0700 Not tainted MSR: 9000000000021033 CR: 22042482 XER: 200400ad CFAR: c000000000039260 IRQMASK: 3 GPR00: c000000000039204 c000007fffbcfbe0 c000000001d6c300 0000000000000003 GPR04: 00007ffffa45d078 0000000000000000 0000000000000008 0000000000000020 GPR08: 0000007ffd4e0000 0000000000000000 c000007ffffceb00 7265677368657265 GPR12: 9000000000009033 c000007ffffceb00 00000f7075bf4480 000000000000002a GPR16: 00000f705745a528 00007ffffa45ddd8 00000f70574d0008 0000000000000000 GPR20: 00000f7075c58d70 00000f7057459c38 0000000000000001 0000000000000040 GPR24: 0000000000000000 0000000000000029 c000000001dae058 0000000000000029 GPR28: 0000000000000000 0000000000000800 0000000000000009 c000007fffbcfd60 NIP [c000000000039534] soft_nmi_interrupt+0x3e4/0x5f0 LR [c000000000039234] soft_nmi_interrupt+0xe4/0x5f0 Call Trace: [c000007fffbcfbe0] [c000000000039204] soft_nmi_interrupt+0xb4/0x5f0 (unreliable) [c000007fffbcfcf0] [c00000000000c0e8] soft_nmi_common+0x138/0x1c4 --- interrupt: 900 at end_real_trampolines+0x0/0x1000 NIP: c000000000003000 LR: 00007ca426adb03c CTR: 900000000280f033 REGS: c000007fffbcfd60 TRAP: 0900 MSR: 9000000000009033 CR: 44042482 XER: 200400ad CFAR: 00007ca426946020 IRQMASK: 0 GPR00: 00000000000000ad 00007ffffa45d050 00007ca426b07f00 0000000000000035 GPR04: 00007ffffa45d078 0000000000000000 0000000000000008 0000000000000020 GPR08: 0000000000000000 0000000000100000 0000000010000000 00007ffffa45d110 GPR12: 0000000000000001 00007ca426d4e680 00000f7075bf4480 000000000000002a GPR16: 00000f705745a528 00007ffffa45ddd8 00000f70574d0008 0000000000000000 GPR20: 00000f7075c58d70 00000f7057459c38 0000000000000001 0000000000000040 GPR24: 0000000000000000 00000f7057473f68 0000000000000003 000000000000041b GPR28: 00007ffffa45d4c4 0000000000000035 0000000000000000 00000f7057473f68 NIP [c000000000003000] end_real_trampolines+0x0/0x1000 LR [00007ca426adb03c] 0x7ca426adb03c --- interrupt: 900 Instruction dump: 60000000 60000000 60420000 38600001 482b3ae5 60000000 e93f0138 a36d0008 7daa6b78 71290001 7f7907b4 4082fd34 <0fe00000> 4bfffd2c 60420000 ea6100a8 ---[ end trace dc75f67d819779da ]--- Fixes: 118178e62e2e ("powerpc: move NMI entry/exit code into wrapper") Reported-by: Cédric Le Goater Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210503111708.758261-1-npiggin@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/interrupt.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h index e8d09a841373..31ed5356590a 100644 --- a/arch/powerpc/include/asm/interrupt.h +++ b/arch/powerpc/include/asm/interrupt.h @@ -138,6 +138,13 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte local_paca->irq_soft_mask = IRQS_ALL_DISABLED; local_paca->irq_happened |= PACA_IRQ_HARD_DIS; + if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && !(regs->msr & MSR_PR) && + regs->nip < (unsigned long)__end_interrupts) { + // Kernel code running below __end_interrupts is + // implicitly soft-masked. + regs->softe = IRQS_ALL_DISABLED; + } + /* Don't do any per-CPU operations until interrupt state is fixed */ #endif /* Allow DEC and PMI to be traced when they are soft-NMI */ -- 2.30.2