xen/arm: time: cycles_t should be an uint64_t and not unsigned long
PATCH 1/1 xen/arm: time: cycles_t should be an uint64_t and not unsigned long
Since commit ca73ac8e7d "xen/arm: Add an isb() before reading CNTPCT_EL0 to prevent re-ordering", get_cycles() is now returning the number of cycles and used in more callers.
While the counter registers is always 64-bit, get_cycles() will only reutrn a 32-bit on Arm32 and therefore truncate the value. This will result to weird behavior by both Xen and the Guest as the timer will not be setup correctly.
This could be resolved by switch cycles_t from unsigned long to unsigned int.
---
This is only targeting xen 4.11 and earlier. Xen 4.12 and later have a correct definition of cycles_t thanks to da3d55ae67 "console:
avoid printing no or null time stamps".
This will hopefully unblock osstest on staging-4.10 and staging-4.11. This patch should be backported up to Xen 4.8.
--- xen/include/asm-arm/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-arm/time.h +1 -1
@@ -7,7 +7,7 @@DT_MATCH_COMPATIBLE ("arm,armv7-timer" ), \ DT_MATCH_COMPATIBLE("arm,armv8-timer") -typedef unsigned long cycles_t ; +typedef uint64_t cycles_t ;static inline cycles_t get_cycles (void ) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Julien Grall
Since commit
ca73ac8e7d"xen/arm: Add anisb()before readingCNTPCT_EL0to prevent re-ordering",get_cycles()is now returning the number of cycles and used in more callers.While the counter registers is always 64-bit,
get_cycles()will only reutrn a 32-bit on Arm32 and therefore truncate the value. This will
"return 32 bits"
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Julien Grall
Since commit
ca73ac8e7d"xen/arm: Add anisb()before readingCNTPCT_EL0to prevent re-ordering",get_cycles()is now returning the number of cycles and used in more callers.While the counter registers is always 64-bit,
get_cycles()will only reutrn a 32-bit on Arm32 and therefore truncate the value. This will"return 32 bits"
Yes, sorry Stefano committed without this change.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Julien Grall
Since commit
ca73ac8e7d"xen/arm: Add anisb()before readingCNTPCT_EL0to prevent re-ordering",get_cycles()is now returning the number of cycles and used in more callers.While the counter registers is always 64-bit,
get_cycles()will only reutrn a 32-bit on Arm32 and therefore truncate the value. This will result to weird behavior by both Xen and the Guest as the timer will not be setup correctly.
Quoted 4 lines
This could be resolved by switch
cycles_tfrom unsigned long to unsigned int.Signed-off-by Julien Grall <[email protected]>
I'll commit adding a reference to da3d55ae67225798c2ad8f42af2f432f6f2b2214 in the commit message.
Quoted 27 lines
---
This is only targeting xen 4.11 and earlier. Xen 4.12 and later have a correct definition ofcycles_tthanks toda3d55ae67"console:
avoid printing no or null time stamps".This will hopefully unblock osstest on staging-4.10 and staging-4.11. This patch should be backported up to Xen 4.8.
--- xen/include/asm-arm/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/include/asm-arm/time.h +1
-1@@ -7,7 +7,7 @@DT_MATCH_COMPATIBLE ("arm,armv7-timer" ), \ DT_MATCH_COMPATIBLE("arm,armv8-timer") -typedef unsigned long cycles_t ; +typedef uint64_t cycles_t ;static inline cycles_t get_cycles (void ) {Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel