提交 26c6ccdf 编写于 作者: F Frederic Weisbecker 提交者: Ingo Molnar

perf/hw_breakpoint: Clean up and consolidate modify_user_hw_breakpoint_check()

Remove the dance around old and new attributes. Just don't modify the
previous breakpoint at all until we have verified everything.
Original-patch-by: NAndy Lutomirski <luto@kernel.org>
Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NFrederic Weisbecker <frederic@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joel Fernandes <joel.opensrc@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: http://lkml.kernel.org/r/1529981939-8231-13-git-send-email-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 cb8b7881
...@@ -461,37 +461,43 @@ register_user_hw_breakpoint(struct perf_event_attr *attr, ...@@ -461,37 +461,43 @@ register_user_hw_breakpoint(struct perf_event_attr *attr,
} }
EXPORT_SYMBOL_GPL(register_user_hw_breakpoint); EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
static void hw_breakpoint_copy_attr(struct perf_event_attr *to,
struct perf_event_attr *from)
{
to->bp_addr = from->bp_addr;
to->bp_type = from->bp_type;
to->bp_len = from->bp_len;
to->disabled = from->disabled;
}
int int
modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr, modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
bool check) bool check)
{ {
u64 old_addr = bp->attr.bp_addr;
u64 old_len = bp->attr.bp_len;
int old_type = bp->attr.bp_type;
bool modify = attr->bp_type != old_type;
struct arch_hw_breakpoint hw; struct arch_hw_breakpoint hw;
int err = 0; int err;
bp->attr.bp_addr = attr->bp_addr; err = hw_breakpoint_parse(bp, attr, &hw);
bp->attr.bp_type = attr->bp_type; if (err)
bp->attr.bp_len = attr->bp_len; return err;
if (check && memcmp(&bp->attr, attr, sizeof(*attr))) if (check) {
return -EINVAL; struct perf_event_attr old_attr;
err = hw_breakpoint_parse(bp, attr, &hw); old_attr = bp->attr;
if (!err && modify) hw_breakpoint_copy_attr(&old_attr, attr);
err = modify_bp_slot(bp, old_type, bp->attr.bp_type); if (memcmp(&old_attr, attr, sizeof(*attr)))
return -EINVAL;
}
if (err) { if (bp->attr.bp_type != attr->bp_type) {
bp->attr.bp_addr = old_addr; err = modify_bp_slot(bp, bp->attr.bp_type, attr->bp_type);
bp->attr.bp_type = old_type; if (err)
bp->attr.bp_len = old_len;
return err; return err;
} }
hw_breakpoint_copy_attr(&bp->attr, attr);
bp->hw.info = hw; bp->hw.info = hw;
bp->attr.disabled = attr->disabled;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册