[vbox-dev] [PATCH] Some 64-bit fixes
Gwenole Beauchesne
gbeauchesne at mandriva.com
Sat Feb 3 17:42:05 GMT 2007
Hi,
Here are few patches to fix enough of Virtual Box to make it run on x86_64
when built with BUILD_TYPE=release (default). Should you still require an
ICA or a particular MIT license for such trivial changes, then I would
only opt for the latter (MIT license) at this time.
BTW, updated binary packages will also reach Mandriva Cooker:
<http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/virtualbox/current/>
Regards,
Gwenole Beauchesne.
2007-02-03 Gwenole Beauchesne <gbeauchesne at mandriva.com>
* Various 64-bit fixes.
--- vbox-1.3.3/include/iprt/asm.h.64bit-fixes 2007-02-02 15:17:17.000000000 +0100
+++ vbox-1.3.3/include/iprt/asm.h 2007-02-03 10:53:35.000000000 +0100
@@ -521,6 +521,19 @@ DECLASM(void) ASMCpuId(uint32_t uOperato
DECLINLINE(void) ASMCpuId(uint32_t uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX)
{
# if RT_INLINE_ASM_GNU_STYLE
+# ifdef __AMD64__
+ uint32_t uEAX;
+ uint32_t uEBX;
+ uint32_t uECX;
+ uint32_t uEDX;
+ __asm__ ("cpuid"
+ : "=a" (uEAX), "=b" (uEBX), "=c" (uECX), "=d" (uEDX)
+ : "0" (uOperator));
+ *(uint32_t *)pvEAX = uEAX;
+ *(uint32_t *)pvEBX = uEBX;
+ *(uint32_t *)pvECX = uECX;
+ *(uint32_t *)pvEDX = uEDX;
+# else
__asm__ ("xchgl %%ebx, %1\n\t"
"cpuid\n\t"
"xchgl %%ebx, %1\n\t"
@@ -529,6 +542,7 @@ DECLINLINE(void) ASMCpuId(uint32_t uOper
"=c" (*(uint32_t *)pvECX),
"=d" (*(uint32_t *)pvEDX)
: "0" (uOperator));
+# endif
# elif RT_INLINE_ASM_USES_INTRIN
int aInfo[4];
--- vbox-1.3.3/src/recompiler/new/cpu-exec.c.64bit-fixes 2007-01-23 10:30:18.000000000 +0100
+++ vbox-1.3.3/src/recompiler/new/cpu-exec.c 2007-02-03 11:57:57.000000000 +0100
@@ -228,32 +228,8 @@ static inline TranslationBlock *tb_find_
int cpu_exec(CPUState *env1)
{
- int saved_T0, saved_T1, saved_T2;
- CPUState *saved_env;
-#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
+#define DO_HOST_REGS_DECLARE
+#include "hostregs_helper.h"
#if defined(__sparc__) && !defined(HOST_SOLARIS)
int saved_i7, tmp_T0;
#endif
@@ -317,44 +293,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);
@@ -627,39 +574,13 @@ int cpu_exec(CPUState *env1)
#if defined(TARGET_I386)
/* 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
#else
#error unsupported target CPU
#endif
- T0 = saved_T0;
- T1 = saved_T1;
- T2 = saved_T2;
- env = saved_env;
+
+ /* restore global registers */
+#define DO_HOST_REGS_RESTORE
+#include "hostregs_helper.h"
return ret;
}
--- vbox-1.3.3/src/recompiler/new/hostregs_helper.h.64bit-fixes 2007-02-03 12:00:03.000000000 +0100
+++ vbox-1.3.3/src/recompiler/new/hostregs_helper.h 2007-02-03 11:51:06.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
--- vbox-1.3.3/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_util.c.64bit-fixes 2007-01-23 10:30:24.000000000 +0100
+++ vbox-1.3.3/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_util.c 2007-02-03 10:53:35.000000000 +0100
@@ -39,6 +39,8 @@
* Utility functions called by various backends.
*/
+#define _GNU_SOURCE 1
+#include <string.h>
#include "xpidl.h"
/* XXXbe static */ char OOM[] = "ERROR: out of memory\n";
--- vbox-1.3.3/src/VBox/Main/MachineImpl.cpp.64bit-fixes 2007-02-02 15:17:23.000000000 +0100
+++ vbox-1.3.3/src/VBox/Main/MachineImpl.cpp 2007-02-03 16:09:36.000000000 +0100
@@ -2386,8 +2386,8 @@ HRESULT Machine::openSession (IInternalS
* one started by #openRemoteSession().
*/
- RTPROCESS pid = NIL_RTPROCESS;
- aControl->GetPID ((ULONG *) &pid);
+ ULONG pid = NIL_RTPROCESS;
+ aControl->GetPID (&pid);
LogFlowThisFunc (("mSession.mPid=%d(0x%x)\n",
mData->mSession.mPid, mData->mSession.mPid));
More information about the vbox-dev
mailing list