summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKirill Korotaev <dev@openvz.org>2007-10-17 18:04:33 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2007-11-26 09:42:31 -0800
commit420b463a199d10fc89f41f24fb8c60ed0181b4ad (patch)
treedf8b85ead3d18fef0429477361129cbc2ecb78e4 /include
parent2e6792e31175f12538e49d72c6dc2fd6e3eb2791 (diff)
x86: mark read_crX() asm code as volatile
patch c1217a75ea102d4e69321f210fab60bc47b9a48e in mainline. x86: mark read_crX() asm code as volatile Some gcc versions (I checked at least 4.1.1 from RHEL5 & 4.1.2 from gentoo) can generate incorrect code with read_crX()/write_crX() functions mix up, due to cached results of read_crX(). The small app for x8664 below compiled with -O2 demonstrates this (i686 does the same thing): Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/asm-i386/system.h2
-rw-r--r--include/asm-x86_64/system.h8
2 files changed, 5 insertions, 5 deletions
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index d69ba937e092..b10465542948 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -141,7 +141,7 @@ static inline unsigned long native_read_cr4_safe(void)
{
unsigned long val;
/* This could fault if %cr4 does not exist */
- asm("1: movl %%cr4, %0 \n"
+ asm volatile("1: movl %%cr4, %0 \n"
"2: \n"
".section __ex_table,\"a\" \n"
".long 1b,2b \n"
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index 02175aa1d16a..47682a6520f6 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -85,7 +85,7 @@ static inline void write_cr0(unsigned long val)
static inline unsigned long read_cr2(void)
{
unsigned long cr2;
- asm("movq %%cr2,%0" : "=r" (cr2));
+ asm volatile("movq %%cr2,%0" : "=r" (cr2));
return cr2;
}
@@ -97,7 +97,7 @@ static inline void write_cr2(unsigned long val)
static inline unsigned long read_cr3(void)
{
unsigned long cr3;
- asm("movq %%cr3,%0" : "=r" (cr3));
+ asm volatile("movq %%cr3,%0" : "=r" (cr3));
return cr3;
}
@@ -109,7 +109,7 @@ static inline void write_cr3(unsigned long val)
static inline unsigned long read_cr4(void)
{
unsigned long cr4;
- asm("movq %%cr4,%0" : "=r" (cr4));
+ asm volatile("movq %%cr4,%0" : "=r" (cr4));
return cr4;
}
@@ -121,7 +121,7 @@ static inline void write_cr4(unsigned long val)
static inline unsigned long read_cr8(void)
{
unsigned long cr8;
- asm("movq %%cr8,%0" : "=r" (cr8));
+ asm volatile("movq %%cr8,%0" : "=r" (cr8));
return cr8;
}