mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Rong Zhang" <i@rong.moe>
Cc: "Derek J . Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"platform-driver-x86@vger.kernel.org"
	<platform-driver-x86@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/13] platform/x86: lenovo: tlmi: Retrieve auth information
Date: Fri, 04 Dec 2026 10:44:35 -0500	[thread overview]
Message-ID: <a7d9dc33-c31b-4b4a-9579-66753030c6ca@app.fastmail.com> (raw)
In-Reply-To: <cc37ea7d89b68c796f00f3520d5101fc2604af86.camel@rong.moe>



On Fri, Dec 4, 2026, at 8:48 AM, Rong Zhang wrote:
> 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@squebb.ca>
>> ---
>>  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.
>
ack

>> +
>> +	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.
>
I've seen warns for FW stuff lots of the time. It handy as when we do Linux enablement we try quite hard to make sure the kernel boot log is clean of errors and warnings. 
My goal here is that if a platform BIOS is giving invalid values then I get a nice warning that I can go and beat up a FW team about. I'd like to leave this in.

>> +
>> +	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@squebb.ca>");
>> +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.
>
Ack

Mark

  reply	other threads:[~2026-12-04 15:44 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  2:20 [PATCH 00/13] New Lenovo common WMI driver - tlmi Mark Pearson
2026-12-04  2:20 ` [PATCH 01/13] platform/x86: lenovo: think-lmi: Convert name arrays to pointers Mark Pearson
2026-12-04  2:20 ` [PATCH 02/13] platform/x86: lenovo: think-lmi: Clean up attributes if not added to list Mark Pearson
2026-12-04 13:20   ` Rong Zhang
2026-12-04 15:09     ` Mark Pearson
2026-12-04  2:20 ` [PATCH 03/13] platform/x86: lenovo: think-lmi: cache current value at init Mark Pearson
2026-12-04 13:28   ` Rong Zhang
2026-12-04 15:14     ` Mark Pearson
2026-12-04  2:20 ` [PATCH 04/13] platform/x86: lenovo: think-lmi: store attributes as linked list Mark Pearson
2026-12-04 13:30   ` Rong Zhang
2026-12-04 15:21     ` Mark Pearson
2026-12-04 16:10       ` Rong Zhang
2026-12-04  2:20 ` [PATCH 05/13] platform/x86: lenovo: tlmi: New tlmi driver for common WMI implementation Mark Pearson
2026-12-04 13:41   ` Rong Zhang
2026-12-04 15:27     ` Mark Pearson
2026-12-05  9:54   ` kernel test robot
2026-12-05  9:55   ` kernel test robot
2026-12-04  2:20 ` [PATCH 06/13] platform/x86: lenovo: tlmi: Add BIOS attributes sysfs entries Mark Pearson
2026-12-04 13:44   ` Rong Zhang
2026-12-04 15:41     ` Mark Pearson
2026-12-04 17:02       ` Rong Zhang
2026-12-04  2:20 ` [PATCH 07/13] platform/x86: lenovo: tlmi: Retrieve auth information Mark Pearson
2026-12-04 13:48   ` Rong Zhang
2026-12-04 15:44     ` Mark Pearson [this message]
2026-12-04 17:14       ` Rong Zhang
2026-12-04 17:26         ` Mark Pearson
2026-12-04  2:20 ` [PATCH 08/13] platform/x86: lenovo: Move TLMI helper functions into wmi-helpers Mark Pearson
2026-12-04 13:49   ` Rong Zhang
2026-12-04 15:50     ` Mark Pearson
2026-12-04 17:19       ` Rong Zhang
2026-12-04 17:27         ` Mark Pearson
2026-12-04  2:20 ` [PATCH 09/13] platform/x86: lenovo: tlmi: Add authentication sysfs entries Mark Pearson
2026-12-04 13:52   ` Rong Zhang
2026-12-05  9:55   ` kernel test robot
2026-12-04  2:20 ` [PATCH 10/13] platform/x86: lenovo: tlmi: Add platform attribute support Mark Pearson
2026-12-04  2:20 ` [PATCH 11/13] platform/x86: lenovo: tlmi: Add function attributes support Mark Pearson
2026-12-04  2:20 ` [PATCH 12/13] platform/x86: lenovo: tlmi: Add method identifier Mark Pearson
2026-12-04  2:20 ` [PATCH 13/13] docs: ABI: sysfs-class-firmware-attributes: Update Lenovo sections Mark Pearson
2026-12-04 13:19 ` [PATCH 00/13] New Lenovo common WMI driver - tlmi Rong Zhang
2026-12-04 14:42   ` Mark Pearson
2026-12-04 17:49     ` Rong Zhang
2026-12-04 18:22       ` Mark Pearson
2026-12-04 20:04         ` Rong Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7d9dc33-c31b-4b4a-9579-66753030c6ca@app.fastmail.com \
    --to=mpearson-lenovo@squebb.ca \
    --cc=derekjohn.clark@gmail.com \
    --cc=hansg@kernel.org \
    --cc=i@rong.moe \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®