diff options
author | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-02-04 13:37:44 +0000 |
---|---|---|
committer | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-02-04 13:37:44 +0000 |
commit | 1057eaa709dba09d1c4f7a363877e635797e4623 (patch) | |
tree | 5d8afb18542e0af8e111cbe2590501e2d7784257 /hostregs_helper.h | |
parent | sem* and msg* for qemu, part2, by Kirill Shutemov. (diff) | |
download | qemu-kvm-1057eaa709dba09d1c4f7a363877e635797e4623.tar.gz qemu-kvm-1057eaa709dba09d1c4f7a363877e635797e4623.tar.bz2 qemu-kvm-1057eaa709dba09d1c4f7a363877e635797e4623.zip |
Fix 64-bit host register corruption.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2384 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hostregs_helper.h')
-rw-r--r-- | hostregs_helper.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/hostregs_helper.h b/hostregs_helper.h new file mode 100644 index 000000000..4fdf8ad96 --- /dev/null +++ b/hostregs_helper.h @@ -0,0 +1,98 @@ +/* + * Save/restore host registrs. + * + * Copyright (c) 2007 CodeSourcery + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* The GCC global register vairable extension is used to reserve some + host registers for use by dyngen. However only the core parts of the + translation engine are compiled with these settings. We must manually + save/restore these registers when called from regular code. + It is not sufficient to save/restore T0 et. al. as these may be declared + with a datatype smaller than the actual register. */ + +#if defined(DECLARE_HOST_REGS) + +#define DO_REG(REG) \ + register host_reg_t reg_AREG##REG asm(AREG##REG); \ + volatile host_reg_t saved_AREG##REG; + +#elif defined(SAVE_HOST_REGS) + +#define DO_REG(REG) \ + __asm__ __volatile__ ("" : "=r" (reg_AREG##REG)); \ + saved_AREG##REG = reg_AREG##REG; + +#else + +#define DO_REG(REG) \ + reg_AREG##REG = saved_AREG##REG; \ + __asm__ __volatile__ ("" : : "r" (reg_AREG##REG)); + +#endif + +#ifdef AREG0 +DO_REG(0) +#endif + +#ifdef AREG1 +DO_REG(1) +#endif + +#ifdef AREG2 +DO_REG(2) +#endif + +#ifdef AREG3 +DO_REG(3) +#endif + +#ifdef AREG4 +DO_REG(4) +#endif + +#ifdef AREG5 +DO_REG(5) +#endif + +#ifdef AREG6 +DO_REG(6) +#endif + +#ifdef AREG7 +DO_REG(7) +#endif + +#ifdef AREG8 +DO_REG(8) +#endif + +#ifdef AREG9 +DO_REG(9) +#endif + +#ifdef AREG10 +DO_REG(10) +#endif + +#ifdef AREG11 +DO_REG(11) +#endif + +#undef SAVE_HOST_REGS +#undef DECLARE_HOST_REGS +#undef DO_REG |