Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-16 Thread David Daney
On 09/16/2015 10:29 AM, Will Deacon wrote: Hi Lorenzo, On Wed, Sep 16, 2015 at 12:28:52PM +0100, Lorenzo Pieralisi wrote: On Wed, Sep 16, 2015 at 11:41:53AM +0100, Will Deacon wrote: Here is the current code: bus_range = pci->cfg.bus_range; for (busn = bus_range->start; busn

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-16 Thread Will Deacon
Hi Lorenzo, On Wed, Sep 16, 2015 at 12:28:52PM +0100, Lorenzo Pieralisi wrote: > On Wed, Sep 16, 2015 at 11:41:53AM +0100, Will Deacon wrote: > > > Here is the current code: > > > > > > >>bus_range = pci->cfg.bus_range; > > > >>for (busn = bus_range->start; busn <= bus_range->end;

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-16 Thread Lorenzo Pieralisi
On Wed, Sep 16, 2015 at 11:41:53AM +0100, Will Deacon wrote: [...] > > Here is the current code: > > > > >> bus_range = pci->cfg.bus_range; > > >> for (busn = bus_range->start; busn <= bus_range->end; ++busn) { > > >> u32 idx = busn - bus_range->start; > > > > The index is offset by

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-16 Thread Will Deacon
On Tue, Sep 15, 2015 at 07:45:56PM +0100, David Daney wrote: > On 09/15/2015 11:35 AM, Will Deacon wrote: > > On Tue, Sep 15, 2015 at 07:02:54PM +0100, David Daney wrote: > >> On 09/15/2015 10:49 AM, Will Deacon wrote: > >>> On Sat, Sep 12, 2015 at 12:21:57AM +0100, David Daney wrote: >

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-15 Thread David Daney
On 09/15/2015 11:35 AM, Will Deacon wrote: On Tue, Sep 15, 2015 at 07:02:54PM +0100, David Daney wrote: On 09/15/2015 10:49 AM, Will Deacon wrote: On Sat, Sep 12, 2015 at 12:21:57AM +0100, David Daney wrote: /* Limit the bus-range to fit within reg */ - bus_max = pci->cfg.bus_ran

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-15 Thread Will Deacon
On Tue, Sep 15, 2015 at 07:02:54PM +0100, David Daney wrote: > On 09/15/2015 10:49 AM, Will Deacon wrote: > > On Sat, Sep 12, 2015 at 12:21:57AM +0100, David Daney wrote: > >>/* Limit the bus-range to fit within reg */ > >> - bus_max = pci->cfg.bus_range->start + > >> -(resource_si

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-15 Thread David Daney
On 09/15/2015 10:49 AM, Will Deacon wrote: On Sat, Sep 12, 2015 at 12:21:57AM +0100, David Daney wrote: From: David Daney There are two problems with the bus_max calculation: 1) The u8 data type can overflow for large config space windows. 2) The calculation is incorrect for a bus range that

Re: [PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-15 Thread Will Deacon
On Sat, Sep 12, 2015 at 12:21:57AM +0100, David Daney wrote: > From: David Daney > > There are two problems with the bus_max calculation: > > 1) The u8 data type can overflow for large config space windows. > > 2) The calculation is incorrect for a bus range that doesn't start at >zero. >

[PATCH 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation.

2015-09-11 Thread David Daney
From: David Daney There are two problems with the bus_max calculation: 1) The u8 data type can overflow for large config space windows. 2) The calculation is incorrect for a bus range that doesn't start at zero. Since the configuration space is relative to bus zero, make bus_max just be the