Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-26 Thread David Gibson
On Thu, Mar 26, 2020 at 11:21:47AM +, Peter Maydell wrote: > On Thu, 26 Mar 2020 at 00:39, David Gibson > wrote: > > > > On Tue, Mar 24, 2020 at 05:39:12PM +1100, Alexey Kardashevskiy wrote: > > > Coverity detected an issue (CID 1421903) with potential call of clz64(0) > > > which returns 64

Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-26 Thread Peter Maydell
On Thu, 26 Mar 2020 at 00:39, David Gibson wrote: > > On Tue, Mar 24, 2020 at 05:39:12PM +1100, Alexey Kardashevskiy wrote: > > Coverity detected an issue (CID 1421903) with potential call of clz64(0) > > which returns 64 which make it do "<<" with a negative number. > > > > This checks the mask a

Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-25 Thread David Gibson
On Tue, Mar 24, 2020 at 05:39:12PM +1100, Alexey Kardashevskiy wrote: > Coverity detected an issue (CID 1421903) with potential call of clz64(0) > which returns 64 which make it do "<<" with a negative number. > > This checks the mask and avoids undefined behaviour. > > In practice pgsizes and me

Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-24 Thread Philippe Mathieu-Daudé
On 3/24/20 3:30 PM, Greg Kurz wrote: On Tue, 24 Mar 2020 14:27:35 +0100 Philippe Mathieu-Daudé wrote: On 3/24/20 7:39 AM, Alexey Kardashevskiy wrote: Coverity detected an issue (CID 1421903) with potential call of clz64(0) which returns 64 which make it do "<<" with a negative number. This

Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-24 Thread Greg Kurz
On Tue, 24 Mar 2020 14:27:35 +0100 Philippe Mathieu-Daudé wrote: > > > On 3/24/20 7:39 AM, Alexey Kardashevskiy wrote: > > Coverity detected an issue (CID 1421903) with potential call of clz64(0) > > which returns 64 which make it do "<<" with a negative number. > > > > This checks the mask an

Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-24 Thread Greg Kurz
On Tue, 24 Mar 2020 17:39:12 +1100 Alexey Kardashevskiy wrote: > Coverity detected an issue (CID 1421903) with potential call of clz64(0) > which returns 64 which make it do "<<" with a negative number. > > This checks the mask and avoids undefined behaviour. > > In practice pgsizes and memory_

Re: [PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-24 Thread Philippe Mathieu-Daudé
On 3/24/20 7:39 AM, Alexey Kardashevskiy wrote: Coverity detected an issue (CID 1421903) with potential call of clz64(0) which returns 64 which make it do "<<" with a negative number. This checks the mask and avoids undefined behaviour. In practice pgsizes and memory_region_iommu_get_min_pag

[PATCH qemu] vfio/spapr: Fix page size calculation

2020-03-23 Thread Alexey Kardashevskiy
Coverity detected an issue (CID 1421903) with potential call of clz64(0) which returns 64 which make it do "<<" with a negative number. This checks the mask and avoids undefined behaviour. In practice pgsizes and memory_region_iommu_get_min_page_size() always have some common page sizes and even