From e85e2e2b8b0a4dd96e10343df19df1a161cd6aac Mon Sep 17 00:00:00 2001 From: Andrew Donnellan Date: Thu, 26 Sep 2019 14:55:46 +0200 Subject: 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 Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: Andrew Donnellan Signed-off-by: Oliver O'Halloran --- hw/npu2-opencapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- cgit v1.1