linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] time: sched_clock: fix integer overflow
@ 2013-07-17  9:46 Baruch Siach
  2013-07-29  5:59 ` Baruch Siach
  0 siblings, 1 reply; 4+ messages in thread
From: Baruch Siach @ 2013-07-17  9:46 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner
  Cc: linux-kernel, linux-arm-kernel, linux-xtensa, Baruch Siach

The expression '(1 << 32)' happens to evaluate as 0 on ARM, but it evaluates as
1 on xtensa and x86_64. This zeros sched_clock_mask, and breaks sched_clock().
Set the type of 1 to 'unsigned long long' to get the value we need.

Reported-by: Max Filippov <jcmvbkbc@gmail.com>
Tested-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 kernel/time/sched_clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index a326f27..0b479a6 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
 	BUG_ON(bits > 32);
 	WARN_ON(!irqs_disabled());
 	read_sched_clock = read;
-	sched_clock_mask = (1 << bits) - 1;
+	sched_clock_mask = (1ULL << bits) - 1;
 	cd.rate = rate;
 
 	/* calculate the mult/shift to convert counter ticks to ns. */
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] time: sched_clock: fix integer overflow
  2013-07-17  9:46 [PATCH] time: sched_clock: fix integer overflow Baruch Siach
@ 2013-07-29  5:59 ` Baruch Siach
  2013-07-29 18:41   ` Stephen Boyd
  2013-08-12  3:03   ` [Linux-Xtensa] " Baruch Siach
  0 siblings, 2 replies; 4+ messages in thread
From: Baruch Siach @ 2013-07-29  5:59 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner; +Cc: linux-kernel, linux-arm-kernel, linux-xtensa

Hi Thomas, John,

On Wed, Jul 17, 2013 at 12:46:53PM +0300, Baruch Siach wrote:
> The expression '(1 << 32)' happens to evaluate as 0 on ARM, but it evaluates as
> 1 on xtensa and x86_64. This zeros sched_clock_mask, and breaks sched_clock().
> Set the type of 1 to 'unsigned long long' to get the value we need.

Ping? -rc3 is out, and this bug (which currently breaks xtensa) is not fixed 
yet. Please consider applying.

baruch

> Reported-by: Max Filippov <jcmvbkbc@gmail.com>
> Tested-by: Max Filippov <jcmvbkbc@gmail.com>
> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  kernel/time/sched_clock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
> index a326f27..0b479a6 100644
> --- a/kernel/time/sched_clock.c
> +++ b/kernel/time/sched_clock.c
> @@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
>  	BUG_ON(bits > 32);
>  	WARN_ON(!irqs_disabled());
>  	read_sched_clock = read;
> -	sched_clock_mask = (1 << bits) - 1;
> +	sched_clock_mask = (1ULL << bits) - 1;
>  	cd.rate = rate;
>  
>  	/* calculate the mult/shift to convert counter ticks to ns. */
> -- 

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] time: sched_clock: fix integer overflow
  2013-07-29  5:59 ` Baruch Siach
@ 2013-07-29 18:41   ` Stephen Boyd
  2013-08-12  3:03   ` [Linux-Xtensa] " Baruch Siach
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2013-07-29 18:41 UTC (permalink / raw)
  To: Baruch Siach
  Cc: John Stultz, Thomas Gleixner, linux-xtensa, linux-kernel,
	linux-arm-kernel

On 07/28/13 22:59, Baruch Siach wrote:
> Hi Thomas, John,
>
> On Wed, Jul 17, 2013 at 12:46:53PM +0300, Baruch Siach wrote:
>> The expression '(1 << 32)' happens to evaluate as 0 on ARM, but it evaluates as
>> 1 on xtensa and x86_64. This zeros sched_clock_mask, and breaks sched_clock().
>> Set the type of 1 to 'unsigned long long' to get the value we need.
> Ping? -rc3 is out, and this bug (which currently breaks xtensa) is not fixed 
> yet. Please consider applying.

Looks good to me.

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

>
>> Reported-by: Max Filippov <jcmvbkbc@gmail.com>
>> Tested-by: Max Filippov <jcmvbkbc@gmail.com>
>> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>> ---
>>  kernel/time/sched_clock.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
>> index a326f27..0b479a6 100644
>> --- a/kernel/time/sched_clock.c
>> +++ b/kernel/time/sched_clock.c
>> @@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
>>  	BUG_ON(bits > 32);
>>  	WARN_ON(!irqs_disabled());
>>  	read_sched_clock = read;
>> -	sched_clock_mask = (1 << bits) - 1;
>> +	sched_clock_mask = (1ULL << bits) - 1;
>>  	cd.rate = rate;
>>  
>>  	/* calculate the mult/shift to convert counter ticks to ns. */
>> -- 


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-Xtensa] Re: [PATCH] time: sched_clock: fix integer overflow
  2013-07-29  5:59 ` Baruch Siach
  2013-07-29 18:41   ` Stephen Boyd
@ 2013-08-12  3:03   ` Baruch Siach
  1 sibling, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2013-08-12  3:03 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner; +Cc: linux-xtensa, linux-kernel, linux-arm-kernel

Hi Thomas, John,

On Mon, Jul 29, 2013 at 08:59:39AM +0300, Baruch Siach wrote:
> On Wed, Jul 17, 2013 at 12:46:53PM +0300, Baruch Siach wrote:
> > The expression '(1 << 32)' happens to evaluate as 0 on ARM, but it evaluates as
> > 1 on xtensa and x86_64. This zeros sched_clock_mask, and breaks sched_clock().
> > Set the type of 1 to 'unsigned long long' to get the value we need.
> 
> Ping? -rc3 is out, and this bug (which currently breaks xtensa) is not fixed 
> yet. Please consider applying.

Sorry to bother again, but -rc5 is here and xtensa sched_clock is still 
broken.

baruch

> > Reported-by: Max Filippov <jcmvbkbc@gmail.com>
> > Tested-by: Max Filippov <jcmvbkbc@gmail.com>
> > Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> > ---
> >  kernel/time/sched_clock.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
> > index a326f27..0b479a6 100644
> > --- a/kernel/time/sched_clock.c
> > +++ b/kernel/time/sched_clock.c
> > @@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
> >  	BUG_ON(bits > 32);
> >  	WARN_ON(!irqs_disabled());
> >  	read_sched_clock = read;
> > -	sched_clock_mask = (1 << bits) - 1;
> > +	sched_clock_mask = (1ULL << bits) - 1;
> >  	cd.rate = rate;
> >  
> >  	/* calculate the mult/shift to convert counter ticks to ns. */
> > -- 

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-12  3:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-17  9:46 [PATCH] time: sched_clock: fix integer overflow Baruch Siach
2013-07-29  5:59 ` Baruch Siach
2013-07-29 18:41   ` Stephen Boyd
2013-08-12  3:03   ` [Linux-Xtensa] " Baruch Siach

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).