Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-09 Thread Peter Xu
On Wed, Mar 09, 2016 at 01:59:03PM +0100, Paolo Bonzini wrote: > If you look at users, they only write about 20 bytes at most. My > suggestion is to use your patch, and replace > > assert(__BUF_SIZE >= n); > > with > > assert(n < ARRAY_SIZE(tmp)); > > Then you don't need the #define.

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-09 Thread Paolo Bonzini
On 09/03/2016 09:07, Peter Xu wrote: >>> > > pxdev:bin# gcc -v >>> > > Using built-in specs. >>> > > COLLECT_GCC=/bin/gcc >>> > > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper >>> > > Target: x86_64-redhat-linux >>> > > Configured with: ../configure --prefix=/usr

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-09 Thread Markus Armbruster
Peter Xu writes: > On Wed, Mar 09, 2016 at 09:34:50AM +0100, Markus Armbruster wrote: >> Peter Xu writes: >> > It's dynamically allocated in stack, can we still use ARRAY_SIZE in >> > this case? >> >> ARRAY_SIZE(x) is defined as (sizeof(x) /

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-09 Thread Peter Xu
On Wed, Mar 09, 2016 at 09:34:50AM +0100, Markus Armbruster wrote: > Peter Xu writes: > > It's dynamically allocated in stack, can we still use ARRAY_SIZE in > > this case? > > ARRAY_SIZE(x) is defined as (sizeof(x) / sizeof((x)[0])). Works when x > is of array type (variable

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-09 Thread Markus Armbruster
Peter Xu writes: > On Wed, Mar 09, 2016 at 08:53:19AM +0100, Paolo Bonzini wrote: >> >> >> On 09/03/2016 06:08, Peter Xu wrote: >> > pxdev:bin# gcc -v >> > Using built-in specs. >> > COLLECT_GCC=/bin/gcc >> >

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-09 Thread Peter Xu
On Wed, Mar 09, 2016 at 08:53:19AM +0100, Paolo Bonzini wrote: > > > On 09/03/2016 06:08, Peter Xu wrote: > > pxdev:bin# gcc -v > > Using built-in specs. > > COLLECT_GCC=/bin/gcc > > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper > > Target: x86_64-redhat-linux > >

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-08 Thread Paolo Bonzini
On 09/03/2016 06:08, Peter Xu wrote: > pxdev:bin# gcc -v > Using built-in specs. > COLLECT_GCC=/bin/gcc > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper > Target: x86_64-redhat-linux > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man >

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-08 Thread Peter Xu
On Tue, Mar 08, 2016 at 02:26:36PM +0700, Peter Maydell wrote: > On 8 March 2016 at 14:00, Peter Xu wrote: > > First of all, this function cannot be inlined even with always_inline, > > so removing inline. > > Please don't mix two different changes in one patch. Sorry. Will

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-08 Thread Peter Xu
On Tue, Mar 08, 2016 at 01:21:52PM +0100, Paolo Bonzini wrote: > > > On 08/03/2016 08:00, Peter Xu wrote: > > First of all, this function cannot be inlined even with always_inline, > > so removing inline. > > Why? always_inline fixes the error for me. I tried this patch: -

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-08 Thread Paolo Bonzini
On 08/03/2016 08:00, Peter Xu wrote: > First of all, this function cannot be inlined even with always_inline, > so removing inline. Why? always_inline fixes the error for me. > int i; > -uint32_t tmp[len / sizeof(uint32_t)]; > +uint32_t n = len / sizeof(uint32_t); > +#define

Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-07 Thread Peter Maydell
On 8 March 2016 at 14:00, Peter Xu wrote: > First of all, this function cannot be inlined even with always_inline, > so removing inline. Please don't mix two different changes in one patch. > After that, make its stack bounded. > > Suggested-by: Paolo Bonzini

[Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s

2016-03-07 Thread Peter Xu
First of all, this function cannot be inlined even with always_inline, so removing inline. After that, make its stack bounded. Suggested-by: Paolo Bonzini CC: Gerd Hoffmann Signed-off-by: Peter Xu --- hw/usb/hcd-xhci.c | 12