Skip to contentSkip to conversation

Resource: wrong resource window calculation

PATCH In review Ram Pai 3 participants 6 messages Sep 22, 2011 – Sep 30, 2011 9 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAErSpo70k6UnhvvOMgQQxJ6BHZOwym=-jaPMvOukAaCr-B0+cQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAErSpo6bofeiAxeRo_RjXQSnwmcWrdymn0MK8H4_CwqwoeD1jg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20110909113409.GE2416@ram-ThinkPad-T61

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20110913110646.GB2425@ram-ThinkPad-T61

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ram Pai

author
#9 lore raw

PATCH 1/1 Resource: wrong resource window calculation

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

---
 kernel/resource.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/resource.c +6 -1
index 3ff4017..b29b83d 100644
@@ -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;
Signature · 1 line
1.7.4.1
Tested-by on v1 1/1
#10 lore raw
Quoted 14 lines · Ram Pai

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.

Quoted 7 lines

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

Works fine on top of 3.1.0-rc7 and solves the problem with my Jetway board.

Thanks Ram!

M.

author
#11 lore raw
Quoted 23 lines · Michal Ludvig
Quoted 14 lines · Ram Pai

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.

Quoted 7 lines

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

Quoted 7 lines

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

#12 lore raw
Quoted 3 lines · Ram Pai

       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

#13 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 2 lines · Ram Pai

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

author
#14 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Ram Pai

       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