r205778 - intrin.h: Fix up bugs in the cr3 and msr intrinsics
Reid Kleckner
reid at kleckner.net
Tue Apr 8 10:49:16 PDT 2014
Author: rnk
Date: Tue Apr 8 12:49:16 2014
New Revision: 205778
URL: http://llvm.org/viewvc/llvm-project?rev=205778&view=rev
Log:
intrin.h: Fix up bugs in the cr3 and msr intrinsics
Don't include input and output regs in clobbers. Prefix some
identifiers with __. Add a memory constraint to __readcr3 to prevent
reordering. This constraint is heavy handed, but conservatively
correct.
Thanks to PaX Team for the suggestions.
Modified:
cfe/trunk/lib/Headers/Intrin.h
Modified: cfe/trunk/lib/Headers/Intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/Intrin.h?rev=205778&r1=205777&r2=205778&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/Intrin.h (original)
+++ cfe/trunk/lib/Headers/Intrin.h Tue Apr 8 12:49:16 2014
@@ -997,23 +997,20 @@ __readmsr(unsigned long __register) {
// undefined.
unsigned long __edx;
unsigned long __eax;
- __asm__ ("rdmsr"
- : "=d"(__edx), "=a"(__eax)
- : "c"(__register)
- : "%ecx", "%edx", "%eax");
+ __asm__ ("rdmsr" : "=d"(__edx), "=a"(__eax) : "c"(__register));
return (((unsigned __int64)__edx) << 32) | (unsigned __int64)__eax;
}
static __inline__ unsigned long __attribute__((always_inline, __nodebug__))
__readcr3(void) {
- unsigned long value;
- __asm__ __volatile__("mov %%cr3, %0" : "=q"(value));
- return value;
+ unsigned long __cr3_val;
+ __asm__ __volatile__ ("mov %%cr3, %0" : "=q"(__cr3_val) : : "memory");
+ return __cr3_val;
}
static __inline__ void __attribute__((always_inline, __nodebug__))
-__writecr3(unsigned int Data) {
- __asm__("mov %0, %%cr3" : : "q"(Data) : "memory");
+__writecr3(unsigned int __cr3_val) {
+ __asm__ ("mov %0, %%cr3" : : "q"(__cr3_val) : "memory");
}
#ifdef __cplusplus
More information about the cfe-commits
mailing list