* [PATCH] Resource: wrong resource window calculation [not found] ` <4E6F400A.6090909@logix.net.nz> @ 2011-09-22 7:48 ` Ram Pai 2011-09-22 9:50 ` Michal Ludvig 0 siblings, 1 reply; 6+ messages in thread From: Ram Pai @ 2011-09-22 7:48 UTC (permalink / raw) To: linux-pci, linux-kernel Cc: Bjorn Helgaas, Jesse Barnes, weiyang, wangyun, shangw, Michal Ludvig Resource: wrong resource window calculation __find_resource() incorrectly returns a resource window which overlaps an existing allocated window. This happens when the parent's resource-window spans 0x00000000 to 0xffffffff and is entirely allocated to all its children resource-windows. __find_resource() looks for gaps in resource allocation among the children resource windows. When it encounters the last child window it blindly tries the range next to one allocated to the last child. Since the last child's window ends at 0xffffffff the calculation overflows, leading the algorithm to believe that any window in the range 0x0000000 to 0xfffffff is available for allocation. This leads to a conflicting window allocation. Michal Ludvig reported this issue seen on his platform. The following patch fixes the problem and has been verified by Michal. I believe this bug has been there for ages. It got exposed by git commit 2bbc6942273b5b3097bd265d82227bdd84b351b2 [PATCH] PCI : ability to relocate assigned pci-resources Signed-off-by: Ram Pai <linuxram@us.ibm.com> --- kernel/resource.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 3ff4017..b29b83d 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -419,6 +419,9 @@ static int __find_resource(struct resource *root, struct resource *old, else tmp.end = root->end; + if (tmp.end < tmp.start) + goto next; + resource_clip(&tmp, constraint->min, constraint->max); arch_remove_reservations(&tmp); @@ -436,8 +439,10 @@ static int __find_resource(struct resource *root, struct resource *old, return 0; } } - if (!this) + +next: if (!this || this->end == root->end) break; + if (this != old) tmp.start = this->end + 1; this = this->sibling; -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Resource: wrong resource window calculation 2011-09-22 7:48 ` [PATCH] Resource: wrong resource window calculation Ram Pai @ 2011-09-22 9:50 ` Michal Ludvig 2011-09-28 15:42 ` Ram Pai 0 siblings, 1 reply; 6+ messages in thread From: Michal Ludvig @ 2011-09-22 9:50 UTC (permalink / raw) To: Ram Pai Cc: linux-pci, linux-kernel, Bjorn Helgaas, Jesse Barnes, weiyang, wangyun, shangw On 09/22/2011 07:48 PM, Ram Pai wrote: > Resource: wrong resource window calculation > > __find_resource() incorrectly returns a resource window which overlaps an > existing allocated window. This happens when the parent's resource-window spans > 0x00000000 to 0xffffffff and is entirely allocated to all its children > resource-windows. > > __find_resource() looks for gaps in resource allocation among the children > resource windows. When it encounters the last child window it blindly tries > the range next to one allocated to the last child. Since the last child's > window ends at 0xffffffff the calculation overflows, leading the algorithm to > believe that any window in the range 0x0000000 to 0xfffffff is available for > allocation. This leads to a conflicting window allocation. > > Michal Ludvig reported this issue seen on his platform. The following patch > fixes the problem and has been verified by Michal. I believe this bug has been > there for ages. It got exposed by git commit > 2bbc6942273b5b3097bd265d82227bdd84b351b2 > [PATCH] PCI : ability to relocate assigned pci-resources > > Signed-off-by: Ram Pai<linuxram@us.ibm.com> Tested-by: Michal Ludvig <mludvig@logix.net.nz> Works fine on top of 3.1.0-rc7 and solves the problem with my Jetway board. Thanks Ram! M. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Resource: wrong resource window calculation 2011-09-22 9:50 ` Michal Ludvig @ 2011-09-28 15:42 ` Ram Pai 2011-09-30 2:44 ` Linus Torvalds 0 siblings, 1 reply; 6+ messages in thread From: Ram Pai @ 2011-09-28 15:42 UTC (permalink / raw) To: Linus Torvalds Cc: linux-pci, linux-kernel, Bjorn Helgaas, Jesse Barnes, weiyang, wangyun, shangw, Michal Ludvig On Thu, Sep 22, 2011 at 09:50:48PM +1200, Michal Ludvig wrote: > On 09/22/2011 07:48 PM, Ram Pai wrote: > > Resource: wrong resource window calculation > > > >__find_resource() incorrectly returns a resource window which overlaps an > >existing allocated window. This happens when the parent's resource-window spans > >0x00000000 to 0xffffffff and is entirely allocated to all its children > >resource-windows. > > > >__find_resource() looks for gaps in resource allocation among the children > >resource windows. When it encounters the last child window it blindly tries > >the range next to one allocated to the last child. Since the last child's > >window ends at 0xffffffff the calculation overflows, leading the algorithm to > >believe that any window in the range 0x0000000 to 0xfffffff is available for > >allocation. This leads to a conflicting window allocation. > > > >Michal Ludvig reported this issue seen on his platform. The following patch > >fixes the problem and has been verified by Michal. I believe this bug has been > >there for ages. It got exposed by git commit > >2bbc6942273b5b3097bd265d82227bdd84b351b2 > >[PATCH] PCI : ability to relocate assigned pci-resources > > > >Signed-off-by: Ram Pai<linuxram@us.ibm.com> > > Tested-by: Michal Ludvig <mludvig@logix.net.nz> > > Works fine on top of 3.1.0-rc7 and solves the problem with my Jetway board. > > Thanks Ram! > > M. Linus, Do you plan to take this patch for 3.1? It fixes a regression w.r.t 3.0 https://bugzilla.kernel.org/show_bug.cgi?id=42002 captures the bug report. RP ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Resource: wrong resource window calculation 2011-09-28 15:42 ` Ram Pai @ 2011-09-30 2:44 ` Linus Torvalds 2011-09-30 2:56 ` Michal Ludvig 2011-09-30 2:59 ` Ram Pai 0 siblings, 2 replies; 6+ messages in thread From: Linus Torvalds @ 2011-09-30 2:44 UTC (permalink / raw) To: Ram Pai Cc: linux-pci, linux-kernel, Bjorn Helgaas, Jesse Barnes, weiyang, wangyun, shangw, Michal Ludvig On Wed, Sep 28, 2011 at 8:42 AM, Ram Pai <linuxram@us.ibm.com> wrote: > > Do you plan to take this patch for 3.1? It fixes a regression w.r.t 3.0 > https://bugzilla.kernel.org/show_bug.cgi?id=42002 captures the bug report. It looks fine, but that bugzilla thing is currently useless. Do you have some other place with the symptoms, discussion etc? I didn't find the original report on lkml.. Linus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Resource: wrong resource window calculation 2011-09-30 2:44 ` Linus Torvalds @ 2011-09-30 2:56 ` Michal Ludvig 2011-09-30 2:59 ` Ram Pai 1 sibling, 0 replies; 6+ messages in thread From: Michal Ludvig @ 2011-09-30 2:56 UTC (permalink / raw) To: Linus Torvalds Cc: Ram Pai, linux-pci, linux-kernel, Bjorn Helgaas, Jesse Barnes, weiyang, wangyun, shangw On 09/30/2011 03:44 PM, Linus Torvalds wrote: > On Wed, Sep 28, 2011 at 8:42 AM, Ram Pai<linuxram@us.ibm.com> wrote: >> Do you plan to take this patch for 3.1? It fixes a regression w.r.t 3.0 >> https://bugzilla.kernel.org/show_bug.cgi?id=42002 captures the bug report. > It looks fine, but that bugzilla thing is currently useless. Do you > have some other place with the symptoms, discussion etc? I didn't > find the original report on lkml.. > Hi, here is the thread from linux-pci@... http://comments.gmane.org/gmane.linux.kernel.pci/11666 Michal ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Resource: wrong resource window calculation 2011-09-30 2:44 ` Linus Torvalds 2011-09-30 2:56 ` Michal Ludvig @ 2011-09-30 2:59 ` Ram Pai 1 sibling, 0 replies; 6+ messages in thread From: Ram Pai @ 2011-09-30 2:59 UTC (permalink / raw) To: Linus Torvalds Cc: Ram Pai, linux-pci, linux-kernel, Bjorn Helgaas, Jesse Barnes, weiyang, wangyun, shangw, Michal Ludvig On Thu, Sep 29, 2011 at 07:44:17PM -0700, Linus Torvalds wrote: > On Wed, Sep 28, 2011 at 8:42 AM, Ram Pai <linuxram@us.ibm.com> wrote: > > > > Do you plan to take this patch for 3.1? It fixes a regression w.r.t 3.0 > > https://bugzilla.kernel.org/show_bug.cgi?id=42002 captures the bug report. > > It looks fine, but that bugzilla thing is currently useless. Do you > have some other place with the symptoms, discussion etc? I didn't > find the original report on lkml.. It was initially reported by Michal Ludwig in the linux-pci mailing list. The following thread captures the discussion http://comments.gmane.org/gmane.linux.kernel.pci/11666 RP ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-30 3:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4E5E0A7E.40301@logix.net.nz>
[not found] ` <CAErSpo70k6UnhvvOMgQQxJ6BHZOwym=-jaPMvOukAaCr-B0+cQ@mail.gmail.com>
[not found] ` <4E5EFFBD.4050201@logix.net.nz>
[not found] ` <CAErSpo6bofeiAxeRo_RjXQSnwmcWrdymn0MK8H4_CwqwoeD1jg@mail.gmail.com>
[not found] ` <4E634814.4050508@logix.net.nz>
[not found] ` <20110909113409.GE2416@ram-ThinkPad-T61>
[not found] ` <4E6C05B7.9000904@logix.net.nz>
[not found] ` <20110913110646.GB2425@ram-ThinkPad-T61>
[not found] ` <4E6F400A.6090909@logix.net.nz>
2011-09-22 7:48 ` [PATCH] Resource: wrong resource window calculation Ram Pai
2011-09-22 9:50 ` Michal Ludvig
2011-09-28 15:42 ` Ram Pai
2011-09-30 2:44 ` Linus Torvalds
2011-09-30 2:56 ` Michal Ludvig
2011-09-30 2:59 ` Ram Pai
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox