From: Anthony Liguori <anthony@codemonkey.ws>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Riku Voipio <riku.voipio@iki.fi>,
qemu-devel@nongnu.org, patches@linaro.org,
Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH] cpu-all.h: Don't accidentally sign extend in g2h()
Date: Mon, 12 Mar 2012 21:00:33 -0500 [thread overview]
Message-ID: <4F5EAA41.9030109@codemonkey.ws> (raw)
In-Reply-To: <1331303600-30715-1-git-send-email-peter.maydell@linaro.org>
On 03/09/2012 08:33 AM, Peter Maydell wrote:
> Cast the argument of the g2h() macro to a target_ulong so that
> it isn't accidentally sign-extended if it is a signed 32 bit
> type and long is a 64 bit type. In particular, this fixes a
> bug where it would return the wrong value for 32 bit guests
> on 64 bit hosts when passed in one of the arg* values from
> do_syscall() [which are all abi_long and thus signed types].
> This could result in spurious failure of mlock(), among others.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
Applied. Thanks.
Regards,
Anthony Liguori
> This should be committed before Alex's patch to make mmap allocate
> downwards (http://patchwork.ozlabs.org/patch/144476/) because that
> hugely increases the chances that g2h will get passed a pointer
> that has the high bit set.
>
> cpu-all.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 80e6d42..a174532 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -197,7 +197,7 @@ extern unsigned long reserved_va;
> #endif
>
> /* All direct uses of g2h and h2g need to go away for usermode softmmu. */
> -#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE))
> +#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE))
>
> #if HOST_LONG_BITS<= TARGET_VIRT_ADDR_SPACE_BITS
> #define h2g_valid(x) 1
prev parent reply other threads:[~2012-03-13 2:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-09 14:33 [Qemu-devel] [PATCH] cpu-all.h: Don't accidentally sign extend in g2h() Peter Maydell
2012-03-09 14:55 ` Andreas Färber
2012-03-09 15:06 ` Peter Maydell
2012-03-13 2:00 ` Anthony Liguori [this message]
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=4F5EAA41.9030109@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=agraf@suse.de \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).