Commit eda52953026a5b6d28b063af13101f1edb580dcf
1 parent
a3772d4d
Fix Sparc64 window handling problems detected by Vince Weaver
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5091 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
18 additions
and
3 deletions
linux-user/main.c
... | ... | @@ -808,11 +808,16 @@ static void save_window(CPUSPARCState *env) |
808 | 808 | |
809 | 809 | static void restore_window(CPUSPARCState *env) |
810 | 810 | { |
811 | - unsigned int new_wim, i, cwp1; | |
811 | +#ifndef TARGET_SPARC64 | |
812 | + unsigned int new_wim; | |
813 | +#endif | |
814 | + unsigned int i, cwp1; | |
812 | 815 | abi_ulong sp_ptr; |
813 | 816 | |
817 | +#ifndef TARGET_SPARC64 | |
814 | 818 | new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) & |
815 | 819 | ((1LL << env->nwindows) - 1); |
820 | +#endif | |
816 | 821 | |
817 | 822 | /* restore the invalid window */ |
818 | 823 | cwp1 = cpu_cwp_inc(env, env->cwp + 1); |
... | ... | @@ -826,12 +831,13 @@ static void restore_window(CPUSPARCState *env) |
826 | 831 | get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr); |
827 | 832 | sp_ptr += sizeof(abi_ulong); |
828 | 833 | } |
829 | - env->wim = new_wim; | |
830 | 834 | #ifdef TARGET_SPARC64 |
831 | 835 | env->canrestore++; |
832 | 836 | if (env->cleanwin < env->nwindows - 1) |
833 | 837 | env->cleanwin++; |
834 | 838 | env->cansave--; |
839 | +#else | |
840 | + env->wim = new_wim; | |
835 | 841 | #endif |
836 | 842 | } |
837 | 843 | |
... | ... | @@ -843,14 +849,23 @@ static void flush_windows(CPUSPARCState *env) |
843 | 849 | for(;;) { |
844 | 850 | /* if restore would invoke restore_window(), then we can stop */ |
845 | 851 | cwp1 = cpu_cwp_inc(env, env->cwp + offset); |
852 | +#ifndef TARGET_SPARC64 | |
846 | 853 | if (env->wim & (1 << cwp1)) |
847 | 854 | break; |
855 | +#else | |
856 | + if (env->canrestore == 0) | |
857 | + break; | |
858 | + env->cansave++; | |
859 | + env->canrestore--; | |
860 | +#endif | |
848 | 861 | save_window_offset(env, cwp1); |
849 | 862 | offset++; |
850 | 863 | } |
851 | - /* set wim so that restore will reload the registers */ | |
852 | 864 | cwp1 = cpu_cwp_inc(env, env->cwp + 1); |
865 | +#ifndef TARGET_SPARC64 | |
866 | + /* set wim so that restore will reload the registers */ | |
853 | 867 | env->wim = 1 << cwp1; |
868 | +#endif | |
854 | 869 | #if defined(DEBUG_WIN) |
855 | 870 | printf("flush_windows: nb=%d\n", offset - 1); |
856 | 871 | #endif | ... | ... |