:: commit b7897f857fcaee0d996e49a351891835dd0cd9b7

Mintsuki <mintsuki@protonmail.com> — 2026-02-23 16:35

parents: 9456dcb1d9

sys/cpu: Add memory clobber to rdtsc inline assembly

diff --git a/common/sys/cpu.h b/common/sys/cpu.h
index e6099053..1d445b83 100644
--- a/common/sys/cpu.h
+++ b/common/sys/cpu.h
@@ -156,7 +156,7 @@ static inline void wrmsr(uint32_t msr, uint64_t value) {
 
 static inline uint64_t rdtsc(void) {
     uint32_t edx, eax;
-    asm volatile ("rdtsc" : "=a" (eax), "=d" (edx));
+    asm volatile ("rdtsc" : "=a" (eax), "=d" (edx) :: "memory");
     return ((uint64_t)edx << 32) | eax;
 }
 
tab: 248 wrap: offon