* [PATCH] linux-user: limit check to HOST_LONG_BITS == 32
@ 2020-05-21 10:21 Alex Bennée
2020-05-21 10:29 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Alex Bennée @ 2020-05-21 10:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Thomas Huth, Riku Voipio, Alex Bennée, Laurent Vivier
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
}
/*
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-user: limit check to HOST_LONG_BITS == 32
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
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2020-05-21 10:29 UTC (permalink / raw)
To: Alex Bennée
Cc: Thomas Huth, Riku Voipio, QEMU Developers, Laurent Vivier
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?
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-user: limit check to HOST_LONG_BITS == 32
2020-05-21 10:29 ` Peter Maydell
@ 2020-05-21 12:32 ` Alex Bennée
0 siblings, 0 replies; 3+ messages in thread
From: Alex Bennée @ 2020-05-21 12:32 UTC (permalink / raw)
To: Peter Maydell; +Cc: Thomas Huth, Riku Voipio, QEMU Developers, Laurent Vivier
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-21 12:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.