linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Ravi Bangoria <ravi.bangoria@linux.ibm.com>,
	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
Subject: Re: [PATCH 15/15] powerpc/watchpoint/xmon: Support 2nd dawr
Date: Tue, 17 Mar 2020 12:14:10 +0100	[thread overview]
Message-ID: <dabb2823-783a-6a3f-4f04-f3200a1086fc@c-s.fr> (raw)
In-Reply-To: <20200309085806.155823-16-ravi.bangoria@linux.ibm.com>



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 <ravi.bangoria@linux.ibm.com>
> ---
>   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

  reply	other threads:[~2020-03-17 11:14 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09  8:57 [PATCH 00/15] powerpc/watchpoint: Preparation for more than one watchpoint Ravi Bangoria
2020-03-09  8:57 ` [PATCH 01/15] powerpc/watchpoint: Rename current DAWR macros Ravi Bangoria
2020-03-17 10:14   ` Christophe Leroy
2020-03-18 12:40     ` Ravi Bangoria
2020-03-09  8:57 ` [PATCH 02/15] powerpc/watchpoint: Add SPRN macros for second DAWR Ravi Bangoria
2020-03-17 10:16   ` Christophe Leroy
2020-03-18 18:30     ` Segher Boessenkool
2020-03-09  8:57 ` [PATCH 03/15] powerpc/watchpoint: Introduce function to get nr watchpoints dynamically Ravi Bangoria
2020-03-17 10:21   ` Christophe Leroy
2020-03-18  5:50     ` Ravi Bangoria
2020-03-09  8:57 ` [PATCH 04/15] powerpc/watchpoint/ptrace: Return actual num of available watchpoints Ravi Bangoria
2020-03-09  8:57 ` [PATCH 05/15] powerpc/watchpoint: Provide DAWR number to set_dawr Ravi Bangoria
2020-03-17 10:28   ` Christophe Leroy
2020-03-18  6:18     ` Ravi Bangoria
2020-03-09  8:57 ` [PATCH 06/15] powerpc/watchpoint: Provide DAWR number to __set_breakpoint Ravi Bangoria
2020-03-09  8:57 ` [PATCH 07/15] powerpc/watchpoint: Get watchpoint count dynamically while disabling them Ravi Bangoria
2020-03-17 10:32   ` Christophe Leroy
2020-03-18  6:57     ` Ravi Bangoria
2020-03-26  3:32       ` Ravi Bangoria
2020-03-09  8:57 ` [PATCH 08/15] powerpc/watchpoint: Disable all available watchpoints when !dawr_force_enable Ravi Bangoria
2020-03-17 10:35   ` Christophe Leroy
2020-03-18  7:32     ` Ravi Bangoria
2020-03-09  8:58 ` [PATCH 09/15] powerpc/watchpoint: Convert thread_struct->hw_brk to an array Ravi Bangoria
2020-03-17 10:37   ` Christophe Leroy
2020-03-18  8:36     ` Ravi Bangoria
2020-03-18  8:56       ` Christophe Leroy
2020-03-18  9:22         ` Ravi Bangoria
2020-03-09  8:58 ` [PATCH 10/15] powerpc/watchpoint: Use loop for thread_struct->ptrace_bps Ravi Bangoria
2020-03-17 10:48   ` Christophe Leroy
2020-03-18  9:43     ` Ravi Bangoria
2020-03-09  8:58 ` [PATCH 11/15] powerpc/watchpoint: Introduce is_ptrace_bp() function Ravi Bangoria
2020-03-17 10:49   ` Christophe Leroy
2020-03-09  8:58 ` [PATCH 12/15] powerpc/watchpoint: Prepare handler to handle more than one watcnhpoint Ravi Bangoria
2020-03-17 10:59   ` Christophe Leroy
2020-03-18 11:35     ` Michael Ellerman
2020-03-18 11:44       ` Christophe Leroy
2020-03-18 21:27         ` Segher Boessenkool
2020-03-18 23:36           ` Michael Ellerman
2020-03-18 12:14     ` Ravi Bangoria
2020-03-09  8:58 ` [PATCH 13/15] powerpc/watchpoint: Don't allow concurrent perf and ptrace events Ravi Bangoria
2020-03-17 11:08   ` Christophe Leroy
2020-03-18 12:35     ` Ravi Bangoria
2020-03-09  8:58 ` [PATCH 14/15] powerpc/watchpoint/xmon: Don't allow breakpoint overwriting Ravi Bangoria
2020-03-17 11:10   ` Christophe Leroy
2020-03-18 12:37     ` Ravi Bangoria
2020-03-18 13:31       ` Christophe Leroy
2020-03-09  8:58 ` [PATCH 15/15] powerpc/watchpoint/xmon: Support 2nd dawr Ravi Bangoria
2020-03-17 11:14   ` Christophe Leroy [this message]
2020-03-18 12:39     ` Ravi Bangoria
2020-03-16 15:05 ` [PATCH 00/15] powerpc/watchpoint: Preparation for more than one watchpoint Christophe Leroy
2020-03-16 18:43   ` Segher Boessenkool
2020-03-17  5:56     ` Christophe Leroy
2020-03-18 12:52   ` Ravi Bangoria
2020-03-23 13:37     ` Ravi Bangoria

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dabb2823-783a-6a3f-4f04-f3200a1086fc@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=apopple@linux.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=oleg@redhat.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).