Skip to content

Commit d43624c

Browse files
LemonBoyvivier
authored andcommitted
linux-user/sparc64: Fix the handling of window spill trap
Fix the handling of window spill traps by keeping cansave into account when calculating the new CWP. Signed-off-by: Giuseppe Musacchio <[email protected]> Signed-off-by: Laurent Vivier <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]>
1 parent aa04c9d commit d43624c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bsd-user/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ static void save_window(CPUSPARCState *env)
413413
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
414414
env->wim = new_wim;
415415
#else
416-
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
416+
/*
417+
* cansave is zero if the spill trap handler is triggered by `save` and
418+
* nonzero if triggered by a `flushw`
419+
*/
420+
save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2));
417421
env->cansave++;
418422
env->canrestore--;
419423
#endif

linux-user/sparc/cpu_loop.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ static void save_window(CPUSPARCState *env)
6969
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
7070
env->wim = new_wim;
7171
#else
72-
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
72+
/*
73+
* cansave is zero if the spill trap handler is triggered by `save` and
74+
* nonzero if triggered by a `flushw`
75+
*/
76+
save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2));
7377
env->cansave++;
7478
env->canrestore--;
7579
#endif

0 commit comments

Comments
 (0)