From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-gpio@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v1 1/2] gpiolib: Fix line event handling in syscall compatible mode
Date: Sat, 12 Sep 2020 10:21:48 +0800 [thread overview]
Message-ID: <20200912022148.GA3880502@sol> (raw)
In-Reply-To: <20200911142846.GM1891694@smile.fi.intel.com>
On Fri, Sep 11, 2020 at 05:28:46PM +0300, Andy Shevchenko wrote:
> On Fri, Sep 11, 2020 at 06:17:14PM +0800, Kent Gibson wrote:
> > On Fri, Sep 11, 2020 at 12:53:55PM +0300, Andy Shevchenko wrote:
> > > On Fri, Sep 11, 2020 at 05:12:49PM +0800, Kent Gibson wrote:
> > > > On Fri, Sep 11, 2020 at 11:31:09AM +0300, Andy Shevchenko wrote:
> > > > > On Fri, Sep 11, 2020 at 11:05:39AM +0800, Kent Gibson wrote:
> > > > > > On Thu, Sep 10, 2020 at 01:19:34PM +0300, Andy Shevchenko wrote:
> > >
[snip]
> >
> > typedef u64 __attribute__((aligned(4))) compat_u64;
> >
> > which is bitwise identical - only allowed to 32-bit align.
>
> Yes. That's what I meant under "not the same".
>
> As far as I understand the alignment makes sense if this type is a part of
> the uAPI definition. But here we have it completely local. copy_to_user() takes
> a pointer to a memory without any specific alignment implied.
>
> So, what you proposing is basically something like
>
> ret = copy_to_user(buf, &ge, compat ? sizeof(compat) : sizeof(ge));
>
> Correct?
>
That isn't how I would write the copy_to_user(). The size would be
calculated once, using the linevent_user_size() helper, with
appropriate documentation as to why this is necessary, and then
used throughout lineevent_read().
The documentation would mainly be on the lineevent_user_size() function
itself.
> I don't like the difference between 2nd and 3rd argument. This what looks to me
> hackish. Variant with explicit compat structure I like more.
>
Agreed - writing it that way does look pretty nasty.
But my suggestion is actually this:
ret = copy_to_user(buf, &ge, event_size);
I suggested ge_size previously, but event_size might help highlight that
it isn't always sizeof(ge).
> But if you think it's okay, I will update your way.
>
I would defer to Bart or Linus, but I think just calculating the
appropriate size is preferable for this case.
Cheers,
Kent.
next prev parent reply other threads:[~2020-09-12 2:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 10:19 [PATCH v1 1/2] gpiolib: Fix line event handling in syscall compatible mode Andy Shevchenko
2020-09-10 10:19 ` [PATCH v1 2/2] gpiolib: convert to use DEFINE_SEQ_ATTRIBUTE macro Andy Shevchenko
2020-09-11 15:45 ` Bartosz Golaszewski
2020-09-11 1:37 ` [PATCH v1 1/2] gpiolib: Fix line event handling in syscall compatible mode kernel test robot
2020-09-11 3:05 ` Kent Gibson
2020-09-11 8:31 ` Andy Shevchenko
2020-09-11 9:12 ` Kent Gibson
2020-09-11 9:53 ` Andy Shevchenko
2020-09-11 10:17 ` Kent Gibson
[not found] ` <20200911142846.GM1891694@smile.fi.intel.com>
2020-09-12 2:21 ` Kent Gibson [this message]
2020-09-14 12:44 ` Bartosz Golaszewski
2020-09-14 13:04 ` Andy Shevchenko
2020-09-11 16:20 ` Arnd Bergmann
2020-09-14 14:26 ` Andy Shevchenko
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=20200912022148.GA3880502@sol \
--to=warthog618@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bgolaszewski@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.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).