Received: from eggs.gnu.org ([2001:4830:134:3::10]:35402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO4wX-0004fe-G8 for qemu-devel@nongnu.org; Fri, 15 Jul 2016 11:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bO4wR-0003mt-EZ for qemu-devel@nongnu.org; Fri, 15 Jul 2016 11:22:20 -0400 Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 15 Jul 2016 17:22:10 +0200 Message-Id: <1468596130-27783-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] target-ppc: fix left shift overflow in hpte_page_shift List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: David Gibson , Alexander Graf , "open list:PowerPC" ps->pte_enc is a 32-bit value, which is shifted left and then compared to a 64-bit value. It needs a cast before the shift. Reported by Coverity. Signed-off-by: Paolo Bonzini --- target-ppc/mmu-hash64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c index 82c2186..8f7e5b4 100644 --- a/target-ppc/mmu-hash64.c +++ b/target-ppc/mmu-hash64.c @@ -479,7 +479,7 @@ static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps, mask = ((1ULL << ps->page_shift) - 1) & HPTE64_R_RPN; - if ((pte1 & mask) == (ps->pte_enc << HPTE64_R_RPN_SHIFT)) { + if ((pte1 & mask) == ((uint64_t)ps->pte_enc << HPTE64_R_RPN_SHIFT)) { return ps->page_shift; } } -- 2.7.4