linux-user: limit check to HOST_LONG_BITS == 32
PATCH v2 1/1 linux-user: limit check to HOST_LONG_BITS == 32
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.
---
v2
- move inside else bracket
--- linux-user/elfload.c | 2 ++ 1 file changed, 2 insertions(+)
linux-user/elfload.c +2 -0
@@ -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 }/*
Signature · 1 line
2.20.1
Quoted 13 lines · Alex Bennée
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.
linux-user/elfload.c static void pgb_have_guest_base(const char *image_name, abi_ulong guest_loaddr, · line 2083
Quoted 8 lines
linux-user/elfload.c +2
-0+#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
Quoted 10 lines · Alex Bennée
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.
Quoted 7 lines
So lets limit the check to 32 bit hosts only.
Fixes ee94743034bfReported-by Thomas Huth <[email protected]>Signed-off-by Alex Bennée <[email protected]>---
I say again that I'd prefer that we disable this warning.
r~