* [PATCH v2] linux-user: limit check to HOST_LONG_BITS == 32
@ 2020-05-21 13:57 Alex Bennée
2020-05-21 14:08 ` Peter Maydell
2020-05-22 3:15 ` Richard Henderson
0 siblings, 2 replies; 3+ messages in thread
From: Alex Bennée @ 2020-05-21 13:57 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>
---
v2
- move inside else bracket
---
linux-user/elfload.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 01a9323a637..de82eaf5420 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2073,12 +2073,14 @@ static void pgb_have_guest_base(const char *image_name, abi_ulong guest_loaddr,
exit(EXIT_FAILURE);
}
} else {
+#if HOST_LONG_BITS == 32
if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) {
error_report("%s: requires more virtual address space "
"than the host can provide (0x%" PRIx64 ")",
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 v2] linux-user: limit check to HOST_LONG_BITS == 32
2020-05-21 13:57 [PATCH v2] linux-user: limit check to HOST_LONG_BITS == 32 Alex Bennée
@ 2020-05-21 14:08 ` Peter Maydell
2020-05-22 3:15 ` Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2020-05-21 14:08 UTC (permalink / raw)
To: Alex Bennée
Cc: Thomas Huth, Riku Voipio, QEMU Developers, Laurent Vivier
On Thu, 21 May 2020 at 14:58, 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.
> +#if HOST_LONG_BITS == 32
> if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) {
> error_report("%s: requires more virtual address space "
> "than the host can provide (0x%" PRIx64 ")",
> image_name, (uint64_t)guest_hiaddr - guest_base);
> exit(EXIT_FAILURE);
> }
> +#endif
Is this also a tautological compare in the host==32 && guest==32
case? Do we maybe want "#if HOST_LONG_BITS < TARGET_ABI_BITS" ?
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] linux-user: limit check to HOST_LONG_BITS == 32
2020-05-21 13:57 [PATCH v2] linux-user: limit check to HOST_LONG_BITS == 32 Alex Bennée
2020-05-21 14:08 ` Peter Maydell
@ 2020-05-22 3:15 ` Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2020-05-22 3:15 UTC (permalink / raw)
To: Alex Bennée, qemu-devel; +Cc: Thomas Huth, Riku Voipio, Laurent Vivier
On 5/21/20 6:57 AM, Alex Bennée 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>
>
> ---
I say again that I'd prefer that we disable this warning.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-22 3:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 13:57 [PATCH v2] linux-user: limit check to HOST_LONG_BITS == 32 Alex Bennée
2020-05-21 14:08 ` Peter Maydell
2020-05-22 3:15 ` Richard Henderson
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).