From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.112 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796404802; b=gNTYifG4WOhdCL5L9suRbCmagCPURam+Ptx3fZ0u14Fto7TSI5YfvEe5MqGinrm5GfZG rMpwd8+mERywDmwYWddoM9fl5fDK2/+OLnUmHcMe9J5t3m5Bk0dHSC+XaAUaYsF8QILW5 QoIbOObkOeRJaJDXZqqcdrd3id6t4Mc5G80DeKGBNl2ljoMELd8i3iJP1ghJeebv8Euun l6ONo9Z4mVsAV5OC1A51Qba7O/ll3VDgyrXaNPkRWcKMbMZ3uRVjsZF88/dJbvG3hr2o6 fUEovtPQMGK7gx7T8waOmpJQJ3t3fpsprjeRuNa6xM9DT5L/cp9sQIdQd/SxbcHm2YA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796404802; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Subject:From:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date: MIME-Version:User-Agent:X-ZohoMailClient; bh=eFbwz1GWbjc7WyEOzEz29QgLxzpPpfXI3+hsezkIhPs=; b=kTI1LCOENVc6A1wUx/ggiK7vkSXirDm0FWmZ2Ge/vQhvYmMF6DFt6Emr+P5QZdMlwk5n Pbv/5FwDpO2mZ7CpC5pL7s4+FQ7TAbchHhGZlYuI4QSQFBFpVGz2aPDCFMctcDysK4zDl IGnjUD0R3J4Hyqzfy2D7x2mpAWgk9+1dWm+/r8cq0Qzq+tnX/VYYkpFyGMTLD8644/H50 JiBjpz1jMfQOz3FLJsjwLt47w4CrpfaIUIndw8ZyzQapJUTzhcRkgYhzKO8eLVlnovrmW 39SxVMx/u9wUFHS9AQ+l9E0VeooRwdQrkVpe8QTdnAQUQ5NtaDv/IQxM4+Patg/+l+w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass header.d=rong.moe header.i=@rong.moe header.a=rsa-sha256 header.s=zmail2048 header.b=VK65HABC; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.112 Received: from sender5-pp-f112.zoho.com (sender5-pp-f112.zoho.com [165.173.182.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67D65606A322; Fri, 4 Dec 2026 17:20:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 67D65606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=rong.moe header.i=@rong.moe header.a=rsa-sha256 header.s=zmail2048 header.b=VK65HABC ARC-Seal: i=1; a=rsa-sha256; t=1796404792; cv=none; d=zohomail.com; s=zohoarc; b=KmTC2o0yE58Gtj6b3b0F5b5nldD3LE5f50JVrAE+Ruk8TAyiy4P7Vs17OkCC5gr16Lmh+AQ9CLNskQtFDpscpJ32WDZFu4gh904x/yMtlqE7U8jQEDRyn3xZWPgajAT5uCXwYccvkCmIrYX58h1UyJ35xRyrgRiRzD7HQRa+B0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796404792; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=eFbwz1GWbjc7WyEOzEz29QgLxzpPpfXI3+hsezkIhPs=; b=KVfKufXeVDKV0R/SCc0WLpoTiDA8IW3frSW9e++dfhQO4B94ulElUGAONgRyCiCkNVeAy62J4lO3Le8HA4hDNaGJoNJS3KPdnKeuQ9fiNgS2/A49sW8L4Ruaw8eCGDUMHbZfzmvnaY6T8ojR3ruNjvtj3U6u6MBqv06cZLqeB6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=VK65HABCCwEtgH0DbtMR4sQa8MGGHLoY8gINZvEOK+Tg4Z3bMoXAU+asohWdepCL5H2IHw9M4hRcGBnoj9+BGXYgT05BGPmH5rYcJExxSh9+cmkC/6KC4HV/Xo9au989K42tW9QyU6kcdWRv1RVyJDACle7Mw7iXSb77Tvd3e3eHrGI4x2Jv6oeOa5JiuFzrOjeWEaRNwqZ9JQoKe8OMqPwPKpfzr6UZZx+WSvMZ6Ad4tBv4S79AG/NAmq1gzBEC7nZ4dNP0t5dpvg/ArKzZhFYdukmN+bAsVMNPoB/TiVXkWOK49/1lNUOGeY0zxhQTMqbi8x0S2k+IxPC8oKusKA==; c=relaxed/relaxed; s=zmail2048; d=rong.moe; v=1; bh=eFbwz1GWbjc7WyEOzEz29QgLxzpPpfXI3+hsezkIhPs=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1796404789152469.36429587841315; Fri, 4 Dec 2026 09:19:49 -0800 (PST) Message-ID: <12652f6165b622ae5fbc5ceb248a273a388b7e44.camel@rong.moe> Subject: Re: [PATCH 07/13] platform/x86: lenovo: tlmi: Retrieve auth information From: Rong Zhang To: Mark Pearson Cc: "Derek J . Clark" , Hans de Goede , Ilpo =?ISO-8859-1?Q?J=E4rvinen?= , "platform-driver-x86@vger.kernel.org" , linux-kernel@vger.kernel.org In-Reply-To: References: <20261204022032.3074618-1-mpearson-lenovo@squebb.ca> <20261204022032.3074618-8-mpearson-lenovo@squebb.ca> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 01:14:44 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Evolution 3.62.2-1 X-ZohoMailClient: External Hi Mark, On Fri, 2026-12-04 at 10:44 -0500, Mark Pearson wrote: >=20 > On Fri, Dec 4, 2026, at 8:48 AM, Rong Zhang wrote: > > Hi Mark, > >=20 > > 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. > > >=20 > > > Signed-off-by: Mark Pearson > > > --- > > > 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 > > >=20 > > > 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)=09+=3D ideapad-laptop.o > > > obj-$(CONFIG_THINKPAD_LMI)=09+=3D think-lmi.o > > > -obj-$(CONFIG_THINKPAD_LMI)=09+=3D tlmi-config.o tlmi-attr.o > > > +obj-$(CONFIG_THINKPAD_LMI)=09+=3D tlmi-config.o tlmi-attr.o tlmi-aut= hdata.o > > > obj-$(CONFIG_THINKPAD_ACPI)=09+=3D thinkpad_acpi.o > > > =20 > > > lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES)=09+=3D wmi-hotke= y-utilities.o > > > diff --git a/drivers/platform/x86/lenovo/think-lmi.h b/drivers/platfo= rm/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 > > > =20 > > > #define TLMI_ATTRIBUTE_GUID "4B79FBA6-FFD4-41B6-8EA8-E81CDA0F5FC3" > > > +#define TLMI_AUTHENTICATION_DATA_GUID "1178acfd-78a1-46d8-a8eb-5f7cb= 74a3b4e" > > > =20 > > > /* Possible error values */ > > > struct tlmi_err_codes { > > > @@ -75,9 +76,20 @@ struct tlmi_pwdcfg_ext { > > > =09uint32_t nvme_master_password; > > > }; > > > =20 > > > +/* fields specific to tlmi-authdata driver */ > > > +struct tlmi_pwdcfg_authdata { > > > +=09bool strong_password; > > > +=09bool deploy_mode; > > > +=09bool sys_mgr_pwd_ctrl; > > > +=09bool power_on_pwd_ctrl; > > > +=09bool storage_pwd_ctrl; > > > +=09bool sys_mgr_setup_ctrl; > > > +}; > > > + > > > struct tlmi_pwdcfg { > > > =09struct tlmi_pwdcfg_core core; > > > =09struct tlmi_pwdcfg_ext ext; > > > +=09struct tlmi_pwdcfg_authdata authdata; > > > }; > > > =20 > > > /* password setting details */ > > > @@ -149,5 +161,6 @@ struct think_lmi { > > > struct component_match; > > > void tlmi_attr_match_add(struct device *master, struct component_mat= ch **matchptr); > > > void tlmi_attr_release_setting(struct tlmi_attr_setting *setting); > > > +void tlmi_authdata_match_add(struct device *master, struct component= _match **matchptr); > > > =20 > > > #endif /* !_THINK_LMI_H_ */ > > > diff --git a/drivers/platform/x86/lenovo/tlmi-authdata.c b/drivers/pl= atform/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 > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include "think-lmi.h" > > > + > > > +#define AUTHDATA_ENTRIES 15 /*number of entries returned from BIOS *= / > > > + > > > +static int tlmi_authdata_sanitize(const union acpi_object *obj) > > > +{ > > > +=09int i; > > > + > > > +=09/*Scan through query result and check it's sane*/ > > > +=09if (obj->type !=3D ACPI_TYPE_PACKAGE) > > > +=09=09return -EINVAL; > > > + > > > +=09if (obj->package.count < AUTHDATA_ENTRIES) > > > +=09=09return -EIO; > > > + > > > +=09for (i =3D 0; i < AUTHDATA_ENTRIES; i++) { > > > +=09=09/* Every entry is an integer which makes this easy */ > > > +=09=09if (obj->package.elements[i].type !=3D ACPI_TYPE_INTEGER) > > > +=09=09=09return -EIO; > > > +=09} > > > +=09return 0; > > > +} > > > + > > > +/* Get password settings from BIOS */ > > > +static int tlmi_authdata_get(struct wmi_device *wdev, struct think_l= mi *td) > > > +{ > > > +=09const union acpi_object *obj __free(kfree) =3D NULL; > > > +=09int ret; > > > + > > > +=09obj =3D wmidev_block_query(wdev, 0); > > > +=09if (!obj) > > > +=09=09return -EIO; > >=20 > > Use modern WMI APIs and move __free() declaration to wherever the > > resource is allocated. > >=20 > ack >=20 > > > + > > > +=09ret =3D tlmi_authdata_sanitize(obj); > > > +=09if (ret) > > > +=09=09return ret; > > > + > > > +=09td->pwdcfg.core.password_state =3D obj->package.elements[0].integ= er.value; > > > +=09td->pwdcfg.core.min_length =3D obj->package.elements[1].integer.v= alue; > > > +=09td->pwdcfg.core.max_length =3D obj->package.elements[2].integer.v= alue; > > > +=09td->pwdcfg.authdata.strong_password =3D obj->package.elements[3].= integer.value; > > > +=09td->pwdcfg.core.supported_encodings =3D obj->package.elements[4].= integer.value; > > > +=09td->pwdcfg.core.supported_keyboard =3D obj->package.elements[5].i= nteger.value; > > > +=09td->pwdcfg.ext.hdd_user_password =3D obj->package.elements[6].int= eger.value; > > > +=09td->pwdcfg.ext.hdd_master_password =3D obj->package.elements[7].i= nteger.value; > > > +=09td->pwdcfg.ext.nvme_user_password =3D obj->package.elements[8].in= teger.value; > > > +=09td->pwdcfg.ext.nvme_master_password =3D obj->package.elements[9].= integer.value; > > > +=09td->pwdcfg.authdata.deploy_mode =3D obj->package.elements[10].int= eger.value; > > > +=09td->pwdcfg.authdata.sys_mgr_pwd_ctrl =3D obj->package.elements[11= ].integer.value; > > > +=09td->pwdcfg.authdata.power_on_pwd_ctrl =3D obj->package.elements[1= 2].integer.value; > > > +=09td->pwdcfg.authdata.storage_pwd_ctrl =3D obj->package.elements[13= ].integer.value; > > > +=09td->pwdcfg.authdata.sys_mgr_setup_ctrl =3D obj->package.elements[= 14].integer.value; > > > + > > > +=09if (WARN_ON(td->pwdcfg.core.max_length >=3D TLMI_PWD_BUFSIZE)) > > > +=09=09td->pwdcfg.core.max_length =3D TLMI_PWD_BUFSIZE - 1; > > > +=09if (WARN_ON(td->pwdcfg.core.min_length > td->pwdcfg.core.max_leng= th)) > > > +=09=09td->pwdcfg.core.min_length =3D td->pwdcfg.core.max_length; > >=20 > > Why would you need to WARN_ON() firmware stuff? Usually it's meant for > > kernel stuff. > >=20 > I've seen warns for FW stuff lots of the time. It handy as when we do Lin= ux enablement we try quite hard to make sure the kernel boot log is clean o= f errors and warnings.=20 > My goal here is that if a platform BIOS is giving invalid values then I g= et a nice warning that I can go and beat up a FW team about. I'd like to le= ave this in. WARN_ON() is basically tagging something as "really wrong and shouldn't happen", so the next step is usually to bail out ASAP. OTOH, the fallback paths following WARN_ON() are also indicating the situations as "not that wrong and may happen". It's quite inconsistent to have both. >=20 > > > + > > > +=09return 0; And the function still succeeds after WARN_ON(). So, for consistency, I'd suggest either demote the WARN_ON() to dev_warn(), or remove the fallback paths and bail out immediately. Thanks, Rong > > > +} > > > + > > > +static int tlmi_authdata_component_bind(struct device *authdata_dev,= struct device *config_dev, > > > +=09=09=09=09=09void *d) > > > +{ > > > +=09struct wmi_device *wdev =3D dev_get_drvdata(authdata_dev); > > > +=09struct think_lmi *td =3D d; > > > + > > > +=09return tlmi_authdata_get(wdev, td); > > > +} > > > + > > > +static const struct component_ops tlmi_authdata_component_ops =3D { > > > +=09.bind =3D tlmi_authdata_component_bind, > > > +}; > > > + > > > +static int tlmi_authdata_probe(struct wmi_device *wdev, const void *= context) > > > +{ > > > +=09dev_set_drvdata(&wdev->dev, wdev); > > > + > > > +=09return component_add(&wdev->dev, &tlmi_authdata_component_ops); > > > +} > > > + > > > +static void tlmi_authdata_remove(struct wmi_device *wdev) > > > +{ > > > +=09component_del(&wdev->dev, &tlmi_authdata_component_ops); > > > +} > > > + > > > +static const struct wmi_device_id tlmi_authdata_id_table[] =3D { > > > +=09{ TLMI_AUTHENTICATION_DATA_GUID, NULL }, > > > +=09{} > > > +}; > > > + > > > +static struct wmi_driver tlmi_authdata_driver =3D { > > > +=09.driver =3D { > > > +=09=09.name =3D "tlmi-authdata", > > > +=09=09.probe_type =3D PROBE_PREFER_ASYNCHRONOUS, > > > +=09}, > > > +=09.id_table =3D tlmi_authdata_id_table, > > > +=09.probe =3D tlmi_authdata_probe, > > > +=09.remove =3D tlmi_authdata_remove, > > > +=09.no_singleton =3D true, > > > +}; > > > + > > > +static int tlmi_authdata_match(struct device *dev, void *type) > > > +{ > > > +=09return (dev->driver =3D=3D &tlmi_authdata_driver.driver); > > > +} > > > + > > > +void tlmi_authdata_match_add(struct device *master, struct component= _match **matchptr) > > > +{ > > > +=09component_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 "); > > > +MODULE_DESCRIPTION("ThinkLMI Authentication Data WMI Driver"); > > > +MODULE_LICENSE("GPL"); > > > diff --git a/drivers/platform/x86/lenovo/tlmi-config.c b/drivers/plat= form/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 aggreg= ate_ops =3D { > > > static int tlmi_config_probe(struct wmi_device *wdev, const void *co= ntext) > > > { > > > =09struct component_match *match =3D NULL; > > > -=09guid_t tlmi_attr_guid; > > > +=09guid_t tlmi_attr_guid, tlmi_authdata_guid; > > > =09struct think_lmi *td; > > > =09int ret; > > > =20 > > > =09guid_parse(TLMI_ATTRIBUTE_GUID, &tlmi_attr_guid); > > > +=09guid_parse(TLMI_AUTHENTICATION_DATA_GUID, &tlmi_authdata_guid); > >=20 > > ret =3D > > if (ret) > >=20 > > > =20 > > > -=09/* At minimum need to support BIOS settings */ > > > -=09if (!wmidev_exists(&tlmi_attr_guid)) > > > +=09/* At minimum need to support BIOS and authentication settings */ > > > +=09if (!wmidev_exists(&tlmi_attr_guid) || > > > +=09 !wmidev_exists(&tlmi_authdata_guid)) > > > =09=09return -EOPNOTSUPP; > > > =20 > > > =09td =3D devm_kzalloc(&wdev->dev, sizeof(struct think_lmi), GFP_KER= NEL); > > > @@ -440,6 +442,7 @@ static int tlmi_config_probe(struct wmi_device *w= dev, const void *context) > > > =20 > > > =09/* Register the other components */ > > > =09tlmi_attr_match_add(&wdev->dev, &match); > > > +=09tlmi_authdata_match_add(&wdev->dev, &match); > >=20 > > Check errors. > >=20 > Ack >=20 > Mark