arm64: zero cntvoff_el2
PATCH 1/1 arm64: zero cntvoff_el2
Currently cntvoff_el2 is initialised with an arbitrary bag of bits derived from the initial value of cnthctl_el2 on the current CPU. This is somewhat odd and problematic as some of these bits are UNKNOWN at reset and may differ across CPUs (which may cause an OS at EL1 to observe time going backwards across CPUs).
This patch instead initialises cntvoff_el2 with xzr, giving the register a consistent value of zero on all CPUs.
--- arch/arm/cpu/armv8/transition.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/transition.S +1 -1
@@ -43,7 +43,7 @@ ENTRY(armv8_switch_to_el1) mrs x0, cnthctl_el2 orr x0, x0, #0x3 /* Enable EL1 access to timers */ msr cnthctl_el2, x0 - msr cntvoff_el2, x0 + msr cntvoff_el2, xzr mrs x0, cntkctl_el1 orr x0, x0, #0x3 /* Enable EL0 access to timers */ msr cntkctl_el1, x0
Signature · 1 line
1.9.1
PATCH 1/1 arm64: zero cntvoff_el2
Quoted 36 lines
Currently
cntvoff_el2is initialised with an arbitrary bag of bits derived from the initial value ofcnthctl_el2on the current CPU. This is somewhat odd and problematic as some of these bits are UNKNOWN at reset and may differ across CPUs (which may cause an OS at EL1 to observe time going backwards across CPUs).This patch instead initialises
cntvoff_el2with xzr, giving the register a consistent value of zero on all CPUs.Signed-off-by Mark Rutland <[email protected]>Acked-by Marc Zyngier <[email protected]>Acked-by Catalin Marinas <[email protected]>Cc Scott Wood <[email protected]>Cc David Feng <[email protected]>Cc Tom Rini <[email protected]>---
arch/arm/cpu/armv8/transition.S| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/cpu/armv8/transition.S +1
-1@@ -43,7 +43,7 @@ ENTRY(armv8_switch_to_el1) mrs x0, cnthctl_el2 orr x0, x0, #0x3 /* Enable EL1 access to timers */ msr cnthctl_el2, x0 - msr cntvoff_el2, x0 + msr cntvoff_el2, xzr mrs x0, cntkctl_el1 orr x0, x0, #0x3 /* Enable EL0 access to timers */ msr cntkctl_el1, x0Signature · 1 line
1.9.1
PATCH 1/1 arm64: zero cntvoff_el2
In reply to Mark RutlandHi Mark,
Quoted 24 lines · Mark Rutland
Currently
cntvoff_el2is initialised with an arbitrary bag of bits derived from the initial value ofcnthctl_el2on the current CPU. This is somewhat odd and problematic as some of these bits are UNKNOWN at reset and may differ across CPUs (which may cause an OS at EL1 to observe time going backwards across CPUs).This patch instead initialises
cntvoff_el2with xzr, giving the register a consistent value of zero on all CPUs.Signed-off-by Mark Rutland <[email protected]>Acked-by Marc Zyngier <[email protected]>Acked-by Catalin Marinas <[email protected]>Cc Scott Wood <[email protected]>Cc David Feng <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/cpu/armv8/transition.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/cpu/armv8/transition.S +0
-0
arch/arm/cpu/armv8/transition.S ENTRY(armv8_switch_to_el1) · line 49
Quoted 8 lines
arch/arm/cpu/armv8/transition.S +1
-1@@ -43,7 +43,7 @@ ENTRY(armv8_switch_to_el1) mrs x0, cnthctl_el2 orr x0, x0, #0x3 /* Enable EL1 access to timers */ msr cnthctl_el2, x0 - msr cntvoff_el2, x0 + msr cntvoff_el2, xzr mrs x0, cntkctl_el1 orr x0, x0, #0x3 /* Enable EL0 access to timers */ msr cntkctl_el1, x0
Applied as a bug fix to u-boot-arm/master, thanks!
Amicalement,
Signature · 1 line
Albert.