Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
include/cpu/x86/tsc: Fix rdtsc on x86_64
The used assembler code only work on x86_32. Use the inline function to provide valid rdtsc readings on both x86_32 and x86_64.
Tested on Lenovo T410 with additional x86_64 patches.
Change-Id: Icf706d6fb751372651e5e56d1856ddad688d9fa3 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/include/cpu/x86/tsc.h 1 file changed, 2 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/45702/1
diff --git a/src/include/cpu/x86/tsc.h b/src/include/cpu/x86/tsc.h index 6943b93..87a8761 100644 --- a/src/include/cpu/x86/tsc.h +++ b/src/include/cpu/x86/tsc.h @@ -43,13 +43,8 @@
static inline unsigned long long rdtscll(void) { - unsigned long long val; - asm volatile ( - TSC_SYNC - "rdtsc" - : "=A" (val) - ); - return val; + const tsc_t res = rdtsc(); + return ((unsigned long long)res.lo)|(((unsigned long long)res.hi) << 32); }
static inline uint64_t tsc_to_uint64(tsc_t tstamp)
Michael Niewöhner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
Patch Set 1: Code-Review+1
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
Patch Set 1: Code-Review+1
(1 comment)
https://review.coreboot.org/c/coreboot/+/45702/1/src/include/cpu/x86/tsc.h File src/include/cpu/x86/tsc.h:
https://review.coreboot.org/c/coreboot/+/45702/1/src/include/cpu/x86/tsc.h@4... PS1, Line 47: return ((unsigned long long)res.lo)|(((unsigned long long)res.hi) << 32); Move this down a bit, then use `tsc_to_uint64` ?
return tsc_to_uint64(rdtsc());
Hello build bot (Jenkins), Angel Pons, Michael Niewöhner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/45702
to look at the new patch set (#2).
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
include/cpu/x86/tsc: Fix rdtsc on x86_64
The used assembler code only works on x86_32, but not on x86_64. Use the inline functions to provide valid rdtsc readings on both x86_32 and x86_64.
Tested on Lenovo T410 with additional x86_64 patches.
Change-Id: Icf706d6fb751372651e5e56d1856ddad688d9fa3 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/include/cpu/x86/tsc.h 1 file changed, 5 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/45702/2
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45702/1/src/include/cpu/x86/tsc.h File src/include/cpu/x86/tsc.h:
https://review.coreboot.org/c/coreboot/+/45702/1/src/include/cpu/x86/tsc.h@4... PS1, Line 47: return ((unsigned long long)res.lo)|(((unsigned long long)res.hi) << 32);
Move this down a bit, then use `tsc_to_uint64` ? […]
Done
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
Patch Set 2: Code-Review+2
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
Patch Set 2: Code-Review+1
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/45702 )
Change subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 ......................................................................
include/cpu/x86/tsc: Fix rdtsc on x86_64
The used assembler code only works on x86_32, but not on x86_64. Use the inline functions to provide valid rdtsc readings on both x86_32 and x86_64.
Tested on Lenovo T410 with additional x86_64 patches.
Change-Id: Icf706d6fb751372651e5e56d1856ddad688d9fa3 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/45702 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/include/cpu/x86/tsc.h 1 file changed, 5 insertions(+), 11 deletions(-)
Approvals: build bot (Jenkins): Verified Kyösti Mälkki: Looks good to me, but someone else must approve Angel Pons: Looks good to me, approved
diff --git a/src/include/cpu/x86/tsc.h b/src/include/cpu/x86/tsc.h index 6943b93..ddce96b 100644 --- a/src/include/cpu/x86/tsc.h +++ b/src/include/cpu/x86/tsc.h @@ -41,22 +41,16 @@ tsc->hi = ((a >> 16) * (b >> 16)) + (tsc->hi >> 16); }
-static inline unsigned long long rdtscll(void) -{ - unsigned long long val; - asm volatile ( - TSC_SYNC - "rdtsc" - : "=A" (val) - ); - return val; -} - static inline uint64_t tsc_to_uint64(tsc_t tstamp) { return (((uint64_t)tstamp.hi) << 32) + tstamp.lo; }
+static inline unsigned long long rdtscll(void) +{ + return tsc_to_uint64(rdtsc()); +} + /* Provided by CPU/chipset code for the TSC rate in MHz. */ unsigned long tsc_freq_mhz(void);