All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Update cr3 in PAE mode when guest walk succeed but shadow walk fails
@ 2009-10-16 13:09 George Dunlap
  2009-10-17 13:51 ` John Levon
  2009-10-21  9:46 ` Paolo Bonzini
  0 siblings, 2 replies; 8+ messages in thread
From: George Dunlap @ 2009-10-16 13:09 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 881 bytes --]

When running in PAE mode, Windows 7 (apparently) will occasionally
switch cr3 with one of the L3 entries invalid, make it valid, and then
expect the hardware to load the new value.  (This behavior is
explicitly not promised in the hardware manuals.)  This leads to a
situation where on a shadow fault, the guest walk succeeds but the
shadow walk fails.  The code assumes this can only happen when the
domain is dying, and makes an ASSERT() to that effect.  So currently,
in debug mode, this will cause the host to crash; in non-debug mode,
this will cause a page-fault loop.

The attached patch solves the problem by calling update_cr3() in that
path when the guest is in PAE mode, and only ASSERT()ing when the
guest is not in PAE mode.  The guest will get one spurious page fault,
but subsequent accesses will succeed.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>

[-- Attachment #2: 20091016-update-cr3-on-shadow-failure.diff --]
[-- Type: text/x-diff, Size: 935 bytes --]

diff -r 4b78d565b535 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c	Wed Oct 07 14:12:09 2009 +0100
+++ b/xen/arch/x86/mm/shadow/multi.c	Thu Oct 15 15:48:52 2009 +0100
@@ -3194,7 +3194,16 @@
          * are OK, this can only have been caused by a failed
          * shadow_set_l*e(), which will have crashed the guest.
          * Get out of the fault handler immediately. */
+        /* Windows 7 apparently relies on the hardware to do something
+         * it explicitly hasn't promised to do: load l3 values after
+         * the cr3 is loaded.
+         * In any case, in the PAE case, the ASSERT is not true; it can
+         * happen because of actions the guest is taking. */
+#if GUEST_PAGING_LEVELS == 3
+        v->arch.paging.mode->update_cr3(v, 0);
+#else
         ASSERT(d->is_shutting_down);
+#endif
         shadow_unlock(d);
         trace_shadow_gen(TRC_SHADOW_DOMF_DYING, va);
         return 0;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-21 10:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-16 13:09 [PATCH] Update cr3 in PAE mode when guest walk succeed but shadow walk fails George Dunlap
2009-10-17 13:51 ` John Levon
2009-10-17 14:15   ` Keir Fraser
2009-10-17 14:17     ` John Levon
2009-10-21  9:46 ` Paolo Bonzini
2009-10-21  9:50   ` Tim Deegan
2009-10-21  9:52     ` Paolo Bonzini
2009-10-21 10:23       ` George Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.