Merge "QEMU update with VENOM (CVE-2015-3456) patch" into 5.0.2
[packages/centos6/qemu.git] / 0079-w64-Fix-TCG-helper-functions-with-5-arguments.patch
1 From e35e8b9bb446ff2693962151b8c80c5c88294959 Mon Sep 17 00:00:00 2001
2 From: Stefan Weil <sw@weilnetz.de>
3 Date: Thu, 13 Sep 2012 19:37:43 +0200
4 Subject: [PATCH] w64: Fix TCG helper functions with 5 arguments
5
6 TCG uses 6 registers for function arguments on 64 bit Linux hosts,
7 but only 4 registers on W64 hosts.
8
9 Commit 2999a0b20074a7e4a58f56572bb1436749368f59 increased the number
10 of arguments for some important helper functions from 4 to 5
11 which triggered a bug for W64 hosts: QEMU aborts when executing
12 helper_lcall_real in the guest's BIOS because function
13 tcg_target_get_call_iarg_regs_count always returned 6.
14
15 As W64 has only 4 registers for arguments, the 5th argument must be
16 passed on the stack using a correct stack offset.
17
18 Signed-off-by: Stefan Weil <sw@weilnetz.de>
19 Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
20 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
21 ---
22  tcg/i386/tcg-target.c | 2 +-
23  tcg/i386/tcg-target.h | 4 ++++
24  2 files changed, 5 insertions(+), 1 deletion(-)
25
26 diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
27 index aa1fa9f..85c6b81 100644
28 --- a/tcg/i386/tcg-target.c
29 +++ b/tcg/i386/tcg-target.c
30 @@ -118,7 +118,7 @@ static void patch_reloc(uint8_t *code_ptr, int type,
31  static inline int tcg_target_get_call_iarg_regs_count(int flags)
32  {
33      if (TCG_TARGET_REG_BITS == 64) {
34 -        return 6;
35 +        return ARRAY_SIZE(tcg_target_call_iarg_regs);
36      }
37  
38      return 0;
39 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
40 index b356d76..ace63ba 100644
41 --- a/tcg/i386/tcg-target.h
42 +++ b/tcg/i386/tcg-target.h
43 @@ -67,7 +67,11 @@ typedef enum {
44  /* used for function call generation */
45  #define TCG_REG_CALL_STACK TCG_REG_ESP 
46  #define TCG_TARGET_STACK_ALIGN 16
47 +#if defined(_WIN64)
48 +#define TCG_TARGET_CALL_STACK_OFFSET 32
49 +#else
50  #define TCG_TARGET_CALL_STACK_OFFSET 0
51 +#endif
52  
53  /* optional instructions */
54  #define TCG_TARGET_HAS_div2_i32         1
55 -- 
56 1.7.12.1
57