Skip to contentSkip to conversation

ACPI, APEI: Fixup common access width firmware bug

PATCH In review Jean Delvare 4 participants 7 messages Jun 12, 2012 – Jul 14, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI, APEI: Fixup common access width firmware bug

Many firmwares have a common register definition bug where 8-bit access width is specified for a 32-bit register. Ideally this should be fixed in the BIOS, but earlier versions of the kernel did not complain, so fix that up silently.

This closes kernel bug #43282:
https://bugzilla.kernel.org/show_bug.cgi?id=43282

---
 drivers/acpi/apei/apei-base.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/acpi/apei/apei-base.c +5 -0
@@ -586,6 +586,11 @@ static int apei_check_gar(struct acpi_ge
 	}
 	*access_bit_width = 1UL << (access_size_code + 2);
 
+	/* Fixup common BIOS bug */
+	if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
+	    *access_bit_width < 32)
+		*access_bit_width = 32;
+
 	if ((bit_width + bit_offset) > *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
 			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
Signature · 2 lines
Jean Delvare
Suse L3
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jean Delvare

Many firmwares have a common register definition bug where 8-bit access width is specified for a 32-bit register. Ideally this should be fixed in the BIOS, but earlier versions of the kernel did not complain, so fix that up silently.

Quoted 7 lines

This closes kernel bug #43282:
https://bugzilla.kernel.org/show_bug.cgi?id=43282

Best Regards,
Huang Ying

#2 lore raw
In reply to Jean Delvare
Quoted 20 lines · Jean Delvare

Many firmwares have a common register definition bug where 8-bit access width is specified for a 32-bit register. Ideally this should be fixed in the BIOS, but earlier versions of the kernel did not complain, so fix that up silently.

This closes kernel bug #43282:
https://bugzilla.kernel.org/show_bug.cgi?id=43282

---
 drivers/acpi/apei/apei-base.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/acpi/apei/apei-base.c +0 -0
@@ -586,6 +586,11 @@ static int apei_check_gar(struct acpi_ge
 	}

drivers/acpi/apei/apei-base.c static int apei_check_gar(struct acpi_ge · line 596

Quoted 10 lines
drivers/acpi/apei/apei-base.c +5 -0
 	*access_bit_width = 1UL << (access_size_code + 2);
 
+	/* Fixup common BIOS bug */
+	if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
+	    *access_bit_width < 32)
+		*access_bit_width = 32;
+
 	if ((bit_width + bit_offset) > *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
 			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",

This seems reasonable but since the "Access Size < Register Bit Width" condition has apparently been seen on a number of systems I have been wondering if this might simply be a BIOS writer's way of telling us not to touch some of the high bits in the register. Reducing the width of the register seems like a better way, but maybe not the only way?

Jean, What do you (and others that are listening who know more about this than I do) think about a change to sanity check only the bit offset and not complain (at least for now) about cases where an access using the specified access size will not address every bit in the register?

Perhaps something like:

drivers/acpi/apei/apei-base.c renamed from drivers/acpi/apei/apei-base.c.ORIG +2 -2
@@ -586,9 +586,9 @@ static int apei_check_gar(struct acpi_ge
 	}
 	*access_bit_width = 1UL << (access_size_code + 2);
 
-	if ((bit_width + bit_offset) > *access_bit_width) {
+	if (bit_offset >= *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
-			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
+			   "Invalid bit offset in GAR [0x%llx/%u/%u/%u/%u]\n",
 			   *paddr, bit_width, bit_offset, access_size_code,
 			   space_id);
 		return -EINVAL;

Gary

Signature · 6 lines
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503  IBM T/L: 775-4503
[email protected]
http://www.ibm.com/linux/ltc
#3 lore raw

Hi Gary,

Quoted 23 lines · Gary Hade
Quoted 22 lines · Jean Delvare

Many firmwares have a common register definition bug where 8-bit access width is specified for a 32-bit register. Ideally this should be fixed in the BIOS, but earlier versions of the kernel did not complain, so fix that up silently.

This closes kernel bug #43282:
https://bugzilla.kernel.org/show_bug.cgi?id=43282

---
 drivers/acpi/apei/apei-base.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/acpi/apei/apei-base.c +0 -0
@@ -586,6 +586,11 @@ static int apei_check_gar(struct acpi_ge
 	}
 	*access_bit_width = 1UL << (access_size_code + 2);
 
Quoted 15 lines

drivers/acpi/apei/apei-base.c static int apei_check_gar(struct acpi_ge · line 596

Quoted 8 lines
drivers/acpi/apei/apei-base.c +5 -0
+	/* Fixup common BIOS bug */
+	if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
+	    *access_bit_width < 32)
+		*access_bit_width = 32;
+
 	if ((bit_width + bit_offset) > *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
 			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",

This seems reasonable but since the "Access Size < Register Bit Width" condition has apparently been seen on a number of systems I have been wondering if this might simply be a BIOS writer's way of telling us not to touch some of the high bits in the register. Reducing the width of the register seems like a better way, but maybe not the only way?

I see it as a firmware bug, nothing else (although I am still waiting for Asus to reply on this.) And if it really isn't a bug, I can only read it as "we have a 32-bit register that can only be read 8-bit at a time so please issue 4 8-bit reads and build up a 32-bit value out of these." And certainly not as "don't touch the upper 24-bits."

As I mentioned in another discussion thread, the 1-bit granularity of bit_width and bit_offset clearly means that these are the fields the vendor must use to tell us which part of a register we should touch - they are the "what". "Access Size" is there for the hardware constraints
- it is the "how".

Quoted 11 lines

Jean, What do you (and others that are listening who know more about this than I do) think about a change to sanity check only the bit offset and not complain (at least for now) about cases where an access using the specified access size will not address every bit in the register?

Perhaps something like:

drivers/acpi/apei/apei-base.c renamed from drivers/acpi/apei/apei-base.c.ORIG +0 -0
@@ -586,9 +586,9 @@ static int apei_check_gar(struct acpi_ge
 	}

drivers/acpi/apei/apei-base.c static int apei_check_gar(struct acpi_ge · line 594

Quoted 10 lines
drivers/acpi/apei/apei-base.c renamed from drivers/acpi/apei/apei-base.c.ORIG +2 -2
 	*access_bit_width = 1UL << (access_size_code + 2);
 
-	if ((bit_width + bit_offset) > *access_bit_width) {
+	if (bit_offset >= *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
-			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
+			   "Invalid bit offset in GAR [0x%llx/%u/%u/%u/%u]\n",
 			   *paddr, bit_width, bit_offset, access_size_code,
 			   space_id);
 		return -EINVAL;

Doesn't make much sense to me, as I don't think it will catch much. Also, your original patch (ACPI, APEI: Fix incorrect APEI register bit width check and usage) was not only reporting new errors, it also changed the width parameter passed to ACPI read and write functions. It was the register width and it is now (correctly, I believe) the access width. So if the access width is wrong, and we don't fix it up (as my proposed patch does) we might have a regression on some systems. Even if the firmware is at fault, regressions are always bad.

(But again I don't know much about ACPI so I might be completely wrong...)

Signature · 7 lines
Jean Delvare
Suse L3

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by
#4 lore raw
Quoted 42 lines · Jean Delvare

Hi Gary,

Quoted 23 lines · Gary Hade
Quoted 22 lines · Jean Delvare

Many firmwares have a common register definition bug where 8-bit access width is specified for a 32-bit register. Ideally this should be fixed in the BIOS, but earlier versions of the kernel did not complain, so fix that up silently.

This closes kernel bug #43282:
https://bugzilla.kernel.org/show_bug.cgi?id=43282

---
 drivers/acpi/apei/apei-base.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/acpi/apei/apei-base.c +0 -0
@@ -586,6 +586,11 @@ static int apei_check_gar(struct acpi_ge
 	}
 	*access_bit_width = 1UL << (access_size_code + 2);
 
Quoted 15 lines

drivers/acpi/apei/apei-base.c static int apei_check_gar(struct acpi_ge · line 596

Quoted 8 lines
drivers/acpi/apei/apei-base.c +5 -0
+	/* Fixup common BIOS bug */
+	if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
+	    *access_bit_width < 32)
+		*access_bit_width = 32;
+
 	if ((bit_width + bit_offset) > *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
 			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",

This seems reasonable but since the "Access Size < Register Bit Width" condition has apparently been seen on a number of systems I have been wondering if this might simply be a BIOS writer's way of telling us not to touch some of the high bits in the register. Reducing the width of the register seems like a better way, but maybe not the only way?

Quoted 1 line

I see it as a firmware bug, nothing else

That was my strong feeling but since the number of sightings seems to be on the increase, I thought it might be good to talk about whether our interpretation is actually correct.

Quoted 5 lines

(although I am still waiting
for Asus to reply on this.) And if it really isn't a bug, I can only read it as "we have a 32-bit register that can only be read 8-bit at a time so please issue 4 8-bit reads and build up a 32-bit value out of these." And certainly not as "don't touch the upper 24-bits."

It will definitely be interesting to see what you hear from Asus.

Multiple reads or writes to access all the bits in a register does _not_ sound like a reasonable interpretation of the ACPI spec to me.

Quoted 29 lines

As I mentioned in another discussion thread, the 1-bit granularity of bit_width and bit_offset clearly means that these are the fields the vendor must use to tell us which part of a register we should touch - they are the "what". "Access Size" is there for the hardware constraints
- it is the "how".

Quoted 11 lines

Jean, What do you (and others that are listening who know more about this than I do) think about a change to sanity check only the bit offset and not complain (at least for now) about cases where an access using the specified access size will not address every bit in the register?

Perhaps something like:

drivers/acpi/apei/apei-base.c renamed from drivers/acpi/apei/apei-base.c.ORIG +0 -0
@@ -586,9 +586,9 @@ static int apei_check_gar(struct acpi_ge
 	}

drivers/acpi/apei/apei-base.c static int apei_check_gar(struct acpi_ge · line 594

Quoted 10 lines
drivers/acpi/apei/apei-base.c renamed from drivers/acpi/apei/apei-base.c.ORIG +2 -2
 	*access_bit_width = 1UL << (access_size_code + 2);
 
-	if ((bit_width + bit_offset) > *access_bit_width) {
+	if (bit_offset >= *access_bit_width) {
 		pr_warning(FW_BUG APEI_PFX
-			   "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
+			   "Invalid bit offset in GAR [0x%llx/%u/%u/%u/%u]\n",
 			   *paddr, bit_width, bit_offset, access_size_code,
 			   space_id);
 		return -EINVAL;
Quoted 8 lines

Doesn't make much sense to me, as I don't think it will catch much. Also, your original patch (ACPI, APEI: Fix incorrect APEI register bit width check and usage) was not only reporting new errors, it also changed the width parameter passed to ACPI read and write functions. It was the register width and it is now (correctly, I believe) the access width. So if the access width is wrong, and we don't fix it up (as my proposed patch does) we might have a regression on some systems. Even if the firmware is at fault, regressions are always bad.

Agreed. Your patch looks fine to me.

Gary

Signature · 11 lines
Gary Hade
System x Enablement
IBM Linux Technology Center
503-578-4503  IBM T/L: 775-4503
[email protected]
http://www.ibm.com/linux/ltc

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Hi Gary,

Quoted 6 lines · Gary Hade
Quoted 1 line · Jean Delvare

I see it as a firmware bug, nothing else

That was my strong feeling but since the number of sightings seems to be on the increase, I thought it might be good to talk about whether our interpretation is actually correct.

It's always good to ensure we got things right, sure. WRT to the number of faulty systems, I wouldn't jump to any conclusion. It is sufficient to have a bug in the reference BIOS code in order to see the same bug spread across boards and vendors all around.

Quoted 7 lines
Quoted 5 lines

(although I am still waiting
for Asus to reply on this.) And if it really isn't a bug, I can only read it as "we have a 32-bit register that can only be read 8-bit at a time so please issue 4 8-bit reads and build up a 32-bit value out of these." And certainly not as "don't touch the upper 24-bits."

It will definitely be interesting to see what you hear from Asus.

If I ever hear something... No news yet :(

Quoted 3 lines

Multiple reads or writes to access all the bits in a register does _not_ sound like a reasonable interpretation of the ACPI spec to me.

Well, I can imagine that some hardware has (or has had) such limitations, and the ACPI spec authors may have wanted to play it safe and make it possible to describe this case. I didn't mean that I expect it to be the case for my Asus board - I still believe it is a simple BIOS bug here.

Signature · 7 lines
Jean Delvare
Suse L3

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
reviewer
#6 lore raw

applied for 3.6

thanks,
Len Brown, Intel Open Source Technology Center