qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Thomas Huth <thuth@redhat.com>, Cornelia Huck <cohuck@redhat.com>,
	Riku Voipio <riku.voipio@iki.fi>,
	qemu-devel@nongnu.org, Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH v1 04/10] linux-user: completely re-write init_guest_space
Date: Fri, 22 May 2020 11:24:12 +0100	[thread overview]
Message-ID: <87tv08e08j.fsf@linaro.org> (raw)
In-Reply-To: <0fcdef39-2e6f-11db-121b-874805ff2518@linaro.org>


Richard Henderson <richard.henderson@linaro.org> writes:

> On 5/21/20 1:21 AM, Alex Bennée wrote:
>> 
>> Thomas Huth <thuth@redhat.com> writes:
>> 
>>> On 13/05/2020 19.51, Alex Bennée wrote:
>>>> First we ensure all guest space initialisation logic comes through
>>>> probe_guest_base once we understand the nature of the binary we are
>>>> loading. The convoluted init_guest_space routine is removed and
>>>> replaced with a number of pgb_* helpers which are called depending on
>>>> what requirements we have when loading the binary.
>>>>
>>>> We first try to do what is requested by the host. Failing that we try
>>>> and satisfy the guest requested base address. If all those options
>>>> fail we fall back to finding a space in the memory map using our
>>>> recently written read_self_maps() helper.
>>>>
>>>> There are some additional complications we try and take into account
>>>> when looking for holes in the address space. We try not to go directly
>>>> after the system brk() space so there is space for a little growth. We
>>>> also don't want to have to use negative offsets which would result in
>>>> slightly less efficient code on x86 when it's unable to use the
>>>> segment offset register.
>>>>
>>>> Less mind-binding gotos and hopefully clearer logic throughout.
>>>>
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> Acked-by: Laurent Vivier <laurent@vivier.eu>
>> <snip>
>>>> +    } else {
>>>> +        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);
>>>>          }
>>>
>>>  Hi Alex,
>>>
>>> this causes an error with newer versions of Clang:
>>>
>>> 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.
>>>
>>> Any ideas how to fix this?
>> 
>> I guess this check only makes sense when abi_ulong > uintptr_t or IOW 64
>> bit guests running on 32 bit hosts. We could just wrap that check in:
>> 
>> #if HOST_LONG_BITS == 32
>> 
>> #endif
>
> As I've suggested elsewhere, I think we should disable this warning on the
> command-line.

Yeah - although after having pushed down this bug it seems there are
still a lot of things clang-10 is finding. I think maybe I should punt
the fedora32 bump to a new series of clang-10 fixups?

Examples:

  /tmp/qemu-test/src/fpu/softfloat.c:3365:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
      absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              !
  /tmp/qemu-test/src/fpu/softfloat.c:3423:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
          absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   !


  /tmp/qemu-test/src/audio/mixeng.c:274:34: error: implicit conversion from 'unsigned int' to 'float' changes value from 4294967295 to 4294967296 [-Werror,-Wimplicit-int-float-conversion]
  static const float float_scale = UINT_MAX / 2.f;
                                   ^~~~~~~~ ~
  /usr/lib64/clang/10.0.0/include/limits.h:56:37: note: expanded from macro 'UINT_MAX'
  #define UINT_MAX  (__INT_MAX__  *2U +1U)
                     ~~~~~~~~~~~~~~~~~^~~


-- 
Alex Bennée


  reply	other threads:[~2020-05-22 10:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 17:51 [PATCH v1 00/10] testing and tcg tweaks Alex Bennée
2020-05-13 17:51 ` [PATCH v1 01/10] tests/guest-debug: catch hanging guests Alex Bennée
2020-05-21 14:06   ` Philippe Mathieu-Daudé
2020-05-13 17:51 ` [PATCH v1 02/10] travis.yml: Improve the --disable-tcg test on s390x Alex Bennée
2020-05-13 17:51 ` [PATCH v1 03/10] tests/docker: Kludge <linux/swab.h> breakage by pinning linux-libc-dev Alex Bennée
2020-05-13 17:51 ` [PATCH v1 04/10] linux-user: completely re-write init_guest_space Alex Bennée
2020-05-21  4:43   ` Thomas Huth
2020-05-21  8:21     ` Alex Bennée
2020-05-21 15:39       ` Richard Henderson
2020-05-22 10:24         ` Alex Bennée [this message]
2020-05-22 10:36           ` Peter Maydell
2020-05-13 17:51 ` [PATCH v1 05/10] exec/cpu-all: Use bool for have_guest_base Alex Bennée
2020-05-13 18:18   ` Laurent Vivier
2020-05-13 17:51 ` [PATCH v1 06/10] accel/tcg: Relax va restrictions on 64-bit guests Alex Bennée
2020-05-13 17:51 ` [PATCH v1 07/10] accel/tcg: don't disable exec_tb trace events Alex Bennée
2020-05-13 17:51 ` [PATCH v1 08/10] disas: include an optional note for the start of disassembly Alex Bennée
2020-05-13 17:51 ` [PATCH v1 09/10] disas: add optional note support to cap_disas Alex Bennée
2020-05-13 17:51 ` [PATCH v1 10/10] translate-all: include guest address in out_asm output Alex Bennée
2020-05-21 14:04   ` Philippe Mathieu-Daudé

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=87tv08e08j.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=cohuck@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).