From c6c2bd4b5eb2d45c66c50c4151080a1060f9306d Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 20 Jan 2006 14:13:55 +0000 Subject: [PATCH] Add Ijk_EmFail, a new kind of IR block exit: an emulation failure (fatal error) from which Vex (generated code) cannot recover. Handle this in the ppc(64) backend. git-svn-id: svn://svn.valgrind.org/vex/trunk@1542 --- VEX/priv/host-ppc/hdefs.c | 1 + VEX/priv/ir/irdefs.c | 1 + VEX/priv/main/vex_main.c | 8 ++++++-- VEX/pub/libvex_emwarn.h | 8 ++++++-- VEX/pub/libvex_ir.h | 9 +++++++++ VEX/pub/libvex_trc_values.h | 5 +++++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/VEX/priv/host-ppc/hdefs.c b/VEX/priv/host-ppc/hdefs.c index 066ba2631f..e88e5f148f 100644 --- a/VEX/priv/host-ppc/hdefs.c +++ b/VEX/priv/host-ppc/hdefs.c @@ -2939,6 +2939,7 @@ Int emit_PPCInstr ( UChar* buf, Int nbuf, PPCInstr* i, case Ijk_Sys_syscall: trc = VEX_TRC_JMP_SYS_SYSCALL; break; case Ijk_Yield: trc = VEX_TRC_JMP_YIELD; break; case Ijk_EmWarn: trc = VEX_TRC_JMP_EMWARN; break; + case Ijk_EmFail: trc = VEX_TRC_JMP_EMFAIL; break; case Ijk_MapFail: trc = VEX_TRC_JMP_MAPFAIL; break; case Ijk_NoDecode: trc = VEX_TRC_JMP_NODECODE; break; case Ijk_TInval: trc = VEX_TRC_JMP_TINVAL; break; diff --git a/VEX/priv/ir/irdefs.c b/VEX/priv/ir/irdefs.c index c04b7da4a5..20da033b76 100644 --- a/VEX/priv/ir/irdefs.c +++ b/VEX/priv/ir/irdefs.c @@ -681,6 +681,7 @@ void ppIRJumpKind ( IRJumpKind kind ) case Ijk_ClientReq: vex_printf("ClientReq"); break; case Ijk_Yield: vex_printf("Yield"); break; case Ijk_EmWarn: vex_printf("EmWarn"); break; + case Ijk_EmFail: vex_printf("EmFail"); break; case Ijk_NoDecode: vex_printf("NoDecode"); break; case Ijk_MapFail: vex_printf("MapFail"); break; case Ijk_TInval: vex_printf("Invalidate"); break; diff --git a/VEX/priv/main/vex_main.c b/VEX/priv/main/vex_main.c index 311f2845e9..b232fbf63a 100644 --- a/VEX/priv/main/vex_main.c +++ b/VEX/priv/main/vex_main.c @@ -664,8 +664,12 @@ HChar* LibVEX_EmWarn_string ( VexEmWarn ew ) return "Setting %mxcsr.daz (SSE treat-denormals-as-zero mode)"; case EmWarn_X86_acFlag: return "Setting %eflags.ac (setting noted but ignored)"; - case EmWarn_PPC32exns: - return "Unmasking PPC32 FP exceptions"; + case EmWarn_PPCexns: + return "Unmasking PPC32/64 FP exceptions"; + case EmWarn_PPC64_redir_overflow: + return "PPC64 function redirection stack overflow"; + case EmWarn_PPC64_redir_underflow: + return "PPC64 function redirection stack underflow"; default: vpanic("LibVEX_EmWarn_string: unknown warning"); } diff --git a/VEX/pub/libvex_emwarn.h b/VEX/pub/libvex_emwarn.h index 8ef6c8d8df..6733a442a9 100644 --- a/VEX/pub/libvex_emwarn.h +++ b/VEX/pub/libvex_emwarn.h @@ -87,8 +87,12 @@ typedef /* settings to %eflags.ac (alignment check) are noted but ignored */ EmWarn_X86_acFlag, - /* unmasking PPC32 FP exceptions is not supported */ - EmWarn_PPC32exns, + /* unmasking PPC32/64 FP exceptions is not supported */ + EmWarn_PPCexns, + + /* overflow/underflow of the PPC64 _REDIR stack (ppc64 only) */ + EmWarn_PPC64_redir_overflow, + EmWarn_PPC64_redir_underflow, EmWarn_NUMBER } diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index 130a4fe13e..1e480b59e8 100644 --- a/VEX/pub/libvex_ir.h +++ b/VEX/pub/libvex_ir.h @@ -843,6 +843,14 @@ extern Bool eqIRAtom ( IRExpr*, IRExpr* ); the size of a guest word. It is the responsibility of the relevant toIR.c to ensure that these are filled in with suitable values before issuing a jump of kind Ijk_TInval. + + Re Ijk_EmWarn and Ijk_EmFail: the guest state must have a + pseudo-register guest_EMWARN, which is 32-bits regardless of + the host or guest word size. That register should be made + to hold an EmWarn_* value to indicate the reason for the exit. + + In the case of Ijk_EmFail, the exit is fatal (Vex-generated code + cannot continue) and so the jump destination can be anything. */ typedef enum { @@ -852,6 +860,7 @@ typedef Ijk_ClientReq, /* do guest client req before continuing */ Ijk_Yield, /* client is yielding to thread scheduler */ Ijk_EmWarn, /* report emulation warning before continuing */ + Ijk_EmFail, /* emulation critical (FATAL) error; give up */ Ijk_NoDecode, /* next instruction cannot be decoded */ Ijk_MapFail, /* Vex-provided address translation failed */ Ijk_TInval, /* Invalidate translations before continuing. */ diff --git a/VEX/pub/libvex_trc_values.h b/VEX/pub/libvex_trc_values.h index ccba4e3cbf..a82518e001 100644 --- a/VEX/pub/libvex_trc_values.h +++ b/VEX/pub/libvex_trc_values.h @@ -54,6 +54,9 @@ This file may get included in assembly code, so do not put C-specific constructs in it. + + These values should be 61 or above so as not to conflict + with Valgrind's VG_TRC_ values, which are 60 or below. */ #define VEX_TRC_JMP_TINVAL 61 /* invalidate translations before @@ -61,6 +64,8 @@ #define VEX_TRC_JMP_NOREDIR 81 /* jump to undirected guest addr */ #define VEX_TRC_JMP_EMWARN 63 /* deliver emulation warning before continuing */ +#define VEX_TRC_JMP_EMFAIL 83 /* emulation fatal error; abort system */ + #define VEX_TRC_JMP_CLIENTREQ 65 /* do a client req before continuing */ #define VEX_TRC_JMP_YIELD 67 /* yield to thread sched before continuing */ -- 2.47.3