WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Clarifiation about WP bit CR0 and copy on write in Xen

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] Clarifiation about WP bit CR0 and copy on write in Xen
From: Mark Williamson <maw48@xxxxxxxxxxxx>
Date: Mon, 11 Apr 2005 13:57:42 +0100
Cc: sting sting <zstingx@xxxxxxxxxxx>
Delivery-date: Mon, 11 Apr 2005 13:14:45 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <BAY2-F69F7F3D09161201842762AA320@xxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <BAY2-F69F7F3D09161201842762AA320@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.8
> As I remember ,and I am not sure abouth the details,
> in Linux (and other *NIX), when a process calls
> fork() it creates another process , and the pages of the old process
> are mapped to the new process; But they are marked
> as read only (for the new process)) and  only when the process tries to
> write
> to the page then a new page is created. (There is a page fault).So this
> fork()
> method uses "copy on write".
>
> Can anybody please elaborate more on this ? what is the simplification
> of "Copy on Write" here? How does it uses the WP bit ?
> Does XenoLinux (for example) has a different implementation of clone() than
> the usual implementation?

If you're in Ring 3 (userspace) then you'll always take a page fault for 
writing to a read only page.  The kernel can CoW the page and fix up your 
mappings.

Presumably (I've not actually checked) the kernel uses the WP bit to ensure 
the CoW fault happens if the kernel tries to write to some memory in the 
child process.  If WP wasn't set, the child could do a read system call and 
the kernel could copy data into a page that's shared with the parent process.  
It makes things simpler to use WP to ensure that a fault occurs (even in 
kernel mode) rather than having to programmatically check if a CoW should be 
done before the kernel writes to userspace.

As a result of this optimisation, guest OS kernels are written with the 
assumption that the WP bit is active.  Therefore it won't affect correct 
operations if Xen makes sure it's set.  If a guest OS relied on being able to 
ignore write protection whilst in the kernel, it would make it trickier to 
port to Xen.

Of course, under Vanderpool / Pacifica, any strange guests that do want WP 
switched off will be able to run happily.

Cheers,
Mark

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>