Skip to contentSkip to conversation

platform/x86: hp-bioscfg: fix attribute enumeration on older HP BIOS

PATCH Superseded Muhammad Bilal 3 participants 6 messages Jun 26 – Jul 4

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover platform/x86: hp-bioscfg: fix attribute enumeration on older HP BIOS

The hp_bioscfg driver silently fails to enumerate BIOS attributes on HP EliteBook 840 G2 (and potentially other older HP models) because:

1. hp_init_bios_package_attribute() hard-fails when a WMI ACPI package contains fewer elements than the per-type expected count (11 < 13), even though only the first 10 common elements are required to register an attribute.

2. hp_populate_enumeration_elements_from_package() returns -EIO and discards the entire attribute when any single element has an unexpected ACPI object type — typically after a BIOS AML error returns malformed data.

Hardware affected:
HP EliteBook 840 G2 (DMI: Hewlett-Packard HP EliteBook 840 G2/2216)
BIOS: M71 Ver. 01.31 (02/24/2020)

How to reproduce:
1. Boot a kernel with CONFIG_HP_BIOSCFG=m on an HP EliteBook 840 G2
2. modprobe hp_bioscfg
3. Observe dmesg:
hp_bioscfg: ACPI-package does not have enough elements: 11 < 13 Error expected type 2 for elem 13, but got type 1 instead

Testing notes:
Tested on HP EliteBook 840 G2 running Arch Linux kernel 7.0.13-arch1-1. After patches, hp_bioscfg loads successfully and enumerates available BIOS attributes. Attributes with shortened packages are partially populated and accessible via sysfs. No regressions on systems that return full 13-element packages (checked via code inspection — pr_warn path is only reached when count < min_elements).

Relevant dmesg (before fix):
[ 11.xxx] hp_bioscfg: ACPI-package does not have enough elements:

              11 < 13
  [   11.xxx] ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT,
              Index (0x000000032) is beyond end of object (length 0x32)
  [   11.xxx] ACPI Error: Aborting method \_SB.WMID.WQBE
  [   11.xxx] Error expected type 2 for elem 13, got type 1
  [   11.xxx] hp_bioscfg: Returned error 0x3

Muhammad Bilal (2):
platform/x86: hp-bioscfg: accept reduced ACPI packages from older HP
BIOS
platform/x86: hp-bioscfg: warn on element type mismatch instead of
failing

 drivers/platform/x86/hp/hp-bioscfg/bioscfg.c         | 11 ++++++++---
 drivers/platform/x86/hp/hp-bioscfg/bioscfg.h         |  3 +++
 drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c |  7 ++++---
 3 files changed, 15 insertions(+), 6 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 platform/x86: hp-bioscfg: accept reduced ACPI packages from older HP BIOS

hp_init_bios_package_attribute() hard-fails when a WMI ACPI package contains fewer elements than the type-specific expected count (e.g. 11 elements instead of 13 for INTEGER or ENUMERATION attributes). This causes the entire hp_bioscfg driver to skip attribute enumeration on older HP hardware whose BIOS returns shortened packages when optional fields like prerequisites or possible values are absent.

Observed on HP EliteBook 840 G2 (BIOS M71 Ver. 01.31):

hp_bioscfg: ACPI-package does not have enough elements: 11 < 13

The element layout has two tiers:
- Elements 0-9 (SECURITY_LEVEL+1 = 10): common to all attribute types
- Elements 10-N: type-specific (bounds, values, encodings, ...)

The per-type populate functions (hp_populate_*_elements_from_package) already handle sparse packages correctly via their own elem < count loop guards and inner-loop bounds checks. The only unsafe case is when we lack even the common elements needed to register the attribute.

Fix by introducing COMMON_ELEM_CNT to mark the hard minimum (10), and splitting the check into two tiers:
- Fewer than COMMON_ELEM_CNT elements: hard fail, can't proceed.
- Fewer than expected type-specific elements: warn, but let the populate function parse what is available.

Fixes a34fc329b189 ("platform/x86: hp-bioscfg: bioscfg")
---
 drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 11 ++++++++---
 drivers/platform/x86/hp/hp-bioscfg/bioscfg.h |  3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +8 -3
index 27fd6cd215290..dd531191e88e2 100644
@@ -661,12 +661,17 @@ static int hp_init_bios_package_attribute(enum hp_wmi_data_type attr_type,
 	int ret = 0;
 
 	/* Take action appropriate to each ACPI TYPE */
-	if (obj->package.count < min_elements) {
-		pr_err("ACPI-package does not have enough elements: %d < %d\n",
-		       obj->package.count, min_elements);
+	if (obj->package.count < COMMON_ELEM_CNT) {
+		pr_err("ACPI-package is missing common elements: %d < %d\n",
+		       obj->package.count, COMMON_ELEM_CNT);
 		goto pack_attr_exit;
 	}
 
+	if (obj->package.count < min_elements) {
+		pr_warn("ACPI-package has fewer elements than expected: %d < %d, parsing available elements\n",
+			obj->package.count, min_elements);
+	}
+
 	elements = obj->package.elements;
 
 	/* sanity checking */
drivers/platform/x86/hp/hp-bioscfg/bioscfg.h +3 -0
index f1eec0e4ba075..f4a375c5669e4 100644
@@ -279,6 +279,9 @@ enum hp_wmi_data_elements {
 	PSWD_ENCODINGS = 13,
 	PSWD_IS_SET = 14,
 	PSWD_ELEM_CNT = 15,
+
+	/* Minimum elements shared by all attribute types (NAME..SECURITY_LEVEL) */
+	COMMON_ELEM_CNT = SECURITY_LEVEL + 1,
 };
 
 #define GET_INSTANCE_ID(type)						\
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/2 platform/x86: hp-bioscfg: warn on element type mismatch instead of failing

In reply to Muhammad Bilal

hp_populate_enumeration_elements_from_package() returns -EIO and aborts enumeration of the entire attribute when any single element has an unexpected ACPI type. This is observed on HP EliteBook 840 G2 when the BIOS returns malformed ACPI data following a failed WMI query:

ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Index (0x000000032)

    is beyond end of object (length 0x32)

ACPI Error: Aborting method \_SB.WMID.WQBE due to previous error Error expected type 2 for elem 13, but got type 1 instead
hp_bioscfg: Returned error 0x3, "Invalid command value/Feature not supported"

A type mismatch on one element does not necessarily corrupt the attribute being built, especially for non-critical type-specific elements such as possible values or bounds. Failing fatally here discards attributes that could otherwise be partially useful.

Change the type mismatch handling from a fatal pr_err + return -EIO to a pr_warn + continue, freeing the accumulated string value and skipping the affected element. The attribute is still registered with whatever valid elements the BIOS did supply.

Fixes a34fc329b189 ("platform/x86: hp-bioscfg: bioscfg")
---
 drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +4 -3
index af4d1920d4880..78729354c04f2 100644
@@ -163,10 +163,11 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
 
 		/* Check that both expected and read object type match */
 		if (expected_enum_types[eloc] != enum_obj[elem].type) {
-			pr_err("Error expected type %d for elem %d, but got type %d instead\n",
-			       expected_enum_types[eloc], elem, enum_obj[elem].type);
+			pr_warn("Unexpected element type at elem %d: expected %d, got %d, skipping\n",
+				elem, expected_enum_types[eloc], enum_obj[elem].type);
 			kfree(str_value);
-			return -EIO;
+			str_value = NULL;
+			continue;
 		}
 
 		/* Assign appropriate element value to corresponding field */
Signature · 1 line
2.54.0
Reviewed-by on the v1 series
#3 lore raw
In reply to Muhammad Bilal
Quoted 47 lines · Muhammad Bilal

The hp_bioscfg driver silently fails to enumerate BIOS attributes on HP EliteBook 840 G2 (and potentially other older HP models) because:

1. hp_init_bios_package_attribute() hard-fails when a WMI ACPI package contains fewer elements than the per-type expected count (11 < 13), even though only the first 10 common elements are required to register an attribute.

2. hp_populate_enumeration_elements_from_package() returns -EIO and discards the entire attribute when any single element has an unexpected ACPI object type — typically after a BIOS AML error returns malformed data.

Hardware affected:

   HP EliteBook 840 G2 (DMI: Hewlett-Packard HP EliteBook 840 G2/2216)
   BIOS: M71 Ver. 01.31 (02/24/2020)

How to reproduce:
1. Boot a kernel with CONFIG_HP_BIOSCFG=m on an HP EliteBook 840 G2
2. modprobe hp_bioscfg
3. Observe dmesg:
hp_bioscfg: ACPI-package does not have enough elements: 11 < 13 Error expected type 2 for elem 13, but got type 1 instead

Testing notes:
Tested on HP EliteBook 840 G2 running Arch Linux kernel 7.0.13-arch1-1. After patches, hp_bioscfg loads successfully and enumerates available BIOS attributes. Attributes with shortened packages are partially populated and accessible via sysfs. No regressions on systems that return full 13-element packages (checked via code inspection — pr_warn path is only reached when count < min_elements).

Relevant dmesg (before fix):
[ 11.xxx] hp_bioscfg: ACPI-package does not have enough elements:

               11 < 13
   [   11.xxx] ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT,
               Index (0x000000032) is beyond end of object (length 0x32)
   [   11.xxx] ACPI Error: Aborting method \_SB.WMID.WQBE
   [   11.xxx] Error expected type 2 for elem 13, got type 1
   [   11.xxx] hp_bioscfg: Returned error 0x3

Muhammad Bilal (2):
platform/x86: hp-bioscfg: accept reduced ACPI packages from older HP
BIOS
platform/x86: hp-bioscfg: warn on element type mismatch instead of
failing

Quoted 5 lines
  drivers/platform/x86/hp/hp-bioscfg/bioscfg.c         | 11 ++++++++---
  drivers/platform/x86/hp/hp-bioscfg/bioscfg.h         |  3 +++
  drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c |  7 ++++---
  3 files changed, 15 insertions(+), 6 deletions(-)
#4 lore raw
In reply to Muhammad Bilal

Am 26.06.26 um 22:49 schrieb Muhammad Bilal:

Quoted 8 lines

The hp_bioscfg driver silently fails to enumerate BIOS attributes on HP EliteBook 840 G2 (and potentially other older HP models) because:

1. hp_init_bios_package_attribute() hard-fails when a WMI ACPI package contains fewer elements than the per-type expected count (11 < 13), even though only the first 10 common elements are required to register an attribute.

Quoted 4 lines

2. hp_populate_enumeration_elements_from_package() returns -EIO and discards the entire attribute when any single element has an unexpected ACPI object type — typically after a BIOS AML error returns malformed data.

Hi,

it could be that the ACPI firmware still transmits all the necessary data, its just that some package elements are combined into a single buffer element
(see https://docs.kernel.org/wmi/acpi-interface.html section "Conversion rules for ACPI data types" for details).

The correct solution would be to migrate the driver to the new buffer-based WMI API, because said API ensures that ACPI objects are properly marshaled into the common WMI data format. However this might require a lot of work :/.

Regarding the BIOS error: this usually happens because creating a ByteField with and invalid length does not cause an error under Windows. Passing a larger buffer usually fixes this problem.

Thanks,
Armin Wolf

Quoted 40 lines

Hardware affected:

   HP EliteBook 840 G2 (DMI: Hewlett-Packard HP EliteBook 840 G2/2216)
   BIOS: M71 Ver. 01.31 (02/24/2020)

How to reproduce:
1. Boot a kernel with CONFIG_HP_BIOSCFG=m on an HP EliteBook 840 G2
2. modprobe hp_bioscfg
3. Observe dmesg:
hp_bioscfg: ACPI-package does not have enough elements: 11 < 13 Error expected type 2 for elem 13, but got type 1 instead

Testing notes:
Tested on HP EliteBook 840 G2 running Arch Linux kernel 7.0.13-arch1-1. After patches, hp_bioscfg loads successfully and enumerates available BIOS attributes. Attributes with shortened packages are partially populated and accessible via sysfs. No regressions on systems that return full 13-element packages (checked via code inspection — pr_warn path is only reached when count < min_elements).

Relevant dmesg (before fix):
[ 11.xxx] hp_bioscfg: ACPI-package does not have enough elements:

               11 < 13
   [   11.xxx] ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT,
               Index (0x000000032) is beyond end of object (length 0x32)
   [   11.xxx] ACPI Error: Aborting method \_SB.WMID.WQBE
   [   11.xxx] Error expected type 2 for elem 13, got type 1
   [   11.xxx] hp_bioscfg: Returned error 0x3

Muhammad Bilal (2):
platform/x86: hp-bioscfg: accept reduced ACPI packages from older HP
BIOS
platform/x86: hp-bioscfg: warn on element type mismatch instead of
failing

  drivers/platform/x86/hp/hp-bioscfg/bioscfg.c         | 11 ++++++++---
  drivers/platform/x86/hp/hp-bioscfg/bioscfg.h         |  3 +++
  drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c |  7 ++++---
  3 files changed, 15 insertions(+), 6 deletions(-)
#5 lore raw

Hi Armin,

I've posted v2 of the series, which includes an additional preparatory patch to ensure parser iteration remains bounded before relaxing the package-length check.

https://lore.kernel.org/all/[email protected]/

Thanks for your review.

Quoted 74 lines · Armin Wolf

Am 26.06.26 um 22:49 schrieb Muhammad Bilal:

Quoted 8 lines

The hp_bioscfg driver silently fails to enumerate BIOS attributes on HP EliteBook 840 G2 (and potentially other older HP models) because:

1. hp_init_bios_package_attribute() hard-fails when a WMI ACPI package contains fewer elements than the per-type expected count (11 < 13), even though only the first 10 common elements are required to register an attribute.

Quoted 4 lines

2. hp_populate_enumeration_elements_from_package() returns -EIO and discards the entire attribute when any single element has an unexpected ACPI object type — typically after a BIOS AML error returns malformed data.

Hi,

it could be that the ACPI firmware still transmits all the necessary data, its just that some package elements are combined into a single buffer element
(see https://docs.kernel.org/wmi/acpi-interface.html section "Conversion rules for ACPI data types" for details).

The correct solution would be to migrate the driver to the new buffer-based WMI API, because said API ensures that ACPI objects are properly marshaled into the common WMI data format. However this might require a lot of work :/.

Regarding the BIOS error: this usually happens because creating a ByteField with and invalid length does not cause an error under Windows. Passing a larger buffer usually fixes this problem.

Thanks,
Armin Wolf

Quoted 40 lines

Hardware affected:

   HP EliteBook 840 G2 (DMI: Hewlett-Packard HP EliteBook 840 G2/2216)
   BIOS: M71 Ver. 01.31 (02/24/2020)

How to reproduce:
1. Boot a kernel with CONFIG_HP_BIOSCFG=m on an HP EliteBook 840 G2
2. modprobe hp_bioscfg
3. Observe dmesg:
hp_bioscfg: ACPI-package does not have enough elements: 11 < 13 Error expected type 2 for elem 13, but got type 1 instead

Testing notes:
Tested on HP EliteBook 840 G2 running Arch Linux kernel 7.0.13-arch1-1. After patches, hp_bioscfg loads successfully and enumerates available BIOS attributes. Attributes with shortened packages are partially populated and accessible via sysfs. No regressions on systems that return full 13-element packages (checked via code inspection — pr_warn path is only reached when count < min_elements).

Relevant dmesg (before fix):
[ 11.xxx] hp_bioscfg: ACPI-package does not have enough elements:

               11 < 13
   [   11.xxx] ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT,
               Index (0x000000032) is beyond end of object (length 0x32)
   [   11.xxx] ACPI Error: Aborting method \_SB.WMID.WQBE
   [   11.xxx] Error expected type 2 for elem 13, got type 1
   [   11.xxx] hp_bioscfg: Returned error 0x3

Muhammad Bilal (2):
platform/x86: hp-bioscfg: accept reduced ACPI packages from older HP
BIOS
platform/x86: hp-bioscfg: warn on element type mismatch instead of
failing

  drivers/platform/x86/hp/hp-bioscfg/bioscfg.c         | 11 ++++++++---
  drivers/platform/x86/hp/hp-bioscfg/bioscfg.h         |  3 +++
  drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c |  7 ++++---
  3 files changed, 15 insertions(+), 6 deletions(-)