From patchwork Tue Aug 2 05:30:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9255175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B20B6077C for ; Tue, 2 Aug 2016 05:33:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89D8728501 for ; Tue, 2 Aug 2016 05:33:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D2CE28504; Tue, 2 Aug 2016 05:33:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0EBA728501 for ; Tue, 2 Aug 2016 05:33:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUSJi-0007El-FP; Tue, 02 Aug 2016 05:32:38 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUSJ9-0006i8-Se for linux-arm-kernel@lists.infradead.org; Tue, 02 Aug 2016 05:32:05 +0000 Received: by mail-pa0-f44.google.com with SMTP id iw10so59672722pac.2 for ; Mon, 01 Aug 2016 22:31:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Dks0kJ8tGOuSRSZiOJTxitpK5rb0rWlwt0PpxZQnNfw=; b=ZRycwPyJUEEDW/JbScLUtCVc8aFUf8Awq8rgYmNmtNmMMD4UI1EzvzsLMupvWLZajm mXAkRwDZshRT9JoxHMY/iXL9muxwUg+Us5J4Ri+Ax9FBwRCV1+Gxas6wSfYrUKJT1VIY nDpkBOcbwecokCkNH4I/FKeiW0qaTDui/RgiERRwATmUUapXVv3qyjruWsb9E+jn+tux b04rNFTXthffdXlKfdXwd0b6yROC+D4EwGEIX92X7xG6OuL27gySH+LwxyhsQhoWCCOZ DI5hNAVxZrD64wVFpuZGu+PRN1ndbZMnlHvP7jfFMkxYQvnfpMKwG5Y5kVw2ef4AlYuE JGlA== X-Gm-Message-State: AEkooutmcc2lE3Pc80q5+uAZws1IfO5Z/s4nVdRt7K2hS60ieGlXjNbjW0VPSoTj8CzpDXG0 X-Received: by 10.66.8.163 with SMTP id s3mr3326167paa.142.1470115903162; Mon, 01 Aug 2016 22:31:43 -0700 (PDT) Received: from localhost ([122.180.189.31]) by smtp.gmail.com with ESMTPSA id g5sm1212476pfg.0.2016.08.01.22.31.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Aug 2016 22:31:42 -0700 (PDT) From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH 4/5] arm64: Handle TRAP_BRKPT for user mode as well Date: Tue, 2 Aug 2016 11:00:08 +0530 Message-Id: <9737ec351e2f9f2e7472d8d7133568f7915f20aa.1470114993.git.panand@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160801_223204_148373_36B2BB17 X-CRM114-Status: GOOD ( 12.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pratyush Anand , Yang Shi , steve.capper@linaro.org, srikar@linux.vnet.ibm.com, Suzuki K Poulose , vijaya.kumar@caviumnetworks.com, linux-kernel@vger.kernel.org, oleg@redhat.com, dave.long@linaro.org, Sandeepa Prabhu , wcohen@redhat.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP uprobe is registered at break_hook with a unique ESR code. So, when a TRAP_BRKPT occurs, call_break_hook checks if it was for uprobe. If not, then send a SIGTRAP to user. Signed-off-by: Pratyush Anand --- arch/arm64/kernel/debug-monitors.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index fae2f57a92b7..466d199498b5 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -326,16 +326,20 @@ NOKPROBE_SYMBOL(call_break_hook); static int brk_handler(unsigned long addr, unsigned int esr, struct pt_regs *regs) { - if (user_mode(regs)) { - send_user_sigtrap(TRAP_BRKPT); - } + bool handler_found = false; + #ifdef CONFIG_KPROBES - else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) { - if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED) - return -EFAULT; + if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) { + if (kprobe_breakpoint_handler(regs, esr) == DBG_HOOK_HANDLED) + handler_found = true; } #endif - else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) { + if (!handler_found && call_break_hook(regs, esr) == DBG_HOOK_HANDLED) + handler_found = true; + + if (!handler_found && user_mode(regs)) { + send_user_sigtrap(TRAP_BRKPT); + } else if (!handler_found) { pr_warn("Unexpected kernel BRK exception at EL1\n"); return -EFAULT; }