diff mbox series

[v2] ARM: virt: Relax arch timer version check during early boot

Message ID 1579527498-31081-1-git-send-email-vladimir.murzin@arm.com (mailing list archive)
State Mainlined
Commit 6849b5eba1965ceb0cad3a75877ef4569dd3638e
Headers show
Series [v2] ARM: virt: Relax arch timer version check during early boot | expand

Commit Message

Vladimir Murzin Jan. 20, 2020, 1:38 p.m. UTC
Updates to the Generic Timer architecture allow ID_PFR1.GenTimer to
have values other than 0 or 1 while still preserving backward
compatibility. At the moment, Linux is quite strict in the way it
handles this field at early boot and will not configure arch timer if
it doesn't find the value 1.

Since here use ubfx for arch timer version extraction (hyb-stub build
with -march=armv7-a, so it is safe)

To help backports (even though the code was correct at the time of writing)
Fixes: 8ec58be9f3ff ("ARM: virt: arch_timers: enable access to physical timers")
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---

Changelog:

    v1 -> v2
       - Clarify that backward compatibility is preserved (per Marc)

 arch/arm/kernel/hyp-stub.S | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Marc Zyngier Jan. 20, 2020, 2:01 p.m. UTC | #1
On 2020-01-20 13:38, Vladimir Murzin wrote:
> Updates to the Generic Timer architecture allow ID_PFR1.GenTimer to
> have values other than 0 or 1 while still preserving backward
> compatibility. At the moment, Linux is quite strict in the way it
> handles this field at early boot and will not configure arch timer if
> it doesn't find the value 1.
> 
> Since here use ubfx for arch timer version extraction (hyb-stub build
> with -march=armv7-a, so it is safe)
> 
> To help backports (even though the code was correct at the time of 
> writing)
> Fixes: 8ec58be9f3ff ("ARM: virt: arch_timers: enable access to physical 
> timers")
> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>

Acked-by: Marc Zyngier <maz@kernel.org>

Feel free to put it into Russell's patch system.

Thanks,

         M.
Vladimir Murzin Jan. 20, 2020, 2:09 p.m. UTC | #2
On 1/20/20 2:01 PM, Marc Zyngier wrote:
> On 2020-01-20 13:38, Vladimir Murzin wrote:
>> Updates to the Generic Timer architecture allow ID_PFR1.GenTimer to
>> have values other than 0 or 1 while still preserving backward
>> compatibility. At the moment, Linux is quite strict in the way it
>> handles this field at early boot and will not configure arch timer if
>> it doesn't find the value 1.
>>
>> Since here use ubfx for arch timer version extraction (hyb-stub build
>> with -march=armv7-a, so it is safe)
>>
>> To help backports (even though the code was correct at the time of writing)
>> Fixes: 8ec58be9f3ff ("ARM: virt: arch_timers: enable access to physical timers")
>> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
> 
> Acked-by: Marc Zyngier <maz@kernel.org>
> 
> Feel free to put it into Russell's patch system.

Patch has been accepted as patch 8955/1

Thanks!

Vladimir

> 
> Thanks,
> 
>         M.
diff mbox series

Patch

diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S
index ae50203..6607fa8 100644
--- a/arch/arm/kernel/hyp-stub.S
+++ b/arch/arm/kernel/hyp-stub.S
@@ -146,10 +146,9 @@  ARM_BE8(orr	r7, r7, #(1 << 25))     @ HSCTLR.EE
 #if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER)
 	@ make CNTP_* and CNTPCT accessible from PL1
 	mrc	p15, 0, r7, c0, c1, 1	@ ID_PFR1
-	lsr	r7, #16
-	and	r7, #0xf
-	cmp	r7, #1
-	bne	1f
+	ubfx	r7, r7, #16, #4
+	teq	r7, #0
+	beq	1f
 	mrc	p15, 4, r7, c14, c1, 0	@ CNTHCTL
 	orr	r7, r7, #3		@ PL1PCEN | PL1PCTEN
 	mcr	p15, 4, r7, c14, c1, 0	@ CNTHCTL