Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4833896ybv; Wed, 26 Feb 2020 03:55:50 -0800 (PST) X-Google-Smtp-Source: APXvYqzJJy0ITfkhEFhr7T2Oim/0SEOcFI4X3IrDK2EXMd/K/gIPYF5OQKBvTb1sg+Rm2etgPwg9 X-Received: by 2002:a05:6830:1f1c:: with SMTP id u28mr2852735otg.143.1582718150671; Wed, 26 Feb 2020 03:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582718150; cv=none; d=google.com; s=arc-20160816; b=uDZv5qbaZetxQ3hEMQMo5Al8Ysy0mlXx81JSFUVLSFsWlD56esIJet9SF+h9H1JqlQ 0ZxzBCv6UtomaklcV+F4cYofpIYOCkeuQ6CtzGc8ddEbua+JfUc32jJsy24ZZhP1JBXO qM13gFe2VPXlDmDm2BCZKUYrHs094jd6sBmQzvmwZ4ClP7SUrDWr3E5xWwi3vuSe/De/ ciBV7NUnXPalxNUnBCmyPD+xnl2XGvH6vICO93porzfvawVsPti/rDKO46ikUoEXdTd3 YAIXVrtAbwm8Y7EF6NfHJDefhB3qpNKDenjD2SdR1dQuJ33ETxNNgRJWWeIb8cxcxkgN 9zvw== 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=hZJ8DAtTC1Z2/C6P5EMPVp5wTV/U8ti8cfqvLkroIAM=; b=FNR5KwEHMJ2/PPvxR1MoA3MhppUFvwPA2NlsT4OMA+3FSda/l2Zxl76mHwkUuGIuAp tl1kTW0LkCq14axypyyv/TCAxNebvd3pcZNFmba208zXMlu35Z/pWV5taIyzJxMlR9j4 WdHaMrMtxUDoEoUiTtEf44GlNBzHKaZH49zOqDzysKbtEfBtHo2R+OgS6boXKZTQsJRI OF/0gBTW5lySrIpuG5Riv8101cTZYl/p8144XprbDpZe2iOPzssyEC1SddLF5jCeUiBX 0dvPzrsfPAc8AyzcQe1eW6wRw5Nu60XqI1HBcHKAwuuO+3r5FkI2STwpo/IXRPJHJZJo aPSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=LFwWfh6P; 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 m4si1150663otn.281.2020.02.26.03.55.38; Wed, 26 Feb 2020 03:55:50 -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=LFwWfh6P; 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 S1727084AbgBZLyO (ORCPT + 99 others); Wed, 26 Feb 2020 06:54:14 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:58178 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbgBZLyE (ORCPT ); Wed, 26 Feb 2020 06:54:04 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48SDjP0m8tz9txV9; Wed, 26 Feb 2020 12:54:01 +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=LFwWfh6P; 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 GCbZPTQw_oi2; Wed, 26 Feb 2020 12:54:01 +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 48SDjN6ldFz9txV6; Wed, 26 Feb 2020 12:54:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582718040; bh=hZJ8DAtTC1Z2/C6P5EMPVp5wTV/U8ti8cfqvLkroIAM=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=LFwWfh6PjRAUGUp/onB29AmkXsFwqQX2juvO59LrabKsos592BaibxXh+uOFvJfje o+bl+26WvCes25KxnXZ71CTbSN6ID5x8x/aBmmsMe23yIzML+ggLq3lDdNvn/H5K0l elg4va43fCCTN5L7VDZ0IsWMaTKPYZmwzvCIX1Kc= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 342F68B847; Wed, 26 Feb 2020 12:54:02 +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 7cnHcLgZXpo2; Wed, 26 Feb 2020 12:54:02 +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 E72228B776; Wed, 26 Feb 2020 12:54:01 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id BD0A565400; Wed, 26 Feb 2020 11:54:01 +0000 (UTC) Message-Id: <5a8ea6405d7cd6b6ca5854d56042416a62ede2cf.1582717645.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v3 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: Wed, 26 Feb 2020 11:54:01 +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 d566a8a13c80..0242b93e8c55 100644 --- a/arch/powerpc/kernel/ptrace/ptrace.c +++ b/arch/powerpc/kernel/ptrace/ptrace.c @@ -189,23 +189,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