Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1027702ybf; Thu, 27 Feb 2020 03:50:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwYfG605Row/XAmOXhLS8HxRsR+KPSbVz8eEjHg96uGMfmd+sIxGTWHDanlokuf5Mrr4lU4 X-Received: by 2002:aca:5303:: with SMTP id h3mr2824455oib.109.1582804207750; Thu, 27 Feb 2020 03:50:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582804207; cv=none; d=google.com; s=arc-20160816; b=fqo/uJtr8Lk5865Au6Wwbq0yRaj9g5xLPoe4buKoY6cHPgUSR3PuztE+0WmNtUSwz1 xuhEs/vwIw4Gngic0qTSFNVbERvL/W70665nlX+Z7WqEZBIdSkI11KTwCol/9UOLKJmV jimngA5pCR49X2CF7g17L4ZDGrCGK+ZtMU3GbH5Wp/SmD0KVNOkQkPNNaWRgf2NvdVwk /OyX9Lb6QHCU8H1XiBurcnDLb9/dE8CtE66Ff0gc2J0QnVKbtirHVab2Knq7SCJN8RlK NFyVyMoOdZXN9pXgz+nx5LECsXCFayoppItIdSRVo/Mx9qoOJVS+nM9Lg5+x3gpngenc stPQ== 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=+qjclCTypUSk8rUN8fryWx8rZBtGiqAJ4Vg5qmlZkUQ=; b=rRZwUyL1K+PGYwAIKAOGmBVUd+jQP7zCT43Y4ZT6kXl5C+kfxIWcEbn1mc7uT+4VRB Pm5jSvAScWKFUg277XNcPbNP6rrj9moLGI/xhp5V2Ig5mvizFYoLQMUN5bf8nZQf72k/ LxEZvV8sWWsiSlb1K4RSc1eVF81fIaeAuieyed8MWD26n74PnvVm4K9MPtGvfB5AYTRY RV0k1o8jWmv87BjuHgKzuI4K8JRtXTC38momju4zcyoDWHdB++4PHoIJiMU9/NbnKama L4/3kfWuIdyUexLIR76m0K48qNKNnDfx6WCG8sLCQtleFKTQnax8kmk4J1LF3Z/sQixc fUcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=klMgwkpu; 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 n186si1134731oig.191.2020.02.27.03.49.55; Thu, 27 Feb 2020 03:50:07 -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=klMgwkpu; 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 S1729093AbgB0LtW (ORCPT + 99 others); Thu, 27 Feb 2020 06:49:22 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:51539 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729042AbgB0LtL (ORCPT ); Thu, 27 Feb 2020 06:49:11 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48SrYJ3qQYz9tyhx; Thu, 27 Feb 2020 12:49:08 +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=klMgwkpu; 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 RHlZ6xokiZLT; Thu, 27 Feb 2020 12:49:08 +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 48SrYJ2nl9z9tyhM; Thu, 27 Feb 2020 12:49:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582804148; bh=+qjclCTypUSk8rUN8fryWx8rZBtGiqAJ4Vg5qmlZkUQ=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=klMgwkpugnSbAPuCNVRiswTWt7vaB0A5wtwf42k6h+h08ea2kY79YEU3XzepsGgaQ GLvKSdGhR7NtF8n1Tdn/Wub/lXCM6Uzbt7fgMi+Vv1tBieJ5dhjlDh0o3ZPPtxCDHk kYoD6DqTriNK3J1RtKMMnBExdxBgt5PWyy8Kzh9I= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A09408B872; Thu, 27 Feb 2020 12:49:09 +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 fIviKnrjjkZM; Thu, 27 Feb 2020 12:49:09 +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 629738B799; Thu, 27 Feb 2020 12:49:09 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 32F1665402; Thu, 27 Feb 2020 11:49:09 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v4 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: Thu, 27 Feb 2020 11:49:09 +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 d6e1a301d20e..a44f6e5e05ff 100644 --- a/arch/powerpc/kernel/ptrace/ptrace.c +++ b/arch/powerpc/kernel/ptrace/ptrace.c @@ -139,37 +139,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