Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1028222ybf; Thu, 27 Feb 2020 03:50:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxWzYO+oBQqc1AK/nIXWfCprDqb4TLybO/AhM9FXqXQ7hbEe9ya0zcIsvdd8YFHbbF2Yae/ X-Received: by 2002:a9d:7559:: with SMTP id b25mr2870393otl.189.1582804240647; Thu, 27 Feb 2020 03:50:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582804240; cv=none; d=google.com; s=arc-20160816; b=tZNMAE+mSKWKPGxLM+TeoeGqINnM1kxSsk6Bn7X99MeTXfI/BJPizLBR+qsjpsJ/5h qOgXRmMLzpfBgopoc7VybBYlaoiwnylEKGVeBd7Z4tYskBSaS8up31vrqUcuN2OaQvNO vx81+4nm/f+1TgWyQWe+iItvfTTHyljYKDr+mT814kBVG5bv5bjAbqCeWwtE+0gnONEC gpXDnFowR7nkK7EfRmavOgt/p+zHFrHLCa0JPVVemaD2QXCHtJlS48g1pbU0E5f6rywi dD3s80sCRKpLNc6bxPQSrmiWSn88s8zgaSdcj90Lew3CFo1qoVPs+uzqQNQG9oBIJ7sw wKrQ== 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=rEjc6QymoDrSI4n5SY+4nnoseNOy07oFi5gv30QsdUfMoDc2RCTDodCW5s+DZ8W8dl daiU4rLH7gCOvFZmfd0Vt5FQtePPhaagwHC5G7PY7aIKNaPcAZBY6o8wEqjibA3fi63O Q7lc6WdmrXDDH240bwPjUG10D0PTqQDB0RVfIQSK7Pb6uIp/wGMrtG96Onk1LkNuDng3 tP2cB2S9GWqoFc35ezX4SDOoZQVkcUUIJg1YBjH3teAGgzY1YK6msbp+vR3dsZsy83vy 0IH1buQfAxipaNIYNAkikA40x9NBANjo6mkoUp2fw0Qv5nbA7tbbDhWmdV9ESm02qymJ Revg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=jlrPGr2P; 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 h3si1323436otq.203.2020.02.27.03.50.28; Thu, 27 Feb 2020 03:50:40 -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=jlrPGr2P; 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 S1729051AbgB0LtM (ORCPT + 99 others); Thu, 27 Feb 2020 06:49:12 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:34710 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729028AbgB0LtK (ORCPT ); Thu, 27 Feb 2020 06:49:10 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48SrYH3nDXz9tyhn; Thu, 27 Feb 2020 12:49:07 +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=jlrPGr2P; 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 B3cR2YTl9hqr; Thu, 27 Feb 2020 12:49:07 +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 48SrYH2myDz9tyhM; Thu, 27 Feb 2020 12:49:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582804147; bh=6un/Hfrg4/12nUEnkUy8j1MRzkBjpG3z1Kv2lY/j4QQ=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=jlrPGr2PK6lQ//KFU/09ft4fYoCyNAJSABKstr2EBeiC5X8mljz71Vh1j+VXgYwO6 x60sKOGpIcQDnfv3uxmL2ygzDvgZPLlWDAM//4/DiOJOk9XUeCmBSS/MirGHp1rAYh YglYvd4SpblVsKENRQyBFx476/ixkmqohtDcb4uM= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 922D88B872; Thu, 27 Feb 2020 12:49:08 +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 uLLQqnlUdYDv; Thu, 27 Feb 2020 12:49:08 +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 44C9F8B799; Thu, 27 Feb 2020 12:49:08 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 13A5465402; Thu, 27 Feb 2020 11:49:08 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v4 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: Thu, 27 Feb 2020 11:49:08 +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