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: <3361fcd0-12e6-aaf8-33c2-54a99bac1900@codeaurora.org>
Date:   Mon, 1 Apr 2019 17:42:17 +0530
From:   Mukesh Ojha <mojha@...eaurora.org>
To:     Geert Uytterhoeven <geert+renesas@...der.be>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jslaby@...e.com>,
        Ulrich Hecht <uli+renesas@...nd.eu>
Cc:     Eugeniu Rosca <erosca@...adit-jv.com>,
        Dirk Behme <dirk.behme@...bosch.com>,
        linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] serial: sh-sci: Fix HSCIF RX sampling point calculation


On 4/1/2019 4:55 PM, Geert Uytterhoeven wrote:
> There are several issues with the formula used for calculating the
> deviation from the intended rate:
>    1. While min_err and last_stop are signed, srr and baud are unsigned.
>       Hence the signed values are promoted to unsigned, which will lead
>       to a bogus value of deviation if min_err is negative,
>    2. Srr is the register field value, which is one less than the actual
>       sampling rate factor,
>    3. The divisions do not use rounding.
>
> Fix this by casting unsigned variables to int, adding one to srr, and
> using a single DIV_ROUND_CLOSEST().
>
> Fixes: 63ba1e00f178a448 ("serial: sh-sci: Support for HSCIF RX sampling point adjustment")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>


Reviewed-by: Mukesh Ojha <mojha@...eaurora.org>

Cheers,
-Mukesh

> ---
> Anyone with a good test setup for verifying this feature actually works
> as advertised?
> ---
>   drivers/tty/serial/sh-sci.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 2bdaeba5d527a6ce..8dea59edde34c224 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -2522,7 +2522,9 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
>   			 * center of the last stop bit in sampling clocks.
>   			 */
>   			int last_stop = bits * 2 - 1;
> -			int deviation = min_err * srr * last_stop / 2 / baud;
> +			int deviation = DIV_ROUND_CLOSEST(min_err * last_stop *
> +							  (int)(srr + 1),
> +							  2 * (int)baud);
>   
>   			if (abs(deviation) >= 2) {
>   				/* At least two sampling clocks off at the

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ