Commit aa98d848 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Reduce casts around bp_addr

perf_event_attr bp_addr is a u64. parse-events.y parses it as a u64, but
casts it to a void* and then parse-events.c casts it back to a u64.
Rather than all the casts, change the type of the address to be a u64.

This removes an issue noted in:

  https://lore.kernel.org/lkml/20200903184359.GC3495158@kernel.org/Signed-off-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200925003903.561568-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 40b74c30
...@@ -940,12 +940,12 @@ do { \ ...@@ -940,12 +940,12 @@ do { \
} }
int parse_events_add_breakpoint(struct list_head *list, int *idx, int parse_events_add_breakpoint(struct list_head *list, int *idx,
void *ptr, char *type, u64 len) u64 addr, char *type, u64 len)
{ {
struct perf_event_attr attr; struct perf_event_attr attr;
memset(&attr, 0, sizeof(attr)); memset(&attr, 0, sizeof(attr));
attr.bp_addr = (unsigned long) ptr; attr.bp_addr = addr;
if (parse_breakpoint_type(type, &attr)) if (parse_breakpoint_type(type, &attr))
return -EINVAL; return -EINVAL;
......
...@@ -190,7 +190,7 @@ int parse_events_add_cache(struct list_head *list, int *idx, ...@@ -190,7 +190,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,
struct parse_events_error *error, struct parse_events_error *error,
struct list_head *head_config); struct list_head *head_config);
int parse_events_add_breakpoint(struct list_head *list, int *idx, int parse_events_add_breakpoint(struct list_head *list, int *idx,
void *ptr, char *type, u64 len); u64 addr, char *type, u64 len);
int parse_events_add_pmu(struct parse_events_state *parse_state, int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, char *name, struct list_head *list, char *name,
struct list_head *head_config, struct list_head *head_config,
......
...@@ -511,7 +511,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc ...@@ -511,7 +511,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
list = alloc_list(); list = alloc_list();
ABORT_ON(!list); ABORT_ON(!list);
err = parse_events_add_breakpoint(list, &parse_state->idx, err = parse_events_add_breakpoint(list, &parse_state->idx,
(void *)(uintptr_t) $2, $6, $4); $2, $6, $4);
free($6); free($6);
if (err) { if (err) {
free(list); free(list);
...@@ -528,7 +528,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc ...@@ -528,7 +528,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
list = alloc_list(); list = alloc_list();
ABORT_ON(!list); ABORT_ON(!list);
if (parse_events_add_breakpoint(list, &parse_state->idx, if (parse_events_add_breakpoint(list, &parse_state->idx,
(void *)(uintptr_t) $2, NULL, $4)) { $2, NULL, $4)) {
free(list); free(list);
YYABORT; YYABORT;
} }
...@@ -544,7 +544,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc ...@@ -544,7 +544,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
list = alloc_list(); list = alloc_list();
ABORT_ON(!list); ABORT_ON(!list);
err = parse_events_add_breakpoint(list, &parse_state->idx, err = parse_events_add_breakpoint(list, &parse_state->idx,
(void *)(uintptr_t) $2, $4, 0); $2, $4, 0);
free($4); free($4);
if (err) { if (err) {
free(list); free(list);
...@@ -561,7 +561,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc ...@@ -561,7 +561,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc
list = alloc_list(); list = alloc_list();
ABORT_ON(!list); ABORT_ON(!list);
if (parse_events_add_breakpoint(list, &parse_state->idx, if (parse_events_add_breakpoint(list, &parse_state->idx,
(void *)(uintptr_t) $2, NULL, 0)) { $2, NULL, 0)) {
free(list); free(list);
YYABORT; YYABORT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment