From: "Alex Bennée" <alex.bennee@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Thomas Huth <thuth@redhat.com>, Riku Voipio <riku.voipio@iki.fi>,
QEMU Developers <qemu-devel@nongnu.org>,
Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH] linux-user: limit check to HOST_LONG_BITS == 32
Date: Thu, 21 May 2020 13:32:41 +0100 [thread overview]
Message-ID: <87blmhfoye.fsf@linaro.org> (raw)
In-Reply-To: <CAFEAcA-0f8tsTSu2nc9Z2tnEA4YBMbzWru1yUbW_xxM1=zV0JQ@mail.gmail.com>
Peter Maydell <peter.maydell@linaro.org> writes:
> On Thu, 21 May 2020 at 11:22, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Newer clangs rightly spot that you can never exceed the full address
>> space of 64 bit hosts with:
>>
>> linux-user/elfload.c:2076:41: error: result of comparison 'unsigned
>> long' > 18446744073709551615 is always false
>> [-Werror,-Wtautological-type-limit-compare]
>> 4685 if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) {
>> 4686 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
>> 4687 1 error generated.
>>
>> So lets limit the check to 32 bit hosts only.
>>
>> Fixes: ee94743034bf
>> Reported-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>> linux-user/elfload.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
>> index 01a9323a637..797fbf2337a 100644
>> --- a/linux-user/elfload.c
>> +++ b/linux-user/elfload.c
>> @@ -2072,6 +2072,7 @@ static void pgb_have_guest_base(const char *image_name, abi_ulong guest_loaddr,
>> image_name, (uint64_t)guest_hiaddr, reserved_va);
>> exit(EXIT_FAILURE);
>> }
>> +#if HOST_LONG_BITS == 32
>> } else {
>> if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) {
>> error_report("%s: requires more virtual address space "
>> @@ -2079,6 +2080,7 @@ static void pgb_have_guest_base(const char *image_name, abi_ulong guest_loaddr,
>> image_name, (uint64_t)guest_hiaddr - guest_base);
>> exit(EXIT_FAILURE);
>> }
>> +#endif
>
> Could we write this so that we have the #if...#endif
> conditional nested inside the if { ... } else { ... },
> rather than having the two conditional constructs
> oddly intermeshed?
Sure - I thought the compiler would complain about having an empty else
leg but I've just checked and it doesn't seem to care.
>
> thanks
> -- PMM
--
Alex Bennée
prev parent reply other threads:[~2020-05-21 12:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 10:21 [PATCH] linux-user: limit check to HOST_LONG_BITS == 32 Alex Bennée
2020-05-21 10:29 ` Peter Maydell
2020-05-21 12:32 ` Alex Bennée [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=87blmhfoye.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=laurent@vivier.eu \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=thuth@redhat.com \
/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).