lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Sep 2020 11:50:51 +0200
From:   Bartosz Golaszewski <bgolaszewski@...libre.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Kent Gibson <warthog618@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Subject: Re: [PATCH v9 04/20] gpio: uapi: define uAPI v2

On Tue, Sep 22, 2020 at 9:41 AM Arnd Bergmann <arnd@...db.de> wrote:
>
> On Tue, Sep 22, 2020 at 4:34 AM Kent Gibson <warthog618@...il.com> wrote:
> > +/**
> > + * struct gpio_v2_line_attribute - a configurable attribute of a line
> > + * @id: attribute identifier with value from &enum gpio_v2_line_attr_id
> > + * @padding: reserved for future use and must be zero filled
> > + * @flags: if id is GPIO_V2_LINE_ATTR_ID_FLAGS, the flags for the GPIO
> > + * line, with values from enum gpio_v2_line_flag, such as
> > + * GPIO_V2_LINE_FLAG_ACTIVE_LOW, GPIO_V2_LINE_FLAG_OUTPUT etc, OR:ed
> > + * together.  This overrides the default flags contained in the &struct
> > + * gpio_v2_line_config for the associated line.
> > + * @values: if id is GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES, a bitmap
> > + * containing the values to which the lines will be set, with each bit
> > + * number corresponding to the index into &struct
> > + * gpio_v2_line_request.offsets.
> > + * @debounce_period_us: if id is GPIO_V2_LINE_ATTR_ID_DEBOUNCE, the desired
> > + * debounce period, in microseconds
> > + */
> > +struct gpio_v2_line_attribute {
> > +       __u32 id;
> > +       __u32 padding;
> > +       union {
> > +               __aligned_u64 flags;
> > +               __aligned_u64 values;
> > +               __u32 debounce_period_us;
> > +       };
> > +};
>
> Having different-sized members in the union makes it hard for
> something like strace to print the contents. How about just making
> them all __aligned_u64 even when 32 bits are sufficient?
>

Ah yes, adding support for GPIO ioctl()'s to strace has been on my
TODO list for 3 years now. :(

> > +struct gpio_v2_line_request {
> > +       __u32 offsets[GPIO_V2_LINES_MAX];
> > +       char consumer[GPIO_MAX_NAME_SIZE];
> > +       struct gpio_v2_line_config config;
> > +       __u32 num_lines;
> > +       __u32 event_buffer_size;
> > +       /* Pad to fill implicit padding and reserve space for future use. */
> > +       __u32 padding[5];
> > +       __s32 fd;
> > +};
>
> > +struct gpio_v2_line_info {
> > +       char name[GPIO_MAX_NAME_SIZE];
> > +       char consumer[GPIO_MAX_NAME_SIZE];
> > +       __u32 offset;
> > +       __u32 num_attrs;
> > +       __aligned_u64 flags;
> > +       struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
> > +       /* Space reserved for future use. */
> > +       __u32 padding[4];
> > +};
>
> These are both several hundred bytes long, requiring a lot of data
> to be copied to the stack and take up space there. I see this is not
> actually much different for the v1 API, but I wonder if there has been
> any analysis of whether this has a noticeable effect on application
> runtime.
>

The main difference between this and V1 is that we can now pass
arguments for flags as defined in struct gpio_v2_line_attribute. I
haven't measured the impact but first: this is not a hot path
(retrieving line info is not done a lot like reading line events or
setting/getting values), and second: this structure is 280 bytes long
which is still less than a page so we should not face more context
switches than with a smaller structure, right?

Bartosz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ