Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2763060pxa; Tue, 25 Aug 2020 02:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza8GeChXYCi/TCQiJtgOdObbuHmtD2GWoRyTjmA5To83SPbuIDWJiK6R/U2gvuL8AUY2sw X-Received: by 2002:aa7:d6d6:: with SMTP id x22mr9736018edr.282.1598347934827; Tue, 25 Aug 2020 02:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598347934; cv=none; d=google.com; s=arc-20160816; b=GEkQHX6L5z6VHRNoXJW26H+OCOVtKgX/hApCuCs0W5aQS04bl8E1kIMqyimhNqLLNz FdaPPxd0Q4qOOFGeCtwLv/QdSKUkk+34noHCD4X/hSCk7xDe87o61V6kTqkEF3zQBOaL Yv3WMQ+Z08UkMVEFe4lpgEqTwKcfU/Udrj1WfIQ8nldlhdvz92DbU+Lswsj/FadXYBYR IVeoVm5szNJDl92sni1Gf1nF0D6q+2bdzFfVmwxCMfJ/6KTO1WwLTLp5f5IywKSkbTMt Y2w1lfklmBG7iraDL9+qcPdc8G+IHK29nfZjM30K73qWdzc0//mVuHDkq3qGWkQkNLhp ZWKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=YxoOaLHIqQ7ZRq/Qt0vcqFYrfw2D68EMEjd0l4Bg/Gw=; b=MjC8IusDNhs5YVUojNueUXa6rU15iBGPTzhQbBWbREo9SpmVHa1EnP0XLb4sjgkQYy gmL+ilAWXi3+qNiOsuwrwtN8F+wyDHJZ7vil6hBSgivB1n9cN67uZOhK5z3aLIm//RQd MLbGEiBfmRaC2veRq7hqREiVskHUO12U7D6gMXiM1ar/BJRMTVWLsIrnvdK0uYx4Ruoh 6ZZiASjPuBZ6pABukQmqoK3m9iItYpXb32ffR6S+eUj7o2BxzSKe1Ol0Krj699KChL23 ae87QtyxkuP2amZWRo66e/sR0pbF0HBpg21F/reEu0LsJwtNavlGXrMCJdW8FAvB7IZx AypQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si8546030ejd.721.2020.08.25.02.31.50; Tue, 25 Aug 2020 02:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729201AbgHYJaX (ORCPT + 99 others); Tue, 25 Aug 2020 05:30:23 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:8883 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728543AbgHYJaW (ORCPT ); Tue, 25 Aug 2020 05:30:22 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4BbNy20M3jz9txvL; Tue, 25 Aug 2020 11:30:18 +0200 (CEST) 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 DLp4VNLfgl2e; Tue, 25 Aug 2020 11:30:17 +0200 (CEST) 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 4BbNy16dWVz9txvH; Tue, 25 Aug 2020 11:30:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id F0C178B806; Tue, 25 Aug 2020 11:30:18 +0200 (CEST) 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 emBSym7Dg09c; Tue, 25 Aug 2020 11:30:18 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DDDB68B803; Tue, 25 Aug 2020 11:30:17 +0200 (CEST) Subject: Re: [PATCH v5 4/8] powerpc/watchpoint: Move DAWR detection logic outside of hw_breakpoint.c To: Ravi Bangoria , mpe@ellerman.id.au, christophe.leroy@c-s.fr Cc: mikey@neuling.org, paulus@samba.org, naveen.n.rao@linux.vnet.ibm.com, pedromfc@linux.ibm.com, rogealve@linux.ibm.com, jniethe5@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20200825043617.1073634-1-ravi.bangoria@linux.ibm.com> <20200825043617.1073634-5-ravi.bangoria@linux.ibm.com> From: Christophe Leroy Message-ID: <0a73280b-c231-a7bb-18d9-abf2a37ba24b@csgroup.eu> Date: Tue, 25 Aug 2020 11:30:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200825043617.1073634-5-ravi.bangoria@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 25/08/2020 à 06:36, Ravi Bangoria a écrit : > Power10 hw has multiple DAWRs but hw doesn't tell which DAWR caused > the exception. So we have a sw logic to detect that in hw_breakpoint.c. > But hw_breakpoint.c gets compiled only with CONFIG_HAVE_HW_BREAKPOINT=Y. > Move DAWR detection logic outside of hw_breakpoint.c so that it can be > reused when CONFIG_HAVE_HW_BREAKPOINT is not set. > > Signed-off-by: Ravi Bangoria > --- > arch/powerpc/include/asm/hw_breakpoint.h | 8 + > arch/powerpc/kernel/Makefile | 3 +- > arch/powerpc/kernel/hw_breakpoint.c | 159 +---------------- > .../kernel/hw_breakpoint_constraints.c | 162 ++++++++++++++++++ > 4 files changed, 174 insertions(+), 158 deletions(-) > create mode 100644 arch/powerpc/kernel/hw_breakpoint_constraints.c > [...] > diff --git a/arch/powerpc/kernel/hw_breakpoint_constraints.c b/arch/powerpc/kernel/hw_breakpoint_constraints.c > new file mode 100644 > index 000000000000..867ee4aa026a > --- /dev/null > +++ b/arch/powerpc/kernel/hw_breakpoint_constraints.c > @@ -0,0 +1,162 @@ [...] > + > +static int cache_op_size(void) > +{ > +#ifdef __powerpc64__ > + return ppc64_caches.l1d.block_size; > +#else > + return L1_CACHE_BYTES; > +#endif > +} You've got l1_dcache_bytes() in arch/powerpc/include/asm/cache.h to do that. > + > +void wp_get_instr_detail(struct pt_regs *regs, struct ppc_inst *instr, > + int *type, int *size, unsigned long *ea) > +{ > + struct instruction_op op; > + > + if (__get_user_instr_inatomic(*instr, (void __user *)regs->nip)) > + return; > + > + analyse_instr(&op, regs, *instr); > + *type = GETTYPE(op.type); > + *ea = op.ea; > +#ifdef __powerpc64__ > + if (!(regs->msr & MSR_64BIT)) > + *ea &= 0xffffffffUL; > +#endif This #ifdef is unneeded, it should build fine on a 32 bits too. > + > + *size = GETSIZE(op.type); > + if (*type == CACHEOP) { > + *size = cache_op_size(); > + *ea &= ~(*size - 1); > + } else if (*type == LOAD_VMX || *type == STORE_VMX) { > + *ea &= ~(*size - 1); > + } > +} > Christophe