Introduction of HP-BIOSCFG driver
Subsystems (3)
v2 cover Introduction of HP-BIOSCFG driver
Version: 1
Introduction of HP-BIOSCFG driver (1/4)
The purpose for this patch is submit HP BIOSCFG driver to be list of HP Linux kernel drivers. HP BIOS Configuration driver purpose is to provide a driver supporting the latest sysfs class firmware attributes framework allowing the user to change BIOS settings and security solutions on HP Inc.’s commercial notebooks.
Many features of HP Commercial PC’s can be managed using Windows Management Instrumentation (WMI). WMI is an implementation of Web-Based Enterprise Management (WBEM) that provides a standards-based interface for changing and monitoring system settings. HP BISOCFG driver provides a native Linux solution and the exposed features facilitates the migration to Linux environments.
The Linux security features to be provided in hp-bioscfg driver enables managing the BIOS settings and security solutions via sysfs, a virtual
filesystem that can be used by user-mode applications. The new
documentation cover features such Secure Platform Management, Sure Admin, and Sure Start. Each section provides security feature description and identifies sysfs directories and files exposed by the driver.
Many HP Commercial PC’s include a feature called Secure Platform Management (SPM), which replaces older password-based BIOS settings management with public key cryptography. PC secure product management begins when a target system is provisioned with cryptographic keys that are used to ensure the integrity of communications between system management utilities and the BIOS.
HP Commercial PC’s have several BIOS settings that control its behaviour and capabilities, many of which are related to security. To prevent unauthorized changes to these settings, the system can be configured to use a Sure Admin cryptographic signature-based authorization string that the BIOS will use to verify authorization to modify the setting.
Version: 2
Update pending_reboot state value (2/4)
There is not a reliable mechanism to programmatically determine which BIOS settings require a reboot to be updated. The latest changes leverages “RequiredPhysicalPresence” reported value to set pending_reboot.
Set current_value permissions appropriate to read-only attributes (3/4)
This patch updates ‘current_value’ permissions to match the value reported by ‘is_readonly’ value associated with the attribute. ‘current_value’ permissions are set to read-only if ‘is_readonly’ value is 1. ‘current_value’ permissions are set to read-write if
‘is_readonly’ value is zero. Other read-only and write-only
permissions will remain unchanged.
Improve friendly display name values (4/4)
The purpose of this patch is to improve the friendly display name for few numbers of attributes associated with ‘Schedule Power-ON.’ BIOS assign names such ‘Tuesday’ to an attribute. The name is correct, but it is not descriptive enough for the user. It is under those conditions a portion of the path data value is append to the attribute name to create a user-friendly name.
For instance, the attribute name is ‘Tuesday,’ and the display name value is ‘Schedule Power-ON – Tuesday’
.../testing/sysfs-class-firmware-attributes | 175 ++- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/hp/Kconfig | 35 + drivers/platform/x86/hp/Makefile | 19 + drivers/platform/x86/hp/biosattr-interface.c | 286 +++++ drivers/platform/x86/hp/bioscfg.c | 1064 +++++++++++++++++ drivers/platform/x86/hp/bioscfg.h | 671 +++++++++++ drivers/platform/x86/hp/enum-attributes.c | 521 ++++++++ drivers/platform/x86/hp/int-attributes.c | 478 ++++++++ drivers/platform/x86/hp/ordered-attributes.c | 586 +++++++++ .../platform/x86/hp/passwdattr-interface.c | 50 + .../platform/x86/hp/passwdobj-attributes.c | 647 ++++++++++ drivers/platform/x86/hp/spmobj-attributes.c | 408 +++++++ drivers/platform/x86/hp/string-attributes.c | 457 +++++++ .../platform/x86/hp/sureadmin-attributes.c | 1014 ++++++++++++++++ .../platform/x86/hp/surestart-attributes.c | 145 +++ 17 files changed, 6557 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/hp/Kconfig create mode 100644 drivers/platform/x86/hp/Makefile create mode 100644 drivers/platform/x86/hp/biosattr-interface.c create mode 100644 drivers/platform/x86/hp/bioscfg.c create mode 100644 drivers/platform/x86/hp/bioscfg.h create mode 100644 drivers/platform/x86/hp/enum-attributes.c create mode 100644 drivers/platform/x86/hp/int-attributes.c create mode 100644 drivers/platform/x86/hp/ordered-attributes.c create mode 100644 drivers/platform/x86/hp/passwdattr-interface.c create mode 100644 drivers/platform/x86/hp/passwdobj-attributes.c create mode 100644 drivers/platform/x86/hp/spmobj-attributes.c create mode 100644 drivers/platform/x86/hp/string-attributes.c create mode 100644 drivers/platform/x86/hp/sureadmin-attributes.c create mode 100644 drivers/platform/x86/hp/surestart-attributes.c
Signature · 1 line
2.34.1
PATCH v2 1/4 Introduction of HP-BIOSCFG driver
The purpose for this patch is submit HP BIOSCFG driver to be list of HP Linux kernel drivers. HP BIOS Configuration driver purpose is to provide a driver supporting the latest sysfs class firmware attributes framework allowing the user to change BIOS settings and security solutions on HP Inc.’s commercial notebooks.
Many features of HP Commercial PC’s can be managed using Windows Management Instrumentation (WMI). WMI is an implementation of Web-Based Enterprise Management (WBEM) that provides a standards-based interface for changing and monitoring system settings. HP BISOCFG driver provides a native Linux solution and the exposed features facilitates the migration to Linux environments.
The Linux security features to be provided in hp-bioscfg driver enables managing the BIOS settings and security solutions via sysfs, a virtual
filesystem that can be used by user-mode applications. The new
documentation cover features such Secure Platform Management, Sure Admin, and Sure Start. Each section provides security feature description and identifies sysfs directories and files exposed by the driver.
Many HP Commercial PC’s include a feature called Secure Platform Management (SPM), which replaces older password-based BIOS settings management with public key cryptography. PC secure product management begins when a target system is provisioned with cryptographic keys that are used to ensure the integrity of communications between system management utilities and the BIOS.
HP Commercial PC’s have several BIOS settings that control its behaviour and capabilities, many of which are related to security. To prevent unauthorized changes to these settings, the system can be configured to use a Sure Admin cryptographic signature-based authorization string that the BIOS will use to verify authorization to modify the setting.
--- .../testing/sysfs-class-firmware-attributes | 175 ++- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/hp/Kconfig | 35 + drivers/platform/x86/hp/Makefile | 19 + drivers/platform/x86/hp/biosattr-interface.c | 286 +++++ drivers/platform/x86/hp/bioscfg.c | 1029 +++++++++++++++++ drivers/platform/x86/hp/bioscfg.h | 667 +++++++++++ drivers/platform/x86/hp/enum-attributes.c | 504 ++++++++ drivers/platform/x86/hp/int-attributes.c | 461 ++++++++ drivers/platform/x86/hp/ordered-attributes.c | 568 +++++++++ .../platform/x86/hp/passwdattr-interface.c | 50 + .../platform/x86/hp/passwdobj-attributes.c | 640 ++++++++++ drivers/platform/x86/hp/spmobj-attributes.c | 408 +++++++ drivers/platform/x86/hp/string-attributes.c | 447 +++++++ .../platform/x86/hp/sureadmin-attributes.c | 984 ++++++++++++++++ .../platform/x86/hp/surestart-attributes.c | 145 +++ 17 files changed, 6419 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/hp/Kconfig create mode 100644 drivers/platform/x86/hp/Makefile create mode 100644 drivers/platform/x86/hp/biosattr-interface.c create mode 100644 drivers/platform/x86/hp/bioscfg.c create mode 100644 drivers/platform/x86/hp/bioscfg.h create mode 100644 drivers/platform/x86/hp/enum-attributes.c create mode 100644 drivers/platform/x86/hp/int-attributes.c create mode 100644 drivers/platform/x86/hp/ordered-attributes.c create mode 100644 drivers/platform/x86/hp/passwdattr-interface.c create mode 100644 drivers/platform/x86/hp/passwdobj-attributes.c create mode 100644 drivers/platform/x86/hp/spmobj-attributes.c create mode 100644 drivers/platform/x86/hp/string-attributes.c create mode 100644 drivers/platform/x86/hp/sureadmin-attributes.c create mode 100644 drivers/platform/x86/hp/surestart-attributes.c
Documentation/ABI/testing/sysfs-class-firmware-attributes +174 -1
@@ -22,6 +22,13 @@ Description: - integer: a range of numerical values - string + HP specific types + ----------------- + - ordered-list - a set of ordered list valid values + - sure-admin + - sure-start + + All attribute types support the following values: current_value:
@@ -126,6 +133,63 @@ Description: value will not be effective through sysfs until this rule is met. + HP specific class extensions + ------------------------------ + + On HP systems the following additional attributes are available: + + "ordered-list"-type specific properties: + + elements: + A file that can be read to obtain the possible + list of values of the <attr>. Values are separated using + semi-colon (``;``) + + "sure-admin"-type specific properties: + + settings: + A file associated with Sure Admin. BIOS settings can + be read or written through the Sure Admin settings file in sysfs. + + [BIOS setting],[new value],[auth token] + + Sample settings reported data + + { + "Class": "HPBIOS_BIOSEnumeration", + "Name": "USB Storage Boot", + "Path": "\\Advanced\\Boot Options", + "IsReadOnly": 0, + ... + "Value": "Enable", + "Size": 2, + "PossibleValues": [ + "Disable", + "Enable" + ] + } + + This file can also be written to in order to update + the value sof a <attr> using a CMSL generated payload. + For example: + + <attr>,[value],[CMSL generated payload] + + "sure-start"-type specific properties: + + audit_log_entries: + A read-only file that returns the events in the log. + + Audit log entry format + + Byte 0-15: Requested Audit Log entry (Each Audit log is 16 bytes) + Byte 16-127: Unused + + audit_log_entry_count: + A read-only file that returns the number of existing audit log events available to be read. + + [No of entries],[log entry size],[Max number of entries supported] + What: /sys/class/firmware-attributes/*/authentication/ Date: February 2021 KernelVersion: 5.11
@@ -206,7 +270,7 @@ Description: Drivers may emit a CHANGE uevent when a password is set or unset userspace may check it again. - On Dell and Lenovo systems, if Admin password is set, then all BIOS attributes + On Dell, Lenovo, and HP systems, if Admin password is set, then all BIOS attributes require password validation. On Lenovo systems if you change the Admin password the new password is not active until the next boot.
@@ -296,6 +360,15 @@ Description: echo "signature" > authentication/Admin/signature echo "password" > authentication/Admin/certificate_to_password + HP specific class extensions + -------------------------------- + + On HP systems the following additional settings are available: + + role: enhanced-bios-auth: + This role is specific to Secure Platform Management (SPM) attribute. + It requires configuring an endorsement (kek) and signing certificate (sk). + What: /sys/class/firmware-attributes/*/attributes/pending_reboot Date: February 2021
@@ -364,3 +437,103 @@ Description: use it to enable extra debug attributes or BIOS features for testing purposes. Note that any changes to this attribute requires a reboot for changes to take effect. + + + HP specific class extensions + -------------------------------- + +What: /sys/class/firmware-attributes/*/authentication/SPM/kek +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: 'kek' is a write-only file that can be used to configure the + RSA public key that will be used by the BIOS to verify + signatures when setting the signing key. When written, + the bytes should correspond to the KEK certificate + (x509 .DER format containing an OU). The size of the + certificate must be less than or equal to 4095 bytes. + + +What: /sys/class/firmware-attributes/*/authentication/SPM/sk +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: 'sk' is a write-only file that can be used to configure the RSA + public key that will be used by the BIOS to verify signatures + when configuring BIOS settings and security features. When + written, the bytes should correspond to the modulus of the + public key. The exponent is assumed to be 0x10001. + + +What: /sys/class/firmware-attributes/*/authentication/SPM/status +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: 'status' is a read-only file that returns ASCII text reporting + the status information. + + State: Not Provisioned / Provisioned / Provisioning in progress + Version: Major. Minor + Feature Bit Mask: <16-bit unsigned number display in hex> + SPM Counter: <16-bit unsigned number display in base 10> + Signing Key Public Key Modulus (base64): + KEK Public Key Modulus (base64): + + +What: /sys/class/firmware-attributes/*/authentication/SPM/statusbin +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: 'statusbin' is a read-only file that returns identical status + information reported by 'status' file in binary format. + + +What: /sys/class/firmware-attributes/*/attributes/Sure_Admin/settings +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: 'settings' is a file associated with Sure Admin. BIOS settings can + be read or written through the Sure Admin settings file in sysfs. + + Expected data format to update BIOS setting + + [BIOS setting],[new value],[auth token] + + Sample settings reported data + + { + "Class": "HPBIOS_BIOSEnumeration", + "Name": "USB Storage Boot", + "Path": "\\Advanced\\Boot Options", + "IsReadOnly": 0, + ... + "Value": "Enable", + "Size": 2, + "PossibleValues": [ + "Disable", + "Enable" + ] + } + + +What: /sys/class/firmware-attributes/*/attributes/Sure_Start/audit_log_entry_count +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: audit_log_entry_count is a read-only file that returns the + number of existing audit log events available to be read. + + [No of entries],[log entry size],[Max number of entries supported] + + +What: /sys/class/firmware-attributes/*/attributes/Sure_Start/audit_log_entries +Date: March 29 +KernelVersion: 5.18 +Contact: "Jorge Lopez" <[email protected]> +Description: audit_log_entries is a read-only file that returns the events + in the log. + + Audit log entry format + + Byte 0-15: Requested Audit Log entry (Each Audit log is 16 bytes) + Byte 16-127: Unused
drivers/platform/x86/Kconfig +1 -0
@@ -366,6 +366,7 @@ config EEEPC_WMI here. source "drivers/platform/x86/dell/Kconfig" +source "drivers/platform/x86/hp/Kconfig" config AMILO_RFKILL tristate "Fujitsu-Siemens Amilo rfkill support"
drivers/platform/x86/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-$(CONFIG_GPD_POCKET_FAN) += gpd-pocket-fan.o obj-$(CONFIG_HP_ACCEL) += hp_accel.o obj-$(CONFIG_HP_WMI) += hp-wmi.o obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o +obj-$(CONFIG_HP_BIOSCFG) += hp/ # Hewlett Packard Enterprise obj-$(CONFIG_UV_SYSFS) += uv_sysfs.o
drivers/platform/x86/hp/Kconfig new file +35 -0
@@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# HP X86 Platform Specific Drivers +# + +menuconfig X86_PLATFORM_DRIVERS_HP + bool "HP X86 Platform Specific Device Drivers" + depends on X86_PLATFORM_DEVICES + help + Say Y here to get to see options for device drivers for various + HP x86 platforms, including vendor-specific laptop extension drivers. + This option alone does not add any kernel code. + + If you say N, all options in this submenu will be skipped and disabled. + +if X86_PLATFORM_DRIVERS_HP + +config HP_BIOSCFG + tristate "HP BIOS Configuration Driver" + default m + depends on ACPI_WMI + depends on DMI + select NLS + select FW_ATTR_CLASS + help + This driver enables administrators to securely manage BIOS settings + using digital certificates and public-key cryptography that eliminate + the need for passwords for both remote and local management. It supports + changing BIOS settings on many HP machines from 2018 and newer without + the use of any additional software. + + To compile this driver as a module, choose M here: the module will + be called hp-bioscfg. + +endif # X86_PLATFORM_DRIVERS_HP
drivers/platform/x86/hp/Makefile new file +19 -0
@@ -0,0 +1,19 @@ +obj-m := hp-bioscfg.o + +hp-bioscfg-objs := bioscfg.o \ + enum-attributes.o \ + int-attributes.o \ + string-attributes.o \ + passwdobj-attributes.o \ + biosattr-interface.o \ + passwdattr-interface.o \ + ordered-attributes.o \ + surestart-attributes.o \ + spmobj-attributes.o \ + sureadmin-attributes.o + +default: + make -C /lib/modules/`uname -r`/build M=$(PWD) hp-bioscfg.ko + +clean: + make -C /lib/modules/`uname -r`/build M=$(PWD) clean
drivers/platform/x86/hp/biosattr-interface.c new file +286 -0
286 lines not on this page · raw message
drivers/platform/x86/hp/bioscfg.c new file +1029 -0
1,029 lines not on this page · raw message
drivers/platform/x86/hp/bioscfg.h new file +667 -0
667 lines not on this page · raw message
drivers/platform/x86/hp/enum-attributes.c new file +504 -0
504 lines not on this page · raw message
drivers/platform/x86/hp/int-attributes.c new file +461 -0
244 lines not on this page · raw message
drivers/platform/x86/hp/ordered-attributes.c new file +568 -0
568 lines not on this page · raw message
drivers/platform/x86/hp/passwdattr-interface.c new file +50 -0
50 lines not on this page · raw message
drivers/platform/x86/hp/passwdobj-attributes.c new file +640 -0
640 lines not on this page · raw message
drivers/platform/x86/hp/spmobj-attributes.c new file +408 -0
408 lines not on this page · raw message
drivers/platform/x86/hp/string-attributes.c new file +447 -0
447 lines not on this page · raw message
drivers/platform/x86/hp/sureadmin-attributes.c new file +984 -0
984 lines not on this page · raw message
drivers/platform/x86/hp/surestart-attributes.c new file +145 -0
145 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
PATCH v2 2/4 Update pending_reboot state value
In reply to Jorge LopezThere is not a reliable mechanism to programmatically determine which BIOS settings require a reboot to be updated. The latest changes leverages “RequiredPhysicalPresence” reported value to set pending_reboot.
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/enum-attributes.c | 6 ++++ drivers/platform/x86/hp/int-attributes.c | 7 +++- drivers/platform/x86/hp/ordered-attributes.c | 6 ++++ .../platform/x86/hp/passwdobj-attributes.c | 9 ++++- .../platform/x86/hp/sureadmin-attributes.c | 34 +++++++++++++++++-- 5 files changed, 58 insertions(+), 4 deletions(-)
drivers/platform/x86/hp/enum-attributes.c +6 -0
@@ -78,6 +78,12 @@ static int validate_enumeration_input(int instance_id, const char *buf)strscpy (bioscfg_drv.enumeration_data[instance_id].new_value, buf,sizeof (bioscfg_drv.enumeration_data[instance_id].new_value)); +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.enumeration_data[instance_id].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; exit_validate_enum_input:kfree (options);
drivers/platform/x86/hp/int-attributes.c +6 -1
@@ -56,7 +56,12 @@ static int validate_integer_input(int instance_id, char *buf)return -EINVAL ; bioscfg_drv.integer_data[instance_id].new_value = in_val; - +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.integer_data[instance_id].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE;return 0 ; }
drivers/platform/x86/hp/ordered-attributes.c +6 -0
@@ -127,6 +127,12 @@ static int validate_ordered_list_input(int instance_id, const char *buf)strscpy (bioscfg_drv.ordered_list_data[instance_id].new_value, buf,sizeof (bioscfg_drv.ordered_list_data[instance_id].new_value)); +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.ordered_list_data[instance_id].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; validate_ordered_list_exit:return ret;
drivers/platform/x86/hp/passwdobj-attributes.c +8 -1
@@ -100,10 +100,17 @@ static ssize_t current_password_store(struct kobject *kobj,if (id >=0 ) ret =validate_password_input (id, buf_cp); -if (!ret) +if (!ret) {strscpy (bioscfg_drv.password_data[id].current_password, buf_cp,sizeof (bioscfg_drv.password_data[id].current_password)); +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.password_data[id].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; + } exit_current_password:kfree (buf_cp);
drivers/platform/x86/hp/sureadmin-attributes.c +32 -2
@@ -158,14 +158,29 @@ int update_attribute_value(char *attr_name, char *attr_value)strscpy (bioscfg_drv.string_data[instance].current_value, attr_value,sizeof (bioscfg_drv.string_data[instance].current_value)); + +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.string_data[instance].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; goto exit_update_attribute; } instance =get_instance_id_for_integer (attr_name);if (instance >=0 ) { ret =kstrtoint (attr_value,10 , &int_val); -if (!ret) +if (!ret) { bioscfg_drv.integer_data[instance].current_value = int_val; +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.integer_data[instance].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; + } + goto exit_update_attribute; }
@@ -174,14 +189,29 @@ int update_attribute_value(char *attr_name, char *attr_value)strscpy (bioscfg_drv.enumeration_data[instance].current_value, attr_value,sizeof (bioscfg_drv.enumeration_data[instance].current_value)); +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.enumeration_data[instance].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; + goto exit_update_attribute; } instance =get_instance_id_for_ordered_list (attr_name); -if (instance >=0 ) +if (instance >=0 ) {strscpy (bioscfg_drv.ordered_list_data[instance].current_value, attr_value,sizeof (bioscfg_drv.ordered_list_data[instance].current_value)); +/* +* set pending reboot flag depending on +* "RequiresPhysicalPresence" value +*/ +if (bioscfg_drv.ordered_list_data[instance].requires_physical_presence) + bioscfg_drv.pending_reboot = TRUE; + } + exit_update_attribute:return instance; }
Signature · 1 line
2.34.1
PATCH v2 3/4 Set current_value permissions appropriate to read-only attributes
In reply to Jorge LopezThis patch updates ‘current_value’ permissions to match the value reported by ‘is_readonly’ value associated with the attribute. ‘current_value’ permissions are set to read-only if ‘is_readonly’ value is 1. ‘current_value’ permissions are set to read-write if
‘is_readonly’ value is zero. Other read-only and write-only
permissions will remain unchanged.
--- drivers/platform/x86/hp/bioscfg.c | 17 +++++++++++++++++ drivers/platform/x86/hp/bioscfg.h | 1 + drivers/platform/x86/hp/enum-attributes.c | 4 ++++ drivers/platform/x86/hp/int-attributes.c | 4 ++++ drivers/platform/x86/hp/ordered-attributes.c | 6 +++++- drivers/platform/x86/hp/string-attributes.c | 4 ++++ 6 files changed, 35 insertions(+), 1 deletion(-)
drivers/platform/x86/hp/bioscfg.c +17 -0
@@ -542,6 +542,23 @@ inline int encode_outsize_for_pvsz(int outsize)return 1 ; } +/** +* update_attribute_permissions() - Update attributes permissions when +* isReadOnly value is 1 +* +* @isReadOnly: ReadOnly value +* @current_val: kobj_attribute corresponding to attribute. +* +**/ +void update_attribute_permissions (u32 isReadOnly,struct kobj_attribute *current_val) +{ +if (isReadOnly) + current_val->attr.mode = (umode_t )0444 ; +else + current_val->attr.mode = (umode_t )0600 ; +} + +/** * destroy_attribute_objs() - Free a kset of kobjects * @kset: The kset to destroy
drivers/platform/x86/hp/bioscfg.h +1 -0
@@ -520,6 +520,7 @@ __BIN_ATTR(_name, 0444 | 0200, _group##_##_name##_read, _group##_##_name##_writeunion acpi_object *get_wmiobj_pointer (int instance_id,const char *guid_string);int get_instance_count (const char *guid_string);void strlcpy_attr (char *dest,char *src); +void update_attribute_permissions (u32 isReadOnly,struct kobj_attribute *current_val);/* String attributes */ int populate_string_buffer_data(union acpi_object *str_obj,
drivers/platform/x86/hp/enum-attributes.c +4 -0
@@ -190,6 +190,8 @@ int populate_enumeration_package_data(union acpi_object *enum_obj, int instance_ str_value =NULL ;populate_enumeration_elements_from_package (enum_obj, instance_id,HPWMI_ENUMERATION_TYPE ); +update_attribute_permissions (bioscfg_drv.enumeration_data[instance_id].is_readonly, + &enumeration_current_val);return sysfs_create_group (attr_name_kobj, &enumeration_attr_group); }
@@ -362,6 +364,8 @@ int populate_enumeration_buffer_data(union acpi_object *enum_obj, int instance_i/* Populate enumeration elements */ populate_enumeration_elements_from_buffer (enum_obj, instance_id,HPWMI_ENUMERATION_TYPE ); +update_attribute_permissions (bioscfg_drv.enumeration_data[instance_id].is_readonly, + &enumeration_current_val);return sysfs_create_group (attr_name_kobj, &enumeration_attr_group); }
drivers/platform/x86/hp/int-attributes.c +4 -0
@@ -168,6 +168,8 @@ int populate_integer_package_data(union acpi_object *elements, int instance_id, str_value =NULL ;populate_integer_elements_from_package (elements, instance_id,HPWMI_INTEGER_TYPE ); +update_attribute_permissions (bioscfg_drv.integer_data[instance_id].is_readonly, + &integer_current_val);return sysfs_create_group (attr_name_kobj, &integer_attr_group); }
@@ -329,6 +331,8 @@ int populate_integer_buffer_data(union acpi_object *integer_obj, int instance_id/* Populate integer elements */ populate_integer_elements_from_buffer (integer_obj, instance_id,HPWMI_INTEGER_TYPE ); +update_attribute_permissions (bioscfg_drv.integer_data[instance_id].is_readonly, + &integer_current_val);return sysfs_create_group (attr_name_kobj, &integer_attr_group); }
drivers/platform/x86/hp/ordered-attributes.c +5 -1
@@ -239,6 +239,9 @@ int populate_ordered_list_package_data(union acpi_object *order_obj, int instanc str_value =NULL ;populate_ordered_list_elements_from_package (order_obj, instance_id,HPWMI_ORDERED_LIST_TYPE ); +update_attribute_permissions (bioscfg_drv.ordered_list_data[instance_id].is_readonly, + &ordered_list_current_val); +return sysfs_create_group (attr_name_kobj, &ordered_list_attr_group); }
@@ -426,7 +429,8 @@ int populate_ordered_list_buffer_data(union acpi_object *order_obj, int instance/* Populate ordered list elements */ populate_ordered_list_elements_from_buffer (order_obj, instance_id,HPWMI_ORDERED_LIST_TYPE ); - +update_attribute_permissions (bioscfg_drv.ordered_list_data[instance_id].is_readonly, + &ordered_list_current_val);return sysfs_create_group (attr_name_kobj, &ordered_list_attr_group); }
drivers/platform/x86/hp/string-attributes.c +4 -0
@@ -164,6 +164,8 @@ int populate_string_package_data(union acpi_object *elements, int instance_id, str_value =NULL ;populate_string_elements_from_package (elements, instance_id,HPWMI_STRING_TYPE ); +update_attribute_permissions (bioscfg_drv.string_data[instance_id].is_readonly, + &string_current_val);return sysfs_create_group (attr_name_kobj, &string_attr_group); }
@@ -321,6 +323,8 @@ int populate_string_buffer_data(union acpi_object *string_obj, int instance_id,/* Populate string elements */ populate_string_elements_from_buffer (string_obj, instance_id,HPWMI_STRING_TYPE ); +update_attribute_permissions (bioscfg_drv.string_data[instance_id].is_readonly, + &string_current_val);return sysfs_create_group (attr_name_kobj, &string_attr_group); }
Signature · 1 line
2.34.1
PATCH v2 4/4 Improve friendly display name values
In reply to Jorge LopezThe purpose of this patch is to improve the friendly display name for few numbers of attributes associated with ‘Schedule Power-ON.’ BIOS assign names such ‘Tuesday’ to an attribute. The name is correct, but it is not descriptive enough for the user. It is under those conditions a portion of the path data value is append to the attribute name to create a user-friendly display name.
For instance, the attribute name is ‘Tuesday,’ and the display name value is ‘Schedule Power-ON – Tuesday’
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/bioscfg.c | 18 ++++++++++++++++++ drivers/platform/x86/hp/bioscfg.h | 5 ++++- drivers/platform/x86/hp/enum-attributes.c | 9 ++++++++- drivers/platform/x86/hp/int-attributes.c | 8 ++++++++ drivers/platform/x86/hp/ordered-attributes.c | 10 +++++++++- drivers/platform/x86/hp/string-attributes.c | 10 ++++++++-- 6 files changed, 55 insertions(+), 5 deletions(-)
drivers/platform/x86/hp/bioscfg.c +18 -0
@@ -542,6 +542,24 @@ inline int encode_outsize_for_pvsz(int outsize)return 1 ; } +/* +* Update friendly display name for several attributes associated to +* 'Schedule Power-On' +*/ +void friendly_user_name_update (char *path,const char *attr_name, +char *attr_display,int attr_size) +{ +char *found =NULL ; + + found =strstr (path,SCHEDULE_POWER_ON ); +if (found) +snprintf (attr_display, + attr_size, +"%s - %s" , +SCHEDULE_POWER_ON , + attr_name); +} +/** * update_attribute_permissions() - Update attributes permissions when * isReadOnly value is 1
drivers/platform/x86/hp/bioscfg.h +4 -1
@@ -33,7 +33,8 @@#define SETUP_PASSWD "Setup Password"#define POWER_ON_PASSWD "Power-On Password" -#define LANG_CODE_STR "en_US.UTF-8" +#define LANG_CODE_STR "en_US.UTF-8" +#define SCHEDULE_POWER_ON "Scheduled Power-On"/* Sure Admin Functions */
@@ -521,6 +522,8 @@ union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string);int get_instance_count (const char *guid_string);void strlcpy_attr (char *dest,char *src);void update_attribute_permissions (u32 isReadOnly,struct kobj_attribute *current_val); +void friendly_user_name_update (char *path,const char *attr_name, +char *attr_display,int attr_size);/* String attributes */ int populate_string_buffer_data(union acpi_object *str_obj,
drivers/platform/x86/hp/enum-attributes.c +8 -1
@@ -192,7 +192,10 @@ int populate_enumeration_package_data(union acpi_object *enum_obj, int instance_populate_enumeration_elements_from_package (enum_obj, instance_id,HPWMI_ENUMERATION_TYPE );update_attribute_permissions (bioscfg_drv.enumeration_data[instance_id].is_readonly, &enumeration_current_val); - +friendly_user_name_update (bioscfg_drv.enumeration_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.enumeration_data[instance_id].display_name, +sizeof (bioscfg_drv.enumeration_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &enumeration_attr_group); }
@@ -366,6 +369,10 @@ int populate_enumeration_buffer_data(union acpi_object *enum_obj, int instance_ipopulate_enumeration_elements_from_buffer (enum_obj, instance_id,HPWMI_ENUMERATION_TYPE );update_attribute_permissions (bioscfg_drv.enumeration_data[instance_id].is_readonly, &enumeration_current_val); +friendly_user_name_update (bioscfg_drv.enumeration_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.enumeration_data[instance_id].display_name, +sizeof (bioscfg_drv.enumeration_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &enumeration_attr_group); }
drivers/platform/x86/hp/int-attributes.c +8 -0
@@ -170,6 +170,10 @@ int populate_integer_package_data(union acpi_object *elements, int instance_id,populate_integer_elements_from_package (elements, instance_id,HPWMI_INTEGER_TYPE );update_attribute_permissions (bioscfg_drv.integer_data[instance_id].is_readonly, &integer_current_val); +friendly_user_name_update (bioscfg_drv.integer_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.integer_data[instance_id].display_name, +sizeof (bioscfg_drv.integer_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &integer_attr_group); }
@@ -333,6 +337,10 @@ int populate_integer_buffer_data(union acpi_object *integer_obj, int instance_idpopulate_integer_elements_from_buffer (integer_obj, instance_id,HPWMI_INTEGER_TYPE );update_attribute_permissions (bioscfg_drv.integer_data[instance_id].is_readonly, &integer_current_val); +friendly_user_name_update (bioscfg_drv.integer_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.integer_data[instance_id].display_name, +sizeof (bioscfg_drv.integer_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &integer_attr_group); }
drivers/platform/x86/hp/ordered-attributes.c +9 -1
@@ -241,7 +241,10 @@ int populate_ordered_list_package_data(union acpi_object *order_obj, int instancpopulate_ordered_list_elements_from_package (order_obj, instance_id,HPWMI_ORDERED_LIST_TYPE );update_attribute_permissions (bioscfg_drv.ordered_list_data[instance_id].is_readonly, &ordered_list_current_val); - +friendly_user_name_update (bioscfg_drv.ordered_list_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.ordered_list_data[instance_id].display_name, +sizeof (bioscfg_drv.ordered_list_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &ordered_list_attr_group); }
@@ -431,6 +434,11 @@ int populate_ordered_list_buffer_data(union acpi_object *order_obj, int instancepopulate_ordered_list_elements_from_buffer (order_obj, instance_id,HPWMI_ORDERED_LIST_TYPE );update_attribute_permissions (bioscfg_drv.ordered_list_data[instance_id].is_readonly, &ordered_list_current_val); +friendly_user_name_update (bioscfg_drv.ordered_list_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.ordered_list_data[instance_id].display_name, +sizeof (bioscfg_drv.ordered_list_data[instance_id].display_name)); +return sysfs_create_group (attr_name_kobj, &ordered_list_attr_group); }
drivers/platform/x86/hp/string-attributes.c +8 -2
@@ -166,7 +166,10 @@ int populate_string_package_data(union acpi_object *elements, int instance_id,populate_string_elements_from_package (elements, instance_id,HPWMI_STRING_TYPE );update_attribute_permissions (bioscfg_drv.string_data[instance_id].is_readonly, &string_current_val); - +friendly_user_name_update (bioscfg_drv.string_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.string_data[instance_id].display_name, +sizeof (bioscfg_drv.string_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &string_attr_group); }
@@ -325,7 +328,10 @@ int populate_string_buffer_data(union acpi_object *string_obj, int instance_id,populate_string_elements_from_buffer (string_obj, instance_id,HPWMI_STRING_TYPE );update_attribute_permissions (bioscfg_drv.string_data[instance_id].is_readonly, &string_current_val); - +friendly_user_name_update (bioscfg_drv.string_data[instance_id].path, + attr_name_kobj->name, + bioscfg_drv.string_data[instance_id].display_name, +sizeof (bioscfg_drv.string_data[instance_id].display_name));return sysfs_create_group (attr_name_kobj, &string_attr_group); }
Signature · 1 line
2.34.1