linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf parse-events: Use uintptr_t when casting numbers to pointers
@ 2020-09-03 18:43 Arnaldo Carvalho de Melo
  2020-09-04  5:31 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-09-03 18:43 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Jin Yao, Adrian Hunter, Alexander Shishkin, Alexei Starovoitov,
	Andi Kleen, Daniel Borkmann, Jiri Olsa, John Garry, Kan Liang,
	Mark Rutland, Martin KaFai Lau, Namhyung Kim, Peter Zijlstra,
	Song Liu, Stephane Eranian, Yonghong Song,
	Linux Kernel Mailing List

Hi Ian,

	Please check that this is ok with you,

Thanks,

- Arnaldo

commit 0823f768b800cca2592fad3b5649766ae6bc4eba
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Thu Sep 3 15:34:20 2020 -0300

    perf parse-events: Use uintptr_t when casting numbers to pointers
    
    To address these errors found when cross building from x86_64 to MIPS
    little endian 32-bit:
    
        CC       /tmp/build/perf/util/parse-events-bison.o
      util/parse-events.y: In function 'parse_events_parse':
      util/parse-events.y:514:6: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        514 |      (void *) $2, $6, $4);
            |      ^
      util/parse-events.y:531:7: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        531 |       (void *) $2, NULL, $4)) {
            |       ^
      util/parse-events.y:547:6: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        547 |      (void *) $2, $4, 0);
            |      ^
      util/parse-events.y:564:7: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        564 |       (void *) $2, NULL, 0)) {
            |       ^
    
    Fixes: cabbf26821aa210f ("perf parse: Before yyabort-ing free components")
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jin Yao <yao.jin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: John Garry <john.garry@huawei.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Yonghong Song <yhs@fb.com>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index b9fb91fdc5de9177..645bf4f1859fd76b 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -511,7 +511,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
 	list = alloc_list();
 	ABORT_ON(!list);
 	err = parse_events_add_breakpoint(list, &parse_state->idx,
-					(void *) $2, $6, $4);
+					(void *)(uintptr_t) $2, $6, $4);
 	free($6);
 	if (err) {
 		free(list);
@@ -528,7 +528,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
 	list = alloc_list();
 	ABORT_ON(!list);
 	if (parse_events_add_breakpoint(list, &parse_state->idx,
-						(void *) $2, NULL, $4)) {
+						(void *)(uintptr_t) $2, NULL, $4)) {
 		free(list);
 		YYABORT;
 	}
@@ -544,7 +544,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
 	list = alloc_list();
 	ABORT_ON(!list);
 	err = parse_events_add_breakpoint(list, &parse_state->idx,
-					(void *) $2, $4, 0);
+					(void *)(uintptr_t) $2, $4, 0);
 	free($4);
 	if (err) {
 		free(list);
@@ -561,7 +561,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc
 	list = alloc_list();
 	ABORT_ON(!list);
 	if (parse_events_add_breakpoint(list, &parse_state->idx,
-						(void *) $2, NULL, 0)) {
+						(void *)(uintptr_t) $2, NULL, 0)) {
 		free(list);
 		YYABORT;
 	}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf parse-events: Use uintptr_t when casting numbers to pointers
  2020-09-03 18:43 [PATCH] perf parse-events: Use uintptr_t when casting numbers to pointers Arnaldo Carvalho de Melo
@ 2020-09-04  5:31 ` Ian Rogers
  2020-09-04 19:09   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2020-09-04  5:31 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jin Yao, Adrian Hunter, Alexander Shishkin, Alexei Starovoitov,
	Andi Kleen, Daniel Borkmann, Jiri Olsa, John Garry, Kan Liang,
	Mark Rutland, Martin KaFai Lau, Namhyung Kim, Peter Zijlstra,
	Song Liu, Stephane Eranian, Yonghong Song,
	Linux Kernel Mailing List

On Thu, Sep 3, 2020 at 11:44 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Hi Ian,
>
>         Please check that this is ok with you,
>
> Thanks,
>
> - Arnaldo

Thanks Arnaldo, this looks good to me! There is a separate issue, the
casts are necessary as we have PE_VALUEs that are supposed to be
numbers but here are list*. It seems error prone to have something
that is a pointer or a number, and so I wonder if we can introduce new
tokens in parse-events.y to handle this. It'd also mean that
yydestructors and the like could clean up error states. I'll try to
take a look.

Thanks,
Ian

> commit 0823f768b800cca2592fad3b5649766ae6bc4eba
> Author: Arnaldo Carvalho de Melo <acme@redhat.com>
> Date:   Thu Sep 3 15:34:20 2020 -0300
>
>     perf parse-events: Use uintptr_t when casting numbers to pointers
>
>     To address these errors found when cross building from x86_64 to MIPS
>     little endian 32-bit:
>
>         CC       /tmp/build/perf/util/parse-events-bison.o
>       util/parse-events.y: In function 'parse_events_parse':
>       util/parse-events.y:514:6: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>         514 |      (void *) $2, $6, $4);
>             |      ^
>       util/parse-events.y:531:7: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>         531 |       (void *) $2, NULL, $4)) {
>             |       ^
>       util/parse-events.y:547:6: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>         547 |      (void *) $2, $4, 0);
>             |      ^
>       util/parse-events.y:564:7: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>         564 |       (void *) $2, NULL, 0)) {
>             |       ^
>
>     Fixes: cabbf26821aa210f ("perf parse: Before yyabort-ing free components")
>     Cc: Adrian Hunter <adrian.hunter@intel.com>
>     Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>     Cc: Alexei Starovoitov <ast@kernel.org>
>     Cc: Andi Kleen <ak@linux.intel.com>
>     Cc: Daniel Borkmann <daniel@iogearbox.net>
>     Cc: Ian Rogers <irogers@google.com>
>     Cc: Jin Yao <yao.jin@linux.intel.com>
>     Cc: Jiri Olsa <jolsa@kernel.org>
>     Cc: John Garry <john.garry@huawei.com>
>     Cc: Kan Liang <kan.liang@linux.intel.com>
>     Cc: Mark Rutland <mark.rutland@arm.com>
>     Cc: Martin KaFai Lau <kafai@fb.com>
>     Cc: Namhyung Kim <namhyung@kernel.org>
>     Cc: Peter Zijlstra <peterz@infradead.org>
>     Cc: Song Liu <songliubraving@fb.com>
>     Cc: Stephane Eranian <eranian@google.com>
>     Cc: Yonghong Song <yhs@fb.com>
>     Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index b9fb91fdc5de9177..645bf4f1859fd76b 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -511,7 +511,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
>         list = alloc_list();
>         ABORT_ON(!list);
>         err = parse_events_add_breakpoint(list, &parse_state->idx,
> -                                       (void *) $2, $6, $4);
> +                                       (void *)(uintptr_t) $2, $6, $4);
>         free($6);
>         if (err) {
>                 free(list);
> @@ -528,7 +528,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
>         list = alloc_list();
>         ABORT_ON(!list);
>         if (parse_events_add_breakpoint(list, &parse_state->idx,
> -                                               (void *) $2, NULL, $4)) {
> +                                               (void *)(uintptr_t) $2, NULL, $4)) {
>                 free(list);
>                 YYABORT;
>         }
> @@ -544,7 +544,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
>         list = alloc_list();
>         ABORT_ON(!list);
>         err = parse_events_add_breakpoint(list, &parse_state->idx,
> -                                       (void *) $2, $4, 0);
> +                                       (void *)(uintptr_t) $2, $4, 0);
>         free($4);
>         if (err) {
>                 free(list);
> @@ -561,7 +561,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc
>         list = alloc_list();
>         ABORT_ON(!list);
>         if (parse_events_add_breakpoint(list, &parse_state->idx,
> -                                               (void *) $2, NULL, 0)) {
> +                                               (void *)(uintptr_t) $2, NULL, 0)) {
>                 free(list);
>                 YYABORT;
>         }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf parse-events: Use uintptr_t when casting numbers to pointers
  2020-09-04  5:31 ` Ian Rogers
@ 2020-09-04 19:09   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-09-04 19:09 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Jin Yao, Adrian Hunter, Alexander Shishkin, Alexei Starovoitov,
	Andi Kleen, Daniel Borkmann, Jiri Olsa, John Garry, Kan Liang,
	Mark Rutland, Martin KaFai Lau, Namhyung Kim, Peter Zijlstra,
	Song Liu, Stephane Eranian, Yonghong Song,
	Linux Kernel Mailing List

Em Thu, Sep 03, 2020 at 10:31:09PM -0700, Ian Rogers escreveu:
> On Thu, Sep 3, 2020 at 11:44 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> >         Please check that this is ok with you,
> 
> Thanks Arnaldo, this looks good to me!

Thanks for checkint!

- Arnaldo

> There is a separate issue, the casts are necessary as we have
> PE_VALUEs that are supposed to be numbers but here are list*. It seems
> error prone to have something that is a pointer or a number, and so I
> wonder if we can introduce new tokens in parse-events.y to handle
> this. It'd also mean that yydestructors and the like could clean up
> error states. I'll try to take a look.
 
> Thanks,
> Ian
> 
> > commit 0823f768b800cca2592fad3b5649766ae6bc4eba
> > Author: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Date:   Thu Sep 3 15:34:20 2020 -0300
> >
> >     perf parse-events: Use uintptr_t when casting numbers to pointers
> >
> >     To address these errors found when cross building from x86_64 to MIPS
> >     little endian 32-bit:
> >
> >         CC       /tmp/build/perf/util/parse-events-bison.o
> >       util/parse-events.y: In function 'parse_events_parse':
> >       util/parse-events.y:514:6: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> >         514 |      (void *) $2, $6, $4);
> >             |      ^
> >       util/parse-events.y:531:7: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> >         531 |       (void *) $2, NULL, $4)) {
> >             |       ^
> >       util/parse-events.y:547:6: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> >         547 |      (void *) $2, $4, 0);
> >             |      ^
> >       util/parse-events.y:564:7: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> >         564 |       (void *) $2, NULL, 0)) {
> >             |       ^
> >
> >     Fixes: cabbf26821aa210f ("perf parse: Before yyabort-ing free components")
> >     Cc: Adrian Hunter <adrian.hunter@intel.com>
> >     Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> >     Cc: Alexei Starovoitov <ast@kernel.org>
> >     Cc: Andi Kleen <ak@linux.intel.com>
> >     Cc: Daniel Borkmann <daniel@iogearbox.net>
> >     Cc: Ian Rogers <irogers@google.com>
> >     Cc: Jin Yao <yao.jin@linux.intel.com>
> >     Cc: Jiri Olsa <jolsa@kernel.org>
> >     Cc: John Garry <john.garry@huawei.com>
> >     Cc: Kan Liang <kan.liang@linux.intel.com>
> >     Cc: Mark Rutland <mark.rutland@arm.com>
> >     Cc: Martin KaFai Lau <kafai@fb.com>
> >     Cc: Namhyung Kim <namhyung@kernel.org>
> >     Cc: Peter Zijlstra <peterz@infradead.org>
> >     Cc: Song Liu <songliubraving@fb.com>
> >     Cc: Stephane Eranian <eranian@google.com>
> >     Cc: Yonghong Song <yhs@fb.com>
> >     Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> >
> > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> > index b9fb91fdc5de9177..645bf4f1859fd76b 100644
> > --- a/tools/perf/util/parse-events.y
> > +++ b/tools/perf/util/parse-events.y
> > @@ -511,7 +511,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
> >         list = alloc_list();
> >         ABORT_ON(!list);
> >         err = parse_events_add_breakpoint(list, &parse_state->idx,
> > -                                       (void *) $2, $6, $4);
> > +                                       (void *)(uintptr_t) $2, $6, $4);
> >         free($6);
> >         if (err) {
> >                 free(list);
> > @@ -528,7 +528,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
> >         list = alloc_list();
> >         ABORT_ON(!list);
> >         if (parse_events_add_breakpoint(list, &parse_state->idx,
> > -                                               (void *) $2, NULL, $4)) {
> > +                                               (void *)(uintptr_t) $2, NULL, $4)) {
> >                 free(list);
> >                 YYABORT;
> >         }
> > @@ -544,7 +544,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
> >         list = alloc_list();
> >         ABORT_ON(!list);
> >         err = parse_events_add_breakpoint(list, &parse_state->idx,
> > -                                       (void *) $2, $4, 0);
> > +                                       (void *)(uintptr_t) $2, $4, 0);
> >         free($4);
> >         if (err) {
> >                 free(list);
> > @@ -561,7 +561,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc
> >         list = alloc_list();
> >         ABORT_ON(!list);
> >         if (parse_events_add_breakpoint(list, &parse_state->idx,
> > -                                               (void *) $2, NULL, 0)) {
> > +                                               (void *)(uintptr_t) $2, NULL, 0)) {
> >                 free(list);
> >                 YYABORT;
> >         }

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-04 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 18:43 [PATCH] perf parse-events: Use uintptr_t when casting numbers to pointers Arnaldo Carvalho de Melo
2020-09-04  5:31 ` Ian Rogers
2020-09-04 19:09   ` Arnaldo Carvalho de Melo

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).