arch/x86_64: Fix wrong RDTSCP implementation
RDTSCP instruction reads the current value of the processor’s time-stamp counter (a 64-bit MSR) into the EDX:EAX registers, and it also reads the value of the IA32_TSC_AUX MSR (address C0000103H) into the ECX register. However, the current RDTSCP implementation does not provide a hint for the compiler that ECX has been changed, resulting in register corrupted and subtle errors. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
parent
e58efb17cc
commit
dc7d3470e6
|
@ -535,7 +535,7 @@ static inline uint64_t rdtscp(void)
|
|||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
|
||||
asm volatile("rdtscp" : "=a" (lo), "=d" (hi)::"memory");
|
||||
asm volatile("rdtscp" : "=a" (lo), "=d" (hi)::"ecx", "memory");
|
||||
return (uint64_t)lo | (((uint64_t)hi) << 32);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue