trace: comment x86 timestamp() implementations

Fixes genodelabs/genode#4243
This commit is contained in:
Johannes Schlatow 2021-08-13 13:38:57 +02:00 committed by Christian Helmuth
parent 31b049864c
commit 2b0bb6dda0
2 changed files with 13 additions and 7 deletions

View File

@ -26,16 +26,19 @@ namespace Genode { namespace Trace {
{
uint64_t t;
__asm__ __volatile__ (
"pushl %%ebx\n\t"
"xorl %%eax,%%eax\n\t"
"cpuid\n\t"
"pushl %%ebx\n\t" /* ebx is reserved in PIC mode, but clobbered by cpuid */
"xorl %%eax,%%eax\n\t" /* provide constant argument to cpuid to reduce variance */
"cpuid\n\t" /* synchronise, i.e. finish all preceeding instructions */
"popl %%ebx\n\t"
:
:
: "%eax", "%ecx", "%edx"
);
__asm__ __volatile__ (
"rdtsc" : "=A" (t)
"rdtsc"
: "=A" (t)
:
: "memory" /* prevent reordering of asm statements */
);
return t;

View File

@ -27,14 +27,17 @@ namespace Genode { namespace Trace {
{
uint32_t lo, hi;
__asm__ __volatile__ (
"xorl %%eax,%%eax\n\t"
"cpuid\n\t"
"xorl %%eax,%%eax\n\t" /* provide constant argument to cpuid to reduce variance */
"cpuid\n\t" /* synchronise, i.e. finish all preceeding instructions */
:
:
: "%rax", "%rbx", "%rcx", "%rdx"
);
__asm__ __volatile__ (
"rdtsc" : "=a" (lo), "=d" (hi)
"rdtsc"
: "=a" (lo), "=d" (hi)
:
: "memory" /* prevent reordering of asm statements */
);
return (uint64_t)hi << 32 | lo;