From patchwork Fri Mar 22 15:44:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160925 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp961672jan; Fri, 22 Mar 2019 08:47:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGtGuIFBD/ZupTmP4YfyMFMIVQZainkw1hLzOAf44OKFnthIZnl2VIplDbKE1zB78uLBAo X-Received: by 2002:a62:560f:: with SMTP id k15mr9803680pfb.231.1553269648288; Fri, 22 Mar 2019 08:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269648; cv=none; d=google.com; s=arc-20160816; b=Anl/OTFuVogLiNecubZ2rXgklAlnl1u07re94vphQCky26EFDq2LUJAI/8AzborHrn EH0lbVBBKJShTGfyliL6ovjhc4YUbvZRuOZ4WBX7FVirkNJ8s4y/LEuzUzdt9XGgNl95 cZ7G36hknR8+66QwZR0qRxNsxqqxleR69J9N8g5EcAy0mTvPmjnICfbTHBVajJhqu+Fj R7sa8yDdiQGNrtNtoWVJoPiwSN9umxux8RIKu5xSbPJ4UtECWNrLBLwoQMutUlAfbvWg nhJZfenV32UzMNg8g8kUON0OJt5LNpr943rE4rczTRYFtLaXOZaQeYWNAD9Tj75BumT2 yd+A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jMF7FGNLq2yAuE1q5n39N1+YXXZh5YtTev4LFokQmgs=; b=kM/0OHXOixC4OV/gPoqvpZpgotM9yTVBMQP1T5rKktZDaF/z0GpHlFYj08+yt6mcfR 1JtdCcZpEqA2J+trs3NWlYgJwFnoaD+syy6eAmyI3PKDaK+pxEwIEIwDVfjAJ01pW9at mZbiwxMMqf2k1CeGiCInxMumeV31d83gb/y2qKszKsteaQmH8aTsENM0P/j8oWfmH/+E FU1mW29sA2GLxQFzyh06f+QLgCbDInrc84ulTiLX6nU92X/iywTwODm2nJcKBsCIX5gu ZM5xje4RGGAFIlbxNBlgB5OuGK1SZ9vuMz+XtrFHbdAmHpDJNrm9PF7pJmVZgc3F7yab XhCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 y4si6963548pfy.157.2019.03.22.08.47.28; Fri, 22 Mar 2019 08:47:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727516AbfCVPr1 (ORCPT + 14 others); Fri, 22 Mar 2019 11:47:27 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:50135 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727438AbfCVPr1 (ORCPT ); Fri, 22 Mar 2019 11:47:27 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1Mz9hF-1glrBT0Dlz-00wEbJ; Fri, 22 Mar 2019 16:46:56 +0100 From: Arnd Bergmann To: stable@vger.kernel.org, Catalin Marinas , Will Deacon , "Eric W. Biederman" , Mark Rutland , "Rafael J. Wysocki" , Anshuman Khandual , James Morse , Peter Maydell , Andrey Konovalov Cc: Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.4.y 10/25] arm64: mm: Add trace_irqflags annotations to do_debug_exception() Date: Fri, 22 Mar 2019 16:44:01 +0100 Message-Id: <20190322154425.3852517-11-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de> References: <20190322154425.3852517-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZFpF8CAe8AmBwG8PGJWPFop0PRfjbeBIlad56HwVq67hsFHJ0tt /vTMl2X1z7FjJcfBD0yN8KM2IpfFg+j50kqftvc8+oe9L9ijCZIB96BSaGpzYkwAB3tKm5x QsQSsWeUgJ4gewKBKXcbAFOG+noCIE8Jlpu1KFR853UTVguO/qJWsuPHpuFMH4tfXZccPsR OKODfg19h+O9i3y9U71xQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:vhym0IdyrDA=:IagoDTjJ/AZm8MOUQihw/h lfjIfsiKuAjcr0YkJUa3nKwnT87irDoj13onxU3W5TDW0hf4b9zn9hX/tbM+y3Kd3QZY9nW4P ENXHg/s6eOeXdL/57nJ3gRv4nWemwtl58VGfkAJ/9GQRdeb4RZO3oaMPLSBP6XDcsIdZ+Idp4 jXvlvemWe6/NVlMZMALxF3//wuKh9mj0yT0WuAeKNOJ0BYycfiAxtLPnnJr8rJnw58QvCZ0ZF MK26TbIvudgq7V25j37GDFSAUKSfLEhsaFJEPlHPH0eO+OeycXf2dsU4DhLSVSXw59ibyHzwU SEni14uvrS8VhclQLU6h69oKllWXhaY2F+GpDcxxdxPb+KglXhXgMOFZO/IrrjUlZPzx0nDud cf6sj3qJA69QviQTQgygrApzKDiROW/IS1pABbOvyJoMLmyfP4b7ykMmYlWnorrgqwdh0+KSH OU3zPAxbKIWvkr2g+XuRnAa9d9lC005SfdyTJjBwS2PuBjfWJpNBRgISiNe82vigjFLRYl0gP m736lhhI/A7M2uTQBr/PhBhc+UsBteTXBV5ZG+7u/fx7jIRqNVOChl+BElMvlbSrgkbbVKIGq y86Da3naDGq/+sZryHTJZ143Z1/7CHhrrG7g00LrJ7pJoIu7jiyjVVUPIdQVv5LEgAW6HE20B Bjs4+SlMn0PTY8zvXnTC7v+YAPGsRnOWEKL1Y0kMjEc/X2G1vOMH91h1y3J+fc2lVvvHsiFT9 ccvN6lPlR10SMbWu8ROHz45cwbajO7eTSOlrjw== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: James Morse 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 (cherry picked from commit 6afedcd23cfd7ac56c011069e4a8db37b46e4623) Signed-off-by: Arnd Bergmann --- arch/arm64/mm/fault.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) -- 2.20.0 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index be7f8416809f..04c4b88706d8 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -595,20 +595,33 @@ asmlinkage int __exception do_debug_exception(unsigned long addr, { 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); + rv = 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); + if (interrupts_enabled(regs)) + trace_hardirqs_on(); - return 0; + return rv; } #ifdef CONFIG_ARM64_PAN