Skip to contentSkip to conversation

[4942] Make MAXTL dynamic, bounds check tl when indexing

Qemu-devel Blue Swirl 1 participant 1 message Jul 25, 2008

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

Revision: 4942

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4942
Author:   blueswir1
Date:     2008-07-25 07:42:14 +0000 (Fri, 25 Jul 2008)

Log Message:
-----------
Make MAXTL dynamic, bounds check tl when indexing

Modified Paths:
--------------
trunk/target-sparc/cpu.h
trunk/target-sparc/helper.c
trunk/target-sparc/machine.c
trunk/target-sparc/op_helper.c

Modified: trunk/target-sparc/cpu.h
===================================================================

target-sparc/cpu.h +5 -3
@@ -252,13 +252,15 @@
     float128 qt0, qt1;
     float_status fp_status;
 #if defined(TARGET_SPARC64)
-#define MAXTL 4
+#define MAXTL_MAX 8
+#define MAXTL_MASK (MAXTL_MAX - 1)
     trap_state *tsptr;
-    trap_state ts[MAXTL];
+    trap_state ts[MAXTL_MAX];
     uint32_t xcc;               /* Extended integer condition codes */
     uint32_t asi;
     uint32_t pstate;
     uint32_t tl;
+    uint32_t maxtl;
     uint32_t cansave, canrestore, otherwin, wstate, cleanwin;
     uint64_t agregs[8]; /* alternate general registers */
     uint64_t bgregs[8]; /* backup for normal global registers */
@@ -270,7 +272,7 @@
     uint64_t gsr;
     uint32_t gl; // UA2005
     /* UA 2005 hyperprivileged registers */
-    uint64_t hpstate, htstate[MAXTL], hintp, htba, hver, hstick_cmpr, ssr;
+    uint64_t hpstate, htstate[MAXTL_MAX], hintp, htba, hver, hstick_cmpr, ssr;
     void *hstick; // UA 2005
 #endif
     uint32_t features;

Modified: trunk/target-sparc/helper.c
===================================================================

target-sparc/helper.c +44 -41

242 lines not on this page · raw message

Modified: trunk/target-sparc/machine.c
===================================================================

target-sparc/machine.c +5 -5
@@ -72,7 +72,7 @@
         qemu_put_be64s(f, &env->dtlb_tte[i]);
     }
     qemu_put_be32s(f, &env->mmu_version);
-    for (i = 0; i < MAXTL; i++) {
+    for (i = 0; i < MAXTL_MAX; i++) {
         qemu_put_be64s(f, &env->ts[i].tpc);
         qemu_put_be64s(f, &env->ts[i].tnpc);
         qemu_put_be64s(f, &env->ts[i].tstate);
@@ -103,7 +103,7 @@
     qemu_put_be64s(f, &env->gsr);
     qemu_put_be32s(f, &env->gl);
     qemu_put_be64s(f, &env->hpstate);
-    for (i = 0; i < MAXTL; i++)
+    for (i = 0; i < MAXTL_MAX; i++)
         qemu_put_be64s(f, &env->htstate[i]);
     qemu_put_be64s(f, &env->hintp);
     qemu_put_be64s(f, &env->htba);
@@ -165,7 +165,7 @@
         qemu_get_be64s(f, &env->dtlb_tte[i]);
     }
     qemu_get_be32s(f, &env->mmu_version);
-    for (i = 0; i < MAXTL; i++) {
+    for (i = 0; i < MAXTL_MAX; i++) {
         qemu_get_be64s(f, &env->ts[i].tpc);
         qemu_get_be64s(f, &env->ts[i].tnpc);
         qemu_get_be64s(f, &env->ts[i].tstate);
@@ -175,7 +175,7 @@
     qemu_get_be32s(f, &env->asi);
     qemu_get_be32s(f, &env->pstate);
     qemu_get_be32s(f, &env->tl);
-    env->tsptr = &env->ts[env->tl];
+    env->tsptr = &env->ts[env->tl & MAXTL_MASK];
     qemu_get_be32s(f, &env->cansave);
     qemu_get_be32s(f, &env->canrestore);
     qemu_get_be32s(f, &env->otherwin);
@@ -197,7 +197,7 @@
     qemu_get_be64s(f, &env->gsr);
     qemu_get_be32s(f, &env->gl);
     qemu_get_be64s(f, &env->hpstate);
-    for (i = 0; i < MAXTL; i++)
+    for (i = 0; i < MAXTL_MAX; i++)
         qemu_get_be64s(f, &env->htstate[i]);
     qemu_get_be64s(f, &env->hintp);
     qemu_get_be64s(f, &env->htba);

Modified: trunk/target-sparc/op_helper.c
===================================================================

target-sparc/op_helper.c +2 -2
@@ -2742,7 +2742,7 @@
     change_pstate((env->tsptr->tstate >> 8) & 0xf3f);
     PUT_CWP64(env, env->tsptr->tstate & 0xff);
     env->tl--;
-    env->tsptr = &env->ts[env->tl];
+    env->tsptr = &env->ts[env->tl & MAXTL_MASK];
 }
 
 void helper_retry(void)
@@ -2754,7 +2754,7 @@
     change_pstate((env->tsptr->tstate >> 8) & 0xf3f);
     PUT_CWP64(env, env->tsptr->tstate & 0xff);
     env->tl--;
-    env->tsptr = &env->ts[env->tl];
+    env->tsptr = &env->ts[env->tl & MAXTL_MASK];
 }
 #endif