qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] x86-64 sign extension exception
@ 2005-12-04  9:45 Filip Navara
  2005-12-04 14:40 ` Filip Navara
  0 siblings, 1 reply; 2+ messages in thread
From: Filip Navara @ 2005-12-04  9:45 UTC (permalink / raw)
  To: qemu-devel

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

Changelog:
Raise a GPF exception instead of page fault if the sign extension of 
64-bit address isn't valid.


[-- Attachment #2: qemu-64-gpf.diff --]
[-- Type: text/x-patch, Size: 2077 bytes --]

Index: target-i386/helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/helper.c,v
retrieving revision 1.58
diff -u -r1.58 helper.c
--- target-i386/helper.c	28 Nov 2005 21:01:52 -0000	1.58
+++ target-i386/helper.c	3 Dec 2005 21:07:24 -0000
@@ -3478,9 +3478,9 @@
             }
         }
         if (retaddr)
-            raise_exception_err(EXCP0E_PAGE, env->error_code);
+            raise_exception_err(ret, env->error_code);
         else
-            raise_exception_err_norestore(EXCP0E_PAGE, env->error_code);
+            raise_exception_err_norestore(ret, env->error_code);
     }
     env = saved_env;
 }
Index: target-i386/helper2.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/helper2.c,v
retrieving revision 1.38
diff -u -r1.38 helper2.c
--- target-i386/helper2.c	28 Nov 2005 21:19:42 -0000	1.38
+++ target-i386/helper2.c	3 Dec 2005 21:09:22 -0000
@@ -566,7 +566,7 @@
     env->cr[2] = addr;
     env->error_code = (is_write << PG_ERROR_W_BIT);
     env->error_code |= PG_ERROR_U_MASK;
-    return 1;
+    return EXCP0E_PAGE;
 }
 
 target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
@@ -621,7 +621,7 @@
             sext = (int64_t)addr >> 47;
             if (sext != 0 && sext != -1) {
                 error_code = 0;
-                goto do_fault;
+                return EXCP0D_GPF;
             }
             
             pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & 
@@ -849,7 +849,7 @@
     vaddr = virt_addr + page_offset;
     
     ret = tlb_set_page_exec(env, vaddr, paddr, prot, is_user, is_softmmu);
-    return ret;
+    return ret ? EXCP0E_PAGE : 0;
  do_fault_protect:
     error_code = PG_ERROR_P_MASK;
  do_fault:
@@ -862,7 +862,7 @@
         (env->cr[4] & CR4_PAE_MASK))
         error_code |= PG_ERROR_I_D_MASK;
     env->error_code = error_code;
-    return 1;
+    return EXCP0E_PAGE;
 }
 
 target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)

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

* Re: [Qemu-devel] [PATCH] x86-64 sign extension exception
  2005-12-04  9:45 [Qemu-devel] [PATCH] x86-64 sign extension exception Filip Navara
@ 2005-12-04 14:40 ` Filip Navara
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Navara @ 2005-12-04 14:40 UTC (permalink / raw)
  To: qemu-devel

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

Filip Navara wrote:

> Changelog:
> Raise a GPF exception instead of page fault if the sign extension of 
> 64-bit address isn't valid.

sigh, i should never make patches just after i wake up...

[-- Attachment #2: qemu-64-gpf.diff --]
[-- Type: text/x-patch, Size: 2115 bytes --]

Index: target-i386/helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/helper.c,v
retrieving revision 1.58
diff -u -r1.58 helper.c
--- target-i386/helper.c	28 Nov 2005 21:01:52 -0000	1.58
+++ target-i386/helper.c	3 Dec 2005 21:07:24 -0000
@@ -3478,9 +3478,9 @@
             }
         }
         if (retaddr)
-            raise_exception_err(EXCP0E_PAGE, env->error_code);
+            raise_exception_err(ret, env->error_code);
         else
-            raise_exception_err_norestore(EXCP0E_PAGE, env->error_code);
+            raise_exception_err_norestore(ret, env->error_code);
     }
     env = saved_env;
 }
Index: target-i386/helper2.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/helper2.c,v
retrieving revision 1.38
diff -u -r1.38 helper2.c
--- target-i386/helper2.c	28 Nov 2005 21:19:42 -0000	1.38
+++ target-i386/helper2.c	3 Dec 2005 21:09:22 -0000
@@ -566,7 +566,7 @@
     env->cr[2] = addr;
     env->error_code = (is_write << PG_ERROR_W_BIT);
     env->error_code |= PG_ERROR_U_MASK;
-    return 1;
+    return EXCP0E_PAGE;
 }
 
 target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
@@ -621,7 +621,7 @@
             sext = (int64_t)addr >> 47;
             if (sext != 0 && sext != -1) {
-                error_code = 0;
+                env->error_code = 0;
-                goto do_fault;
+                return EXCP0D_GPF;
             }
             
             pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & 
@@ -849,7 +849,7 @@
     vaddr = virt_addr + page_offset;
     
     ret = tlb_set_page_exec(env, vaddr, paddr, prot, is_user, is_softmmu);
-    return ret;
+    return ret ? EXCP0E_PAGE : 0;
  do_fault_protect:
     error_code = PG_ERROR_P_MASK;
  do_fault:
@@ -862,7 +862,7 @@
         (env->cr[4] & CR4_PAE_MASK))
         error_code |= PG_ERROR_I_D_MASK;
     env->error_code = error_code;
-    return 1;
+    return EXCP0E_PAGE;
 }
 
 target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)

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

end of thread, other threads:[~2005-12-04 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-04  9:45 [Qemu-devel] [PATCH] x86-64 sign extension exception Filip Navara
2005-12-04 14:40 ` Filip Navara

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).