login
Header Space

 
 

[PATCH] [33/35] x86_64: Remove duplicated code for reading control registers

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Glauber de Oliveira Costa <gcosta@...>, <linux-kernel@...>, <patches@...>
Date: Saturday, April 28, 2007 - 1:52 pm

From: Glauber de Oliveira Costa <gcosta@redhat.com>

On Tue, Mar 13, 2007 at 05:33:09AM -0700, Randy.Dunlap wrote:
thanks. Attached now

-- 
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"


Signed-off-by: Andi Kleen <ak@suse.de>

---

 include/asm-x86_64/system.h   |    7 ++++++-
 include/asm-x86_64/tlbflush.h |   33 +++++----------------------------
 2 files changed, 11 insertions(+), 29 deletions(-)

2d19cf472903fa4c9e763301b7b1cc0fa53bd023
Index: linux/include/asm-x86_64/system.h
===================================================================
--- linux.orig/include/asm-x86_64/system.h
+++ linux/include/asm-x86_64/system.h
@@ -89,6 +89,11 @@ static inline unsigned long read_cr3(voi
 	return cr3;
 } 
 
+static inline void write_cr3(unsigned long val)
+{
+	asm volatile("movq %0,%%cr3" :: "r" (val) : "memory");
+}
+
 static inline unsigned long read_cr4(void)
 { 
 	unsigned long cr4;
@@ -98,7 +103,7 @@ static inline unsigned long read_cr4(voi
 
 static inline void write_cr4(unsigned long val)
 { 
-	asm volatile("movq %0,%%cr4" :: "r" (val));
+	asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
 } 
 
 #define stts() write_cr0(8 | read_cr0())
Index: linux/include/asm-x86_64/tlbflush.h
===================================================================
--- linux.orig/include/asm-x86_64/tlbflush.h
+++ linux/include/asm-x86_64/tlbflush.h
@@ -3,41 +3,18 @@
 
 #include <linux/mm.h>
 #include <asm/processor.h>
-
-static inline unsigned long get_cr3(void)
-{
-	unsigned long cr3;
-	asm volatile("mov %%cr3,%0" : "=r" (cr3));
-	return cr3;
-}
-
-static inline void set_cr3(unsigned long cr3)
-{
-	asm volatile("mov %0,%%cr3" :: "r" (cr3) : "memory");
-}
+#include <asm/system.h>
 
 static inline void __flush_tlb(void)
 {
-	set_cr3(get_cr3());
-}
-
-static inline unsigned long get_cr4(void)
-{
-	unsigned long cr4;
-	asm volatile("mov %%cr4,%0" : "=r" (cr4));
-	return cr4;
-}
-
-static inline void set_cr4(unsigned long cr4)
-{
-	asm volatile("mov %0,%%cr4" :: "r" (cr4) : "memory");
+	write_cr3(read_cr3());
 }
 
 static inline void __flush_tlb_all(void)
 {
-	unsigned long cr4 = get_cr4();
-	set_cr4(cr4 & ~X86_CR4_PGE);	/* clear PGE */
-	set_cr4(cr4);			/* write old PGE again and flush TLBs */
+	unsigned long cr4 = read_cr4();
+	write_cr4(cr4 & ~X86_CR4_PGE);	/* clear PGE */
+	write_cr4(cr4);			/* write old PGE again and flush TLBs */
 }
 
 #define __flush_tlb_one(addr) \
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [14/35] i386: mtrr range check correction, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [15/35] i386: pit_latch_buggy has no effect, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [12/35] x86: consolidate smp_send_stop(), Andi Kleen, (Sat Apr 28, 1:52 pm)
Re: [patches] [PATCH] [8/35] x86_64: a memcpy that tries to ..., Bryan O'Sullivan, (Mon Apr 30, 12:14 pm)
[PATCH] [33/35] x86_64: Remove duplicated code for reading c..., Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [32/35] x86_64: Remove unused set_seg_base, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [30/35] i386: clean up mach_reboot_fixups, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [24/35] i386: Add __init to probe_bigsmp, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [21/35] x86_64: Some cleanup in time.c, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [17/35] i386: probe_roms() cleanup, Andi Kleen, (Sat Apr 28, 1:52 pm)
[PATCH] [6/35] x86_64: remove clustered APIC mode, Andi Kleen, (Sat Apr 28, 1:52 pm)
speck-geostationary