]> Git Repo - qemu.git/commitdiff
spapr: Force SPAPR_MEMORY_BLOCK_SIZE to be a hwaddr (64-bit)
authorDavid Gibson <[email protected]>
Wed, 6 Mar 2019 03:15:26 +0000 (14:15 +1100)
committerDavid Gibson <[email protected]>
Tue, 12 Mar 2019 03:33:04 +0000 (14:33 +1100)
SPAPR_MEMORY_BLOCK_SIZE is logically a difference in memory addresses, and
hence of type hwaddr which is 64-bit.  Previously it wasn't marked as such
which means that it could be treated as 32-bit.  That will work in some
circumstances but if multiplied by another 32-bit value it could lead to
a 32-bit overflow and an incorrect result.

One specific instance of this in spapr_lmb_dt_populate() was spotted by
Coverity (CID 1399145).

Reported-by: Peter Maydell <[email protected]>
Signed-off-by: David Gibson <[email protected]>
include/hw/ppc/spapr.h

index ff1bd6061540375900e857ffa35ded0bfac0c86b..1311ebe28e9801d17b32ee4462e56f6819a24fd2 100644 (file)
@@ -792,7 +792,7 @@ int spapr_rtc_import_offset(sPAPRRTCState *rtc, int64_t legacy_offset);
 
 #define TYPE_SPAPR_RNG "spapr-rng"
 
-#define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */
+#define SPAPR_MEMORY_BLOCK_SIZE ((hwaddr)1 << 28) /* 256MB */
 
 /*
  * This defines the maximum number of DIMM slots we can have for sPAPR
This page took 0.029967 seconds and 4 git commands to generate.