Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Eric Blake
On 08/16/2013 01:46 PM, Richard Henderson wrote: > On 08/16/2013 08:37 AM, Alex Williamson wrote: >> On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote: >>> On 08/16/2013 05:50 AM, Alex Williamson wrote: +/* Size must be a power of 2 */ +if (l & (l - 1)) { +wh

Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Richard Henderson
On 08/16/2013 08:37 AM, Alex Williamson wrote: > On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote: >> On 08/16/2013 05:50 AM, Alex Williamson wrote: >>> +/* Size must be a power of 2 */ >>> +if (l & (l - 1)) { >>> +while (l & (access_size_max - 1)) { >>> +acces

Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Alex Williamson
On Fri, 2013-08-16 at 09:43 -0600, Alex Williamson wrote: > On Fri, 2013-08-16 at 09:37 -0600, Alex Williamson wrote: > > On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote: > > > On 08/16/2013 05:50 AM, Alex Williamson wrote: > > > > +/* Size must be a power of 2 */ > > > > +if (l

Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Alex Williamson
On Fri, 2013-08-16 at 09:37 -0600, Alex Williamson wrote: > On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote: > > On 08/16/2013 05:50 AM, Alex Williamson wrote: > > > +/* Size must be a power of 2 */ > > > +if (l & (l - 1)) { > > > +while (l & (access_size_max - 1)) { > >

Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Alex Williamson
On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote: > On 08/16/2013 05:50 AM, Alex Williamson wrote: > > +/* Size must be a power of 2 */ > > +if (l & (l - 1)) { > > +while (l & (access_size_max - 1)) { > > +access_size_max >>= 1; > > +} > > +} > > +

Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Richard Henderson
On 08/16/2013 05:50 AM, Alex Williamson wrote: > +/* Size must be a power of 2 */ > +if (l & (l - 1)) { > +while (l & (access_size_max - 1)) { > +access_size_max >>= 1; > +} > +} > + Why the loop at all? x & -x extracts the lsb of x. r~

Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Laszlo Ersek
On 08/16/13 14:50, Alex Williamson wrote: > Since commit 23326164 we align access sizes to match the alignment of > the address, but we don't align the access size itself. This means we > let illegal access sizes (ex. 3) slip through if the address is > sufficiently aligned (ex. 4). This results

[Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses

2013-08-16 Thread Alex Williamson
Since commit 23326164 we align access sizes to match the alignment of the address, but we don't align the access size itself. This means we let illegal access sizes (ex. 3) slip through if the address is sufficiently aligned (ex. 4). This results in an abort which would be easy for a guest to tri