x86-64 sign extension exception
PATCH 1/1 x86-64 sign extension exception
Changelog:
Raise a GPF exception instead of page fault if the sign extension of 64-bit address isn't valid.
Index: target-i386/helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/helper.c,v retrieving revision 1.58
helper.c +2 -2
@@ -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
helper2.c +4 -4
@@ -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)
Quoted 2 lines · Filip Navara
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...
Index: target-i386/helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/helper.c,v retrieving revision 1.58
helper.c +2 -2
@@ -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
helper2.c +5 -5
@@ -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)