All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Stefan Weil <sw@weilnetz.de>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Alexander Graf <agraf@suse.de>,
	qemu-devel@nongnu.org, Blue Swirl <blauwirbel@gmail.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments
Date: Sat, 22 Sep 2012 16:55:08 +0200	[thread overview]
Message-ID: <20120922145508.GA19973@ohm.aurel32.net> (raw)
In-Reply-To: <1347557866-7256-2-git-send-email-sw@weilnetz.de>

On Thu, Sep 13, 2012 at 07:37:43PM +0200, Stefan Weil wrote:
> TCG uses 6 registers for function arguments on 64 bit Linux hosts,
> but only 4 registers on W64 hosts.
> 
> Commit 2999a0b20074a7e4a58f56572bb1436749368f59 increased the number
> of arguments for some important helper functions from 4 to 5
> which triggered a bug for W64 hosts: QEMU aborts when executing
> helper_lcall_real in the guest's BIOS because function
> tcg_target_get_call_iarg_regs_count always returned 6.
> 
> As W64 has only 4 registers for arguments, the 5th argument must be
> passed on the stack using a correct stack offset.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  tcg/i386/tcg-target.c |    2 +-
>  tcg/i386/tcg-target.h |    4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
> index da17bba..43b5572 100644
> --- a/tcg/i386/tcg-target.c
> +++ b/tcg/i386/tcg-target.c
> @@ -118,7 +118,7 @@ static void patch_reloc(uint8_t *code_ptr, int type,
>  static inline int tcg_target_get_call_iarg_regs_count(int flags)
>  {
>      if (TCG_TARGET_REG_BITS == 64) {
> -        return 6;
> +        return ARRAY_SIZE(tcg_target_call_iarg_regs);
>      }
>  
>      return 0;
> diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
> index c3cfe05..87417d0 100644
> --- a/tcg/i386/tcg-target.h
> +++ b/tcg/i386/tcg-target.h
> @@ -67,7 +67,11 @@ typedef enum {
>  /* used for function call generation */
>  #define TCG_REG_CALL_STACK TCG_REG_ESP 
>  #define TCG_TARGET_STACK_ALIGN 16
> +#if defined(_WIN64)
> +#define TCG_TARGET_CALL_STACK_OFFSET 32
> +#else
>  #define TCG_TARGET_CALL_STACK_OFFSET 0
> +#endif
>  
>  /* optional instructions */
>  #define TCG_TARGET_HAS_div2_i32         1
> -- 
> 1.7.10
> 
> 

Thanks, applied.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  parent reply	other threads:[~2012-09-22 14:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 17:37 [Qemu-devel] [PATCH v2 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Stefan Weil
2012-09-13 17:37 ` [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments Stefan Weil
2012-09-13 21:22   ` Aurelien Jarno
2012-09-22 14:55   ` Aurelien Jarno [this message]
2012-09-13 17:37 ` [Qemu-devel] [PATCH 2/4] tcg/i386: Add shortcuts for registers used in L constraint Stefan Weil
2012-09-13 21:21   ` Aurelien Jarno
2012-09-13 21:30     ` Richard Henderson
2012-09-13 21:47       ` Aurelien Jarno
2012-09-13 22:03         ` Peter Maydell
2012-09-13 22:20           ` Richard Henderson
2012-09-14  5:18             ` Stefan Weil
2012-09-22 14:55               ` Aurelien Jarno
2012-09-13 17:37 ` [Qemu-devel] [PATCH 3/4] tcg/i386: Remove unused registers from tcg_target_call_iarg_regs Stefan Weil
2012-09-13 21:22   ` Aurelien Jarno
2012-09-22 14:55   ` Aurelien Jarno
2012-09-13 17:37 ` [Qemu-devel] [PATCH 4/4] tcg: Remove tcg_target_get_call_iarg_regs_count Stefan Weil
2012-09-13 21:22   ` Aurelien Jarno
2012-09-22 14:55   ` Aurelien Jarno
2012-09-13 17:52 ` [Qemu-devel] [PATCH v2 0/4] Fix and clean tcg_target_get_call_iarg_regs_count Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2012-09-12 20:44 [Qemu-devel] [PATCH " Stefan Weil
2012-09-12 20:44 ` [Qemu-devel] [PATCH 1/4] w64: Fix TCG helper functions with 5 arguments Stefan Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120922145508.GA19973@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=agraf@suse.de \
    --cc=blauwirbel@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.