diff mbox

clocksource: arch_timer: Only use the virtual counter (CNTVCT) on arm64

Message ID 1418209329-28615-1-git-send-email-catalin.marinas@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Catalin Marinas Dec. 10, 2014, 11:02 a.m. UTC
Commit 0b46b8a718c6 (clocksource: arch_timer: Fix code to use physical
timers when requested) introduces the use of physical counters in the
ARM architected timer driver. However, he arm64 kernel uses CNTVCT in
VDSO. When booting in EL2, the kernel switches to the physical timers to
make things easier for KVM but it continues to use the virtual counter
both in user and kernel. While in such scenario CNTVCT == CNTPCT (since
CNTVOFF is initialised by the kernel to 0), we want to spot firmware
bugs corrupting CNTVOFF early (which would affect CNTVCT).

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
---

Daniel,

Do you plan to take this patch and push into mainline (ideally before -rc1)?
Otherwise we can push it via the arm64 tree.

Thanks,

Catalin


 drivers/clocksource/arm_arch_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Lezcano Dec. 10, 2014, 11:04 a.m. UTC | #1
On 12/10/2014 12:02 PM, Catalin Marinas wrote:
> Commit 0b46b8a718c6 (clocksource: arch_timer: Fix code to use physical
> timers when requested) introduces the use of physical counters in the
> ARM architected timer driver. However, he arm64 kernel uses CNTVCT in
> VDSO. When booting in EL2, the kernel switches to the physical timers to
> make things easier for KVM but it continues to use the virtual counter
> both in user and kernel. While in such scenario CNTVCT == CNTPCT (since
> CNTVOFF is initialised by the kernel to 0), we want to spot firmware
> bugs corrupting CNTVOFF early (which would affect CNTVCT).
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>
> Daniel,
>
> Do you plan to take this patch and push into mainline (ideally before -rc1)?
> Otherwise we can push it via the arm64 tree.

I will take care of it.

Thanks !

   -- Daniel

>
> Thanks,
>
> Catalin
>
>
>   drivers/clocksource/arm_arch_timer.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index 6a79fc4f900c..095c1774592c 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -462,7 +462,7 @@ static void __init arch_counter_register(unsigned type)
>
>   	/* Register the CP15 based counter if we have one */
>   	if (type & ARCH_CP15_TIMER) {
> -		if (arch_timer_use_virtual)
> +		if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual)
>   			arch_timer_read_counter = arch_counter_get_cntvct;
>   		else
>   			arch_timer_read_counter = arch_counter_get_cntpct;
>
Catalin Marinas Dec. 10, 2014, 11:23 a.m. UTC | #2
On Wed, Dec 10, 2014 at 11:04:38AM +0000, Daniel Lezcano wrote:
> On 12/10/2014 12:02 PM, Catalin Marinas wrote:
> > Commit 0b46b8a718c6 (clocksource: arch_timer: Fix code to use physical
> > timers when requested) introduces the use of physical counters in the
> > ARM architected timer driver. However, he arm64 kernel uses CNTVCT in
> > VDSO. When booting in EL2, the kernel switches to the physical timers to
> > make things easier for KVM but it continues to use the virtual counter
> > both in user and kernel. While in such scenario CNTVCT == CNTPCT (since
> > CNTVOFF is initialised by the kernel to 0), we want to spot firmware
> > bugs corrupting CNTVOFF early (which would affect CNTVCT).
> >
> > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> > Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > ---
> >
> > Daniel,
> >
> > Do you plan to take this patch and push into mainline (ideally before -rc1)?
> > Otherwise we can push it via the arm64 tree.
> 
> I will take care of it.

Thanks.
Mark Rutland Dec. 15, 2014, 10:58 a.m. UTC | #3
Hi Daniel,

On Wed, Dec 10, 2014 at 11:04:38AM +0000, Daniel Lezcano wrote:
> On 12/10/2014 12:02 PM, Catalin Marinas wrote:
> > Commit 0b46b8a718c6 (clocksource: arch_timer: Fix code to use physical
> > timers when requested) introduces the use of physical counters in the
> > ARM architected timer driver. However, he arm64 kernel uses CNTVCT in
> > VDSO. When booting in EL2, the kernel switches to the physical timers to
> > make things easier for KVM but it continues to use the virtual counter
> > both in user and kernel. While in such scenario CNTVCT == CNTPCT (since
> > CNTVOFF is initialised by the kernel to 0), we want to spot firmware
> > bugs corrupting CNTVOFF early (which would affect CNTVCT).
> >
> > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> > Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > ---
> >
> > Daniel,
> >
> > Do you plan to take this patch and push into mainline (ideally before -rc1)?
> > Otherwise we can push it via the arm64 tree.
> 
> I will take care of it.
> 
> Thanks !
> 
>    -- Daniel

What's the state of this patch?

It doesn't seem to be in linux-next (next-20141215), which is failing to
boot for me due to hitting the BUG in the arm64 arch_counter_get_cntpct.

Thanks,
Mark.

> 
> >
> > Thanks,
> >
> > Catalin
> >
> >
> >   drivers/clocksource/arm_arch_timer.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> > index 6a79fc4f900c..095c1774592c 100644
> > --- a/drivers/clocksource/arm_arch_timer.c
> > +++ b/drivers/clocksource/arm_arch_timer.c
> > @@ -462,7 +462,7 @@ static void __init arch_counter_register(unsigned type)
> >
> >   	/* Register the CP15 based counter if we have one */
> >   	if (type & ARCH_CP15_TIMER) {
> > -		if (arch_timer_use_virtual)
> > +		if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual)
> >   			arch_timer_read_counter = arch_counter_get_cntvct;
> >   		else
> >   			arch_timer_read_counter = arch_counter_get_cntpct;
> >
> 
> 
> -- 
>   <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Daniel Lezcano Dec. 15, 2014, 1:27 p.m. UTC | #4
Hi Olof, Arnd,

Do you mind to apply this patch ?

I was about to take care of it but it depends on the commit:

https://git.kernel.org/cgit/linux/kernel/git/arm/arm-soc.git/commit/drivers/clocksource?h=for-next&id=0b46b8a718c6e90910a1b1b0fe797be3c167e186

Thanks
   -- Daniel



On 12/15/2014 11:58 AM, Mark Rutland wrote:
> Hi Daniel,
>
> On Wed, Dec 10, 2014 at 11:04:38AM +0000, Daniel Lezcano wrote:
>> On 12/10/2014 12:02 PM, Catalin Marinas wrote:
>>> Commit 0b46b8a718c6 (clocksource: arch_timer: Fix code to use physical
>>> timers when requested) introduces the use of physical counters in the
>>> ARM architected timer driver. However, he arm64 kernel uses CNTVCT in
>>> VDSO. When booting in EL2, the kernel switches to the physical timers to
>>> make things easier for KVM but it continues to use the virtual counter
>>> both in user and kernel. While in such scenario CNTVCT == CNTPCT (since
>>> CNTVOFF is initialised by the kernel to 0), we want to spot firmware
>>> bugs corrupting CNTVOFF early (which would affect CNTVCT).
>>>
>>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>>> Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
>>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>>> ---
>>>
>>> Daniel,
>>>
>>> Do you plan to take this patch and push into mainline (ideally before -rc1)?
>>> Otherwise we can push it via the arm64 tree.
>>
>> I will take care of it.
>>
>> Thanks !
>>
>>     -- Daniel
>
> What's the state of this patch?
>
> It doesn't seem to be in linux-next (next-20141215), which is failing to
> boot for me due to hitting the BUG in the arm64 arch_counter_get_cntpct.
>
> Thanks,
> Mark.
>
>>
>>>
>>> Thanks,
>>>
>>> Catalin
>>>
>>>
>>>    drivers/clocksource/arm_arch_timer.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
>>> index 6a79fc4f900c..095c1774592c 100644
>>> --- a/drivers/clocksource/arm_arch_timer.c
>>> +++ b/drivers/clocksource/arm_arch_timer.c
>>> @@ -462,7 +462,7 @@ static void __init arch_counter_register(unsigned type)
>>>
>>>    	/* Register the CP15 based counter if we have one */
>>>    	if (type & ARCH_CP15_TIMER) {
>>> -		if (arch_timer_use_virtual)
>>> +		if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual)
>>>    			arch_timer_read_counter = arch_counter_get_cntvct;
>>>    		else
>>>    			arch_timer_read_counter = arch_counter_get_cntpct;
>>>
>>
>>
>> --
>>    <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs
>>
>> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
>> <http://twitter.com/#!/linaroorg> Twitter |
>> <http://www.linaro.org/linaro-blog/> Blog
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff mbox

Patch

diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 6a79fc4f900c..095c1774592c 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -462,7 +462,7 @@  static void __init arch_counter_register(unsigned type)
 
 	/* Register the CP15 based counter if we have one */
 	if (type & ARCH_CP15_TIMER) {
-		if (arch_timer_use_virtual)
+		if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual)
 			arch_timer_read_counter = arch_counter_get_cntvct;
 		else
 			arch_timer_read_counter = arch_counter_get_cntpct;