public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Marcelo Tosatti
	<mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [patch 3/4] paravirt: set_access_flags/set_wrprotect should use paravirt interface
Date: Wed, 30 Jan 2008 16:26:23 -0500	[thread overview]
Message-ID: <20080130213608.562741627@harmony.lab.boston.redhat.com> (raw)
In-Reply-To: 20080130212620.272364704@harmony.lab.boston.redhat.com

[-- Attachment #1: pte-access-paravirt --]
[-- Type: text/plain, Size: 2480 bytes --]

ptep_set_access_flags and ptep_set_wrprotect are doing direct pte
updates ignoring the paravirt interface.

The wrprotect change is especially important since it allows full
batching of fork() on COW mappings.

There are still a few PTE update interfaces bypassing paravirt, such as
ptep_get_and_clear_full and ptep_get_and_clear.


Signed-off-by: Marcelo Tosatti <mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Index: linux-2.6-x86-kvm/include/asm-x86/paravirt.h
===================================================================
--- linux-2.6-x86-kvm.orig/include/asm-x86/paravirt.h
+++ linux-2.6-x86-kvm/include/asm-x86/paravirt.h
@@ -1004,6 +1004,13 @@ static inline void set_pte(pte_t *ptep, 
 			    pte.pte);
 }
 
+static inline void pte_clear_bit(unsigned int bit, pte_t *ptep)
+{
+	pte_t pte = *ptep;
+	clear_bit(bit, (unsigned long *)&pte.pte);
+	set_pte(ptep, pte);
+}
+
 static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
 			      pte_t *ptep, pte_t pte)
 {
Index: linux-2.6-x86-kvm/include/asm-x86/pgtable.h
===================================================================
--- linux-2.6-x86-kvm.orig/include/asm-x86/pgtable.h
+++ linux-2.6-x86-kvm/include/asm-x86/pgtable.h
@@ -227,6 +227,8 @@ void native_pagetable_setup_done(pgd_t *
 #define pte_update(mm, addr, ptep)              do { } while (0)
 #define pte_update_defer(mm, addr, ptep)        do { } while (0)
 
+#define pte_clear_bit(bit, ptep)	clear_bit(bit, (unsigned long *)&ptep->pte)
+
 static inline void paravirt_pagetable_setup_start(pgd_t *base)
 {
 	native_pagetable_setup_start(base);
@@ -302,7 +304,7 @@ static inline void native_set_pte_at(str
 ({									\
 	int __changed = !pte_same(*(ptep), entry);			\
 	if (__changed && dirty) {					\
-		*ptep = entry;						\
+		set_pte(ptep, entry);					\
 		pte_update_defer((vma)->vm_mm, (address), (ptep));	\
 		flush_tlb_page(vma, address);				\
 	}								\
@@ -357,7 +359,7 @@ static inline pte_t ptep_get_and_clear_f
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
-	clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte);
+	pte_clear_bit(_PAGE_BIT_RW, ptep);
 	pte_update(mm, addr, ptep);
 }
 

-- 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2008-01-30 21:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-30 21:26 [patch 0/4] KVM paravirt MMU updates Marcelo Tosatti
2008-01-30 21:26 ` [patch 1/4] KVM: basic paravirt support Marcelo Tosatti
2008-01-30 21:26 ` [patch 2/4] KVM: hypercall based pte updates and TLB flushes Marcelo Tosatti
2008-01-30 21:26 ` Marcelo Tosatti [this message]
2008-01-30 21:26 ` [patch 4/4] KVM: hypercall batching Marcelo Tosatti

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=20080130213608.562741627@harmony.lab.boston.redhat.com \
    --to=mtosatti-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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