Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp514408yba; Mon, 1 Apr 2019 10:49:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVNXxYJ2BeC0IoBdn7uyTwUnaVCWGqIlS7SMH19kMBRMA6VDYzZxnEoSA5sZzmXPQ8no4r X-Received: by 2002:a17:902:b210:: with SMTP id t16mr41925540plr.84.1554140999741; Mon, 01 Apr 2019 10:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554140999; cv=none; d=google.com; s=arc-20160816; b=KxYXWf8PY8l4goMylFVF6wd9xph+MOgr7FRD8HOFjAze4uYtyWi4hPXNxxsGy1BfZW S3yBqX9AImtGUYiPJZat/+Ji19DoYHS2igTGuKVAsIz45MWJcUjZUC8qsF/xqh8orE+s NrPmoTBbP9vUjSsQoEac5LacUKVSb1Vt40ZmD6a7FPCH4E2UvO+0puoYIEwqHwNb9Cjg rctlcCefZTgOMuiC5HfXIc+qyvE28pMVkpMdsfqDH797CqI85ZoY6hA1jWszC9e8KtXj mL2aPtvM2BCT67hY53HUHN63ZaPxMVVztdfBjb9kdvUbZ15pk3bC15sUSyx3OyuTQdM3 e9zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bEtHpE0aZOu4FgztrXQQD/WcdTsZdAl878sQWpcMJqo=; b=MqtV6sehdQbn6ikbvhkUKtD5tx7RVcjojrOeTUdsQkc3qjEQB4wF3mEFNmKTE8D1mE zU3heOB/h152lDKMLG0anS3+VLjzbVL7ElMhR1jieskW48sHX8OaXo8plcIn+bjfFwYB fJ8pry5FaJuhgJCgo4+i2GohqIEaXRp/ZC/4vLYuvAgC07rFSj8ze5YOYRze1K0cTwoQ Lcios0SV1JAZi6jWW5IJTZzjPc2LAhvg1+ARKCGwmtppZUyq36HkqvpofIINSK0NlUMD Pe4BltG/VDkWtBvpD8rE8MCr+P4wYcEYltWyye4rVY6AgrI9e+UGpGM2XWr55n8URuRH Ni+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w6q6yexN; 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 m2si8892831pgp.463.2019.04.01.10.49.44; Mon, 01 Apr 2019 10:49:59 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=w6q6yexN; 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 S1732365AbfDARaM (ORCPT + 99 others); Mon, 1 Apr 2019 13:30:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:36968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732856AbfDARaK (ORCPT ); Mon, 1 Apr 2019 13:30:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3C532146E; Mon, 1 Apr 2019 17:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554139809; bh=zSrnYiL5OwQjDytkXpn8x3JAC1eugB9gO1N7jis0Qdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w6q6yexNn1kw2VBgRoQ8uKzfVQeWCf1SQlkbAwAYAYKb/cVEAPF2gxvP6/vU95qCd RKnf/bTmA1o99li+JxVLmBccNonzzAeMoHdi/TNFkRyHMEef0qmaJDL5SlbweF+lpR kGGUtIQEYqX4t5YD2wn5D+wNk5JQbn9kVhcJeazM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Will Deacon , Arnd Bergmann Subject: [PATCH 4.4 021/131] arm64: mm: Add trace_irqflags annotations to do_debug_exception() Date: Mon, 1 Apr 2019 19:01:31 +0200 Message-Id: <20190401170053.773108923@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170051.645954551@linuxfoundation.org> References: <20190401170051.645954551@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Morse commit 6afedcd23cfd7ac56c011069e4a8db37b46e4623 upstream. With CONFIG_PROVE_LOCKING, CONFIG_DEBUG_LOCKDEP and CONFIG_TRACE_IRQFLAGS enabled, lockdep will compare current->hardirqs_enabled with the flags from local_irq_save(). When a debug exception occurs, interrupts are disabled in entry.S, but lockdep isn't told, resulting in: DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled) ------------[ cut here ]------------ WARNING: at ../kernel/locking/lockdep.c:3523 Modules linked in: CPU: 3 PID: 1752 Comm: perf Not tainted 4.5.0-rc4+ #2204 Hardware name: ARM Juno development board (r1) (DT) task: ffffffc974868000 ti: ffffffc975f40000 task.ti: ffffffc975f40000 PC is at check_flags.part.35+0x17c/0x184 LR is at check_flags.part.35+0x17c/0x184 pc : [] lr : [] pstate: 600003c5 [...] ---[ end trace 74631f9305ef5020 ]--- Call trace: [] check_flags.part.35+0x17c/0x184 [] lock_acquire+0xa8/0xc4 [] breakpoint_handler+0x118/0x288 [] do_debug_exception+0x3c/0xa8 [] el1_dbg+0x18/0x6c [] do_filp_open+0x64/0xdc [] do_sys_open+0x140/0x204 [] SyS_openat+0x10/0x18 [] el0_svc_naked+0x24/0x28 possible reason: unannotated irqs-off. irq event stamp: 65857 hardirqs last enabled at (65857): [] lookup_mnt+0xf4/0x1b4 hardirqs last disabled at (65856): [] lookup_mnt+0xbc/0x1b4 softirqs last enabled at (65790): [] __do_softirq+0x1f8/0x290 softirqs last disabled at (65757): [] irq_exit+0x9c/0xd0 This patch adds the annotations to do_debug_exception(), while trying not to call trace_hardirqs_off() if el1_dbg() interrupted a task that already had irqs disabled. Signed-off-by: James Morse Signed-off-by: Will Deacon Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/fault.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -595,20 +595,33 @@ asmlinkage int __exception do_debug_exce { const struct fault_info *inf = debug_fault_info + DBG_ESR_EVT(esr); struct siginfo info; + int rv; - if (!inf->fn(addr, esr, regs)) - return 1; + /* + * Tell lockdep we disabled irqs in entry.S. Do nothing if they were + * already disabled to preserve the last enabled/disabled addresses. + */ + if (interrupts_enabled(regs)) + trace_hardirqs_off(); - pr_alert("Unhandled debug exception: %s (0x%08x) at 0x%016lx\n", - inf->name, esr, addr); + if (!inf->fn(addr, esr, regs)) { + rv = 1; + } else { + pr_alert("Unhandled debug exception: %s (0x%08x) at 0x%016lx\n", + inf->name, esr, addr); - info.si_signo = inf->sig; - info.si_errno = 0; - info.si_code = inf->code; - info.si_addr = (void __user *)addr; - arm64_notify_die("", regs, &info, 0); + info.si_signo = inf->sig; + info.si_errno = 0; + info.si_code = inf->code; + info.si_addr = (void __user *)addr; + arm64_notify_die("", regs, &info, 0); + rv = 0; + } - return 0; + if (interrupts_enabled(regs)) + trace_hardirqs_on(); + + return rv; } #ifdef CONFIG_ARM64_PAN