linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Jacob Shin <jacob.shin@amd.com>, Ingo Molnar <mingo@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, Stephane Eranian <eranian@google.com>,
	Jiri Olsa <jolsa@redhat.com>,
	linux-kernel@vger.kernel.org, Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH 2/3] perf tools: allow user to specify hardware breakpoint bp_len
Date: Sun, 28 Apr 2013 18:12:45 +0200	[thread overview]
Message-ID: <20130428161245.GA25197@redhat.com> (raw)
In-Reply-To: <517CB8AC.600@zytor.com>

On 04/27, H. Peter Anvin wrote:
>
> On 04/27/2013 09:58 AM, Oleg Nesterov wrote:
> >
> > Stupid question... So X86_FEATURE_BPEXT only works for r/w? I mean, it
> > doesn't allow to specify the mask for an execute breakpoint?
>
> x86 execute breakpoints in general are only a single byte, which has to
> be the first byte of the instruction.

OK, thanks, but this new X86_FEATURE_BPEXT allows to specify the range
even for HW_BREAKPOINT_X... But lets ignore this series for the moment.

If execute breakpoints are only a single byte, then why
arch_build_bp_info() requires ->bp_len = sizeof(long) but not 1?

And note that it sets info->len = X86_BREAKPOINT_LEN_X. The comment says

	x86 inst breakpoints need to have a specific undefined len

but despite its "special" name LEN_X is simply LEN_1, and other code
relies on this fact.

And, otoh, ptrace requires DR_LEN_1. Then arch_bp_generic_fields()
translates this into "gen_len = sizeof(long)" for validate. Which
is translated to LEN_1 later.

This looks confusing, imho. And imho X86_BREAKPOINT_LEN_X should die...

But I guess we can't change arch_build_bp_info() to require bp_len = 1,
this can break userspace...


And it is not clear to me how we can change this code to support a
range for the execute breakpoints, perhaps something like below.

Oleg.

--- x/arch/x86/kernel/hw_breakpoint.c
+++ x/arch/x86/kernel/hw_breakpoint.c
@@ -270,10 +270,11 @@ static int arch_build_bp_info(struct per
 		 * But we still need to check userspace is not trying to setup
 		 * an unsupported length, to get a range breakpoint for example.
 		 */
-		if (bp->attr.bp_len == sizeof(long)) {
-			info->len = X86_BREAKPOINT_LEN_X;
-			return 0;
-		}
+		if (bp->attr.bp_len == sizeof(long))
+			bp->attr.bp_len = HW_BREAKPOINT_LEN_1;
+		else if (!cpu_has_bpext)
+			return -EINVAL;
+		break;
 	default:
 		return -EINVAL;
 	}


  reply	other threads:[~2013-04-28 16:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26 18:57 [PATCH 0/3] perf/x86/amd: AMD Family 16h Data Breakpoint Extensions Jacob Shin
2013-04-26 18:57 ` [PATCH 1/3] perf/x86/amd: AMD support for bp_len > HW_BREAKPOINT_LEN_8 Jacob Shin
2013-04-27 15:05   ` Oleg Nesterov
2013-04-27 15:14     ` Oleg Nesterov
2013-04-27 15:40     ` Jacob Shin
2013-04-27 16:10       ` Oleg Nesterov
2013-04-28  6:05         ` Jacob Shin
2013-04-26 18:57 ` [PATCH 2/3] perf tools: allow user to specify hardware breakpoint bp_len Jacob Shin
2013-04-27 16:58   ` Oleg Nesterov
2013-04-27 17:34     ` Oleg Nesterov
2013-04-28  5:44       ` Jacob Shin
2013-04-28  5:50     ` H. Peter Anvin
2013-04-28 16:12       ` Oleg Nesterov [this message]
2013-04-26 18:57 ` [PATCH 3/3] perf tools: add hardware breakpoint bp_len test cases Jacob Shin
  -- strict thread matches above, loose matches on Subject: below --
2013-04-28  6:05 [PATCH V4 0/3] perf/x86/amd: AMD Family 16h Data Breakpoint Extensions Jacob Shin
2013-04-28  6:05 ` [PATCH 2/3] perf tools: allow user to specify hardware breakpoint bp_len Jacob Shin
2013-10-02 16:11 [PATCH V5 0/3] perf/x86/amd: AMD Family 16h Data Breakpoint Extensions suravee.suthikulpanit
2013-10-02 16:11 ` [PATCH 2/3] perf tools: allow user to specify hardware breakpoint bp_len suravee.suthikulpanit
2013-12-10 15:25   ` Frederic Weisbecker
2013-12-10 16:22     ` Oleg Nesterov
2013-12-10 16:26       ` Frederic Weisbecker

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=20130428161245.GA25197@redhat.com \
    --to=oleg@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jacob.shin@amd.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    /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).