Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3656767ybh; Tue, 17 Mar 2020 04:15:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt2rX2FDtg06m22ZdI02JDUdktnRxvpqpQnlyQQ/xW2U77E2TInYhstPpqBhD7cEOGrFV11 X-Received: by 2002:a9d:282:: with SMTP id 2mr3169407otl.178.1584443711538; Tue, 17 Mar 2020 04:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584443711; cv=none; d=google.com; s=arc-20160816; b=JYil4+Q2TAYX4t9+QL6sekNoPDXykW63K5zmUYZpJht55kFk2N37jxRhtX7iWwMBk7 o4k+D4OSXpesuo450ic5lxf8plmc4jRCck/zP/Y1HoRlI1NhbRw03MFl/AyXOoji/x9/ ktT7atcZLB90A6WPkefVmgEMpd8ty7LbEAES255NpcV2sT1kFDctgGOxuKJuyk5Nxv3C GDUZp8pxdcDhiZg9LU1RMIqVs6Q0b0k6IQHANt1mg1D6E9ZgVHqtKi5Wcg2qVX31//uJ RGsr4ygFOO57FEgzk20EdiyF1ceuerj1cDIw5RX7OIDSRZJO0uAJYZ7vl8peFu5DknzV L99g== 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:dkim-signature; bh=BZ0LYBWWFO9urZQIr4mGJkiXKv895B7QODHRrvOV2AU=; b=zJyJ/6UldcMnYlmQWacH+BfehwBm/lz3eG1WQ4Bt4hl4itkLIOPsaxE0jtDYP12mj1 SNRxNx0klWa0EGvnQbFFhHpOHGIh0bcYZu582V4Axdki5ZkA6w3HqrHZz5apNc1Tmwtm QbPwGC4BNwkaiVPCpCbC0B/xULbpAtUCT6a2LJdNeRPlsoQmpARDgvvnXLte/lO+g3h0 JqqQ5IxeiHcK4y/UUnbJn16TKHhLZNeijwFqimQNjFAM9LH63GoGnIcCE5gY/6Kd9VkZ T5P5uRvz7GgfOjBRjgr4UXTEauvtbbGgyOrb2jdbpdj9QJL3HZqHXBiTCIi/bTdy8Wfl XnpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=cCQpZUj0; 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 d16si1520369otp.135.2020.03.17.04.14.58; Tue, 17 Mar 2020 04:15:11 -0700 (PDT) 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=cCQpZUj0; 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 S1729635AbgCQLOd (ORCPT + 99 others); Tue, 17 Mar 2020 07:14:33 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:56716 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729052AbgCQLO0 (ORCPT ); Tue, 17 Mar 2020 07:14:26 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48hVtQ5ppyz9v0xK; Tue, 17 Mar 2020 12:14:22 +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=cCQpZUj0; 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 Rz4HNBhm-l3C; Tue, 17 Mar 2020 12:14:22 +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 48hVtQ3lwhz9v0xF; Tue, 17 Mar 2020 12:14:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584443662; bh=BZ0LYBWWFO9urZQIr4mGJkiXKv895B7QODHRrvOV2AU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=cCQpZUj0Sk/tvj0qZdyMJ/s5V8UQYcITTFhrQyV+46r4pDhdwWfE5E9owV2m4s4ey 78Zs9E7G+xi2BcM0YhflUcW5Uw3BLZpXBSqJJx943v0W9lyZsBX4LFLu/756PEtxK+ J3yCNF6OSmTIF5c3lLrHUW/Te6vDVy3K8cJSRD2E= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 330C88B785; Tue, 17 Mar 2020 12:14:23 +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 AfLjiEvarbtM; Tue, 17 Mar 2020 12:14:22 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E1B088B787; Tue, 17 Mar 2020 12:14:17 +0100 (CET) Subject: Re: [PATCH 15/15] powerpc/watchpoint/xmon: Support 2nd dawr To: Ravi Bangoria , mpe@ellerman.id.au, mikey@neuling.org Cc: apopple@linux.ibm.com, paulus@samba.org, npiggin@gmail.com, naveen.n.rao@linux.vnet.ibm.com, peterz@infradead.org, jolsa@kernel.org, oleg@redhat.com, fweisbec@gmail.com, mingo@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20200309085806.155823-1-ravi.bangoria@linux.ibm.com> <20200309085806.155823-16-ravi.bangoria@linux.ibm.com> From: Christophe Leroy Message-ID: Date: Tue, 17 Mar 2020 12:14:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200309085806.155823-16-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 09/03/2020 à 09:58, Ravi Bangoria a écrit : > Add support for 2nd DAWR in xmon. With this, we can have two > simultaneous breakpoints from xmon. > > Signed-off-by: Ravi Bangoria > --- > arch/powerpc/xmon/xmon.c | 101 ++++++++++++++++++++++++++------------- > 1 file changed, 69 insertions(+), 32 deletions(-) > > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c > index ac18fe3e4295..20adc83404c8 100644 > --- a/arch/powerpc/xmon/xmon.c > +++ b/arch/powerpc/xmon/xmon.c > @@ -110,7 +110,7 @@ struct bpt { > > #define NBPTS 256 > static struct bpt bpts[NBPTS]; > -static struct bpt dabr; > +static struct bpt dabr[HBP_NUM_MAX]; > static struct bpt *iabr; > static unsigned bpinstr = 0x7fe00008; /* trap */ > > @@ -786,10 +786,17 @@ static int xmon_sstep(struct pt_regs *regs) > > static int xmon_break_match(struct pt_regs *regs) > { > + int i; > + > if ((regs->msr & (MSR_IR|MSR_PR|MSR_64BIT)) != (MSR_IR|MSR_64BIT)) > return 0; > - if (dabr.enabled == 0) > - return 0; > + for (i = 0; i < nr_wp_slots(); i++) { > + if (dabr[i].enabled) > + goto found; > + } > + return 0; > + > +found: > xmon_core(regs, 0); > return 1; > } > @@ -928,13 +935,16 @@ static void insert_bpts(void) > > static void insert_cpu_bpts(void) > { > + int i; > struct arch_hw_breakpoint brk; > > - if (dabr.enabled) { > - brk.address = dabr.address; > - brk.type = (dabr.enabled & HW_BRK_TYPE_DABR) | HW_BRK_TYPE_PRIV_ALL; > - brk.len = DABR_MAX_LEN; > - __set_breakpoint(&brk, 0); > + for (i = 0; i < nr_wp_slots(); i++) { > + if (dabr[i].enabled) { > + brk.address = dabr[i].address; > + brk.type = (dabr[i].enabled & HW_BRK_TYPE_DABR) | HW_BRK_TYPE_PRIV_ALL; > + brk.len = 8; > + __set_breakpoint(&brk, i); > + } > } > > if (iabr) > @@ -1348,6 +1358,35 @@ static long check_bp_loc(unsigned long addr) > return 1; > } > > +static int free_data_bpt(void) This names suggests the function frees a breakpoint. I guess it should be find_free_data_bpt() > +{ > + int i; > + > + for (i = 0; i < nr_wp_slots(); i++) { > + if (!dabr[i].enabled) > + return i; > + } > + printf("Couldn't find free breakpoint register\n"); > + return -1; > +} > + > +static void print_data_bpts(void) > +{ > + int i; > + > + for (i = 0; i < nr_wp_slots(); i++) { > + if (!dabr[i].enabled) > + continue; > + > + printf(" data "REG" [", dabr[i].address); > + if (dabr[i].enabled & 1) > + printf("r"); > + if (dabr[i].enabled & 2) > + printf("w"); > + printf("]\n"); > + } > +} > + > static char *breakpoint_help_string = > "Breakpoint command usage:\n" > "b show breakpoints\n" > @@ -1381,10 +1420,9 @@ bpt_cmds(void) > printf("Hardware data breakpoint not supported on this cpu\n"); > break; > } > - if (dabr.enabled) { > - printf("Couldn't find free breakpoint register\n"); > + i = free_data_bpt(); > + if (i < 0) > break; > - } > mode = 7; > cmd = inchar(); > if (cmd == 'r') > @@ -1393,15 +1431,15 @@ bpt_cmds(void) > mode = 6; > else > termch = cmd; > - dabr.address = 0; > - dabr.enabled = 0; > - if (scanhex(&dabr.address)) { > - if (!is_kernel_addr(dabr.address)) { > + dabr[i].address = 0; > + dabr[i].enabled = 0; > + if (scanhex(&dabr[i].address)) { > + if (!is_kernel_addr(dabr[i].address)) { > printf(badaddr); > break; > } > - dabr.address &= ~HW_BRK_TYPE_DABR; > - dabr.enabled = mode | BP_DABR; > + dabr[i].address &= ~HW_BRK_TYPE_DABR; > + dabr[i].enabled = mode | BP_DABR; > } > > force_enable_xmon(); > @@ -1440,7 +1478,9 @@ bpt_cmds(void) > for (i = 0; i < NBPTS; ++i) > bpts[i].enabled = 0; > iabr = NULL; > - dabr.enabled = 0; > + for (i = 0; i < nr_wp_slots(); i++) > + dabr[i].enabled = 0; > + > printf("All breakpoints cleared\n"); > break; > } > @@ -1474,14 +1514,7 @@ bpt_cmds(void) > if (xmon_is_ro || !scanhex(&a)) { > /* print all breakpoints */ > printf(" type address\n"); > - if (dabr.enabled) { > - printf(" data "REG" [", dabr.address); > - if (dabr.enabled & 1) > - printf("r"); > - if (dabr.enabled & 2) > - printf("w"); > - printf("]\n"); > - } > + print_data_bpts(); > for (bp = bpts; bp < &bpts[NBPTS]; ++bp) { > if (!bp->enabled) > continue; > @@ -1941,8 +1974,13 @@ static void dump_207_sprs(void) > > printf("hfscr = %.16lx dhdes = %.16lx rpr = %.16lx\n", > mfspr(SPRN_HFSCR), mfspr(SPRN_DHDES), mfspr(SPRN_RPR)); > - printf("dawr = %.16lx dawrx = %.16lx ciabr = %.16lx\n", > - mfspr(SPRN_DAWR0), mfspr(SPRN_DAWRX0), mfspr(SPRN_CIABR)); > + printf("dawr0 = %.16lx dawrx0 = %.16lx\n", > + mfspr(SPRN_DAWR0), mfspr(SPRN_DAWRX0)); > + if (nr_wp_slots() > 1) { > + printf("dawr1 = %.16lx dawrx1 = %.16lx\n", > + mfspr(SPRN_DAWR1), mfspr(SPRN_DAWRX1)); > + } > + printf("ciabr = %.16lx\n", mfspr(SPRN_CIABR)); > #endif > } > > @@ -3862,10 +3900,9 @@ static void clear_all_bpt(void) > bpts[i].enabled = 0; > > /* Clear any data or iabr breakpoints */ > - if (iabr || dabr.enabled) { > - iabr = NULL; > - dabr.enabled = 0; > - } > + iabr = NULL; > + for (i = 0; i < nr_wp_slots(); i++) > + dabr[i].enabled = 0; > } > > #ifdef CONFIG_DEBUG_FS > Christophe