Re: [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN

2020-12-23 Thread Sean Christopherson
On Tue, Dec 22, 2020, Paolo Bonzini wrote: > On 22/12/20 19:31, David Laight wrote: > > > /* > > >* Use 2ULL to incorporate the necessary +1 in the shift; adding +1 in > > >* the shift count will overflow SHL's max shift of 63 if s=0 and e=63. > > >*/ > > A comment of the desired outp

Re: [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN

2020-12-22 Thread Paolo Bonzini
On 22/12/20 19:31, David Laight wrote: /* * Use 2ULL to incorporate the necessary +1 in the shift; adding +1 in * the shift count will overflow SHL's max shift of 63 if s=0 and e=63. */ A comment of the desired output value would be more use. I think it is:

RE: [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN

2020-12-22 Thread David Laight
From: Sean Christopherson > Sent: 22 December 2020 18:13 > > On Tue, Dec 22, 2020, Paolo Bonzini wrote: > > Since we know that e >= s, we can reassociate the left shift, > > changing the shifted number from 1 to 2 in exchange for > > decreasing the right hand side by 1. > > I assume the edge case

Re: [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN

2020-12-22 Thread Sean Christopherson
On Tue, Dec 22, 2020, Paolo Bonzini wrote: > Since we know that e >= s, we can reassociate the left shift, > changing the shifted number from 1 to 2 in exchange for > decreasing the right hand side by 1. I assume the edge case is that this ends up as `(1ULL << 64) - 1` and overflows SHL's max shif