diff options
author | Wei Gang <gang.wei@intel.com> | 2011-03-14 17:07:29 +0000 |
---|---|---|
committer | Wei Gang <gang.wei@intel.com> | 2011-03-14 17:07:29 +0000 |
commit | 9f6e5982b48e58ebf9f256843a5178473aec7a65 (patch) | |
tree | 67e63ff51910361efcf175a1784d63479a63048a | |
parent | 37f93e9a115551536436e1f99b371afb1740fda1 (diff) | |
download | xen-9f6e5982b48e58ebf9f256843a5178473aec7a65.tar.gz xen-9f6e5982b48e58ebf9f256843a5178473aec7a65.tar.bz2 xen-9f6e5982b48e58ebf9f256843a5178473aec7a65.zip |
x86: add volatile prefix for cpuid asm clauses
cpuid results are possible to be changed now. For example, changing
CR4.OSXSAVE bit or setting MSR XCR_XFEATURE_ENABLED_MASK may change
XSAVE related cpuid leave return values.
The volatile prefix is required to avoid the second cpuid calls
following some possible changing operations being optimized in
incorrect way by compiler.
The sample bug is in xsave_init while debug=3Dn. The second call to
cpuid_count() may be optimized and lead to a BUG_ON case while compare
xsave_cntxt_size with ebx.
Signed-off-by: Wei Gang <gang.wei@intel.com>
xen-unstable changeset: 23036:9a15ff175e00
xen-unstable date: Mon Mar 14 17:04:42 2011 +0000
-rw-r--r-- | xen/include/asm-x86/processor.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index 78d9278173..b4b3d5cb8b 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -223,7 +223,7 @@ static always_inline void detect_ht(struct cpuinfo_x86 *c) {} * resulting in stale register contents being returned. */ #define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - asm ( "cpuid" \ + asm volatile ( "cpuid" \ : "=a" (*(int *)(_eax)), \ "=b" (*(int *)(_ebx)), \ "=c" (*(int *)(_ecx)), \ @@ -239,7 +239,7 @@ static inline void cpuid_count( unsigned int *ecx, unsigned int *edx) { - asm ( "cpuid" + asm volatile ( "cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "0" (op), "c" (count) ); } @@ -251,7 +251,7 @@ static always_inline unsigned int cpuid_eax(unsigned int op) { unsigned int eax; - asm ( "cpuid" + asm volatile ( "cpuid" : "=a" (eax) : "0" (op) : "bx", "cx", "dx" ); @@ -262,7 +262,7 @@ static always_inline unsigned int cpuid_ebx(unsigned int op) { unsigned int eax, ebx; - asm ( "cpuid" + asm volatile ( "cpuid" : "=a" (eax), "=b" (ebx) : "0" (op) : "cx", "dx" ); @@ -273,7 +273,7 @@ static always_inline unsigned int cpuid_ecx(unsigned int op) { unsigned int eax, ecx; - asm ( "cpuid" + asm volatile ( "cpuid" : "=a" (eax), "=c" (ecx) : "0" (op) : "bx", "dx" ); @@ -284,7 +284,7 @@ static always_inline unsigned int cpuid_edx(unsigned int op) { unsigned int eax, edx; - asm ( "cpuid" + asm volatile ( "cpuid" : "=a" (eax), "=d" (edx) : "0" (op) : "bx", "cx" ); |