mbox series

[v5,00/46] Use the IEC binary prefix definitions

Message ID 20180625124238.25339-1-f4bug@amsat.org
Headers show
Series Use the IEC binary prefix definitions | expand

Message

Philippe Mathieu-Daudé June 25, 2018, 12:41 p.m. UTC
Hi,

This series:

- split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
  (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
- clean hw/ includes;
- replace different constants used for byte size with their corresponding
  IEC binary prefix definitions.

Since v4:
- fixed checkpatch (do not match the IEC binary prefix as camelcase typedefs)
- use signed format for size (Richard)
- fix 32-bit (Thomas)
- update '[<>][<>]= ?[1-5]0', adding 5 new patches (Eric)

Since v3:
- use IEC binary prefix definitions (Stefan Weil)
- rebased
- added R-b tags

Since v2:
- use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé)
- avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth)
- more constant replaced

Since v1:
- corrected Xen mult -> div (Alan Robinson)
- tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC
- fixed mips_r4k 'params_size' (Thomas Huth)
- added command used to generate patch in each commit (Alistair Francis)
- use G_BYTE for the raspi3 machine
- added Reviewed-by tags

Regards,

Phil.

[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/46:[0012] [FC] 'include: Add IEC binary prefixes in "qemu/units.h"'
002/46:[0005] [FC] 'vdi: Use definitions from "qemu/units.h"'
003/46:[----] [--] 'x86/cpu: Use definitions from "qemu/units.h"'
004/46:[0002] [FC] 'checkpatch: Recognize IEC binary prefix definitions'
005/46:[----] [-C] 'hw: Use IEC binary prefix definitions from "qemu/units.h"'
006/46:[----] [--] 'hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"'
007/46:[----] [--] 'hw/ivshmem: Use the IEC binary prefix definitions'
008/46:[----] [--] 'hw/ipack: Use the IEC binary prefix definitions'
009/46:[----] [--] 'hw/scsi: Use the IEC binary prefix definitions'
010/46:[----] [--] 'hw/smbios: Use the IEC binary prefix definitions'
011/46:[0002] [FC] 'hw/xen: Use the IEC binary prefix definitions'
012/46:[----] [--] 'hw/tpm: Use the IEC binary prefix definitions'
013/46:[----] [--] 'hw/block: Use the IEC binary prefix definitions'
014/46:[0008] [FC] 'hw/display: Use the IEC binary prefix definitions'
015/46:[----] [--] 'hw/misc: Use the IEC binary prefix definitions'
016/46:[----] [--] 'hw/riscv: Use the IEC binary prefix definitions'
017/46:[----] [--] 'hw/m68k: Use the IEC binary prefix definitions'
018/46:[0006] [FC] 'hw/sparc: Use the IEC binary prefix definitions'
019/46:[0003] [FC] 'hw/s390x: Use the IEC binary prefix definitions'
020/46:[0004] [FC] 'hw/hppa: Use the IEC binary prefix definitions'
021/46:[0009] [FC] 'hw/xtensa: Use the IEC binary prefix definitions'
022/46:[----] [--] 'hw/alpha: Use the IEC binary prefix definitions'
023/46:[----] [--] 'hw/tricore: Use the IEC binary prefix definitions'
024/46:[----] [--] 'hw/microblaze: Use the IEC binary prefix definitions'
025/46:[----] [--] 'hw/nios2: Use the IEC binary prefix definitions'
026/46:[----] [--] 'hw/cris: Use the IEC binary prefix definitions'
027/46:[----] [--] 'hw/lm32: Use the IEC binary prefix definitions'
028/46:[----] [--] 'hw/sh4: Use the IEC binary prefix definitions'
029/46:[----] [--] 'hw/mips/r4k: Constify params_size'
030/46:[0012] [FC] 'hw/mips: Use the IEC binary prefix definitions'
031/46:[----] [--] 'hw/arm: Use the IEC binary prefix definitions'
032/46:[0022] [FC] 'hw/ppc: Use the IEC binary prefix definitions'
033/46:[0006] [FC] 'hw/i386: Use the IEC binary prefix definitions'
034/46:[----] [--] 'hw/net: Use the IEC binary prefix definitions'
035/46:[0002] [FC] 'hw/usb: Use the IEC binary prefix definitions'
036/46:[0002] [FC] 'hw/sd: Use the IEC binary prefix definitions'
037/46:[----] [--] 'hw/vfio: Use the IEC binary prefix definitions'
038/46:[----] [--] 'hw/virtio: Use the IEC binary prefix definitions'
039/46:[----] [--] 'hw/rdma: Use the IEC binary prefix definitions'
040/46:[----] [--] 'cutils: Do not include "qemu/units.h" directly'
041/46:[0148] [FC] 'hw/ppc: Use the IEC binary prefix definitions'
042/46:[down] 'monitor: Use the IEC binary prefix definitions'
043/46:[down] 'vl: Use the IEC binary prefix definitions'
044/46:[down] 'tests/crypto: Use the IEC binary prefix definitions'
045/46:[down] 'linux-user: Use the IEC binary prefix definitions'
046/46:[down] 'bsd-user: Use the IEC binary prefix definitions'

Philippe Mathieu-Daudé (46):
  include: Add IEC binary prefixes in "qemu/units.h"
  vdi: Use definitions from "qemu/units.h"
  x86/cpu: Use definitions from "qemu/units.h"
  checkpatch: Recognize IEC binary prefix definitions
  hw: Use IEC binary prefix definitions from "qemu/units.h"
  hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
  hw/ivshmem: Use the IEC binary prefix definitions
  hw/ipack: Use the IEC binary prefix definitions
  hw/scsi: Use the IEC binary prefix definitions
  hw/smbios: Use the IEC binary prefix definitions
  hw/xen: Use the IEC binary prefix definitions
  hw/tpm: Use the IEC binary prefix definitions
  hw/block: Use the IEC binary prefix definitions
  hw/display: Use the IEC binary prefix definitions
  hw/misc: Use the IEC binary prefix definitions
  hw/riscv: Use the IEC binary prefix definitions
  hw/m68k: Use the IEC binary prefix definitions
  hw/sparc: Use the IEC binary prefix definitions
  hw/s390x: Use the IEC binary prefix definitions
  hw/hppa: Use the IEC binary prefix definitions
  hw/xtensa: Use the IEC binary prefix definitions
  hw/alpha: Use the IEC binary prefix definitions
  hw/tricore: Use the IEC binary prefix definitions
  hw/microblaze: Use the IEC binary prefix definitions
  hw/nios2: Use the IEC binary prefix definitions
  hw/cris: Use the IEC binary prefix definitions
  hw/lm32: Use the IEC binary prefix definitions
  hw/sh4: Use the IEC binary prefix definitions
  hw/mips/r4k: Constify params_size
  hw/mips: Use the IEC binary prefix definitions
  hw/arm: Use the IEC binary prefix definitions
  hw/ppc: Use the IEC binary prefix definitions
  hw/i386: Use the IEC binary prefix definitions
  hw/net: Use the IEC binary prefix definitions
  hw/usb: Use the IEC binary prefix definitions
  hw/sd: Use the IEC binary prefix definitions
  hw/vfio: Use the IEC binary prefix definitions
  hw/virtio: Use the IEC binary prefix definitions
  hw/rdma: Use the IEC binary prefix definitions
  cutils: Do not include "qemu/units.h" directly
  hw/ppc: Use the IEC binary prefix definitions
  monitor: Use the IEC binary prefix definitions
  vl: Use the IEC binary prefix definitions
  tests/crypto: Use the IEC binary prefix definitions
  linux-user: Use the IEC binary prefix definitions
  bsd-user: Use the IEC binary prefix definitions

 hw/net/ne2000.h                          |  5 ++--
 hw/ppc/mac.h                             |  3 ++-
 hw/rdma/vmw/pvrdma.h                     |  3 ++-
 include/hw/acpi/tpm.h                    |  3 ++-
 include/hw/arm/fsl-imx7.h                |  5 ++--
 include/hw/arm/stm32f205_soc.h           |  5 ++--
 include/hw/display/xlnx_dp.h             |  5 ++--
 include/hw/i386/ich9.h                   |  3 ++-
 include/hw/intc/mips_gic.h               |  3 ++-
 include/hw/mips/bios.h                   |  3 ++-
 include/hw/net/allwinner_emac.h          |  5 ++--
 include/hw/ppc/spapr.h                   |  5 ++--
 include/hw/virtio/virtio-net.h           |  3 ++-
 include/qemu/cutils.h                    |  7 ------
 include/qemu/units.h                     | 20 ++++++++++++++++
 block/vdi.c                              |  7 +++---
 bsd-user/main.c                          |  5 ++--
 hw/alpha/typhoon.c                       | 17 +++++++-------
 hw/arm/bcm2835_peripherals.c             |  3 ++-
 hw/arm/boot.c                            |  7 +++---
 hw/arm/collie.c                          |  5 ++--
 hw/arm/digic_boards.c                    |  7 +++---
 hw/arm/exynos4_boards.c                  |  3 ++-
 hw/arm/gumstix.c                         |  3 ++-
 hw/arm/integratorcp.c                    |  3 ++-
 hw/arm/mainstone.c                       |  3 ++-
 hw/arm/msf2-soc.c                        |  6 ++---
 hw/arm/msf2-som.c                        |  8 +++----
 hw/arm/musicpal.c                        |  9 +++----
 hw/arm/omap_sx1.c                        | 11 +++++----
 hw/arm/raspi.c                           |  5 ++--
 hw/arm/smmu-common.c                     |  3 ++-
 hw/arm/stellaris.c                       |  5 ++--
 hw/arm/versatilepb.c                     |  5 ++--
 hw/arm/vexpress.c                        |  7 +++---
 hw/arm/virt.c                            |  5 ++--
 hw/arm/xilinx_zynq.c                     |  7 +++---
 hw/block/m25p80.c                        |  5 ++--
 hw/block/nvme.c                          |  3 ++-
 hw/block/tc58128.c                       |  3 ++-
 hw/block/xen_disk.c                      |  3 ++-
 hw/core/loader-fit.c                     |  3 ++-
 hw/core/machine.c                        |  4 ++--
 hw/cris/axis_dev88.c                     |  3 ++-
 hw/display/bochs-display.c               |  9 +++----
 hw/display/cirrus_vga.c                  | 10 ++++----
 hw/display/g364fb.c                      |  4 ++--
 hw/display/qxl.c                         | 30 +++++++++++-------------
 hw/display/sm501.c                       | 16 ++++++-------
 hw/display/vga-isa-mm.c                  |  5 ++--
 hw/display/vga.c                         |  5 ++--
 hw/display/virtio-gpu.c                  |  4 ++--
 hw/display/vmware_vga.c                  |  3 ++-
 hw/display/xenfb.c                       |  3 ++-
 hw/hppa/dino.c                           |  5 ++--
 hw/hppa/machine.c                        | 12 +++++-----
 hw/i386/acpi-build.c                     |  5 ++--
 hw/i386/pc.c                             | 19 ++++++++-------
 hw/i386/pc_piix.c                        |  4 ++--
 hw/i386/pc_q35.c                         |  3 ++-
 hw/i386/pc_sysfw.c                       |  9 +++----
 hw/i386/xen/xen-mapcache.c               |  3 ++-
 hw/intc/apic_common.c                    |  3 ++-
 hw/ipack/tpci200.c                       |  5 ++--
 hw/lm32/lm32_boards.c                    | 13 +++++-----
 hw/lm32/milkymist.c                      | 10 ++++----
 hw/m68k/mcf5208.c                        |  3 ++-
 hw/microblaze/petalogix_ml605_mmu.c      |  7 +++---
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  7 +++---
 hw/mips/boston.c                         | 30 ++++++++++++------------
 hw/mips/mips_fulong2e.c                  |  7 +++---
 hw/mips/mips_malta.c                     | 25 +++++++++++---------
 hw/mips/mips_r4k.c                       | 15 ++++++------
 hw/misc/aspeed_sdmc.c                    |  9 +++----
 hw/misc/auxbus.c                         |  3 ++-
 hw/misc/edu.c                            |  3 ++-
 hw/misc/imx7_gpr.c                       |  3 ++-
 hw/misc/ivshmem.c                        |  3 ++-
 hw/misc/mips_itu.c                       |  3 ++-
 hw/misc/omap_gpmc.c                      |  5 ++--
 hw/net/e1000e.c                          |  7 +++---
 hw/net/e1000x_common.c                   |  3 ++-
 hw/net/eepro100.c                        |  3 +--
 hw/nios2/boot.c                          |  6 ++---
 hw/nvram/spapr_nvram.c                   | 11 +++++----
 hw/pci-host/designware.c                 |  3 ++-
 hw/pci-host/gpex.c                       |  3 ++-
 hw/pci-host/piix.c                       |  5 ++--
 hw/pci-host/prep.c                       |  3 ++-
 hw/pci-host/q35.c                        | 17 +++++++-------
 hw/pci-host/xilinx-pcie.c                |  5 ++--
 hw/ppc/e500.c                            | 13 +++++-----
 hw/ppc/e500plat.c                        |  3 ++-
 hw/ppc/mac_newworld.c                    |  1 -
 hw/ppc/mac_oldworld.c                    |  9 ++++---
 hw/ppc/pnv.c                             |  6 ++---
 hw/ppc/ppc405_boards.c                   |  9 +++----
 hw/ppc/ppc405_uc.c                       |  7 +++---
 hw/ppc/ppc440_bamboo.c                   |  5 ++--
 hw/ppc/ppc440_uc.c                       | 28 +++++++++++-----------
 hw/ppc/ppc4xx_devs.c                     | 22 +++++++++--------
 hw/ppc/ppce500_spin.c                    |  3 ++-
 hw/ppc/prep.c                            |  6 ++---
 hw/ppc/rs6000_mc.c                       | 13 +++++-----
 hw/ppc/sam460ex.c                        | 18 +++++++-------
 hw/ppc/spapr.c                           | 12 +++++-----
 hw/ppc/spapr_rtas.c                      |  2 +-
 hw/ppc/virtex_ml507.c                    |  7 +++---
 hw/riscv/virt.c                          |  3 ++-
 hw/s390x/s390-skeys.c                    |  3 ++-
 hw/s390x/s390-stattrib.c                 |  3 ++-
 hw/s390x/sclp.c                          |  3 ++-
 hw/scsi/scsi-disk.c                      |  9 +++----
 hw/sd/sd.c                               |  8 +++----
 hw/sd/sdhci.c                            |  8 +++----
 hw/sh4/r2d.c                             |  3 ++-
 hw/smbios/smbios.c                       | 15 +++++-------
 hw/sparc/leon3.c                         | 10 ++++----
 hw/sparc/sun4m.c                         | 10 ++++----
 hw/sparc64/niagara.c                     |  3 ++-
 hw/sparc64/sun4u.c                       |  4 ++--
 hw/ssi/aspeed_smc.c                      | 29 ++++++++++++-----------
 hw/tricore/tricore_testboard.c           | 13 +++++-----
 hw/usb/ccid-card-passthru.c              |  5 ++--
 hw/usb/combined-packet.c                 |  3 ++-
 hw/usb/dev-smartcard-reader.c            |  3 ++-
 hw/usb/redirect.c                        |  3 ++-
 hw/vfio/pci-quirks.c                     |  9 +++----
 hw/vfio/pci.c                            |  3 ++-
 hw/xenpv/xen_domainbuild.c               | 13 +++++-----
 hw/xtensa/xtfpga.c                       |  9 +++----
 linux-user/main.c                        |  5 ++--
 monitor.c                                |  3 ++-
 target/i386/cpu.c                        |  4 +---
 target/ppc/mmu_helper.c                  |  8 +++----
 target/xtensa/helper.c                   |  5 ++--
 tests/benchmark-crypto-cipher.c          |  6 ++---
 tests/benchmark-crypto-hash.c            |  5 ++--
 tests/benchmark-crypto-hmac.c            |  6 ++---
 tests/test-cutils.c                      | 18 +++++++-------
 tests/test-keyval.c                      |  6 ++---
 tests/test-qemu-opts.c                   |  7 +++---
 vl.c                                     |  3 ++-
 scripts/checkpatch.pl                    |  1 +
 144 files changed, 565 insertions(+), 453 deletions(-)
 create mode 100644 include/qemu/units.h

Comments

Michael S. Tsirkin June 26, 2018, 1:08 a.m. UTC | #1
On Mon, Jun 25, 2018 at 09:41:52AM -0300, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series:
> 
> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>   (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
> - clean hw/ includes;
> - replace different constants used for byte size with their corresponding
>   IEC binary prefix definitions.

Series:

Acked-by: Michael S. Tsirkin <mst@redhat.com>


> Since v4:
> - fixed checkpatch (do not match the IEC binary prefix as camelcase typedefs)
> - use signed format for size (Richard)
> - fix 32-bit (Thomas)
> - update '[<>][<>]= ?[1-5]0', adding 5 new patches (Eric)
> 
> Since v3:
> - use IEC binary prefix definitions (Stefan Weil)
> - rebased
> - added R-b tags
> 
> Since v2:
> - use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé)
> - avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth)
> - more constant replaced
> 
> Since v1:
> - corrected Xen mult -> div (Alan Robinson)
> - tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC
> - fixed mips_r4k 'params_size' (Thomas Huth)
> - added command used to generate patch in each commit (Alistair Francis)
> - use G_BYTE for the raspi3 machine
> - added Reviewed-by tags
> 
> Regards,
> 
> Phil.
> 
> [----] : patches are identical
> [####] : number of functional differences between upstream/downstream patch
> [down] : patch is downstream-only
> The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively
> 
> 001/46:[0012] [FC] 'include: Add IEC binary prefixes in "qemu/units.h"'
> 002/46:[0005] [FC] 'vdi: Use definitions from "qemu/units.h"'
> 003/46:[----] [--] 'x86/cpu: Use definitions from "qemu/units.h"'
> 004/46:[0002] [FC] 'checkpatch: Recognize IEC binary prefix definitions'
> 005/46:[----] [-C] 'hw: Use IEC binary prefix definitions from "qemu/units.h"'
> 006/46:[----] [--] 'hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"'
> 007/46:[----] [--] 'hw/ivshmem: Use the IEC binary prefix definitions'
> 008/46:[----] [--] 'hw/ipack: Use the IEC binary prefix definitions'
> 009/46:[----] [--] 'hw/scsi: Use the IEC binary prefix definitions'
> 010/46:[----] [--] 'hw/smbios: Use the IEC binary prefix definitions'
> 011/46:[0002] [FC] 'hw/xen: Use the IEC binary prefix definitions'
> 012/46:[----] [--] 'hw/tpm: Use the IEC binary prefix definitions'
> 013/46:[----] [--] 'hw/block: Use the IEC binary prefix definitions'
> 014/46:[0008] [FC] 'hw/display: Use the IEC binary prefix definitions'
> 015/46:[----] [--] 'hw/misc: Use the IEC binary prefix definitions'
> 016/46:[----] [--] 'hw/riscv: Use the IEC binary prefix definitions'
> 017/46:[----] [--] 'hw/m68k: Use the IEC binary prefix definitions'
> 018/46:[0006] [FC] 'hw/sparc: Use the IEC binary prefix definitions'
> 019/46:[0003] [FC] 'hw/s390x: Use the IEC binary prefix definitions'
> 020/46:[0004] [FC] 'hw/hppa: Use the IEC binary prefix definitions'
> 021/46:[0009] [FC] 'hw/xtensa: Use the IEC binary prefix definitions'
> 022/46:[----] [--] 'hw/alpha: Use the IEC binary prefix definitions'
> 023/46:[----] [--] 'hw/tricore: Use the IEC binary prefix definitions'
> 024/46:[----] [--] 'hw/microblaze: Use the IEC binary prefix definitions'
> 025/46:[----] [--] 'hw/nios2: Use the IEC binary prefix definitions'
> 026/46:[----] [--] 'hw/cris: Use the IEC binary prefix definitions'
> 027/46:[----] [--] 'hw/lm32: Use the IEC binary prefix definitions'
> 028/46:[----] [--] 'hw/sh4: Use the IEC binary prefix definitions'
> 029/46:[----] [--] 'hw/mips/r4k: Constify params_size'
> 030/46:[0012] [FC] 'hw/mips: Use the IEC binary prefix definitions'
> 031/46:[----] [--] 'hw/arm: Use the IEC binary prefix definitions'
> 032/46:[0022] [FC] 'hw/ppc: Use the IEC binary prefix definitions'
> 033/46:[0006] [FC] 'hw/i386: Use the IEC binary prefix definitions'
> 034/46:[----] [--] 'hw/net: Use the IEC binary prefix definitions'
> 035/46:[0002] [FC] 'hw/usb: Use the IEC binary prefix definitions'
> 036/46:[0002] [FC] 'hw/sd: Use the IEC binary prefix definitions'
> 037/46:[----] [--] 'hw/vfio: Use the IEC binary prefix definitions'
> 038/46:[----] [--] 'hw/virtio: Use the IEC binary prefix definitions'
> 039/46:[----] [--] 'hw/rdma: Use the IEC binary prefix definitions'
> 040/46:[----] [--] 'cutils: Do not include "qemu/units.h" directly'
> 041/46:[0148] [FC] 'hw/ppc: Use the IEC binary prefix definitions'
> 042/46:[down] 'monitor: Use the IEC binary prefix definitions'
> 043/46:[down] 'vl: Use the IEC binary prefix definitions'
> 044/46:[down] 'tests/crypto: Use the IEC binary prefix definitions'
> 045/46:[down] 'linux-user: Use the IEC binary prefix definitions'
> 046/46:[down] 'bsd-user: Use the IEC binary prefix definitions'
> 
> Philippe Mathieu-Daudé (46):
>   include: Add IEC binary prefixes in "qemu/units.h"
>   vdi: Use definitions from "qemu/units.h"
>   x86/cpu: Use definitions from "qemu/units.h"
>   checkpatch: Recognize IEC binary prefix definitions
>   hw: Use IEC binary prefix definitions from "qemu/units.h"
>   hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
>   hw/ivshmem: Use the IEC binary prefix definitions
>   hw/ipack: Use the IEC binary prefix definitions
>   hw/scsi: Use the IEC binary prefix definitions
>   hw/smbios: Use the IEC binary prefix definitions
>   hw/xen: Use the IEC binary prefix definitions
>   hw/tpm: Use the IEC binary prefix definitions
>   hw/block: Use the IEC binary prefix definitions
>   hw/display: Use the IEC binary prefix definitions
>   hw/misc: Use the IEC binary prefix definitions
>   hw/riscv: Use the IEC binary prefix definitions
>   hw/m68k: Use the IEC binary prefix definitions
>   hw/sparc: Use the IEC binary prefix definitions
>   hw/s390x: Use the IEC binary prefix definitions
>   hw/hppa: Use the IEC binary prefix definitions
>   hw/xtensa: Use the IEC binary prefix definitions
>   hw/alpha: Use the IEC binary prefix definitions
>   hw/tricore: Use the IEC binary prefix definitions
>   hw/microblaze: Use the IEC binary prefix definitions
>   hw/nios2: Use the IEC binary prefix definitions
>   hw/cris: Use the IEC binary prefix definitions
>   hw/lm32: Use the IEC binary prefix definitions
>   hw/sh4: Use the IEC binary prefix definitions
>   hw/mips/r4k: Constify params_size
>   hw/mips: Use the IEC binary prefix definitions
>   hw/arm: Use the IEC binary prefix definitions
>   hw/ppc: Use the IEC binary prefix definitions
>   hw/i386: Use the IEC binary prefix definitions
>   hw/net: Use the IEC binary prefix definitions
>   hw/usb: Use the IEC binary prefix definitions
>   hw/sd: Use the IEC binary prefix definitions
>   hw/vfio: Use the IEC binary prefix definitions
>   hw/virtio: Use the IEC binary prefix definitions
>   hw/rdma: Use the IEC binary prefix definitions
>   cutils: Do not include "qemu/units.h" directly
>   hw/ppc: Use the IEC binary prefix definitions
>   monitor: Use the IEC binary prefix definitions
>   vl: Use the IEC binary prefix definitions
>   tests/crypto: Use the IEC binary prefix definitions
>   linux-user: Use the IEC binary prefix definitions
>   bsd-user: Use the IEC binary prefix definitions
> 
>  hw/net/ne2000.h                          |  5 ++--
>  hw/ppc/mac.h                             |  3 ++-
>  hw/rdma/vmw/pvrdma.h                     |  3 ++-
>  include/hw/acpi/tpm.h                    |  3 ++-
>  include/hw/arm/fsl-imx7.h                |  5 ++--
>  include/hw/arm/stm32f205_soc.h           |  5 ++--
>  include/hw/display/xlnx_dp.h             |  5 ++--
>  include/hw/i386/ich9.h                   |  3 ++-
>  include/hw/intc/mips_gic.h               |  3 ++-
>  include/hw/mips/bios.h                   |  3 ++-
>  include/hw/net/allwinner_emac.h          |  5 ++--
>  include/hw/ppc/spapr.h                   |  5 ++--
>  include/hw/virtio/virtio-net.h           |  3 ++-
>  include/qemu/cutils.h                    |  7 ------
>  include/qemu/units.h                     | 20 ++++++++++++++++
>  block/vdi.c                              |  7 +++---
>  bsd-user/main.c                          |  5 ++--
>  hw/alpha/typhoon.c                       | 17 +++++++-------
>  hw/arm/bcm2835_peripherals.c             |  3 ++-
>  hw/arm/boot.c                            |  7 +++---
>  hw/arm/collie.c                          |  5 ++--
>  hw/arm/digic_boards.c                    |  7 +++---
>  hw/arm/exynos4_boards.c                  |  3 ++-
>  hw/arm/gumstix.c                         |  3 ++-
>  hw/arm/integratorcp.c                    |  3 ++-
>  hw/arm/mainstone.c                       |  3 ++-
>  hw/arm/msf2-soc.c                        |  6 ++---
>  hw/arm/msf2-som.c                        |  8 +++----
>  hw/arm/musicpal.c                        |  9 +++----
>  hw/arm/omap_sx1.c                        | 11 +++++----
>  hw/arm/raspi.c                           |  5 ++--
>  hw/arm/smmu-common.c                     |  3 ++-
>  hw/arm/stellaris.c                       |  5 ++--
>  hw/arm/versatilepb.c                     |  5 ++--
>  hw/arm/vexpress.c                        |  7 +++---
>  hw/arm/virt.c                            |  5 ++--
>  hw/arm/xilinx_zynq.c                     |  7 +++---
>  hw/block/m25p80.c                        |  5 ++--
>  hw/block/nvme.c                          |  3 ++-
>  hw/block/tc58128.c                       |  3 ++-
>  hw/block/xen_disk.c                      |  3 ++-
>  hw/core/loader-fit.c                     |  3 ++-
>  hw/core/machine.c                        |  4 ++--
>  hw/cris/axis_dev88.c                     |  3 ++-
>  hw/display/bochs-display.c               |  9 +++----
>  hw/display/cirrus_vga.c                  | 10 ++++----
>  hw/display/g364fb.c                      |  4 ++--
>  hw/display/qxl.c                         | 30 +++++++++++-------------
>  hw/display/sm501.c                       | 16 ++++++-------
>  hw/display/vga-isa-mm.c                  |  5 ++--
>  hw/display/vga.c                         |  5 ++--
>  hw/display/virtio-gpu.c                  |  4 ++--
>  hw/display/vmware_vga.c                  |  3 ++-
>  hw/display/xenfb.c                       |  3 ++-
>  hw/hppa/dino.c                           |  5 ++--
>  hw/hppa/machine.c                        | 12 +++++-----
>  hw/i386/acpi-build.c                     |  5 ++--
>  hw/i386/pc.c                             | 19 ++++++++-------
>  hw/i386/pc_piix.c                        |  4 ++--
>  hw/i386/pc_q35.c                         |  3 ++-
>  hw/i386/pc_sysfw.c                       |  9 +++----
>  hw/i386/xen/xen-mapcache.c               |  3 ++-
>  hw/intc/apic_common.c                    |  3 ++-
>  hw/ipack/tpci200.c                       |  5 ++--
>  hw/lm32/lm32_boards.c                    | 13 +++++-----
>  hw/lm32/milkymist.c                      | 10 ++++----
>  hw/m68k/mcf5208.c                        |  3 ++-
>  hw/microblaze/petalogix_ml605_mmu.c      |  7 +++---
>  hw/microblaze/petalogix_s3adsp1800_mmu.c |  7 +++---
>  hw/mips/boston.c                         | 30 ++++++++++++------------
>  hw/mips/mips_fulong2e.c                  |  7 +++---
>  hw/mips/mips_malta.c                     | 25 +++++++++++---------
>  hw/mips/mips_r4k.c                       | 15 ++++++------
>  hw/misc/aspeed_sdmc.c                    |  9 +++----
>  hw/misc/auxbus.c                         |  3 ++-
>  hw/misc/edu.c                            |  3 ++-
>  hw/misc/imx7_gpr.c                       |  3 ++-
>  hw/misc/ivshmem.c                        |  3 ++-
>  hw/misc/mips_itu.c                       |  3 ++-
>  hw/misc/omap_gpmc.c                      |  5 ++--
>  hw/net/e1000e.c                          |  7 +++---
>  hw/net/e1000x_common.c                   |  3 ++-
>  hw/net/eepro100.c                        |  3 +--
>  hw/nios2/boot.c                          |  6 ++---
>  hw/nvram/spapr_nvram.c                   | 11 +++++----
>  hw/pci-host/designware.c                 |  3 ++-
>  hw/pci-host/gpex.c                       |  3 ++-
>  hw/pci-host/piix.c                       |  5 ++--
>  hw/pci-host/prep.c                       |  3 ++-
>  hw/pci-host/q35.c                        | 17 +++++++-------
>  hw/pci-host/xilinx-pcie.c                |  5 ++--
>  hw/ppc/e500.c                            | 13 +++++-----
>  hw/ppc/e500plat.c                        |  3 ++-
>  hw/ppc/mac_newworld.c                    |  1 -
>  hw/ppc/mac_oldworld.c                    |  9 ++++---
>  hw/ppc/pnv.c                             |  6 ++---
>  hw/ppc/ppc405_boards.c                   |  9 +++----
>  hw/ppc/ppc405_uc.c                       |  7 +++---
>  hw/ppc/ppc440_bamboo.c                   |  5 ++--
>  hw/ppc/ppc440_uc.c                       | 28 +++++++++++-----------
>  hw/ppc/ppc4xx_devs.c                     | 22 +++++++++--------
>  hw/ppc/ppce500_spin.c                    |  3 ++-
>  hw/ppc/prep.c                            |  6 ++---
>  hw/ppc/rs6000_mc.c                       | 13 +++++-----
>  hw/ppc/sam460ex.c                        | 18 +++++++-------
>  hw/ppc/spapr.c                           | 12 +++++-----
>  hw/ppc/spapr_rtas.c                      |  2 +-
>  hw/ppc/virtex_ml507.c                    |  7 +++---
>  hw/riscv/virt.c                          |  3 ++-
>  hw/s390x/s390-skeys.c                    |  3 ++-
>  hw/s390x/s390-stattrib.c                 |  3 ++-
>  hw/s390x/sclp.c                          |  3 ++-
>  hw/scsi/scsi-disk.c                      |  9 +++----
>  hw/sd/sd.c                               |  8 +++----
>  hw/sd/sdhci.c                            |  8 +++----
>  hw/sh4/r2d.c                             |  3 ++-
>  hw/smbios/smbios.c                       | 15 +++++-------
>  hw/sparc/leon3.c                         | 10 ++++----
>  hw/sparc/sun4m.c                         | 10 ++++----
>  hw/sparc64/niagara.c                     |  3 ++-
>  hw/sparc64/sun4u.c                       |  4 ++--
>  hw/ssi/aspeed_smc.c                      | 29 ++++++++++++-----------
>  hw/tricore/tricore_testboard.c           | 13 +++++-----
>  hw/usb/ccid-card-passthru.c              |  5 ++--
>  hw/usb/combined-packet.c                 |  3 ++-
>  hw/usb/dev-smartcard-reader.c            |  3 ++-
>  hw/usb/redirect.c                        |  3 ++-
>  hw/vfio/pci-quirks.c                     |  9 +++----
>  hw/vfio/pci.c                            |  3 ++-
>  hw/xenpv/xen_domainbuild.c               | 13 +++++-----
>  hw/xtensa/xtfpga.c                       |  9 +++----
>  linux-user/main.c                        |  5 ++--
>  monitor.c                                |  3 ++-
>  target/i386/cpu.c                        |  4 +---
>  target/ppc/mmu_helper.c                  |  8 +++----
>  target/xtensa/helper.c                   |  5 ++--
>  tests/benchmark-crypto-cipher.c          |  6 ++---
>  tests/benchmark-crypto-hash.c            |  5 ++--
>  tests/benchmark-crypto-hmac.c            |  6 ++---
>  tests/test-cutils.c                      | 18 +++++++-------
>  tests/test-keyval.c                      |  6 ++---
>  tests/test-qemu-opts.c                   |  7 +++---
>  vl.c                                     |  3 ++-
>  scripts/checkpatch.pl                    |  1 +
>  144 files changed, 565 insertions(+), 453 deletions(-)
>  create mode 100644 include/qemu/units.h
> 
> -- 
> 2.18.0
Igor Mammedov June 27, 2018, 2:01 p.m. UTC | #2
On Mon, 25 Jun 2018 09:42:25 -0300
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> It eases code review, unit is explicit.
> 
> Patch generated using:
> 
>   $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
> 
> and modified manually.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

non important nit below

> ---
>  include/hw/i386/ich9.h |  3 ++-
>  hw/i386/acpi-build.c   |  5 +++--
>  hw/i386/pc.c           | 19 ++++++++++---------
>  hw/i386/pc_piix.c      |  4 ++--
>  hw/i386/pc_q35.c       |  3 ++-
>  hw/i386/pc_sysfw.c     |  9 +++++----
>  hw/intc/apic_common.c  |  3 ++-
>  hw/pci-host/piix.c     |  5 +++--
>  hw/pci-host/q35.c      | 17 +++++++++--------
>  9 files changed, 38 insertions(+), 30 deletions(-)
> 
> diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h
> index 673d13d28f..3f0b80f0da 100644
> --- a/include/hw/i386/ich9.h
> +++ b/include/hw/i386/ich9.h
> @@ -1,6 +1,7 @@
>  #ifndef HW_ICH9_H
>  #define HW_ICH9_H
>  
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/isa/isa.h"
>  #include "hw/sysbus.h"
> @@ -22,7 +23,7 @@ I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
>  
>  void ich9_generate_smi(void);
>  
> -#define ICH9_CC_SIZE (16 * 1024) /* 16KB. Chipset configuration registers */
> +#define ICH9_CC_SIZE (16 * KiB) /* Chipset configuration registers */
>  
>  #define TYPE_ICH9_LPC_DEVICE "ICH9-LPC"
>  #define ICH9_LPC_DEVICE(obj) \
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 9bc6d97ea1..05fed5af44 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -21,6 +21,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "qapi/qmp/qnum.h"
>  #include "acpi-build.h"
> @@ -2248,8 +2249,8 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
>                   (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NULL);
>  }
>  
> -#define HOLE_640K_START  (640 * 1024)
> -#define HOLE_640K_END   (1024 * 1024)
> +#define HOLE_640K_START  (640 * KiB)
> +#define HOLE_640K_END   (1024 * KiB)
>  
>  static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
>                                             uint64_t len, int default_node)
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 622e49d6bc..41c434d7e3 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -23,6 +23,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/i386/pc.h"
>  #include "hw/char/serial.h"
> @@ -452,8 +453,8 @@ void pc_cmos_init(PCMachineState *pcms,
>      rtc_set_memory(s, 0x15, val);
>      rtc_set_memory(s, 0x16, val >> 8);
>      /* extended memory (next 64MiB) */
> -    if (pcms->below_4g_mem_size > 1024 * 1024) {
> -        val = (pcms->below_4g_mem_size - 1024 * 1024) / 1024;
> +    if (pcms->below_4g_mem_size > 1 * MiB) {
> +        val = (pcms->below_4g_mem_size - 1 * MiB) / 1024;
could be:
   val = (pcms->below_4g_mem_size - 1 * MiB) / KiB

>      } else {
>          val = 0;
>      }
> @@ -464,8 +465,8 @@ void pc_cmos_init(PCMachineState *pcms,
>      rtc_set_memory(s, 0x30, val);
>      rtc_set_memory(s, 0x31, val >> 8);
>      /* memory between 16MiB and 4GiB */
> -    if (pcms->below_4g_mem_size > 16 * 1024 * 1024) {
> -        val = (pcms->below_4g_mem_size - 16 * 1024 * 1024) / 65536;
> +    if (pcms->below_4g_mem_size > 16 * MiB) {
> +        val = (pcms->below_4g_mem_size - 16 * MiB) / 65536;
>      } else {
>          val = 0;
>      }
> @@ -1392,11 +1393,11 @@ void pc_memory_init(PCMachineState *pcms,
>          }
>  
>          machine->device_memory->base =
> -            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
> +            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, GiB);
>  
>          if (pcmc->enforce_aligned_dimm) {
>              /* size device region assuming 1G page max alignment per slot */
> -            device_mem_size += (1ULL << 30) * machine->ram_slots;
> +            device_mem_size += machine->ram_slots * GiB;
>          }
>  
>          if ((machine->device_memory->base + device_mem_size) <
> @@ -1438,7 +1439,7 @@ void pc_memory_init(PCMachineState *pcms,
>          if (!pcmc->broken_reserved_end) {
>              res_mem_end += memory_region_size(&machine->device_memory->mr);
>          }
> -        *val = cpu_to_le64(ROUND_UP(res_mem_end, 0x1ULL << 30));
> +        *val = cpu_to_le64(ROUND_UP(res_mem_end, GiB));
>          fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
>      }
>  
> @@ -1475,7 +1476,7 @@ uint64_t pc_pci_hole64_start(void)
>          hole64_start = 0x100000000ULL + pcms->above_4g_mem_size;
>      }
>  
> -    return ROUND_UP(hole64_start, 1ULL << 30);
> +    return ROUND_UP(hole64_start, 1 * GiB);
>  }
>  
>  qemu_irq pc_allocate_cpu_irq(void)
> @@ -2100,7 +2101,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
>          return;
>      }
>  
> -    if (value < (1ULL << 20)) {
> +    if (value < 1 * MiB) {
>          warn_report("Only %" PRIu64 " bytes of RAM below the 4GiB boundary,"
>                      "BIOS may not work with less than 1MiB", value);
>      }
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index e9b6f064fb..fd740bbc9c 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -23,7 +23,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> -
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/loader.h"
>  #include "hw/i386/pc.h"
> @@ -131,7 +131,7 @@ static void pc_init1(MachineState *machine,
>                  if (lowmem > 0xc0000000) {
>                      lowmem = 0xc0000000;
>                  }
> -                if (lowmem & ((1ULL << 30) - 1)) {
> +                if (lowmem & (1 * GiB - 1)) {
>                      warn_report("Large machine and max_ram_below_4g "
>                                  "(%" PRIu64 ") not a multiple of 1G; "
>                                  "possible bad performance.",
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 1a73e1848a..532241e3f8 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -29,6 +29,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/loader.h"
>  #include "sysemu/arch_init.h"
> @@ -105,7 +106,7 @@ static void pc_q35_init(MachineState *machine)
>      if (lowmem > pcms->max_ram_below_4g) {
>          lowmem = pcms->max_ram_below_4g;
>          if (machine->ram_size - lowmem > lowmem &&
> -            lowmem & ((1ULL << 30) - 1)) {
> +            lowmem & (1 * GiB - 1)) {
>              warn_report("There is possibly poor performance as the ram size "
>                          " (0x%" PRIx64 ") is more then twice the size of"
>                          " max-ram-below-4g (%"PRIu64") and"
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index 73ac783f20..a9e2a72736 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c
> @@ -24,6 +24,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qapi/error.h"
>  #include "sysemu/block-backend.h"
>  #include "qemu/error-report.h"
> @@ -56,7 +57,7 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
>      flash_size = memory_region_size(flash_mem);
>  
>      /* map the last 128KB of the BIOS in ISA space */
> -    isa_bios_size = MIN(flash_size, 128 * 1024);
> +    isa_bios_size = MIN(flash_size, 128 * KiB);
>      isa_bios = g_malloc(sizeof(*isa_bios));
>      memory_region_init_ram(isa_bios, NULL, "isa-bios", isa_bios_size,
>                             &error_fatal);
> @@ -83,7 +84,7 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
>   * only 18MB-4KB below 4G. For now, restrict the cumulative mapping to 8MB in
>   * size.
>   */
> -#define FLASH_MAP_BASE_MIN ((hwaddr)(0x100000000ULL - 8*1024*1024))
> +#define FLASH_MAP_BASE_MIN ((hwaddr)(0x100000000ULL - 8 * MiB))
>  
>  /* This function maps flash drives from 4G downward, in order of their unit
>   * numbers. The mapping starts at unit#0, with unit number increments of 1, and
> @@ -222,8 +223,8 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
>  
>      /* map the last 128KB of the BIOS in ISA space */
>      isa_bios_size = bios_size;
> -    if (isa_bios_size > (128 * 1024)) {
> -        isa_bios_size = 128 * 1024;
> +    if (isa_bios_size > 128 * KiB) {
> +        isa_bios_size = 128 * KiB;
>      }
>      isa_bios = g_malloc(sizeof(*isa_bios));
>      memory_region_init_alias(isa_bios, NULL, "isa-bios", bios,
> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
> index 78903ea909..75fa49cbc3 100644
> --- a/hw/intc/apic_common.c
> +++ b/hw/intc/apic_common.c
> @@ -18,6 +18,7 @@
>   * License along with this library; if not, see <http://www.gnu.org/licenses/>
>   */
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "qemu/error-report.h"
>  #include "qapi/error.h"
>  #include "qemu-common.h"
> @@ -319,7 +320,7 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
>  
>      /* Note: We need at least 1M to map the VAPIC option ROM */
>      if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
> -        !hax_enabled() && ram_size >= 1024 * 1024) {
> +        !hax_enabled() && ram_size >= 1 * MiB) {
>          vapic = sysbus_create_simple("kvmvapic", -1, NULL);
>      }
>      s->vapic = vapic;
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 0e608347c1..391dd6c9b8 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -23,6 +23,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/i386/pc.h"
>  #include "hw/pci/pci.h"
> @@ -284,7 +285,7 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v,
>  
>      pci_bus_get_w64_range(h->bus, &w64);
>      value = range_is_empty(&w64) ? 0 : range_upb(&w64) + 1;
> -    hole64_end = ROUND_UP(hole64_start + s->pci_hole64_size, 1ULL << 30);
> +    hole64_end = ROUND_UP(hole64_start + s->pci_hole64_size, 1 * GiB);
>      if (s->pci_hole64_fix && value < hole64_end) {
>          value = hole64_end;
>      }
> @@ -430,7 +431,7 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
>  
>      *piix3_devfn = piix3->dev.devfn;
>  
> -    ram_size = ram_size / 8 / 1024 / 1024;
> +    ram_size /= 8 * MiB;
>      if (ram_size > 255) {
>          ram_size = 255;
>      }
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index 02f9576588..fbc255ca39 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -28,6 +28,7 @@
>   * THE SOFTWARE.
>   */
>  #include "qemu/osdep.h"
> +#include "qemu/units.h"
>  #include "hw/hw.h"
>  #include "hw/pci-host/q35.h"
>  #include "qapi/error.h"
> @@ -144,7 +145,7 @@ static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v,
>  
>      pci_bus_get_w64_range(h->bus, &w64);
>      value = range_is_empty(&w64) ? 0 : range_upb(&w64) + 1;
> -    hole64_end = ROUND_UP(hole64_start + s->mch.pci_hole64_size, 1ULL << 30);
> +    hole64_end = ROUND_UP(hole64_start + s->mch.pci_hole64_size, 1 * GiB);
>      if (s->pci_hole64_fix && value < hole64_end) {
>          value = hole64_end;
>      }
> @@ -310,15 +311,15 @@ static void mch_update_pciexbar(MCHPCIState *mch)
>      addr_mask = MCH_HOST_BRIDGE_PCIEXBAR_ADMSK;
>      switch (pciexbar & MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_MASK) {
>      case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_256M:
> -        length = 256 * 1024 * 1024;
> +        length = 256 * MiB;
>          break;
>      case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_128M:
> -        length = 128 * 1024 * 1024;
> +        length = 128 * MiB;
>          addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK |
>              MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
>          break;
>      case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_64M:
> -        length = 64 * 1024 * 1024;
> +        length = 64 * MiB;
>          addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
>          break;
>      case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_RVD:
> @@ -396,16 +397,16 @@ static void mch_update_smram(MCHPCIState *mch)
>          switch (pd->config[MCH_HOST_BRIDGE_ESMRAMC] &
>                  MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK) {
>          case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB:
> -            tseg_size = 1024 * 1024;
> +            tseg_size = 1 * MiB;
>              break;
>          case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_2MB:
> -            tseg_size = 1024 * 1024 * 2;
> +            tseg_size = 2 * MiB;
>              break;
>          case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_8MB:
> -            tseg_size = 1024 * 1024 * 8;
> +            tseg_size = 8 * MiB;
>              break;
>          default:
> -            tseg_size = 1024 * 1024 * (uint32_t)mch->ext_tseg_mbytes;
> +            tseg_size = (uint32_t)mch->ext_tseg_mbytes * MiB;
>              break;
>          }
>      } else {
Paolo Bonzini June 29, 2018, 2:08 p.m. UTC | #3
Queued with this squashed in:

diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index e75d433e56..0a6c657228 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -276,9 +276,9 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size)
     VSCMsgHeader *hdr;
 
     if (card->vscard_in_pos + size > VSCARD_IN_SIZE) {
-        error_report(
-            "no room for data: pos %u +  size %d > %ld. dropping connection.",
-            card->vscard_in_pos, size, VSCARD_IN_SIZE);
+        error_report("no room for data: pos %u +  size %d > %" PRId64 "."
+                     " dropping connection.",
+                     card->vscard_in_pos, size, VSCARD_IN_SIZE);
         ccid_card_vscard_drop_connection(card);
         return;
     }
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 7074a176d7..fd4d848f66 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -709,7 +709,7 @@ static void test_opts_parse_size(void)
                            false, &error_abort);
     g_assert_cmpuint(opts_count(opts), ==, 2);
     g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, GiB / 10);
-    g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 16777215 * TiB);
+    g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 16777215U * TiB);
 
     /* Beyond limit with suffix */
     opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",
diff --git a/vl.c b/vl.c
index 2018052394..93795c1b9f 100644
--- a/vl.c
+++ b/vl.c
@@ -2810,7 +2810,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
             uint64_t overflow_check = sz;
 
             sz *= MiB;
-            if ((sz >> 20) != overflow_check) {
+            if (sz / MiB != overflow_check) {
                 error_report("too large 'size' option value");
                 exit(EXIT_FAILURE);
             }

Because Patchew is down, I couldn't gather all the Reviewed-by and Acked-by.
Thanks to all the reviewers anyway!

Paolo

On 25/06/2018 14:41, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series:
> 
> - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h"
>   (this now triggers WARNING: 1 added file, does MAINTAINERS need updating?)
> - clean hw/ includes;
> - replace different constants used for byte size with their corresponding
>   IEC binary prefix definitions.
> 
> Since v4:
> - fixed checkpatch (do not match the IEC binary prefix as camelcase typedefs)
> - use signed format for size (Richard)
> - fix 32-bit (Thomas)
> - update '[<>][<>]= ?[1-5]0', adding 5 new patches (Eric)
> 
> Since v3:
> - use IEC binary prefix definitions (Stefan Weil)
> - rebased
> - added R-b tags
> 
> Since v2:
> - use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé)
> - avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth)
> - more constant replaced
> 
> Since v1:
> - corrected Xen mult -> div (Alan Robinson)
> - tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC
> - fixed mips_r4k 'params_size' (Thomas Huth)
> - added command used to generate patch in each commit (Alistair Francis)
> - use G_BYTE for the raspi3 machine
> - added Reviewed-by tags
> 
> Regards,
> 
> Phil.
> 
> [----] : patches are identical
> [####] : number of functional differences between upstream/downstream patch
> [down] : patch is downstream-only
> The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively
> 
> 001/46:[0012] [FC] 'include: Add IEC binary prefixes in "qemu/units.h"'
> 002/46:[0005] [FC] 'vdi: Use definitions from "qemu/units.h"'
> 003/46:[----] [--] 'x86/cpu: Use definitions from "qemu/units.h"'
> 004/46:[0002] [FC] 'checkpatch: Recognize IEC binary prefix definitions'
> 005/46:[----] [-C] 'hw: Use IEC binary prefix definitions from "qemu/units.h"'
> 006/46:[----] [--] 'hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"'
> 007/46:[----] [--] 'hw/ivshmem: Use the IEC binary prefix definitions'
> 008/46:[----] [--] 'hw/ipack: Use the IEC binary prefix definitions'
> 009/46:[----] [--] 'hw/scsi: Use the IEC binary prefix definitions'
> 010/46:[----] [--] 'hw/smbios: Use the IEC binary prefix definitions'
> 011/46:[0002] [FC] 'hw/xen: Use the IEC binary prefix definitions'
> 012/46:[----] [--] 'hw/tpm: Use the IEC binary prefix definitions'
> 013/46:[----] [--] 'hw/block: Use the IEC binary prefix definitions'
> 014/46:[0008] [FC] 'hw/display: Use the IEC binary prefix definitions'
> 015/46:[----] [--] 'hw/misc: Use the IEC binary prefix definitions'
> 016/46:[----] [--] 'hw/riscv: Use the IEC binary prefix definitions'
> 017/46:[----] [--] 'hw/m68k: Use the IEC binary prefix definitions'
> 018/46:[0006] [FC] 'hw/sparc: Use the IEC binary prefix definitions'
> 019/46:[0003] [FC] 'hw/s390x: Use the IEC binary prefix definitions'
> 020/46:[0004] [FC] 'hw/hppa: Use the IEC binary prefix definitions'
> 021/46:[0009] [FC] 'hw/xtensa: Use the IEC binary prefix definitions'
> 022/46:[----] [--] 'hw/alpha: Use the IEC binary prefix definitions'
> 023/46:[----] [--] 'hw/tricore: Use the IEC binary prefix definitions'
> 024/46:[----] [--] 'hw/microblaze: Use the IEC binary prefix definitions'
> 025/46:[----] [--] 'hw/nios2: Use the IEC binary prefix definitions'
> 026/46:[----] [--] 'hw/cris: Use the IEC binary prefix definitions'
> 027/46:[----] [--] 'hw/lm32: Use the IEC binary prefix definitions'
> 028/46:[----] [--] 'hw/sh4: Use the IEC binary prefix definitions'
> 029/46:[----] [--] 'hw/mips/r4k: Constify params_size'
> 030/46:[0012] [FC] 'hw/mips: Use the IEC binary prefix definitions'
> 031/46:[----] [--] 'hw/arm: Use the IEC binary prefix definitions'
> 032/46:[0022] [FC] 'hw/ppc: Use the IEC binary prefix definitions'
> 033/46:[0006] [FC] 'hw/i386: Use the IEC binary prefix definitions'
> 034/46:[----] [--] 'hw/net: Use the IEC binary prefix definitions'
> 035/46:[0002] [FC] 'hw/usb: Use the IEC binary prefix definitions'
> 036/46:[0002] [FC] 'hw/sd: Use the IEC binary prefix definitions'
> 037/46:[----] [--] 'hw/vfio: Use the IEC binary prefix definitions'
> 038/46:[----] [--] 'hw/virtio: Use the IEC binary prefix definitions'
> 039/46:[----] [--] 'hw/rdma: Use the IEC binary prefix definitions'
> 040/46:[----] [--] 'cutils: Do not include "qemu/units.h" directly'
> 041/46:[0148] [FC] 'hw/ppc: Use the IEC binary prefix definitions'
> 042/46:[down] 'monitor: Use the IEC binary prefix definitions'
> 043/46:[down] 'vl: Use the IEC binary prefix definitions'
> 044/46:[down] 'tests/crypto: Use the IEC binary prefix definitions'
> 045/46:[down] 'linux-user: Use the IEC binary prefix definitions'
> 046/46:[down] 'bsd-user: Use the IEC binary prefix definitions'
> 
> Philippe Mathieu-Daudé (46):
>   include: Add IEC binary prefixes in "qemu/units.h"
>   vdi: Use definitions from "qemu/units.h"
>   x86/cpu: Use definitions from "qemu/units.h"
>   checkpatch: Recognize IEC binary prefix definitions
>   hw: Use IEC binary prefix definitions from "qemu/units.h"
>   hw: Directly use "qemu/units.h" instead of "qemu/cutils.h"
>   hw/ivshmem: Use the IEC binary prefix definitions
>   hw/ipack: Use the IEC binary prefix definitions
>   hw/scsi: Use the IEC binary prefix definitions
>   hw/smbios: Use the IEC binary prefix definitions
>   hw/xen: Use the IEC binary prefix definitions
>   hw/tpm: Use the IEC binary prefix definitions
>   hw/block: Use the IEC binary prefix definitions
>   hw/display: Use the IEC binary prefix definitions
>   hw/misc: Use the IEC binary prefix definitions
>   hw/riscv: Use the IEC binary prefix definitions
>   hw/m68k: Use the IEC binary prefix definitions
>   hw/sparc: Use the IEC binary prefix definitions
>   hw/s390x: Use the IEC binary prefix definitions
>   hw/hppa: Use the IEC binary prefix definitions
>   hw/xtensa: Use the IEC binary prefix definitions
>   hw/alpha: Use the IEC binary prefix definitions
>   hw/tricore: Use the IEC binary prefix definitions
>   hw/microblaze: Use the IEC binary prefix definitions
>   hw/nios2: Use the IEC binary prefix definitions
>   hw/cris: Use the IEC binary prefix definitions
>   hw/lm32: Use the IEC binary prefix definitions
>   hw/sh4: Use the IEC binary prefix definitions
>   hw/mips/r4k: Constify params_size
>   hw/mips: Use the IEC binary prefix definitions
>   hw/arm: Use the IEC binary prefix definitions
>   hw/ppc: Use the IEC binary prefix definitions
>   hw/i386: Use the IEC binary prefix definitions
>   hw/net: Use the IEC binary prefix definitions
>   hw/usb: Use the IEC binary prefix definitions
>   hw/sd: Use the IEC binary prefix definitions
>   hw/vfio: Use the IEC binary prefix definitions
>   hw/virtio: Use the IEC binary prefix definitions
>   hw/rdma: Use the IEC binary prefix definitions
>   cutils: Do not include "qemu/units.h" directly
>   hw/ppc: Use the IEC binary prefix definitions
>   monitor: Use the IEC binary prefix definitions
>   vl: Use the IEC binary prefix definitions
>   tests/crypto: Use the IEC binary prefix definitions
>   linux-user: Use the IEC binary prefix definitions
>   bsd-user: Use the IEC binary prefix definitions
> 
>  hw/net/ne2000.h                          |  5 ++--
>  hw/ppc/mac.h                             |  3 ++-
>  hw/rdma/vmw/pvrdma.h                     |  3 ++-
>  include/hw/acpi/tpm.h                    |  3 ++-
>  include/hw/arm/fsl-imx7.h                |  5 ++--
>  include/hw/arm/stm32f205_soc.h           |  5 ++--
>  include/hw/display/xlnx_dp.h             |  5 ++--
>  include/hw/i386/ich9.h                   |  3 ++-
>  include/hw/intc/mips_gic.h               |  3 ++-
>  include/hw/mips/bios.h                   |  3 ++-
>  include/hw/net/allwinner_emac.h          |  5 ++--
>  include/hw/ppc/spapr.h                   |  5 ++--
>  include/hw/virtio/virtio-net.h           |  3 ++-
>  include/qemu/cutils.h                    |  7 ------
>  include/qemu/units.h                     | 20 ++++++++++++++++
>  block/vdi.c                              |  7 +++---
>  bsd-user/main.c                          |  5 ++--
>  hw/alpha/typhoon.c                       | 17 +++++++-------
>  hw/arm/bcm2835_peripherals.c             |  3 ++-
>  hw/arm/boot.c                            |  7 +++---
>  hw/arm/collie.c                          |  5 ++--
>  hw/arm/digic_boards.c                    |  7 +++---
>  hw/arm/exynos4_boards.c                  |  3 ++-
>  hw/arm/gumstix.c                         |  3 ++-
>  hw/arm/integratorcp.c                    |  3 ++-
>  hw/arm/mainstone.c                       |  3 ++-
>  hw/arm/msf2-soc.c                        |  6 ++---
>  hw/arm/msf2-som.c                        |  8 +++----
>  hw/arm/musicpal.c                        |  9 +++----
>  hw/arm/omap_sx1.c                        | 11 +++++----
>  hw/arm/raspi.c                           |  5 ++--
>  hw/arm/smmu-common.c                     |  3 ++-
>  hw/arm/stellaris.c                       |  5 ++--
>  hw/arm/versatilepb.c                     |  5 ++--
>  hw/arm/vexpress.c                        |  7 +++---
>  hw/arm/virt.c                            |  5 ++--
>  hw/arm/xilinx_zynq.c                     |  7 +++---
>  hw/block/m25p80.c                        |  5 ++--
>  hw/block/nvme.c                          |  3 ++-
>  hw/block/tc58128.c                       |  3 ++-
>  hw/block/xen_disk.c                      |  3 ++-
>  hw/core/loader-fit.c                     |  3 ++-
>  hw/core/machine.c                        |  4 ++--
>  hw/cris/axis_dev88.c                     |  3 ++-
>  hw/display/bochs-display.c               |  9 +++----
>  hw/display/cirrus_vga.c                  | 10 ++++----
>  hw/display/g364fb.c                      |  4 ++--
>  hw/display/qxl.c                         | 30 +++++++++++-------------
>  hw/display/sm501.c                       | 16 ++++++-------
>  hw/display/vga-isa-mm.c                  |  5 ++--
>  hw/display/vga.c                         |  5 ++--
>  hw/display/virtio-gpu.c                  |  4 ++--
>  hw/display/vmware_vga.c                  |  3 ++-
>  hw/display/xenfb.c                       |  3 ++-
>  hw/hppa/dino.c                           |  5 ++--
>  hw/hppa/machine.c                        | 12 +++++-----
>  hw/i386/acpi-build.c                     |  5 ++--
>  hw/i386/pc.c                             | 19 ++++++++-------
>  hw/i386/pc_piix.c                        |  4 ++--
>  hw/i386/pc_q35.c                         |  3 ++-
>  hw/i386/pc_sysfw.c                       |  9 +++----
>  hw/i386/xen/xen-mapcache.c               |  3 ++-
>  hw/intc/apic_common.c                    |  3 ++-
>  hw/ipack/tpci200.c                       |  5 ++--
>  hw/lm32/lm32_boards.c                    | 13 +++++-----
>  hw/lm32/milkymist.c                      | 10 ++++----
>  hw/m68k/mcf5208.c                        |  3 ++-
>  hw/microblaze/petalogix_ml605_mmu.c      |  7 +++---
>  hw/microblaze/petalogix_s3adsp1800_mmu.c |  7 +++---
>  hw/mips/boston.c                         | 30 ++++++++++++------------
>  hw/mips/mips_fulong2e.c                  |  7 +++---
>  hw/mips/mips_malta.c                     | 25 +++++++++++---------
>  hw/mips/mips_r4k.c                       | 15 ++++++------
>  hw/misc/aspeed_sdmc.c                    |  9 +++----
>  hw/misc/auxbus.c                         |  3 ++-
>  hw/misc/edu.c                            |  3 ++-
>  hw/misc/imx7_gpr.c                       |  3 ++-
>  hw/misc/ivshmem.c                        |  3 ++-
>  hw/misc/mips_itu.c                       |  3 ++-
>  hw/misc/omap_gpmc.c                      |  5 ++--
>  hw/net/e1000e.c                          |  7 +++---
>  hw/net/e1000x_common.c                   |  3 ++-
>  hw/net/eepro100.c                        |  3 +--
>  hw/nios2/boot.c                          |  6 ++---
>  hw/nvram/spapr_nvram.c                   | 11 +++++----
>  hw/pci-host/designware.c                 |  3 ++-
>  hw/pci-host/gpex.c                       |  3 ++-
>  hw/pci-host/piix.c                       |  5 ++--
>  hw/pci-host/prep.c                       |  3 ++-
>  hw/pci-host/q35.c                        | 17 +++++++-------
>  hw/pci-host/xilinx-pcie.c                |  5 ++--
>  hw/ppc/e500.c                            | 13 +++++-----
>  hw/ppc/e500plat.c                        |  3 ++-
>  hw/ppc/mac_newworld.c                    |  1 -
>  hw/ppc/mac_oldworld.c                    |  9 ++++---
>  hw/ppc/pnv.c                             |  6 ++---
>  hw/ppc/ppc405_boards.c                   |  9 +++----
>  hw/ppc/ppc405_uc.c                       |  7 +++---
>  hw/ppc/ppc440_bamboo.c                   |  5 ++--
>  hw/ppc/ppc440_uc.c                       | 28 +++++++++++-----------
>  hw/ppc/ppc4xx_devs.c                     | 22 +++++++++--------
>  hw/ppc/ppce500_spin.c                    |  3 ++-
>  hw/ppc/prep.c                            |  6 ++---
>  hw/ppc/rs6000_mc.c                       | 13 +++++-----
>  hw/ppc/sam460ex.c                        | 18 +++++++-------
>  hw/ppc/spapr.c                           | 12 +++++-----
>  hw/ppc/spapr_rtas.c                      |  2 +-
>  hw/ppc/virtex_ml507.c                    |  7 +++---
>  hw/riscv/virt.c                          |  3 ++-
>  hw/s390x/s390-skeys.c                    |  3 ++-
>  hw/s390x/s390-stattrib.c                 |  3 ++-
>  hw/s390x/sclp.c                          |  3 ++-
>  hw/scsi/scsi-disk.c                      |  9 +++----
>  hw/sd/sd.c                               |  8 +++----
>  hw/sd/sdhci.c                            |  8 +++----
>  hw/sh4/r2d.c                             |  3 ++-
>  hw/smbios/smbios.c                       | 15 +++++-------
>  hw/sparc/leon3.c                         | 10 ++++----
>  hw/sparc/sun4m.c                         | 10 ++++----
>  hw/sparc64/niagara.c                     |  3 ++-
>  hw/sparc64/sun4u.c                       |  4 ++--
>  hw/ssi/aspeed_smc.c                      | 29 ++++++++++++-----------
>  hw/tricore/tricore_testboard.c           | 13 +++++-----
>  hw/usb/ccid-card-passthru.c              |  5 ++--
>  hw/usb/combined-packet.c                 |  3 ++-
>  hw/usb/dev-smartcard-reader.c            |  3 ++-
>  hw/usb/redirect.c                        |  3 ++-
>  hw/vfio/pci-quirks.c                     |  9 +++----
>  hw/vfio/pci.c                            |  3 ++-
>  hw/xenpv/xen_domainbuild.c               | 13 +++++-----
>  hw/xtensa/xtfpga.c                       |  9 +++----
>  linux-user/main.c                        |  5 ++--
>  monitor.c                                |  3 ++-
>  target/i386/cpu.c                        |  4 +---
>  target/ppc/mmu_helper.c                  |  8 +++----
>  target/xtensa/helper.c                   |  5 ++--
>  tests/benchmark-crypto-cipher.c          |  6 ++---
>  tests/benchmark-crypto-hash.c            |  5 ++--
>  tests/benchmark-crypto-hmac.c            |  6 ++---
>  tests/test-cutils.c                      | 18 +++++++-------
>  tests/test-keyval.c                      |  6 ++---
>  tests/test-qemu-opts.c                   |  7 +++---
>  vl.c                                     |  3 ++-
>  scripts/checkpatch.pl                    |  1 +
>  144 files changed, 565 insertions(+), 453 deletions(-)
>  create mode 100644 include/qemu/units.h
>