qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Patch: ptable calculation broken for 32bit code under x86_64
@ 2007-04-10 13:30 Bernhard Kauer
  0 siblings, 0 replies; only message in thread
From: Bernhard Kauer @ 2007-04-10 13:30 UTC (permalink / raw)
  To: qemu-devel

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

The calculation of pdpe and pde addresses is broken, when running 32bit
code under x86_64-qemu. The code assumes that the addr parameter is 32bit
wide. This assumption does not hold for x86_64 as target.

	Bernhard Kauer


[-- Attachment #2: qemu_pte_bug.diff --]
[-- Type: text/x-diff, Size: 1715 bytes --]

Index: target-i386/helper2.c
===================================================================
RCS file: /sources/qemu/qemu/target-i386/helper2.c,v
retrieving revision 1.46
diff -u -r1.46 helper2.c
--- target-i386/helper2.c	7 Apr 2007 11:21:28 -0000	1.46
+++ target-i386/helper2.c	10 Apr 2007 13:28:02 -0000
@@ -670,7 +670,7 @@
 #endif
         {
             /* XXX: load them when cr3 is loaded ? */
-            pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 30) << 3)) & 
+            pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & 
                 env->a20_mask;
             pdpe = ldq_phys(pdpe_addr);
             if (!(pdpe & PG_PRESENT_MASK)) {
@@ -765,7 +765,7 @@
         uint32_t pde;
 
         /* page directory entry */
-        pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & 
+        pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & 
             env->a20_mask;
         pde = ldl_phys(pde_addr);
         if (!(pde & PG_PRESENT_MASK)) {
@@ -910,7 +910,7 @@
         } else 
 #endif
         {
-            pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 30) << 3)) & 
+            pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & 
                 env->a20_mask;
             pdpe = ldl_phys(pdpe_addr);
             if (!(pdpe & PG_PRESENT_MASK))
@@ -940,7 +940,7 @@
             page_size = 4096;
         } else {
             /* page directory entry */
-            pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & env->a20_mask;
+            pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask;
             pde = ldl_phys(pde_addr);
             if (!(pde & PG_PRESENT_MASK)) 
                 return -1;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-04-10 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-10 13:30 [Qemu-devel] Patch: ptable calculation broken for 32bit code under x86_64 Bernhard Kauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).