Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4832934ybv; Wed, 26 Feb 2020 03:54:48 -0800 (PST) X-Google-Smtp-Source: APXvYqz0goqiudbQbwFLcLGC3KLXN9LnO/1dhqnj1pIwDvYVmhpFiVoJSYFa1f+i0Zu6cCV47gsZ X-Received: by 2002:a05:6830:1198:: with SMTP id u24mr2560532otq.215.1582718088308; Wed, 26 Feb 2020 03:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582718088; cv=none; d=google.com; s=arc-20160816; b=QcTg6I/EYyYTGjaUx1V2HMBi/dD50j1hd75IJGB0v8sBbWL1tZMFjH+kHLv5UKojBv RPOk53vuLbtjGl/ygUeuC/subMhkWmBhldhwSiC9OlSYAliBtR3HygIU7k8A16wdYiLJ 4BNy/IXgZPCO4/zhai7nIcmbZ9Z0jgQLuhODoJQXW3aHzRTcea1fL156VE5yyllX62X0 /yuz8ItxWlYpgu+mj/sjc5eQ3z8OEHTS61dKR6IoOsWtw450EoXpvgRp47gI0/QJo8Vv c6MW6Nlu+IBzjTALubwntb9wmuyn/J7O9Tm8JTKFLhKNTd8Nj5RbwiFHyzmrhRbg1vMz YSoQ== 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=bGce2AiLLFTdMZORBbVqJu0eX7cRWI7cYv+4NoEik2Q=; b=MEXAg/qD7Y1tMLuK4sdmauqet3trhQOeZJRT4B6sdGcwLMdE+BXPIqAPpnmyM1I/Ro i9EQgod84cmrqW+CRf4Z0S0slREZvMmQCmDgv3EytWSFEnLwqX3dwmcV1QLza2toHjup EH/3tXXF1rG90jMURpeDhBcAz+vpSvwYK0GvUKSEWyd/iO/zPhSOv72stVAEyn1r3uwY ZZGdCQw4IRJPUf1K2/WNKi7LZaHYIJKy0+tbJUonzq3Xmn/S/R3+fz8NzAGgIl1bC8xz GwsZeQd8AoTBGXhOIjy7tpwkuwTqVhIVxhsFHZI1mHGVP9RX3qHHqmDRxD/Apwb0CT7T lUFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=a31XRN5y; 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 h18si1032270otj.114.2020.02.26.03.54.36; Wed, 26 Feb 2020 03:54:48 -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=a31XRN5y; 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 S1727103AbgBZLyQ (ORCPT + 99 others); Wed, 26 Feb 2020 06:54:16 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:6797 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbgBZLyF (ORCPT ); Wed, 26 Feb 2020 06:54:05 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48SDjQ0VsQz9txVB; Wed, 26 Feb 2020 12:54:02 +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=a31XRN5y; 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 U0-8BMQDVXha; Wed, 26 Feb 2020 12:54:02 +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 48SDjP6cNDz9txV6; Wed, 26 Feb 2020 12:54:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582718041; bh=bGce2AiLLFTdMZORBbVqJu0eX7cRWI7cYv+4NoEik2Q=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=a31XRN5ycQ9IcvIRAkTrXLAOQfwDjYvFebdrFT4zjoT7qLGnCauKihEcIl+H8iRyv DHVaOlqdOtJTglIc6XTi92KJ8axjksxoxz90JXXIfnjskd+IzNmPqiA0Ph0y1nAFQW 3uGUFljtDirwv9EUtr8gcfhUo5s786ue1wOLcUDE= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 334628B846; Wed, 26 Feb 2020 12:54:03 +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 17Ofx6SMVyLa; Wed, 26 Feb 2020 12:54:03 +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 F01828B776; Wed, 26 Feb 2020 12:54:02 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id C7E2D65400; Wed, 26 Feb 2020 11:54:02 +0000 (UTC) Message-Id: <14bfeb22402a324826c79422931c34617173c885.1582717645.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v3 12/13] powerpc/ptrace: create ppc_gethwdinfo() 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:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create ippc_gethwdinfo() to handle PPC_PTRACE_GETHWDBGINFO and reduce ifdef mess Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/ptrace/ptrace-adv.c | 15 +++++++++++ arch/powerpc/kernel/ptrace/ptrace-decl.h | 1 + arch/powerpc/kernel/ptrace/ptrace-noadv.c | 20 ++++++++++++++ arch/powerpc/kernel/ptrace/ptrace.c | 32 +---------------------- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/kernel/ptrace/ptrace-adv.c b/arch/powerpc/kernel/ptrace/ptrace-adv.c index c71bedd54a8b..3990c01ef8cf 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-adv.c +++ b/arch/powerpc/kernel/ptrace/ptrace-adv.c @@ -56,6 +56,21 @@ void user_disable_single_step(struct task_struct *task) clear_tsk_thread_flag(task, TIF_SINGLESTEP); } +void ppc_gethwdinfo(struct ppc_debug_info *dbginfo) +{ + dbginfo->version = 1; + dbginfo->num_instruction_bps = CONFIG_PPC_ADV_DEBUG_IACS; + dbginfo->num_data_bps = CONFIG_PPC_ADV_DEBUG_DACS; + dbginfo->num_condition_regs = CONFIG_PPC_ADV_DEBUG_DVCS; + dbginfo->data_bp_alignment = 4; + dbginfo->sizeof_condition = 4; + dbginfo->features = PPC_DEBUG_FEATURE_INSN_BP_RANGE | + PPC_DEBUG_FEATURE_INSN_BP_MASK; + if (IS_ENABLED(CONFIG_PPC_ADV_DEBUG_DAC_RANGE)) + dbginfo->features |= PPC_DEBUG_FEATURE_DATA_BP_RANGE | + PPC_DEBUG_FEATURE_DATA_BP_MASK; +} + int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, unsigned long __user *datalp) { diff --git a/arch/powerpc/kernel/ptrace/ptrace-decl.h b/arch/powerpc/kernel/ptrace/ptrace-decl.h index 4b4b6a1d508a..3c8a81999292 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-decl.h +++ b/arch/powerpc/kernel/ptrace/ptrace-decl.h @@ -176,6 +176,7 @@ 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 */ +void ppc_gethwdinfo(struct ppc_debug_info *dbginfo); 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); diff --git a/arch/powerpc/kernel/ptrace/ptrace-noadv.c b/arch/powerpc/kernel/ptrace/ptrace-noadv.c index 9c1ef9c2ffd4..8a616d87fffb 100644 --- a/arch/powerpc/kernel/ptrace/ptrace-noadv.c +++ b/arch/powerpc/kernel/ptrace/ptrace-noadv.c @@ -39,6 +39,26 @@ void user_disable_single_step(struct task_struct *task) clear_tsk_thread_flag(task, TIF_SINGLESTEP); } +void ppc_gethwdinfo(struct ppc_debug_info *dbginfo) +{ + dbginfo->version = 1; + dbginfo->num_instruction_bps = 0; + if (ppc_breakpoint_available()) + dbginfo->num_data_bps = 1; + else + dbginfo->num_data_bps = 0; + dbginfo->num_condition_regs = 0; + dbginfo->data_bp_alignment = sizeof(long); + dbginfo->sizeof_condition = 0; + if (IS_ENABLED(CONFIG_HAVE_HW_BREAKPOINT)) { + dbginfo->features = PPC_DEBUG_FEATURE_DATA_BP_RANGE; + if (dawr_enabled()) + dbginfo->features |= PPC_DEBUG_FEATURE_DATA_BP_DAWR; + } else { + dbginfo->features = 0; + } +} + int ptrace_get_debugreg(struct task_struct *child, unsigned long addr, unsigned long __user *datalp) { diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptrace/ptrace.c index 0242b93e8c55..269749e2756c 100644 --- a/arch/powerpc/kernel/ptrace/ptrace.c +++ b/arch/powerpc/kernel/ptrace/ptrace.c @@ -137,37 +137,7 @@ long arch_ptrace(struct task_struct *child, long request, case PPC_PTRACE_GETHWDBGINFO: { struct ppc_debug_info dbginfo; - dbginfo.version = 1; -#ifdef CONFIG_PPC_ADV_DEBUG_REGS - dbginfo.num_instruction_bps = CONFIG_PPC_ADV_DEBUG_IACS; - dbginfo.num_data_bps = CONFIG_PPC_ADV_DEBUG_DACS; - dbginfo.num_condition_regs = CONFIG_PPC_ADV_DEBUG_DVCS; - dbginfo.data_bp_alignment = 4; - dbginfo.sizeof_condition = 4; - dbginfo.features = PPC_DEBUG_FEATURE_INSN_BP_RANGE | - PPC_DEBUG_FEATURE_INSN_BP_MASK; -#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE - dbginfo.features |= - PPC_DEBUG_FEATURE_DATA_BP_RANGE | - PPC_DEBUG_FEATURE_DATA_BP_MASK; -#endif -#else /* !CONFIG_PPC_ADV_DEBUG_REGS */ - dbginfo.num_instruction_bps = 0; - if (ppc_breakpoint_available()) - dbginfo.num_data_bps = 1; - else - dbginfo.num_data_bps = 0; - dbginfo.num_condition_regs = 0; - dbginfo.data_bp_alignment = sizeof(long); - dbginfo.sizeof_condition = 0; -#ifdef CONFIG_HAVE_HW_BREAKPOINT - dbginfo.features = PPC_DEBUG_FEATURE_DATA_BP_RANGE; - if (dawr_enabled()) - dbginfo.features |= PPC_DEBUG_FEATURE_DATA_BP_DAWR; -#else - dbginfo.features = 0; -#endif /* CONFIG_HAVE_HW_BREAKPOINT */ -#endif /* CONFIG_PPC_ADV_DEBUG_REGS */ + ppc_gethwdinfo(&dbginfo); if (copy_to_user(datavp, &dbginfo, sizeof(struct ppc_debug_info))) -- 2.25.0