* [Qemu-devel] [PATCH] target-ppc: fix left shift overflow in hpte_page_shift
@ 2016-07-15 15:22 Paolo Bonzini
2016-07-18 0:45 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2016-07-15 15:22 UTC (permalink / raw)
To: qemu-devel; +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 <pbonzini@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] target-ppc: fix left shift overflow in hpte_page_shift
2016-07-15 15:22 [Qemu-devel] [PATCH] target-ppc: fix left shift overflow in hpte_page_shift Paolo Bonzini
@ 2016-07-18 0:45 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2016-07-18 0:45 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Alexander Graf, open list:PowerPC
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
On Fri, Jul 15, 2016 at 05:22:10PM +0200, Paolo Bonzini wrote:
> 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 <pbonzini@redhat.com>
Applied to ppc-for-2.7, thanks.
> ---
> 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;
> }
> }
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-18 0:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 15:22 [Qemu-devel] [PATCH] target-ppc: fix left shift overflow in hpte_page_shift Paolo Bonzini
2016-07-18 0:45 ` David Gibson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.