Re: [PATCH 07/13] platform/x86: lenovo: tlmi: Retrieve auth information

From: Rong Zhang

Date: Fri Dec 04 2026 - 08:55:22 EST


Hi Mark,

On Thu, 2026-12-03 at 21:20 -0500, Mark Pearson wrote:
> Add authdata module for reading in the authorisation account
> details from the BIOS.
>
> Signed-off-by: Mark Pearson <mpearson-lenovo@xxxxxxxxx>
> ---
> drivers/platform/x86/lenovo/Makefile | 2 +-
> drivers/platform/x86/lenovo/think-lmi.h | 13 ++
> drivers/platform/x86/lenovo/tlmi-authdata.c | 135 ++++++++++++++++++++
> drivers/platform/x86/lenovo/tlmi-config.c | 10 +-
> 4 files changed, 156 insertions(+), 4 deletions(-)
> create mode 100644 drivers/platform/x86/lenovo/tlmi-authdata.c
>
> diff --git a/drivers/platform/x86/lenovo/Makefile b/drivers/platform/x86/lenovo/Makefile
> index d22b56553297..f1600b562273 100644
> --- a/drivers/platform/x86/lenovo/Makefile
> +++ b/drivers/platform/x86/lenovo/Makefile
> @@ -5,7 +5,7 @@
> #
> obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad-laptop.o
> obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o
> -obj-$(CONFIG_THINKPAD_LMI) += tlmi-config.o tlmi-attr.o
> +obj-$(CONFIG_THINKPAD_LMI) += tlmi-config.o tlmi-attr.o tlmi-authdata.o
> obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
>
> lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o
> diff --git a/drivers/platform/x86/lenovo/think-lmi.h b/drivers/platform/x86/lenovo/think-lmi.h
> index 07a235b3a886..75b21dcc2f42 100644
> --- a/drivers/platform/x86/lenovo/think-lmi.h
> +++ b/drivers/platform/x86/lenovo/think-lmi.h
> @@ -13,6 +13,7 @@
> #define TLMI_INDEX_MAX 32
>
> #define TLMI_ATTRIBUTE_GUID "4B79FBA6-FFD4-41B6-8EA8-E81CDA0F5FC3"
> +#define TLMI_AUTHENTICATION_DATA_GUID "1178acfd-78a1-46d8-a8eb-5f7cb74a3b4e"
>
> /* Possible error values */
> struct tlmi_err_codes {
> @@ -75,9 +76,20 @@ struct tlmi_pwdcfg_ext {
> uint32_t nvme_master_password;
> };
>
> +/* fields specific to tlmi-authdata driver */
> +struct tlmi_pwdcfg_authdata {
> + bool strong_password;
> + bool deploy_mode;
> + bool sys_mgr_pwd_ctrl;
> + bool power_on_pwd_ctrl;
> + bool storage_pwd_ctrl;
> + bool sys_mgr_setup_ctrl;
> +};
> +
> struct tlmi_pwdcfg {
> struct tlmi_pwdcfg_core core;
> struct tlmi_pwdcfg_ext ext;
> + struct tlmi_pwdcfg_authdata authdata;
> };
>
> /* password setting details */
> @@ -149,5 +161,6 @@ struct think_lmi {
> struct component_match;
> void tlmi_attr_match_add(struct device *master, struct component_match **matchptr);
> void tlmi_attr_release_setting(struct tlmi_attr_setting *setting);
> +void tlmi_authdata_match_add(struct device *master, struct component_match **matchptr);
>
> #endif /* !_THINK_LMI_H_ */
> diff --git a/drivers/platform/x86/lenovo/tlmi-authdata.c b/drivers/platform/x86/lenovo/tlmi-authdata.c
> new file mode 100644
> index 000000000000..668d07029139
> --- /dev/null
> +++ b/drivers/platform/x86/lenovo/tlmi-authdata.c
> @@ -0,0 +1,135 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Lenovo ThinkLMI authentication data WMI interface driver.
> + *
> + * Read in the WMI authentication settings and their properties.
> + *
> + * This driver supports the "Common WMI" approach implemented on
> + * Thinkpad, ThinkStation & ThinkCenter from 2027 onwards.
> + */
> +
> +#include <linux/cleanup.h>
> +#include <linux/component.h>
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/types.h>
> +#include <linux/wmi.h>
> +#include "think-lmi.h"
> +
> +#define AUTHDATA_ENTRIES 15 /*number of entries returned from BIOS */
> +
> +static int tlmi_authdata_sanitize(const union acpi_object *obj)
> +{
> + int i;
> +
> + /*Scan through query result and check it's sane*/
> + if (obj->type != ACPI_TYPE_PACKAGE)
> + return -EINVAL;
> +
> + if (obj->package.count < AUTHDATA_ENTRIES)
> + return -EIO;
> +
> + for (i = 0; i < AUTHDATA_ENTRIES; i++) {
> + /* Every entry is an integer which makes this easy */
> + if (obj->package.elements[i].type != ACPI_TYPE_INTEGER)
> + return -EIO;
> + }
> + return 0;
> +}
> +
> +/* Get password settings from BIOS */
> +static int tlmi_authdata_get(struct wmi_device *wdev, struct think_lmi *td)
> +{
> + const union acpi_object *obj __free(kfree) = NULL;
> + int ret;
> +
> + obj = wmidev_block_query(wdev, 0);
> + if (!obj)
> + return -EIO;

Use modern WMI APIs and move __free() declaration to wherever the
resource is allocated.

> +
> + ret = tlmi_authdata_sanitize(obj);
> + if (ret)
> + return ret;
> +
> + td->pwdcfg.core.password_state = obj->package.elements[0].integer.value;
> + td->pwdcfg.core.min_length = obj->package.elements[1].integer.value;
> + td->pwdcfg.core.max_length = obj->package.elements[2].integer.value;
> + td->pwdcfg.authdata.strong_password = obj->package.elements[3].integer.value;
> + td->pwdcfg.core.supported_encodings = obj->package.elements[4].integer.value;
> + td->pwdcfg.core.supported_keyboard = obj->package.elements[5].integer.value;
> + td->pwdcfg.ext.hdd_user_password = obj->package.elements[6].integer.value;
> + td->pwdcfg.ext.hdd_master_password = obj->package.elements[7].integer.value;
> + td->pwdcfg.ext.nvme_user_password = obj->package.elements[8].integer.value;
> + td->pwdcfg.ext.nvme_master_password = obj->package.elements[9].integer.value;
> + td->pwdcfg.authdata.deploy_mode = obj->package.elements[10].integer.value;
> + td->pwdcfg.authdata.sys_mgr_pwd_ctrl = obj->package.elements[11].integer.value;
> + td->pwdcfg.authdata.power_on_pwd_ctrl = obj->package.elements[12].integer.value;
> + td->pwdcfg.authdata.storage_pwd_ctrl = obj->package.elements[13].integer.value;
> + td->pwdcfg.authdata.sys_mgr_setup_ctrl = obj->package.elements[14].integer.value;
> +
> + if (WARN_ON(td->pwdcfg.core.max_length >= TLMI_PWD_BUFSIZE))
> + td->pwdcfg.core.max_length = TLMI_PWD_BUFSIZE - 1;
> + if (WARN_ON(td->pwdcfg.core.min_length > td->pwdcfg.core.max_length))
> + td->pwdcfg.core.min_length = td->pwdcfg.core.max_length;

Why would you need to WARN_ON() firmware stuff? Usually it's meant for
kernel stuff.

> +
> + return 0;
> +}
> +
> +static int tlmi_authdata_component_bind(struct device *authdata_dev, struct device *config_dev,
> + void *d)
> +{
> + struct wmi_device *wdev = dev_get_drvdata(authdata_dev);
> + struct think_lmi *td = d;
> +
> + return tlmi_authdata_get(wdev, td);
> +}
> +
> +static const struct component_ops tlmi_authdata_component_ops = {
> + .bind = tlmi_authdata_component_bind,
> +};
> +
> +static int tlmi_authdata_probe(struct wmi_device *wdev, const void *context)
> +{
> + dev_set_drvdata(&wdev->dev, wdev);
> +
> + return component_add(&wdev->dev, &tlmi_authdata_component_ops);
> +}
> +
> +static void tlmi_authdata_remove(struct wmi_device *wdev)
> +{
> + component_del(&wdev->dev, &tlmi_authdata_component_ops);
> +}
> +
> +static const struct wmi_device_id tlmi_authdata_id_table[] = {
> + { TLMI_AUTHENTICATION_DATA_GUID, NULL },
> + {}
> +};
> +
> +static struct wmi_driver tlmi_authdata_driver = {
> + .driver = {
> + .name = "tlmi-authdata",
> + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> + },
> + .id_table = tlmi_authdata_id_table,
> + .probe = tlmi_authdata_probe,
> + .remove = tlmi_authdata_remove,
> + .no_singleton = true,
> +};
> +
> +static int tlmi_authdata_match(struct device *dev, void *type)
> +{
> + return (dev->driver == &tlmi_authdata_driver.driver);
> +}
> +
> +void tlmi_authdata_match_add(struct device *master, struct component_match **matchptr)
> +{
> + component_match_add(master, matchptr, tlmi_authdata_match, NULL);
> +}
> +EXPORT_SYMBOL_NS_GPL(tlmi_authdata_match_add, "TLMI-AUTHDATA");
> +
> +module_wmi_driver(tlmi_authdata_driver);
> +
> +MODULE_DEVICE_TABLE(wmi, tlmi_authdata_id_table);
> +MODULE_AUTHOR("Mark Pearson <mpearson-lenovo@xxxxxxxxx>");
> +MODULE_DESCRIPTION("ThinkLMI Authentication Data WMI Driver");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/platform/x86/lenovo/tlmi-config.c b/drivers/platform/x86/lenovo/tlmi-config.c
> index ef5efae2e395..ddbf0307f810 100644
> --- a/drivers/platform/x86/lenovo/tlmi-config.c
> +++ b/drivers/platform/x86/lenovo/tlmi-config.c
> @@ -415,14 +415,16 @@ static const struct component_master_ops aggregate_ops = {
> static int tlmi_config_probe(struct wmi_device *wdev, const void *context)
> {
> struct component_match *match = NULL;
> - guid_t tlmi_attr_guid;
> + guid_t tlmi_attr_guid, tlmi_authdata_guid;
> struct think_lmi *td;
> int ret;
>
> guid_parse(TLMI_ATTRIBUTE_GUID, &tlmi_attr_guid);
> + guid_parse(TLMI_AUTHENTICATION_DATA_GUID, &tlmi_authdata_guid);

ret =
if (ret)

>
> - /* At minimum need to support BIOS settings */
> - if (!wmidev_exists(&tlmi_attr_guid))
> + /* At minimum need to support BIOS and authentication settings */
> + if (!wmidev_exists(&tlmi_attr_guid) ||
> + !wmidev_exists(&tlmi_authdata_guid))
> return -EOPNOTSUPP;
>
> td = devm_kzalloc(&wdev->dev, sizeof(struct think_lmi), GFP_KERNEL);
> @@ -440,6 +442,7 @@ static int tlmi_config_probe(struct wmi_device *wdev, const void *context)
>
> /* Register the other components */
> tlmi_attr_match_add(&wdev->dev, &match);
> + tlmi_authdata_match_add(&wdev->dev, &match);

Check errors.

Thanks,
Rong

>
> ret = component_master_add_with_match(&wdev->dev, &aggregate_ops, match);
> if (ret)
> @@ -475,6 +478,7 @@ static struct wmi_driver tlmi_config_driver = {
> module_wmi_driver(tlmi_config_driver);
>
> MODULE_IMPORT_NS("TLMI-ATTR");
> +MODULE_IMPORT_NS("TLMI-AUTHDATA");
> MODULE_DEVICE_TABLE(wmi, tlmi_config_id_table);
> MODULE_AUTHOR("Mark Pearson <mpearson-lenovo@xxxxxxxxx>");
> MODULE_DESCRIPTION("TLMI Config WMI Driver");