From: Marco Elver <elver@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: kbuild-all@lists.01.org, kernel test robot <lkp@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [peterz-queue:perf/core 18/22] kernel/events/core.c:6418:22: sparse: sparse: incorrect type in assignment (different address spaces)
Date: Thu, 15 Apr 2021 11:03:09 +0200 [thread overview]
Message-ID: <YHgBTRciZNDUkfId@elver.google.com> (raw)
In-Reply-To: <YHf92aCeN65rANQY@hirez.programming.kicks-ass.net>
On Thu, Apr 15, 2021 at 10:48AM +0200, Peter Zijlstra wrote:
> On Wed, Apr 14, 2021 at 04:33:22PM +0200, Marco Elver wrote:
> > On Wed, Apr 14, 2021 at 10:10PM +0800, kernel test robot wrote:
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git perf/core
> > > head: 0da503cd07380952599b67ded6efe030d78ea42d
> > > commit: c7d4112e9f0e69edd649665836ce72008b95ab9f [18/22] perf: Add support for SIGTRAP on perf events
> > [...]
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > [...]
> > > 6416 info.si_errno = event->attr.type;
> > > 6417 info.si_perf = event->attr.sig_data;
> > > > 6418 info.si_addr = (void *)event->sig_addr;
> > > 6419 force_sig_info(&info);
> >
> > I think it wants the below (feel free to squash into "perf: Add support
> > for SIGTRAP on perf events").
> >
> > Thanks,
> > -- Marco
> >
[...]
>
> Now the silly robot complains about:
>
> CC kernel/events/core.o
> ../kernel/events/core.c: In function ‘perf_sigtrap’:
> ../kernel/events/core.c:6418:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 6418 | info.si_addr = (void __user *)event->sig_addr;
>
> for all 32bit builds (because sig_addr is u64 and the pointer cast
> truncates bits).
>
> This had me look a little harder at sig_addr and I figured it should be
> next to the pending fields for cache locality.
>
> I've ended up with the below delta, does that work for you?
Thanks, that works for me. Do note that I explicitly chose u64 for
sig_addr/pending_addr because data->addr is u64. There might be a new
warning about the u64 to unsigned long assignment on 32 bit arches.
Perhaps it needs something ugly like this:
info.si_addr = (void __user *)(unsigned long)event->pending_addr;
if pending_addr wants to be u64. Or just
event->pending_addr = (unsigned long)data->addr;
if data->addr being u64 on 32 bit arches is simply overkill.
Thanks,
-- Marco
> ---
>
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -735,6 +735,7 @@ struct perf_event {
> int pending_wakeup;
> int pending_kill;
> int pending_disable;
> + unsigned long pending_addr; /* SIGTRAP */
> struct irq_work pending;
>
> atomic_t event_limit;
> @@ -778,9 +779,6 @@ struct perf_event {
> void *security;
> #endif
> struct list_head sb_list;
> -
> - /* Address associated with event, which can be passed to siginfo_t. */
> - u64 sig_addr;
> #endif /* CONFIG_PERF_EVENTS */
> };
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6415,7 +6415,7 @@ static void perf_sigtrap(struct perf_eve
> info.si_code = TRAP_PERF;
> info.si_errno = event->attr.type;
> info.si_perf = event->attr.sig_data;
> - info.si_addr = (void __user *)event->sig_addr;
> + info.si_addr = (void __user *)event->pending_addr;
> force_sig_info(&info);
> }
>
> @@ -9137,7 +9137,7 @@ static int __perf_event_overflow(struct
> if (events && atomic_dec_and_test(&event->event_limit)) {
> ret = 1;
> event->pending_kill = POLL_HUP;
> - event->sig_addr = data->addr;
> + event->pending_addr = data->addr;
>
> perf_event_disable_inatomic(event);
> }
next prev parent reply other threads:[~2021-04-15 9:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <202104142209.hLOfOONR-lkp@intel.com>
2021-04-14 14:33 ` Marco Elver
2021-04-15 8:48 ` Peter Zijlstra
2021-04-15 9:03 ` Marco Elver [this message]
2021-04-15 9:11 ` Peter Zijlstra
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=YHgBTRciZNDUkfId@elver.google.com \
--to=elver@google.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=peterz@infradead.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
Powered by JetHome