unicorn/qemu/include
Eric Blake be742759b0
osdep: Fix ROUND_UP(64-bit, 32-bit)
When using bit-wise operations that exploit the power-of-two
nature of the second argument of ROUND_UP(), we still need to
ensure that the mask is as wide as the first argument (done
by using a ternary to force proper arithmetic promotion).
Unpatched, ROUND_UP(2ULL*1024*1024*1024*1024, 512U) produces 0,
instead of the intended 2TiB, because negation of an unsigned
32-bit quantity followed by widening to 64-bits does not
sign-extend the mask.

Broken since its introduction in commit 292c8e50 (v1.5.0).
Callers that passed the same width type to both macro parameters,
or that had other code to ensure the first parameter's maximum
runtime value did not exceed the second parameter's width, are
unaffected, but I did not audit to see which (if any) existing
clients of the macro could trigger incorrect behavior (I found
the bug while adding a new use of the macro).

While preparing the patch, checkpatch complained about poor
spacing, so I also fixed that here and in the nearby DIV_ROUND_UP.

Backports commit 33a599667a9e70588483a31286dfff8cfc27d513 from qemu
2018-03-04 01:54:09 -05:00
..
crypto Drop unused crypto source files 2018-02-17 15:23:57 -05:00
exec tcg: Pass generic CPUState to gen_intermediate_code() 2018-03-03 23:34:18 -05:00
fpu softfloat: define floatx80_round() 2018-03-03 20:57:27 -05:00
hw include/hw/boards.h: Document memory_region_allocate_system_memory() 2018-03-03 22:18:49 -05:00
qapi qnum: add uint type 2018-03-03 18:37:56 -05:00
qemu osdep: Fix ROUND_UP(64-bit, 32-bit) 2018-03-04 01:54:09 -05:00
qom Revert "cpu: add APIs to allocate/free CPU environment" 2018-03-04 01:42:49 -05:00
sysemu tcg: add options for enabling MTTCG 2018-03-02 09:25:01 -05:00
config.h import 2015-08-21 15:04:50 +08:00
elf.h fix merge conflicts 2017-03-10 21:04:33 +08:00
glib_compat.h qapi: Improve qobject input visitor error reporting 2018-03-02 12:05:53 -05:00
qemu-common.h tcg: Add EXCP_ATOMIC 2018-02-27 11:57:58 -05:00