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:	Sun, 19 Apr 2015 14:13:04 +0200
From:	Heiko Stübner <heiko@...ech.de>
To:	Boris Brezillon <boris.brezillon@...e-electrons.com>
Cc:	Mike Turquette <mturquette@...aro.org>,
	Mikko Perttunen <mikko.perttunen@...si.fi>,
	Jonathan Corbet <corbet@....net>,
	Shawn Guo <shawn.guo@...aro.org>,
	ascha Hauer <kernel@...gutronix.de>,
	David Brown <davidb@...eaurora.org>,
	Daniel Walker <dwalker@...o99.com>,
	Bryan Huntsman <bryanh@...eaurora.org>,
	Tony Lindgren <tony@...mide.com>,
	Paul Walmsley <paul@...an.com>,
	Liviu Dudau <liviu.dudau@....com>,
	Sudeep Holla <sudeep.holla@....com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Max Filippov <jcmvbkbc@...il.com>,
	Sylwester Nawrocki <s.nawrocki@...sung.com>,
	Tomasz Figa <tomasz.figa@...il.com>,
	Barry Song <baohua@...nel.org>,
	Viresh Kumar <viresh.linux@...il.com>,
	Emilio López <emilio@...pez.com.ar>,
	Maxime Ripard <maxime.ripard@...e-electrons.com>,
	Peter De Schrijver <pdeschrijver@...dia.com>,
	Prashant Gaikwad <pgaikwad@...dia.com>,
	Stephen Warren <swarren@...dotorg.org>,
	Thierry Reding <thierry.reding@...il.com>,
	Alexandre Courbot <gnurou@...il.com>,
	Tero Kristo <t-kristo@...com>,
	Ulf Hansson <ulf.hansson@...aro.org>,
	Michal Simek <michal.simek@...inx.com>,
	Philipp Zabel <p.zabel@...gutronix.de>,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-arm-msm@...r.kernel.org, linux-omap@...r.kernel.org,
	linux-mips@...ux-mips.org, patches@...nsource.wolfsonmicro.com,
	linux-rockchip@...ts.infradead.org,
	linux-samsung-soc@...r.kernel.org, spear-devel@...t.st.com,
	linux-tegra@...r.kernel.org, dri-devel@...ts.freedesktop.org,
	linux-media@...r.kernel.org, rtc-linux@...glegroups.com
Subject: Re: [PATCH 1/2] clk: change clk_ops' ->round_rate() prototype

Hi Boris,

Am Freitag, 17. April 2015, 09:29:28 schrieb Boris Brezillon:
> Clock rates are stored in an unsigned long field, but ->round_rate()
> (which returns a rounded rate from a requested one) returns a long
> value (errors are reported using negative error codes), which can lead
> to long overflow if the clock rate exceed 2Ghz.
> 
> Change ->round_rate() prototype to return 0 or an error code, and pass the
> requested rate as a pointer so that it can be adjusted depending on
> hardware capabilities.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@...e-electrons.com>
> ---

On a rk3288-veyron-pinky with the fix described below:
Tested-by: Heiko Stuebner <heiko@...ech.de>


> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index fa5a00e..1462ddc 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -1640,8 +1643,10 @@ static struct clk_core *clk_calc_new_rates(struct
> clk_core *clk, &parent_hw);
>  		parent = parent_hw ? parent_hw->core : NULL;
>  	} else if (clk->ops->round_rate) {
> -		new_rate = clk->ops->round_rate(clk->hw, rate,
> -						&best_parent_rate);
> +		if (clk->ops->round_rate(clk->hw, &new_rate,
> +					 &best_parent_rate))
> +			return NULL;
> +
>  		if (new_rate < min_rate || new_rate > max_rate)
>  			return NULL;
>  	} else if (!parent || !(clk->flags & CLK_SET_RATE_PARENT)) {

This is using new_rate uninitialized when calling into the round_rate
callback. Which in turn pushed my PLLs up to 2.2GHz :-)

I guess you'll need something like the following:

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index db4e4b2..afc7733 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1605,6 +1605,7 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *clk,
 						    &parent_hw);
 		parent = parent_hw ? parent_hw->core : NULL;
 	} else if (clk->ops->round_rate) {
+		new_rate = rate;
 		if (clk->ops->round_rate(clk->hw, &new_rate,
 					 &best_parent_rate))
 			return NULL;




> diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
> index f8d3baf..bd408ef 100644
> --- a/drivers/clk/rockchip/clk-pll.c
> +++ b/drivers/clk/rockchip/clk-pll.c
> @@ -63,8 +63,8 @@ static const struct rockchip_pll_rate_table
> *rockchip_get_pll_settings( return NULL;
>  }
> 
> -static long rockchip_pll_round_rate(struct clk_hw *hw,
> -			    unsigned long drate, unsigned long *prate)
> +static int rockchip_pll_round_rate(struct clk_hw *hw,
> +			    unsigned long *drate, unsigned long *prate)
>  {
>  	struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
>  	const struct rockchip_pll_rate_table *rate_table = pll->rate_table;
> @@ -72,12 +72,15 @@ static long rockchip_pll_round_rate(struct clk_hw *hw,
> 
>  	/* Assumming rate_table is in descending order */
>  	for (i = 0; i < pll->rate_count; i++) {
> -		if (drate >= rate_table[i].rate)
> -			return rate_table[i].rate;
> +		if (*drate >= rate_table[i].rate) {
> +			*drate = rate_table[i].rate;
> +			return 0;
> +		}
>  	}
> 
>  	/* return minimum supported value */
> -	return rate_table[i - 1].rate;
> +	*drate = rate_table[i - 1].rate;
> +	return 0;
>  }
> 
>  /*

The rockchip-part:
Reviewed-by: Heiko Stuebner <heiko@...ech.de>


And as I've stumbled onto this recently too, the clock-maintainership has
expanded to Stephen Boyd and linux-clk@...r.kernel.org .


Heiko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ