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

[Xen-devel] [HVM]A possible mov_to_cr3 bug

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [HVM]A possible mov_to_cr3 bug
From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
Date: Tue, 28 Nov 2006 17:25:03 +0800
Cc: "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>
Delivery-date: Tue, 28 Nov 2006 01:25:14 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AccSzxWUTAgw8FqmRbGoM38uNhFz4Q==
Thread-topic: [HVM]A possible mov_to_cr3 bug
When we (Yunhong and I) looked into the shadow code recently, we 
happened to find a possible shadow bug when emulating move to 
cr3.

Current policy of emulating mov_to_cr3 is:
        - If guest changes guest_cr3:
                Update_cr3(v);
                Update shadow pointer (GUEST_CR3) in VMCS
        - Or else, only:
                shadow_update_cr3(v);

The 2nd direction has the assumption that shadow l4 pointer doesn't 
change if so do guest cr3. 

However the logic within shadow_update_cr3() doesn't ensure this, 
which will sh_put_ref old shadow. Normally l4 shadow page is pinned 
and thus with refcount as 2. So above sh_put_ref doesn't free this 
shadow page, and the original one will be re-chosed immediately.

This is the normal case, however it doesn't hold true once 
shadow_prealloc is invoked before this update. Shadow_prealloc() 
will unpin top level shadow pages, which made refcount of these 
pages decremented to 1 before shadow_update_cr3. Under this 
special case, sh_put_ref in the latter will really free the original l4 
shadow, and then later a new l4 shadow will be allocated. This 
definitely breaks the assumption made by mov_to_cr3 emulation. 
Shadow pointer in VMCS will keep stale.

So we'd better abandon the assumption and always update shadow 
pointer in VMCS whatever guest sets to its cr3. 

Does it sound OK? Or are we missing anything important? :-)

Thanks,
Kevin

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

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