Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-06 Thread BALATON Zoltan
On Sat, 6 Aug 2022, Peter Maydell wrote: On Sat, 6 Aug 2022 at 12:24, BALATON Zoltan wrote: I may look at it later when Peter's second patch changing this code lands if there are any cleanups possible You mean the 2nd patch I sent in that RFC series? I'm not Yes I mean that patch. current

Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-06 Thread Peter Maydell
On Sat, 6 Aug 2022 at 12:24, BALATON Zoltan wrote: > I may look at it later when Peter's second patch changing > this code lands if there are any cleanups possible You mean the 2nd patch I sent in that RFC series? I'm not currently totally sure what I want to do with that. Looking at the code and

Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-06 Thread Peter Maydell
On Sat, 6 Aug 2022 at 12:17, Daniel Henrique Barboza wrote: > > Balaton, > > I had a change of heart. The code is too clear that it won't overflow. > It felt overkill changing var types just for that. > > Peter already marked it as Ignored - False Positive in Coverity as well. > So this would be a

Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-06 Thread BALATON Zoltan
On Sat, 6 Aug 2022, Daniel Henrique Barboza wrote: Balaton, I had a change of heart. The code is too clear that it won't overflow. It felt overkill changing var types just for that. Peter already marked it as Ignored - False Positive in Coverity as well. So this would be a code change to "look

Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-06 Thread Daniel Henrique Barboza
Balaton, I had a change of heart. The code is too clear that it won't overflow. It felt overkill changing var types just for that. Peter already marked it as Ignored - False Positive in Coverity as well. So this would be a code change to "look better". It didn't look particularly better after th

Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-06 Thread Daniel Henrique Barboza
On 8/5/22 21:30, BALATON Zoltan wrote: On Fri, 5 Aug 2022, Daniel Henrique Barboza wrote: Coverity reports a OVERFLOW_BEFORE_WIDEN issue in dcr_write_dma(). When handling the DMA0_CR switch we're doing a multiplication between two integers (count and width), and the product is assigned to an

Re: [PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-05 Thread BALATON Zoltan
On Fri, 5 Aug 2022, Daniel Henrique Barboza wrote: Coverity reports a OVERFLOW_BEFORE_WIDEN issue in dcr_write_dma(). When handling the DMA0_CR switch we're doing a multiplication between two integers (count and width), and the product is assigned to an uint64_t (xferlen). The int32 product can b

[PATCH] hw/ppc: ppc440_uc: avoid multiply overflow in dcr_write_dma()

2022-08-05 Thread Daniel Henrique Barboza
Coverity reports a OVERFLOW_BEFORE_WIDEN issue in dcr_write_dma(). When handling the DMA0_CR switch we're doing a multiplication between two integers (count and width), and the product is assigned to an uint64_t (xferlen). The int32 product can be overflow before widened. Fix it by casting the fir