Author: gb
Date: Sat Feb  3 10:22:19 2007
New Revision: 116057

Added:
   packages/cooker/qemu/current/SOURCES/qemu-0.8.3-preserve-host-registers.patch
Modified:
   packages/cooker/qemu/current/SPECS/qemu.spec

Log:
- 64-bit fixes (preserve host registers)


Added: 
packages/cooker/qemu/current/SOURCES/qemu-0.8.3-preserve-host-registers.patch
==============================================================================
--- (empty file)
+++ 
packages/cooker/qemu/current/SOURCES/qemu-0.8.3-preserve-host-registers.patch   
    Sat Feb  3 10:22:19 2007
@@ -0,0 +1,296 @@
+2007-02-03  Gwenole Beauchesne  <[EMAIL PROTECTED]>
+
+       * Preserve callee-saved global registers.
+
+--- qemu-0.8.3/cpu-exec.c.preserve-host-registers      2007-02-02 
13:45:47.000000000 +0100
++++ qemu-0.8.3/cpu-exec.c      2007-02-03 09:51:55.000000000 +0100
+@@ -226,37 +226,9 @@ static inline TranslationBlock *tb_find_
+ 
+ int cpu_exec(CPUState *env1)
+ {
+-    target_ulong saved_T0, saved_T1;
+-#if defined(reg_T2)
+-    target_ulong saved_T2;
+-#endif
+-    CPUState *saved_env;
+-#if defined(TARGET_I386)
+-#ifdef reg_EAX
+-    int saved_EAX;
+-#endif
+-#ifdef reg_ECX
+-    int saved_ECX;
+-#endif
+-#ifdef reg_EDX
+-    int saved_EDX;
+-#endif
+-#ifdef reg_EBX
+-    int saved_EBX;
+-#endif
+-#ifdef reg_ESP
+-    int saved_ESP;
+-#endif
+-#ifdef reg_EBP
+-    int saved_EBP;
+-#endif
+-#ifdef reg_ESI
+-    int saved_ESI;
+-#endif
+-#ifdef reg_EDI
+-    int saved_EDI;
+-#endif
+-#elif defined(TARGET_SPARC)
++#define DO_HOST_REGS_DECLARE
++#include "hostregs_helper.h"
++#if defined(TARGET_SPARC)
+ #if defined(reg_REGWPTR)
+     uint32_t *saved_regwptr;
+ #endif
+@@ -325,44 +297,15 @@ int cpu_exec(CPUState *env1)
+     cpu_single_env = env1; 
+ 
+     /* first we save global registers */
+-    saved_env = env;
++#define DO_HOST_REGS_SAVE
++#include "hostregs_helper.h"
+     env = env1;
+-    saved_T0 = T0;
+-    saved_T1 = T1;
+-#if defined(reg_T2)
+-    saved_T2 = T2;
+-#endif
+ #if defined(__sparc__) && !defined(HOST_SOLARIS)
+     /* we also save i7 because longjmp may not restore it */
+     asm volatile ("mov %%i7, %0" : "=r" (saved_i7));
+ #endif
+ 
+ #if defined(TARGET_I386)
+-#ifdef reg_EAX
+-    saved_EAX = EAX;
+-#endif
+-#ifdef reg_ECX
+-    saved_ECX = ECX;
+-#endif
+-#ifdef reg_EDX
+-    saved_EDX = EDX;
+-#endif
+-#ifdef reg_EBX
+-    saved_EBX = EBX;
+-#endif
+-#ifdef reg_ESP
+-    saved_ESP = ESP;
+-#endif
+-#ifdef reg_EBP
+-    saved_EBP = EBP;
+-#endif
+-#ifdef reg_ESI
+-    saved_ESI = ESI;
+-#endif
+-#ifdef reg_EDI
+-    saved_EDI = EDI;
+-#endif
+-
+     env_to_regs();
+     /* put eflags in CPU temporary format */
+     CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
+@@ -827,32 +770,6 @@ int cpu_exec(CPUState *env1)
+ #endif
+     /* restore flags in standard format */
+     env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & 
DF_MASK);
+-
+-    /* restore global registers */
+-#ifdef reg_EAX
+-    EAX = saved_EAX;
+-#endif
+-#ifdef reg_ECX
+-    ECX = saved_ECX;
+-#endif
+-#ifdef reg_EDX
+-    EDX = saved_EDX;
+-#endif
+-#ifdef reg_EBX
+-    EBX = saved_EBX;
+-#endif
+-#ifdef reg_ESP
+-    ESP = saved_ESP;
+-#endif
+-#ifdef reg_EBP
+-    EBP = saved_EBP;
+-#endif
+-#ifdef reg_ESI
+-    ESI = saved_ESI;
+-#endif
+-#ifdef reg_EDI
+-    EDI = saved_EDI;
+-#endif
+ #elif defined(TARGET_ARM)
+     /* XXX: Save/restore host fpu exception state?.  */
+ #elif defined(TARGET_SPARC)
+@@ -871,15 +788,14 @@ int cpu_exec(CPUState *env1)
+ #else
+ #error unsupported target CPU
+ #endif
++
++    /* restore global registers */
+ #if defined(__sparc__) && !defined(HOST_SOLARIS)
+     asm volatile ("mov %0, %%i7" : : "r" (saved_i7));
+ #endif
+-    T0 = saved_T0;
+-    T1 = saved_T1;
+-#if defined(reg_T2)
+-    T2 = saved_T2;
+-#endif
+-    env = saved_env;
++#define DO_HOST_REGS_RESTORE
++#include "hostregs_helper.h"
++
+     /* fail safe : never use cpu_single_env outside cpu_exec() */
+     cpu_single_env = NULL; 
+     return ret;
+--- qemu-0.8.3/hostregs_helper.h.preserve-host-registers       2007-02-03 
10:02:51.000000000 +0100
++++ qemu-0.8.3/hostregs_helper.h       2007-02-03 10:02:27.000000000 +0100
+@@ -0,0 +1,145 @@
++/*
++ *  host registers helpers for dyngen execution engine
++ *
++ *  Copyright (c) 2003 Fabrice Bellard
++ *
++ * 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
++ */
++
++#ifdef AREG0
++#define DO_AREG0(x) x
++#else
++#define DO_AREG0(x)
++#endif
++
++#ifdef AREG1
++#define DO_AREG1(x) x
++#else
++#define DO_AREG1(x)
++#endif
++
++#ifdef AREG2
++#define DO_AREG2(x) x
++#else
++#define DO_AREG2(x)
++#endif
++
++#ifdef AREG3
++#define DO_AREG3(x) x
++#else
++#define DO_AREG3(x)
++#endif
++
++#ifdef AREG4
++#define DO_AREG4(x) x
++#else
++#define DO_AREG4(x)
++#endif
++
++#ifdef AREG5
++#define DO_AREG5(x) x
++#else
++#define DO_AREG5(x)
++#endif
++
++#ifdef AREG6
++#define DO_AREG6(x) x
++#else
++#define DO_AREG6(x)
++#endif
++
++#ifdef AREG7
++#define DO_AREG7(x) x
++#else
++#define DO_AREG7(x)
++#endif
++
++#ifdef AREG8
++#define DO_AREG8(x) x
++#else
++#define DO_AREG8(x)
++#endif
++
++#ifdef AREG9
++#define DO_AREG9(x) x
++#else
++#define DO_AREG9(x)
++#endif
++
++#ifdef AREG10
++#define DO_AREG10(x) x
++#else
++#define DO_AREG10(x)
++#endif
++
++#ifdef AREG11
++#define DO_AREG11(x) x
++#else
++#define DO_AREG11(x)
++#endif
++
++#if defined(DO_HOST_REGS_DECLARE)
++#define DO_EXPR(REG)                                                          
        \
++    register uintptr_t reg_AREG##REG asm(AREG##REG);  \
++    volatile uintptr_t saved_AREG##REG;
++#elif defined(DO_HOST_REGS_SAVE)
++#define DO_EXPR(REG) saved_AREG##REG = reg_AREG##REG;
++#elif defined(DO_HOST_REGS_RESTORE)
++#define DO_EXPR(REG) do {                                                     
        \
++    reg_AREG##REG = saved_AREG##REG;                                  \
++    __asm__ __volatile__ ("" : : "r" (reg_AREG##REG));        \
++} while (0);
++#endif
++
++DO_AREG0(DO_EXPR(0))
++#undef DO_AREG0
++
++DO_AREG1(DO_EXPR(1))
++#undef DO_AREG1
++
++DO_AREG2(DO_EXPR(2))
++#undef DO_AREG2
++
++DO_AREG3(DO_EXPR(3))
++#undef DO_AREG3
++
++DO_AREG4(DO_EXPR(4))
++#undef DO_AREG4
++
++DO_AREG5(DO_EXPR(5))
++#undef DO_AREG5
++
++DO_AREG6(DO_EXPR(6))
++#undef DO_AREG6
++
++DO_AREG7(DO_EXPR(7))
++#undef DO_AREG7
++
++DO_AREG8(DO_EXPR(8))
++#undef DO_AREG8
++
++DO_AREG9(DO_EXPR(9))
++#undef DO_AREG9
++
++DO_AREG10(DO_EXPR(10))
++#undef DO_AREG10
++
++DO_AREG11(DO_EXPR(11))
++#undef DO_AREG11
++
++#undef DO_EXPR
++#undef DO_HOST_REGS_DECLARE
++#undef DO_HOST_REGS_SAVE
++#undef DO_HOST_REGS_RESTORE

Modified: packages/cooker/qemu/current/SPECS/qemu.spec
==============================================================================
--- packages/cooker/qemu/current/SPECS/qemu.spec        (original)
+++ packages/cooker/qemu/current/SPECS/qemu.spec        Sat Feb  3 10:22:19 2007
@@ -30,6 +30,7 @@
 Patch5:                qemu-0.8.3-enforce-16byte-boundaries.patch
 Patch6:                qemu-0.8.3-osx-intel-port.patch
 Patch10:       qemu-0.7.0-cross64-mingw32-fixes.patch
+Patch11:       qemu-0.8.3-preserve-host-registers.patch
 Patch12:       qemu-0.7.2-no-nptl.patch
 Patch13:       qemu-0.8.1-fix-errno-tls.patch
 Patch14:       qemu-0.8.3-dont-strip.patch
@@ -69,6 +70,7 @@
 %patch5 -p1 -b .enforce-16byte-boundaries
 %patch6 -p1 -b .osx-intel-port
 %patch10 -p1 -b .cross64-mingw32-fixes
+%patch11 -p1 -b .preserve-host-registers
 %patch12 -p1 -b .no-nptl
 %patch13 -p1 -b .fix-errno-tls
 %patch14 -p1 -b .dont-strip

Reply via email to