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]
Message-ID: <CAMuHMdV_jt4zRQV1WXL8yy-AUNtDvrV5U-TRLcNdvFhTLjfG1A@mail.gmail.com>
Date:   Tue, 7 Sep 2021 11:40:07 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Guenter Roeck <linux@...ck-us.net>
Cc:     Dmitry Torokhov <dmitry.torokhov@...il.com>,
        linux-input <linux-input@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] Input: analog: Always use ktime functions

Hi Günter,

On Tue, Sep 7, 2021 at 8:35 AM Guenter Roeck <linux@...ck-us.net> wrote:
> m68k, mips, s390, and sparc allmodconfig images fail to build with the
> following error.
>
> drivers/input/joystick/analog.c:160:2: error:
>         #warning Precise timer not defined for this architecture.
>
> Remove architecture specific time handling code and always use ktime
> functions to determine time deltas. Also remove the now useless use_ktime
> kernel parameter.
>
> Signed-off-by: Guenter Roeck <linux@...ck-us.net>
> ---
> v2: Drop helper functions and use ktime_get() and ktime_sub() directly
>     Drop 'speed' variable and use NSEC_PER_MSEC directly
>
>  drivers/input/joystick/analog.c | 103 ++++----------------------------
>  1 file changed, 11 insertions(+), 92 deletions(-)
>
> diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
> index f798922a4598..a9ec41f48068 100644
> --- a/drivers/input/joystick/analog.c
> +++ b/drivers/input/joystick/analog.c

> @@ -275,7 +210,7 @@ static int analog_cooked_read(struct analog_port *port)
>                 this |= data[i];
>                 for (j = 0; j < 4; j++)
>                         if (data[i] & (1 << j))
> -                               port->axes[j] = (delta(start, time[i]) << ANALOG_FUZZ_BITS) / port->loop;
> +                               port->axes[j] = (ktime_sub(time[i], start) << ANALOG_FUZZ_BITS) / port->loop;

This is now a 64-by-32 division, triggering undefined references to __udivdi3
on some 32-bit platforms.

Assumed deltas are small, the simple solution of truncating to
32 bit (like delta() did before):

-  port->axes[j] = (ktime_sub(time[i], start) << ANALOG_FUZZ_BITS) / port->loop;
+ port->axes[j] = ((u32)ktime_sub(time[i], start) << ANALOG_FUZZ_BITS)
/ port->loop;

is probably safe.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ