<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/resource.c, branch v3.9</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.9</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.9'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2012-10-05T18:05:31Z</updated>
<entry>
<title>kernel/resource.c: fix stack overflow in __reserve_region_with_split()</title>
<updated>2012-10-05T18:05:31Z</updated>
<author>
<name>T Makphaibulchoke</name>
<email>tmac@hp.com</email>
</author>
<published>2012-10-05T00:16:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4965f5667f36a95b41cda6638875bc992bd7d18b'/>
<id>urn:sha1:4965f5667f36a95b41cda6638875bc992bd7d18b</id>
<content type='text'>
Using a recursive call add a non-conflicting region in
__reserve_region_with_split() could result in a stack overflow in the case
that the recursive calls are too deep.  Convert the recursive calls to an
iterative loop to avoid the problem.

Tested on a machine containing 135 regions.  The kernel no longer panicked
with stack overflow.

Also tested with code arbitrarily adding regions with no conflict,
embedding two consecutive conflicts and embedding two non-consecutive
conflicts.

Signed-off-by: T Makphaibulchoke &lt;tmac@hp.com&gt;
Reviewed-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: Paul Gortmaker &lt;paul.gortmaker@gmail.com&gt;
Cc: Wei Yang &lt;weiyang@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resource: make sure requested range is included in the root range</title>
<updated>2012-07-31T00:25:21Z</updated>
<author>
<name>Octavian Purdila</name>
<email>octavian.purdila@intel.com</email>
</author>
<published>2012-07-30T21:42:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=65fed8f6f23070b56d0ed3841173ddd410130a89'/>
<id>urn:sha1:65fed8f6f23070b56d0ed3841173ddd410130a89</id>
<content type='text'>
When the requested range is outside of the root range the logic in
__reserve_region_with_split will cause an infinite recursion which will
overflow the stack as seen in the warning bellow.

This particular stack overflow was caused by requesting the
(100000000-107ffffff) range while the root range was (0-ffffffff).  In
this case __request_resource would return the whole root range as
conflict range (i.e.  0-ffffffff).  Then, the logic in
__reserve_region_with_split would continue the recursion requesting the
new range as (conflict-&gt;end+1, end) which incidentally in this case
equals the originally requested range.

This patch aborts looking for an usable range when the request does not
intersect with the root range.  When the request partially overlaps with
the root range, it ajust the request to fall in the root range and then
continues with the new request.

When the request is modified or aborted errors and a stack trace are
logged to allow catching the errors in the upper layers.

[    5.968374] WARNING: at kernel/sched.c:4129 sub_preempt_count+0x63/0x89()
[    5.975150] Modules linked in:
[    5.978184] Pid: 1, comm: swapper Not tainted 3.0.22-mid27-00004-gb72c817 #46
[    5.985324] Call Trace:
[    5.987759]  [&lt;c1039dfc&gt;] ? console_unlock+0x17b/0x18d
[    5.992891]  [&lt;c1039620&gt;] warn_slowpath_common+0x48/0x5d
[    5.998194]  [&lt;c1031758&gt;] ? sub_preempt_count+0x63/0x89
[    6.003412]  [&lt;c1039644&gt;] warn_slowpath_null+0xf/0x13
[    6.008453]  [&lt;c1031758&gt;] sub_preempt_count+0x63/0x89
[    6.013499]  [&lt;c14d60c4&gt;] _raw_spin_unlock+0x27/0x3f
[    6.018453]  [&lt;c10c6349&gt;] add_partial+0x36/0x3b
[    6.022973]  [&lt;c10c7c0a&gt;] deactivate_slab+0x96/0xb4
[    6.027842]  [&lt;c14cf9d9&gt;] __slab_alloc.isra.54.constprop.63+0x204/0x241
[    6.034456]  [&lt;c103f78f&gt;] ? kzalloc.constprop.5+0x29/0x38
[    6.039842]  [&lt;c103f78f&gt;] ? kzalloc.constprop.5+0x29/0x38
[    6.045232]  [&lt;c10c7dc9&gt;] kmem_cache_alloc_trace+0x51/0xb0
[    6.050710]  [&lt;c103f78f&gt;] ? kzalloc.constprop.5+0x29/0x38
[    6.056100]  [&lt;c103f78f&gt;] kzalloc.constprop.5+0x29/0x38
[    6.061320]  [&lt;c17b45e9&gt;] __reserve_region_with_split+0x1c/0xd1
[    6.067230]  [&lt;c17b4693&gt;] __reserve_region_with_split+0xc6/0xd1
...
[    7.179057]  [&lt;c17b4693&gt;] __reserve_region_with_split+0xc6/0xd1
[    7.184970]  [&lt;c17b4779&gt;] reserve_region_with_split+0x30/0x42
[    7.190709]  [&lt;c17a8ebf&gt;] e820_reserve_resources_late+0xd1/0xe9
[    7.196623]  [&lt;c17c9526&gt;] pcibios_resource_survey+0x23/0x2a
[    7.202184]  [&lt;c17cad8a&gt;] pcibios_init+0x23/0x35
[    7.206789]  [&lt;c17ca574&gt;] pci_subsys_init+0x3f/0x44
[    7.211659]  [&lt;c1002088&gt;] do_one_initcall+0x72/0x122
[    7.216615]  [&lt;c17ca535&gt;] ? pci_legacy_init+0x3d/0x3d
[    7.221659]  [&lt;c17a27ff&gt;] kernel_init+0xa6/0x118
[    7.226265]  [&lt;c17a2759&gt;] ? start_kernel+0x334/0x334
[    7.231223]  [&lt;c14d7482&gt;] kernel_thread_helper+0x6/0x10

Signed-off-by: Octavian Purdila &lt;octavian.purdila@intel.com&gt;
Signed-off-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: Jesse Barnes &lt;jbarnes@virtuousgeek.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resources: allow adjust_resource() for resources with no parent</title>
<updated>2012-06-13T21:42:22Z</updated>
<author>
<name>Yinghai Lu</name>
<email>yinghai@kernel.org</email>
</author>
<published>2012-05-18T01:51:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=82ec90eac304e81b1389175b4dded7abecc678ef'/>
<id>urn:sha1:82ec90eac304e81b1389175b4dded7abecc678ef</id>
<content type='text'>
If a resource has no parent, allow its start/end to be set arbitrarily
as long as any children are still contained within the new range.

[bhelgaas: changelog]
Signed-off-by: Yinghai Lu &lt;yinghai@kernel.org&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;</content>
</entry>
<entry>
<title>kernel/resource.c: correct the comment of allocate_resource()</title>
<updated>2012-06-01T00:49:26Z</updated>
<author>
<name>Wei Yang</name>
<email>weiyang@linux.vnet.ibm.com</email>
</author>
<published>2012-05-31T23:26:05Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ee5e5683d8ac3fec876cb6c26792212f773d5898'/>
<id>urn:sha1:ee5e5683d8ac3fec876cb6c26792212f773d5898</id>
<content type='text'>
In the comment of allocate_resource(), the explanation of parameter max
and min is not correct.

Actually, these two parameters are used to specify the range of the
resource that will be allocated, not the min/max size that will be
allocated.

Signed-off-by: Wei Yang &lt;weiyang@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>kernel/resource.c: move EXPORT_SYMBOL right after definition</title>
<updated>2012-02-03T22:37:07Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2012-02-03T13:42:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=241057486646dd42278538218376c79aae2c359f'/>
<id>urn:sha1:241057486646dd42278538218376c79aae2c359f</id>
<content type='text'>
EXPORT_SYMBOL(adjust_resource) should be right after adjust_resource().

Signed-off-by: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
<entry>
<title>kernel: Map most files to use export.h instead of module.h</title>
<updated>2011-10-31T13:20:12Z</updated>
<author>
<name>Paul Gortmaker</name>
<email>paul.gortmaker@windriver.com</email>
</author>
<published>2011-05-23T18:51:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9984de1a5a8a96275fcab818f7419af5a3c86e71'/>
<id>urn:sha1:9984de1a5a8a96275fcab818f7419af5a3c86e71</id>
<content type='text'>
The changed files were only including linux/module.h for the
EXPORT_SYMBOL infrastructure, and nothing else.  Revector them
onto the isolated export header for faster compile times.

Nothing to see here but a whole lot of instances of:

  -#include &lt;linux/module.h&gt;
  +#include &lt;linux/export.h&gt;

This commit is only changing the kernel dir; next targets
will probably be mm, fs, the arch dirs, etc.

Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
</content>
</entry>
<entry>
<title>Resource: fix wrong resource window calculation</title>
<updated>2011-09-30T03:04:34Z</updated>
<author>
<name>Ram Pai</name>
<email>linuxram@us.ibm.com</email>
</author>
<published>2011-09-22T07:48:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=47ea91b4052d9e94b9dca5d7a3d947fbebd07ba9'/>
<id>urn:sha1:47ea91b4052d9e94b9dca5d7a3d947fbebd07ba9</id>
<content type='text'>
__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 2bbc6942273b
("PCI : ability to relocate assigned pci-resources")

Signed-off-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Tested-by: Michal Ludvig &lt;mludvig@logix.net.nz&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resources: Add lookup_resource()</title>
<updated>2011-07-30T19:21:39Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert@linux-m68k.org</email>
</author>
<published>2011-05-07T18:53:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1c388919d89ca35741e9c4d3255adf87f76f0c06'/>
<id>urn:sha1:1c388919d89ca35741e9c4d3255adf87f76f0c06</id>
<content type='text'>
Add a function to find an existing resource by a resource start address.
This allows to implement simple allocators (with a malloc/free-alike API)
on top of the resource system.

Signed-off-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
</content>
</entry>
<entry>
<title>resource: ability to resize an allocated resource</title>
<updated>2011-07-06T17:54:08Z</updated>
<author>
<name>Ram Pai</name>
<email>linuxram@us.ibm.com</email>
</author>
<published>2011-07-06T06:44:30Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=23c570a67448e803408191f529ed9a83fd34a25a'/>
<id>urn:sha1:23c570a67448e803408191f529ed9a83fd34a25a</id>
<content type='text'>
Provides the ability to resize a resource that is already allocated.
This functionality is put in place to support reallocation needs of
pci resources.

Signed-off-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Acked-by: Jesse Barnes &lt;jbarnes@virtuousgeek.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resources: add arch hook for preventing allocation in reserved areas</title>
<updated>2010-12-17T18:01:09Z</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bjorn.helgaas@hp.com</email>
</author>
<published>2010-12-16T17:38:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fcb119183c73bf0781009713f303e28b1fb13d3e'/>
<id>urn:sha1:fcb119183c73bf0781009713f303e28b1fb13d3e</id>
<content type='text'>
This adds arch_remove_reservations(), which an arch can implement if it
needs to protect part of the address space from allocation.

Sometimes that can be done by just putting a region in the resource tree,
but there are cases where that doesn't work well.  For example, x86 BIOS
E820 reservations are not related to devices, so they may overlap part of,
all of, or more than a device resource, so they may not end up at the
correct spot in the resource tree.

Acked-by: H. Peter Anvin &lt;hpa@zytor.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bjorn.helgaas@hp.com&gt;
Signed-off-by: Jesse Barnes &lt;jbarnes@virtuousgeek.org&gt;
</content>
</entry>
</feed>
