qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/2] topic: meson: add more compiler hardening flags


From: Thomas Huth
Subject: Re: [PATCH 0/2] topic: meson: add more compiler hardening flags
Date: Mon, 9 Oct 2023 09:21:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

On 05/10/2023 19.38, Daniel P. Berrangé wrote:
...

I also tested enabling -ftrapv, to change signed integer
overflow from wrapping, to trapping instead. This exposed a
bug in the string-input-visitor which overflows when parsing
ranges, and exposed the test-int128 code as (harmlessly)
overflowing during its testing. Both can be fixed, but I'm
not entirely sure whether -ftrapv is viable or not. I was
wondering about TCG and whether it has a need to intentionally
allow integer overflow for any of its instruction emulation
requirements ?
I'm not an expert when it comes to this question, but as far as I understood, we are using -fwrapv (with "w", not "t") on purpose, see meson.build:

# We use -fwrapv to tell the compiler that we require a C dialect where
# left shift of signed integers is well defined and has the expected
# 2s-complement style results. (Both clang and gcc agree that it
# provides these semantics.)

And according to the man-page of gcc:

 The options -ftrapv and -fwrapv override each other,
 so using -ftrapv -fwrapv on the command-line results
 in -fwrapv being effective.

If I got that right, this means you cannot use -ftrapv with QEMU.

 Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]