X86 platform drivers
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Kean Ren" <kean0048@gmail.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Sasha Levin" <sashal@kernel.org>,
	derekjohn.clark@gmail.com, platform-driver-x86@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17] platform/x86: think-lmi: Add extra TC BIOS error messages
Date: Sat, 25 Oct 2025 11:56:02 -0400	[thread overview]
Message-ID: <20251025160905.3857885-131-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

From: Mark Pearson <mpearson-lenovo@squebb.ca>

[ Upstream commit a0d6959c345d89d811288a718e3f6b145dcadc8c ]

Add extra error messages that are used by ThinkCenter platforms.

Signed-off-by: Kean Ren <kean0048@gmail.com>
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20250903173824.1472244-4-mpearson-lenovo@squebb.ca
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

YES

- What it fixes
  - On ThinkCentre systems, BIOS WMI calls for certificate operations
    can return TC‑specific strings that this driver did not recognize.
    Unknown strings fall back to -EPERM, so a successful operation could
    be reported as failure, and real failures would be collapsed into a
    generic error. This creates real user-facing breakage for sysfs
    writes that manage BIOS certificates.

- Where the bug is
  - Error mapping logic: `tlmi_errstr_to_err()` maps BIOS strings to
    errno by scanning `tlmi_errs[]`, and returns -EPERM on no match:
    drivers/platform/x86/lenovo/think-lmi.c:247–257.
  - All BIOS WMI method wrappers use this path via `tlmi_simple_call()`:
    drivers/platform/x86/lenovo/think-lmi.c:273–300. Any non-zero
    mapping is propagated as the sysfs write result.

- What changed
  - Added ThinkCentre-specific strings to the mapping table
    `tlmi_errs[]`:
    - Success string: `"Set Certificate operation was successful."` →
      `0`
    - Specific failure strings: invalid parameter/type/password, retry
      exceeded, password invalid, operation aborted, no free slots,
      certificate not found, internal error, certificate too large →
      appropriate `-EINVAL`, `-EACCES`, `-EBUSY`, `-ENOSPC`, `-EEXIST`,
      `-EFAULT`, `-EFBIG`
    - Location: drivers/platform/x86/lenovo/think-lmi.c:207–224
  - This ensures ThinkCentre BIOS responses are properly interpreted
    instead of defaulting to -EPERM.

- Why it matters in practice
  - Certificate operations in this driver (e.g., install/update/clear
    certificate, cert→password) call `tlmi_simple_call()` with
    ThinkCentre certificate GUIDs (see call sites in
    `certificate_store()` and `cert_to_password_store()`):
    drivers/platform/x86/lenovo/think-lmi.c:841, 895–906, 795. With the
    old table, a genuine success response like `"Set Certificate
    operation was successful."` would be treated as an error (-EPERM),
    causing sysfs writes such as `.../authentication/*/certificate` to
    fail even though the BIOS accepted the operation.
  - The new entries also surface more precise errno for failures,
    improving diagnostics for userspace tools and admins.

- Risk and scope
  - Minimal: a localized addition to a string→errno table; no control
    flow or architectural changes.
  - Affects only Lenovo think-lmi driver behavior on ThinkCentre
    platforms when handling certificate-related WMI responses.
  - No user-visible API changes beyond correcting erroneous return
    codes; improves correctness and debuggability.

- Stable backport fit
  - Fixes a real user-impacting bug (false -EPERM on success, ambiguous
    errors).
  - Small, self-contained, and low-risk.
  - Confined to platform/x86/lenovo/think-lmi.

Given the above, this is a good candidate for stable backporting.

 drivers/platform/x86/lenovo/think-lmi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/platform/x86/lenovo/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
index 0992b41b6221d..e6a2c8e94cfdc 100644
--- a/drivers/platform/x86/lenovo/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -179,10 +179,21 @@ MODULE_PARM_DESC(debug_support, "Enable debug command support");
 
 static const struct tlmi_err_codes tlmi_errs[] = {
 	{"Success", 0},
+	{"Set Certificate operation was successful.", 0},
 	{"Not Supported", -EOPNOTSUPP},
 	{"Invalid Parameter", -EINVAL},
 	{"Access Denied", -EACCES},
 	{"System Busy", -EBUSY},
+	{"Set Certificate operation failed with status:Invalid Parameter.", -EINVAL},
+	{"Set Certificate operation failed with status:Invalid certificate type.", -EINVAL},
+	{"Set Certificate operation failed with status:Invalid password format.", -EINVAL},
+	{"Set Certificate operation failed with status:Password retry count exceeded.", -EACCES},
+	{"Set Certificate operation failed with status:Password Invalid.", -EACCES},
+	{"Set Certificate operation failed with status:Operation aborted.", -EBUSY},
+	{"Set Certificate operation failed with status:No free slots to write.", -ENOSPC},
+	{"Set Certificate operation failed with status:Certificate not found.", -EEXIST},
+	{"Set Certificate operation failed with status:Internal error.", -EFAULT},
+	{"Set Certificate operation failed with status:Certificate too large.", -EFBIG},
 };
 
 static const char * const encoding_options[] = {
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 16:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-6.12] platform/x86/intel-uncore-freq: Fix warning in partitioned system Sasha Levin
2025-10-25 15:56 ` Sasha Levin [this message]
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] platform/x86/intel-uncore-freq: Present unique domain ID per package Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] platform/x86: x86-android-tablets: Stop using EPROBE_DEFER Sasha Levin

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=20251025160905.3857885-131-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=derekjohn.clark@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kean0048@gmail.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=patches@lists.linux.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stable@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