Skip to content

Commit dc7d347

Browse files
Fix-Pointraiden00pl
authored andcommitted
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 <[email protected]>
1 parent e58efb1 commit dc7d347

File tree

1 file changed

+1
-1
lines changed
  • arch/x86_64/include/intel64

1 file changed

+1
-1
lines changed

arch/x86_64/include/intel64/irq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static inline uint64_t rdtscp(void)
535535
uint32_t lo;
536536
uint32_t hi;
537537

538-
asm volatile("rdtscp" : "=a" (lo), "=d" (hi)::"memory");
538+
asm volatile("rdtscp" : "=a" (lo), "=d" (hi)::"ecx", "memory");
539539
return (uint64_t)lo | (((uint64_t)hi) << 32);
540540
}
541541

0 commit comments

Comments
 (0)