Blame 0079-w64-Fix-TCG-helper-functions-with-5-arguments.patch

5544c1
From e35e8b9bb446ff2693962151b8c80c5c88294959 Mon Sep 17 00:00:00 2001
5544c1
From: Stefan Weil <sw@weilnetz.de>
5544c1
Date: Thu, 13 Sep 2012 19:37:43 +0200
5544c1
Subject: [PATCH] w64: Fix TCG helper functions with 5 arguments
5544c1
5544c1
TCG uses 6 registers for function arguments on 64 bit Linux hosts,
5544c1
but only 4 registers on W64 hosts.
5544c1
5544c1
Commit 2999a0b20074a7e4a58f56572bb1436749368f59 increased the number
5544c1
of arguments for some important helper functions from 4 to 5
5544c1
which triggered a bug for W64 hosts: QEMU aborts when executing
5544c1
helper_lcall_real in the guest's BIOS because function
5544c1
tcg_target_get_call_iarg_regs_count always returned 6.
5544c1
5544c1
As W64 has only 4 registers for arguments, the 5th argument must be
5544c1
passed on the stack using a correct stack offset.
5544c1
5544c1
Signed-off-by: Stefan Weil <sw@weilnetz.de>
5544c1
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 tcg/i386/tcg-target.c | 2 +-
5544c1
 tcg/i386/tcg-target.h | 4 ++++
5544c1
 2 files changed, 5 insertions(+), 1 deletion(-)
5544c1
5544c1
diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
5544c1
index aa1fa9f..85c6b81 100644
5544c1
--- a/tcg/i386/tcg-target.c
5544c1
+++ b/tcg/i386/tcg-target.c
5544c1
@@ -118,7 +118,7 @@ static void patch_reloc(uint8_t *code_ptr, int type,
5544c1
 static inline int tcg_target_get_call_iarg_regs_count(int flags)
5544c1
 {
5544c1
     if (TCG_TARGET_REG_BITS == 64) {
5544c1
-        return 6;
5544c1
+        return ARRAY_SIZE(tcg_target_call_iarg_regs);
5544c1
     }
5544c1
 
5544c1
     return 0;
5544c1
diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
5544c1
index b356d76..ace63ba 100644
5544c1
--- a/tcg/i386/tcg-target.h
5544c1
+++ b/tcg/i386/tcg-target.h
5544c1
@@ -67,7 +67,11 @@ typedef enum {
5544c1
 /* used for function call generation */
5544c1
 #define TCG_REG_CALL_STACK TCG_REG_ESP 
5544c1
 #define TCG_TARGET_STACK_ALIGN 16
5544c1
+#if defined(_WIN64)
5544c1
+#define TCG_TARGET_CALL_STACK_OFFSET 32
5544c1
+#else
5544c1
 #define TCG_TARGET_CALL_STACK_OFFSET 0
5544c1
+#endif
5544c1
 
5544c1
 /* optional instructions */
5544c1
 #define TCG_TARGET_HAS_div2_i32         1
5544c1
-- 
5544c1
1.7.12.1
5544c1