]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
We incorrectly stored the archinfo_host argument of iselSB_S390 into
authorFlorian Krohm <florian@eich-krohm.de>
Sat, 21 Apr 2012 03:34:54 +0000 (03:34 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sat, 21 Apr 2012 03:34:54 +0000 (03:34 +0000)
a global variable not realising it points to a stack-allocated variable.
This caused s390_archinfo_host->hwcaps member to change its value
randomly over time. It could have caused invalid code to be generated.
Curious that it did not surface.

git-svn-id: svn://svn.valgrind.org/vex/trunk@2297

VEX/priv/host_s390_defs.c
VEX/priv/host_s390_defs.h
VEX/priv/host_s390_isel.c

index f46a1bed1fa3160a19287a173fda9e9af4191424..8bcfb39620208146d63ec8f9e228b57d3b1df206 100644 (file)
@@ -49,7 +49,7 @@
    Until then, we use a global variable. This variable is set as a side
    effect of iselSB_S390. This is safe because instructions are selected
    before they are emitted. */
-const VexArchInfo *s390_archinfo_host;
+UInt s390_host_hwcaps;
 
 
 /*------------------------------------------------------------*/
index ad99c4ffcfdf8e6c73ca5ba9da37ad4cbf5e2bf0..ce4a19726033ef1adc9703f004a74861fcfd3183 100644 (file)
@@ -547,21 +547,21 @@ VexInvalRange patchProfInc_S390(void  *code_to_patch,
                                 ULong *location_of_counter);
 
 /* KLUDGE: See detailled comment in host_s390_defs.c. */
-extern const VexArchInfo *s390_archinfo_host;
+extern UInt s390_host_hwcaps;
 
 /* Convenience macros to test installed facilities */
 #define s390_host_has_ldisp \
-                      (s390_archinfo_host->hwcaps & (VEX_HWCAPS_S390X_LDISP))
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_LDISP))
 #define s390_host_has_eimm \
-                      (s390_archinfo_host->hwcaps & (VEX_HWCAPS_S390X_EIMM))
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_EIMM))
 #define s390_host_has_gie \
-                      (s390_archinfo_host->hwcaps & (VEX_HWCAPS_S390X_GIE))
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_GIE))
 #define s390_host_has_dfp \
-                      (s390_archinfo_host->hwcaps & (VEX_HWCAPS_S390X_DFP))
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_DFP))
 #define s390_host_has_fgx \
-                      (s390_archinfo_host->hwcaps & (VEX_HWCAPS_S390X_FGX))
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_FGX))
 #define s390_host_has_etf2 \
-                      (s390_archinfo_host->hwcaps & (VEX_HWCAPS_S390X_ETF2))
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_ETF2))
 
 #endif /* ndef __VEX_HOST_S390_DEFS_H */
 
index 9400012ad7a25eb6f865c1e8cb6bb5ae5acea8d7..35226f9963bbb399b94a7e42375d80fdae2395bc 100644 (file)
@@ -2619,7 +2619,9 @@ iselNext(ISelEnv *env, IRExpr *next, IRJumpKind jk, int offsIP)
 /*--- Insn selector top-level                           ---*/
 /*---------------------------------------------------------*/
 
-/* Translate an entire SB to s390 code. */
+/* Translate an entire SB to s390 code.
+   Note: archinfo_host is a pointer to a stack-allocated variable.
+   Do not assign it to a global variable! */
 
 HInstrArray *
 iselSB_S390(IRSB *bb, VexArch arch_host, VexArchInfo *archinfo_host,
@@ -2632,8 +2634,8 @@ iselSB_S390(IRSB *bb, VexArch arch_host, VexArchInfo *archinfo_host,
    ISelEnv *env;
    UInt     hwcaps_host = archinfo_host->hwcaps;
 
-   /* KLUDGE: export archinfo_host. */
-   s390_archinfo_host = archinfo_host;
+   /* KLUDGE: export hwcaps. */
+   s390_host_hwcaps = hwcaps_host;
 
    /* Do some sanity checks */
    vassert((VEX_HWCAPS_S390X(hwcaps_host) & ~(VEX_HWCAPS_S390X_ALL)) == 0);