Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp74443ybf; Thu, 27 Feb 2020 16:21:29 -0800 (PST) X-Google-Smtp-Source: APXvYqziZ9H9ni57muWBfaz5sUyrKIZYW9pGWPSyqFiP+Z4K0qsPThNCJiBRqw/WGyPhSQjfVhoB X-Received: by 2002:a05:6830:1047:: with SMTP id b7mr1262235otp.77.1582849289385; Thu, 27 Feb 2020 16:21:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582849289; cv=none; d=google.com; s=arc-20160816; b=tUHFdF8taMkxz5FCoZnBJxnhe4o425ibOEUbQom2Gr1vyLonVcHQzHuWGJ3g8qRYqW XUVJX0Ctgum2NJ1t9cqE9PI1+epgI4l/AZavbNE/vPwsy2m8jTjp+Qnr+2FuWgSVK8pw iAisVtdl/rQeUBzifl57aKaEZ7Pr5XbIVLHlH6lR2kdRZvB+Q+k51d/tWXHlJkWR8OyG e7t+ObFcMplkYLwLKDe3H3ZEnYqnkuXRCd6TpXjWR/f31e5+iIqAvVgtb8hPA34FTzCd GtlXY0BUAWqsL2bKB2at9h+j2D55awKZHM0ZzxvukvF0jSRR30OdL6QZ2nfCJG1mCvXZ DW9Q== 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:references :in-reply-to:message-id:dkim-signature; bh=6un/Hfrg4/12nUEnkUy8j1MRzkBjpG3z1Kv2lY/j4QQ=; b=MSz+519loGDvsFzq8eUCZJD65WOJwUvJ1LpkN3b+psiMYbYdjqt8MvQyCV3yaHDe6U RqVWYvqA3tWaLZp74OwO5wg80k8+phQXAFBX91kI8p06RF2IkgV5OLi/QDoPbB+L73y2 nVqStbvOZOj/5SW46TsfQRRXlR7kchJP5fRk5bNaI/D70n5L1CXuIQS+RKUPx3JAl3nM x6jBfondiCvWxmN2wYGERpGPud2eRjHlEQ5Fko3WY2KyGpqRJ7u83UmBgMfBIgW5ZiRR W4wKXcm8jclDF5fk+4z7Y+qIGa+u7zpRVJLegklJR5Z0Rka/YbDYF1dvesUdZ7UvYPvM JHiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b="Diy0bFR/"; 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 f190si839961oig.229.2020.02.27.16.21.17; Thu, 27 Feb 2020 16:21:29 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b="Diy0bFR/"; 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 S1730135AbgB1AUz (ORCPT + 99 others); Thu, 27 Feb 2020 19:20:55 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:44155 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730059AbgB1AUy (ORCPT ); Thu, 27 Feb 2020 19:20:54 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48T9Dh5FtCz9tyJw; Fri, 28 Feb 2020 01:20:52 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=Diy0bFR/; dkim-adsp=pass; dkim-atps=neutral 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 jK7mK9d4mc75; Fri, 28 Feb 2020 01:20:52 +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 48T9Dh3w2pz9tyJt; Fri, 28 Feb 2020 01:20:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582849252; bh=6un/Hfrg4/12nUEnkUy8j1MRzkBjpG3z1Kv2lY/j4QQ=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=Diy0bFR/LkQX8T/vucthw0xSiRSYGIE+RvNSCo11/m9ECF7RPLC3l7glbeFgLi2K/ BoiaScXfoNhE13z9me05pKQtfzHkHlPolyd45EBqMxQ/7Q4w3s5hg1Hpl8b/DDgBir FwauZEh1fmk+E/0YfNoYaoTt+hjC5ZZspnTH26xU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C22998B881; Fri, 28 Feb 2020 01:20:52 +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 gjAfM4m_rQhH; Fri, 28 Feb 2020 01:20:52 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0930A8B799; Fri, 28 Feb 2020 01:20:52 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id D96DD65417; Fri, 28 Feb 2020 00:14:47 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v5 11/13] powerpc/ptrace: create ptrace_get_debugreg() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , mikey@neuling.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 28 Feb 2020 00:14:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create ptrace_get_debugreg() to handle PTRACE_GET_DEBUGREG and reduce ifdef mess Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/ptrace/ptrace-adv.c | 9 +++++++++ arch/powerpc/kernel/ptrace/ptrace-decl.h | 2 ++ arch/powerpc/kernel/ptrace/ptrace-noadv.c | 13 +++++++++++++ arch/powerpc/kernel/ptrace/ptrace.c | 18 ++---------------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/kernel/ptrace/ptrace-adv.c b/arch/powerpc/kernel/ptrace/ptrace-adv.c index eebcd41edc3d..c71bedd54a8b 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-adv.c +++ b/arch/powerpc/kernel/ptrace/ptrace-adv.c @@ -56,6 +56,15 @@ void user_disable_single_step(struct task_struct *task) clear_tsk_thread_flag(task, TIF_SINGLESTEP); } +int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, + unsigned long __user *datalp) +{ + /* We only support one DABR and no IABRS at the moment */ + if (addr > 0) + return -EINVAL; + return put_user(child->thread.debug.dac1, datalp); +} + int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data) { #ifdef CONFIG_HAVE_HW_BREAKPOINT diff --git a/arch/powerpc/kernel/ptrace/ptrace-decl.h b/arch/powerpc/kernel/ptrace/ptrace-decl.h index bdba09a87aea..4b4b6a1d508a 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-decl.h +++ b/arch/powerpc/kernel/ptrace/ptrace-decl.h @@ -176,6 +176,8 @@ int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset, extern const struct user_regset_view user_ppc_native_view; /* ptrace-(no)adv */ +int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, + unsigned long __user *datalp); int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data); long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info); long ppc_del_hwdebug(struct task_struct *child, long data); diff --git a/arch/powerpc/kernel/ptrace/ptrace-noadv.c b/arch/powerpc/kernel/ptrace/ptrace-noadv.c index cf05fadba0d5..9c1ef9c2ffd4 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-noadv.c +++ b/arch/powerpc/kernel/ptrace/ptrace-noadv.c @@ -39,6 +39,19 @@ void user_disable_single_step(struct task_struct *task) clear_tsk_thread_flag(task, TIF_SINGLESTEP); } +int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, + unsigned long __user *datalp) +{ + unsigned long dabr_fake; + + /* We only support one DABR and no IABRS at the moment */ + if (addr > 0) + return -EINVAL; + dabr_fake = ((child->thread.hw_brk.address & (~HW_BRK_TYPE_DABR)) | + (child->thread.hw_brk.type & HW_BRK_TYPE_DABR)); + return put_user(dabr_fake, datalp); +} + int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data) { #ifdef CONFIG_HAVE_HW_BREAKPOINT diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptrace/ptrace.c index 48e095e88a2f..d6e1a301d20e 100644 --- a/arch/powerpc/kernel/ptrace/ptrace.c +++ b/arch/powerpc/kernel/ptrace/ptrace.c @@ -191,23 +191,9 @@ long arch_ptrace(struct task_struct *child, long request, break; } - case PTRACE_GET_DEBUGREG: { -#ifndef CONFIG_PPC_ADV_DEBUG_REGS - unsigned long dabr_fake; -#endif - ret = -EINVAL; - /* We only support one DABR and no IABRS at the moment */ - if (addr > 0) - break; -#ifdef CONFIG_PPC_ADV_DEBUG_REGS - ret = put_user(child->thread.debug.dac1, datalp); -#else - dabr_fake = ((child->thread.hw_brk.address & (~HW_BRK_TYPE_DABR)) | - (child->thread.hw_brk.type & HW_BRK_TYPE_DABR)); - ret = put_user(dabr_fake, datalp); -#endif + case PTRACE_GET_DEBUGREG: + ret = ptrace_get_debugreg(child, addr, datalp); break; - } case PTRACE_SET_DEBUGREG: ret = ptrace_set_debugreg(child, addr, data); -- 2.25.0