Skip to contentSkip to conversation

Fix coalescing of host bridge windows in arch/x86/pci/acpi.c

PATCH In review Alexey Neyman 2 participants 4 messages Sep 13, 2013 – Sep 18, 2013 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix coalescing of host bridge windows in arch/x86/pci/acpi.c

Hi all,

I have a board with a BIOS bug that reports the following I/O port regions in _CRS on one of the host bridges:

0x0000-0x03af // #0
0x03e0-0x0cf7 // #1
0x03b0-0x03bb // #2
0x03c0-0x03df // #3
0x0000-0xdfff // #4
0xf000-0xffff // #5

Obviously, region number #4 is erroneous as it overlaps with regions #0..3. However, code in coalesce_windows() in arch/x86/pci/acpi.c attempts to recover from such kind of BIOS bugs by merging the overlapping regions. Current code expands region #0 to 0x0000-0xdffff and makes region #4 ignored. As a result, overlap of the expanded region #0 with regions #1..3 remains undetected. As a result, regions #1..3 are inserted into the resource tree as if they were consumers of the 0x0000-0xdfff regions, and devices that have resources in one of these regions (e.g. 0x3f6 for legacy IDE) have a resource conflict - the kernel does not initialize them.

The attached patch makes the code in coalesce_windows() instead ignore res1 (which is already dealt with), possibly expanding res2 instead. As res2 has not been reached in the outer loop in coalesce_windows(), the code will then check for overlaps of the just-expanded resource with the rest of the resources.

Regards,
Alexey.

x86/pci/acpi.c renamed from x86/pci/acpi.c.orig +4 -4
@@ -357,12 +357,12 @@
 			 * the kernel resource tree doesn't allow overlaps.
 			 */
 			if (resource_overlaps(res1, res2)) {
-				res1->start = min(res1->start, res2->start);
-				res1->end = max(res1->end, res2->end);
+				res2->start = min(res1->start, res2->start);
+				res2->end = max(res1->end, res2->end);
 				dev_info(&info->bridge->dev,
 					 "host bridge window expanded to %pR; %pR ignored\n",
-					 res1, res2);
-				res2->flags = 0;
+					 res2, res1);
+				res1->flags = 0;
 			}
 		}
 	}
#1 lore raw

Hi all,

Could anybody review/commit the patch?

Regards,
Alexey.

Quoted 22 lines · Alexey Neyman

Hi all,

I have a board with a BIOS bug that reports the following I/O port regions in _CRS on one of the host bridges:

0x0000-0x03af // #0
0x03e0-0x0cf7 // #1
0x03b0-0x03bb // #2
0x03c0-0x03df // #3
0x0000-0xdfff // #4
0xf000-0xffff // #5

Obviously, region number #4 is erroneous as it overlaps with regions #0..3. However, code in coalesce_windows() in arch/x86/pci/acpi.c attempts to recover from such kind of BIOS bugs by merging the overlapping regions. Current code expands region #0 to 0x0000-0xdffff and makes region #4 ignored. As a result, overlap of the expanded region #0 with regions #1..3 remains undetected. As a result, regions #1..3 are inserted into the resource tree as if they were consumers of the 0x0000-0xdfff regions, and devices that have resources in one of these regions (e.g. 0x3f6 for legacy IDE) have a resource conflict - the kernel does not initialize them.

Quoted 8 lines

The attached patch makes the code in coalesce_windows() instead ignore res1 (which is already dealt with), possibly expanding res2 instead. As res2 has not been reached in the outer loop in coalesce_windows(), the code will then check for overlaps of the just-expanded resource with the rest of the resources.

Regards,
Alexey.

x86/pci/acpi.c renamed from x86/pci/acpi.c.orig +4 -4
@@ -357,12 +357,12 @@
 			 * the kernel resource tree doesn't allow overlaps.
 			 */
 			if (resource_overlaps(res1, res2)) {
-				res1->start = min(res1->start, res2->start);
-				res1->end = max(res1->end, res2->end);
+				res2->start = min(res1->start, res2->start);
+				res2->end = max(res1->end, res2->end);
 				dev_info(&info->bridge->dev,
 					 "host bridge window expanded to %pR; %pR ignored\n",
-					 res1, res2);
-				res2->flags = 0;
+					 res2, res1);
+				res1->flags = 0;
 			}
 		}
 	}
#2 lore raw

[ +cc Bjorn Helgaas, Rafael Wysocki, linux-acpi ]

Quoted 3 lines · Alexey Neyman

Hi all,

Could anybody review/commit the patch?

LKML is a pretty general list and maintainers don't typically trawl the list for more work to do. The get_maintainer script can be used to help determine to whom to address a patch.

peter@thor:~/src/kernels/next$ ./scripts/get_maintainer.pl -f arch/x86/pci/acpi.c
Thomas Gleixner <[email protected]> (maintainer:X86 ARCHITECTURE...)
Ingo Molnar <[email protected]> (maintainer:X86 ARCHITECTURE...)
"H. Peter Anvin" <[email protected]> (maintainer:X86 ARCHITECTURE...)
[email protected] (maintainer:X86 ARCHITECTURE...)
Bjorn Helgaas <[email protected]> (commit_signer:5/8=62%)
"Rafael J. Wysocki" <[email protected]> (commit_signer:3/8=38%)
Feng Tang <[email protected]> (commit_signer:1/8=12%)
Yijing Wang <[email protected]> (commit_signer:1/8=12%)
Mike Yoknis <[email protected]> (commit_signer:1/8=12%)
[email protected] (open list)

Regards,
Peter Hurley

PS - You'll want to inline your patch as well because as you can see replies don't include it.

Quoted 34 lines

Regards,
Alexey.

Quoted 30 lines · Alexey Neyman

Hi all,

I have a board with a BIOS bug that reports the following I/O port regions in _CRS on one of the host bridges:

0x0000-0x03af // #0
0x03e0-0x0cf7 // #1
0x03b0-0x03bb // #2
0x03c0-0x03df // #3
0x0000-0xdfff // #4
0xf000-0xffff // #5

Obviously, region number #4 is erroneous as it overlaps with regions #0..3. However, code in coalesce_windows() in arch/x86/pci/acpi.c attempts to recover from such kind of BIOS bugs by merging the overlapping regions. Current code expands region #0 to 0x0000-0xdffff and makes region #4 ignored. As a result, overlap of the expanded region #0 with regions #1..3 remains undetected. As a result, regions #1..3 are inserted into the resource tree as if they were consumers of the 0x0000-0xdfff regions, and devices that have resources in one of these regions (e.g. 0x3f6 for legacy IDE) have a resource conflict - the kernel does not initialize them.

The attached patch makes the code in coalesce_windows() instead ignore res1 (which is already dealt with), possibly expanding res2 instead. As res2 has not been reached in the outer loop in coalesce_windows(), the code will then check for overlaps of the just-expanded resource with the rest of the resources.

Regards,
Alexey.

#3 lore raw

[Resending without HTML part - sorry for possible duplicates]

As requested by Peter, resending the patch with ACPI/x86 maintainers CC'ed.

Short description:
Make coalesce_windows() handle multiple resource overlaps.

Regards,
Alexey.

Quoted 24 lines · Peter Hurley

[ +cc Bjorn Helgaas, Rafael Wysocki, linux-acpi ]

Quoted 3 lines · Alexey Neyman

Hi all,

Could anybody review/commit the patch?

LKML is a pretty general list and maintainers don't typically trawl the list for more work to do. The get_maintainer script can be used to help determine to whom to address a patch.

peter@thor:~/src/kernels/next$ ./scripts/get_maintainer.pl -f
arch/x86/pci/acpi.c Thomas Gleixner <[email protected]> (maintainer:X86
ARCHITECTURE...) Ingo Molnar <[email protected]> (maintainer:X86
ARCHITECTURE...)
"H. Peter Anvin" <[email protected]> (maintainer:X86 ARCHITECTURE...)
[email protected] (maintainer:X86 ARCHITECTURE...)
Bjorn Helgaas <[email protected]> (commit_signer:5/8=62%)
"Rafael J. Wysocki" <[email protected]> (commit_signer:3/8=38%)
Feng Tang <[email protected]> (commit_signer:1/8=12%)
Yijing Wang <[email protected]> (commit_signer:1/8=12%)
Mike Yoknis <[email protected]> (commit_signer:1/8=12%)
[email protected] (open list)
Quoted 47 lines

Regards,
Peter Hurley

PS - You'll want to inline your patch as well because as you can see replies don't include it.

Quoted 41 lines

Regards,
Alexey.

Quoted 37 lines · Alexey Neyman

Hi all,

I have a board with a BIOS bug that reports the following I/O port regions
in _CRS on one of the host bridges:

0x0000-0x03af // #0
0x03e0-0x0cf7 // #1
0x03b0-0x03bb // #2
0x03c0-0x03df // #3
0x0000-0xdfff // #4
0xf000-0xffff // #5

Obviously, region number #4 is erroneous as it overlaps with regions #0..3.
However, code in coalesce_windows() in arch/x86/pci/acpi.c attempts to recover from such kind of BIOS bugs by merging the overlapping regions. Current code expands region #0 to 0x0000-0xdffff and makes region #4 ignored. As a result, overlap of the expanded region #0 with regions #1..3
remains undetected. As a result, regions #1..3 are inserted into the resource tree as if they were consumers of the 0x0000-0xdfff regions, and devices that have resources in one of these regions (e.g. 0x3f6 for legacy
IDE) have a resource conflict - the kernel does not initialize them.

The attached patch makes the code in coalesce_windows() instead ignore res1
(which is already dealt with), possibly expanding res2 instead. As res2 has
not been reached in the outer loop in coalesce_windows(), the code will then check for overlaps of the just-expanded resource with the rest of the
resources.

Regards,
Alexey.

x86/pci/acpi.c renamed from x86/pci/acpi.c.orig +4 -4
@@ -357,12 +357,12 @@
 			 * the kernel resource tree doesn't allow overlaps.
 			 */
 			if (resource_overlaps(res1, res2)) {
-				res1->start = min(res1->start, res2->start);
-				res1->end = max(res1->end, res2->end);
+				res2->start = min(res1->start, res2->start);
+				res2->end = max(res1->end, res2->end);
 				dev_info(&info->bridge->dev,
 					 "host bridge window expanded to %pR; %pR ignored\n",
-					 res1, res2);
-				res2->flags = 0;
+					 res2, res1);
+				res1->flags = 0;
 			}
 		}
 	}