aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Donnellan <ajd@linux.ibm.com>2019-09-26 14:55:46 +0200
committerOliver O'Halloran <oohall@gmail.com>2019-11-05 19:39:16 +1100
commite85e2e2b8b0a4dd96e10343df19df1a161cd6aac (patch)
treef420e90e42f553954b19195530a9b192ecd4441f
parentad8cdd0f83bf55e9717326afb7af6eeedb33e031 (diff)
downloadskiboot-e85e2e2b8b0a4dd96e10343df19df1a161cd6aac.zip
skiboot-e85e2e2b8b0a4dd96e10343df19df1a161cd6aac.tar.gz
skiboot-e85e2e2b8b0a4dd96e10343df19df1a161cd6aac.tar.bz2
npu2-opencapi: Fix integer promotion bug in LPC allocation
If you try to allocate an amount of LPC memory that's not a power of 2, we round the value up to the nearest power of 2. By the magic of C, "1 << n" gets treated as an int, even if you're assigning it to a uint64_t. Change 1 to 1ULL to fix this. (C, it's great.) Reported-by: Alastair D'Silva <alistair@d-silva.org> Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
-rw-r--r--hw/npu2-opencapi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
index fc9e50c..e2319f2 100644
--- a/hw/npu2-opencapi.c
+++ b/hw/npu2-opencapi.c
@@ -2219,7 +2219,7 @@ static int64_t alloc_mem_bar(struct npu2_dev *dev, uint64_t size, uint64_t *bar)
}
if (!is_pow2(size)) {
- size = 1 << (ilog2(size) + 1);
+ size = 1ull << (ilog2(size) + 1);
}
set_mem_bar(dev, phys_map_base, size);