public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Glauber de Oliveira Costa <gcosta@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, rusty@rustcorp.com.au, ak@suse.de,
	mingo@elte.hu, chrisw@sous-sol.org, jeremy@goop.org,
	avi@qumranet.com, anthony@codemonkey.ws,
	virtualization@lists.linux-foundation.org, lguest@ozlabs.org,
	glommer@gmail.com, Glauber de Oliveira Costa <gcosta@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 5/25 -v2] native versions for system.h functions
Date: Fri, 10 Aug 2007 16:12:17 -0300	[thread overview]
Message-ID: <11867731831138-git-send-email-gcosta@redhat.com> (raw)
In-Reply-To: <11867731781610-git-send-email-gcosta@redhat.com>

This patch adds the native hook for the functions in system.h
They are the read/write_crX, clts and wbinvd. The later, also
gets its call sites patched.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86_64/kernel/tce.c    |    2 +-
 arch/x86_64/mm/pageattr.c   |    2 +-
 include/asm-x86_64/system.h |   54 +++++++++++++++++++++++++++++-------------
 3 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/arch/x86_64/kernel/tce.c b/arch/x86_64/kernel/tce.c
index e3f2569..587f0c2 100644
--- a/arch/x86_64/kernel/tce.c
+++ b/arch/x86_64/kernel/tce.c
@@ -42,7 +42,7 @@ static inline void flush_tce(void* tceaddr)
 	if (cpu_has_clflush)
 		asm volatile("clflush (%0)" :: "r" (tceaddr));
 	else
-		asm volatile("wbinvd":::"memory");
+		wbinvd();
 }
 
 void tce_build(struct iommu_table *tbl, unsigned long index,
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
index 7e161c6..b497afd 100644
--- a/arch/x86_64/mm/pageattr.c
+++ b/arch/x86_64/mm/pageattr.c
@@ -76,7 +76,7 @@ static void flush_kernel_map(void *arg)
 	/* When clflush is available always use it because it is
 	   much cheaper than WBINVD. */
 	if (!cpu_has_clflush)
-		asm volatile("wbinvd" ::: "memory");
+		wbinvd();
 	else list_for_each_entry(pg, l, lru) {
 		void *adr = page_address(pg);
 		cache_flush_page(adr);
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index 02175aa..20ed9df 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -68,53 +68,56 @@ extern void load_gs_index(unsigned);
 /*
  * Clear and set 'TS' bit respectively
  */
-#define clts() __asm__ __volatile__ ("clts")
+static inline void native_clts(void)
+{
+	asm volatile ("clts");
+}
 
-static inline unsigned long read_cr0(void)
-{ 
+static inline unsigned long native_read_cr0(void)
+{
 	unsigned long cr0;
 	asm volatile("movq %%cr0,%0" : "=r" (cr0));
 	return cr0;
 }
 
-static inline void write_cr0(unsigned long val) 
-{ 
+static inline void native_write_cr0(unsigned long val)
+{
 	asm volatile("movq %0,%%cr0" :: "r" (val));
 }
 
-static inline unsigned long read_cr2(void)
+static inline unsigned long native_read_cr2(void)
 {
 	unsigned long cr2;
 	asm("movq %%cr2,%0" : "=r" (cr2));
 	return cr2;
 }
 
-static inline void write_cr2(unsigned long val)
+static inline void native_write_cr2(unsigned long val)
 {
 	asm volatile("movq %0,%%cr2" :: "r" (val));
 }
 
-static inline unsigned long read_cr3(void)
-{ 
+static inline unsigned long native_read_cr3(void)
+{
 	unsigned long cr3;
 	asm("movq %%cr3,%0" : "=r" (cr3));
 	return cr3;
 }
 
-static inline void write_cr3(unsigned long val)
+static inline void native_write_cr3(unsigned long val)
 {
 	asm volatile("movq %0,%%cr3" :: "r" (val) : "memory");
 }
 
-static inline unsigned long read_cr4(void)
-{ 
+static inline unsigned long native_read_cr4(void)
+{
 	unsigned long cr4;
 	asm("movq %%cr4,%0" : "=r" (cr4));
 	return cr4;
 }
 
-static inline void write_cr4(unsigned long val)
-{ 
+static inline void native_write_cr4(unsigned long val)
+{
 	asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
 }
 
@@ -130,10 +133,27 @@ static inline void write_cr8(unsigned long val)
 	asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
 }
 
-#define stts() write_cr0(8 | read_cr0())
+static inline void native_wbinvd(void)
+{
+	asm volatile ("wbinvd" ::: "memory");
+}
 
-#define wbinvd() \
-	__asm__ __volatile__ ("wbinvd": : :"memory")
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else
+#define clts		native_clts
+#define wbinvd		native_wbinvd
+#define read_cr0 	native_read_cr0
+#define read_cr2 	native_read_cr2
+#define read_cr3 	native_read_cr3
+#define read_cr4 	native_read_cr4
+#define write_cr0	native_write_cr0
+#define write_cr2	native_write_cr2
+#define write_cr3	native_write_cr3
+#define write_cr4	native_write_cr4
+#endif
+
+#define stts() write_cr0(8 | read_cr0())
 
 #endif	/* __KERNEL__ */
 
-- 
1.4.4.2


  reply	other threads:[~2007-08-10 22:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-10 19:12 [PATCH 0/25 -v2] paravirt_ops for x86_64, second round Glauber de Oliveira Costa
2007-08-10 19:12 ` [PATCH 1/25 -v2] header file move Glauber de Oliveira Costa
2007-08-10 19:12   ` [PATCH 2/25 -v2] tlb flushing routines Glauber de Oliveira Costa
2007-08-10 19:12     ` [PATCH 3/25 -v2] irq_flags / halt routines Glauber de Oliveira Costa
2007-08-10 19:12       ` [PATCH 4/25 -v2] Add debugreg/load_rsp native hooks Glauber de Oliveira Costa
2007-08-10 19:12         ` Glauber de Oliveira Costa [this message]
2007-08-10 19:12           ` [PATCH 6/25 -v2] add native_apic read and write functions, as well as boot clocks ones Glauber de Oliveira Costa
2007-08-10 19:12             ` [PATCH 7/25 -v2] interrupt related native paravirt functions Glauber de Oliveira Costa
2007-08-10 19:12               ` [PATCH 8/25 -v2] use macro for sti/cli in spinlock definitions Glauber de Oliveira Costa
2007-08-10 19:12                 ` [PATCH 9/25 -v2] report ring kernel is running without paravirt Glauber de Oliveira Costa
2007-08-10 19:12                   ` [PATCH 10/25 -v2] export math_state_restore Glauber de Oliveira Costa
2007-08-10 19:12                     ` [PATCH 11/25 -v2] native versions for set pagetables Glauber de Oliveira Costa
2007-08-10 19:12                       ` [PATCH 12/25 -v2] turn msr.h functions into native versions Glauber de Oliveira Costa
2007-08-10 19:12                         ` [PATCH 13/25 -v2] add native functions for descriptors handling Glauber de Oliveira Costa
2007-08-10 19:12                           ` [PATCH 14/25 -v2] get rid of inline asm for load_cr3 Glauber de Oliveira Costa
2007-08-10 19:12                             ` [PATCH 15/25 -v2] introducing paravirt_activate_mm Glauber de Oliveira Costa
2007-08-10 19:12                               ` [PATCH 16/25 -v2] turn page operations into native versions Glauber de Oliveira Costa
2007-08-10 19:12                                 ` [PATCH 17/25 -v2] introduce paravirt_release_pgd() Glauber de Oliveira Costa
2007-08-10 19:12                                   ` [PATCH 18/25 -v2] turn priviled operations into macros in entry.S Glauber de Oliveira Costa
2007-08-10 19:12                                     ` [PATCH 19/25 -v2] time-related functions paravirt provisions Glauber de Oliveira Costa
2007-08-10 19:12                                       ` [PATCH 20/25 -v2] replace syscall_init Glauber de Oliveira Costa
2007-08-10 19:12                                         ` [PATCH 21/25 -v2] export cpu_gdt_descr Glauber de Oliveira Costa
2007-08-10 19:12                                           ` [PATCH 22/25 -v2] turn priviled operation into a macro Glauber de Oliveira Costa
2007-08-10 19:12                                             ` [PATCH 23/25 -v2] provide paravirt patching function Glauber de Oliveira Costa
2007-08-10 19:12                                               ` [PATCH 24/25 -v2] paravirt hooks for arch initialization Glauber de Oliveira Costa
2007-08-10 19:12                                                 ` [PATCH 25/25 -v2] add paravirtualization support for x86_64 Glauber de Oliveira Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11867731831138-git-send-email-gcosta@redhat.com \
    --to=gcosta@redhat.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=anthony@codemonkey.ws \
    --cc=avi@qumranet.com \
    --cc=chrisw@sous-sol.org \
    --cc=glommer@gmail.com \
    --cc=jeremy@goop.org \
    --cc=lguest@ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox