From patchwork Thu May 25 19:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13255608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30D50C77B7A for ; Thu, 25 May 2023 19:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240643AbjEYTdi (ORCPT ); Thu, 25 May 2023 15:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233039AbjEYTdf (ORCPT ); Thu, 25 May 2023 15:33:35 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D949E69; Thu, 25 May 2023 12:32:59 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 255DB5C010E; Thu, 25 May 2023 15:31:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 May 2023 15:31:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1685043096; x= 1685129496; bh=2YuucB8ge+Gjjiz/CAErVcfKQLxgmGcYZa0k32yeS+o=; b=V NddOGdr11wVcCWiNRkYsBegF/WljAvWvksusx68y/+1/FNxd4EE7nJmHqnr/qCgD Sypzx3vSWxUHSO1cSl9dhr1NxjyuD1+osg30HIBihODpLP8GGYGUQv+XuMfDEy1g UPkT/ylzF4hGTjeqjr5TaUifsWKz//nwmvHfsM1bXKSe1RnPX6bStfphsk7POoP+ 1fhWz1rH1ha/Ib2c9Thw8646R5uE0aY3v9bqP7L1jNfPCsT+gC35NKdqQ7cMEW1m GotGxUE7iprVjIfEE01fm41JS6m/w9V0uVpSMNcwgzgo06tUY/JloeK7FyTb2oi7 vLdMPInASb4BOvifBIXbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685043096; x= 1685129496; bh=2YuucB8ge+Gjjiz/CAErVcfKQLxgmGcYZa0k32yeS+o=; b=i NGvbCK7t0iqhF1zqVLwOYOE2BCiXEKtGx56hLHKAPclCBHKgIJWijZssastntqKt OJOCy8JIhxonAEHir8h/OCn+yQA8I8rjD28SVWcn0KZU1K6Ad7wOyITZQYCULCK8 krhYvUNpC1b3N8mjDD+/yZpWFUVAVJi0XZnk5QQI+QsIZAwH5XPlHDa4OZBKgbhL cvFMC2hAAVQ4wiDHEh8ZKc+mFZ+4W5B9Gk7KMx5T461/r3EO/r/WCUqKnA/dcIeJ UGcDIrtQcAopp1nEgGgjBrQP4G3C45/IXRG5P1WmjCWvP/lLNp3nHsTnqUIFlYrj f/oqbS1NfeEyku2jkIE7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuogetfedtuddqtdduucdludehmdenucfjughrpe fhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforghrkhcurfgvrghr shhonhcuoehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggrqeenucggtf frrghtthgvrhhnpeeftddvjeefleffvefhgfejjeehudetteeigeeugfekhffhgeejudeu teehgfdvffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 15:31:35 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] platform/x86: think-lmi: Enable opcode support on BIOS settings Date: Thu, 25 May 2023 15:31:28 -0400 Message-Id: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Whilst reviewing some documentation from the FW team on using WMI on Lenovo system I noticed that we weren't using Opcode support when changing BIOS settings in the thinkLMI driver. We should be doing this to ensure we're future proof as the old non-opcode mechanism has been deprecated. Tested on X1 Carbon G10 and G11. Signed-off-by: Mark Pearson --- Changes in V2: Update comment for clearer explanation of what the driver is doing drivers/platform/x86/think-lmi.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 1138f770149d..2745224f62ab 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1001,7 +1001,33 @@ static ssize_t current_value_store(struct kobject *kobj, tlmi_priv.pwd_admin->save_signature); if (ret) goto out; - } else { /* Non certiifcate based authentication */ + } else if (tlmi_priv.opcode_support) { + /* + * If opcode support is present use that interface. + * Note - this sets the variable and then the password as separate + * WMI calls. Function tlmi_save_bios_settings will error if the + * password is incorrect. + */ + set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name, + new_setting); + if (!set_str) { + ret = -ENOMEM; + goto out; + } + + ret = tlmi_simple_call(LENOVO_SET_BIOS_SETTINGS_GUID, set_str); + if (ret) + goto out; + + if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) { + ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin", + tlmi_priv.pwd_admin->password); + if (ret) + goto out; + } + + ret = tlmi_save_bios_settings(""); + } else { /* old non opcode based authentication method (deprecated)*/ if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) { auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;", tlmi_priv.pwd_admin->password, From patchwork Thu May 25 19:31:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13255610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D51BC7EE29 for ; Thu, 25 May 2023 19:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241497AbjEYTfO (ORCPT ); Thu, 25 May 2023 15:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242117AbjEYTfL (ORCPT ); Thu, 25 May 2023 15:35:11 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C189E76; Thu, 25 May 2023 12:34:33 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B924E5C0163; Thu, 25 May 2023 15:31:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 25 May 2023 15:31:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1685043096; x= 1685129496; bh=nIF4nS4aI6UYDF03seQTWUx2L320yvW6X+vuwnM3gHs=; b=H etWuZb/DQn5hyQA486hENqKq91k8fa/wqsbZG9smS994puEzZJ656wEHjrsihNk8 n+PWnI8XgXgZF/IiliScJ8RR/09ShTyL4YRFLG4tWm8us6A5Zp4sqsVulED4HmJz LVqd7LUNdmRO7gXtFkdCE57LrUmMO4ZpuXk2OswIr2YqjEb5YzgVpBYEj+ljvetv oG7bm2faNzWsJs52yx0MFytAk2qMHSJ1TWoqmPlWBoApO1cwUfdKcAmPe8AP6Wxe W9+EM45PjHVfmyJ0jhUGHQwsCm57lkWyoHWVPkphNMutUKx3FrURRJPKTxqtHn/H eE+GrwQy/sazIYuoKhZVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685043096; x= 1685129496; bh=nIF4nS4aI6UYDF03seQTWUx2L320yvW6X+vuwnM3gHs=; b=e Q4PWgHOWR3v1M71bF4E4VhTVAm51jlY8CQLDXCUwhhi//Czz6XPiPGhXdyqNi2fX aF5cEJbYNfycQmVj1K/d70shvmidJHqXYUY+AL6m+QdN9W33cNTENjO+gRx3uCMl qH5Ydq1RAZfjwjKat1xIw+kKd0zK1iknoh2UXrTRtfZFH3V5hhpCSg+yx6ZrsLrp KCvWO9zmmDCb9YiSfCLMmGTO0yT3pCLfY2V1s33JaB/XTxrLL5lq6l7mPTRRPfqv chujFyo59Dx/jzucV4r+mBuhPgaNUcAl1e1dsOkt7WPytg21D+BqZsIXiWdGCgG5 NnNRYx1qNItvMN8cj5VHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuogetfedtuddqtdduucdludehmdenucfjughrpe fhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforghrkhcurfgvrghr shhonhcuoehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggrqeenucggtf frrghtthgvrhhnpeeftddvjeefleffvefhgfejjeehudetteeigeeugfekhffhgeejudeu teehgfdvffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 15:31:36 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] platform/x86: think-lmi: Correct System password interface Date: Thu, 25 May 2023 15:31:29 -0400 Message-Id: <20230525193132.3727-2-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> References: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The system password identification was incorrect. This means that if the password was enabled it wouldn't be detected correctly; and setting it would not work. Also updated code to use TLMI_SMP_PWD instead of TLMI_SYS_PWD to be in sync with Lenovo documentation. Correct these mistakes. Signed-off-by: Mark Pearson --- Changes in V2: - Updated define name to be SMP_PWD instead of SYS_PWD - Clarified in comments what each password type is. drivers/platform/x86/think-lmi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 2745224f62ab..c7e98fbe7c3d 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -168,11 +168,11 @@ MODULE_PARM_DESC(debug_support, "Enable debug command support"); */ #define LENOVO_CERT_THUMBPRINT_GUID "C59119ED-1C0D-4806-A8E9-59AA318176C4" -#define TLMI_POP_PWD (1 << 0) -#define TLMI_PAP_PWD (1 << 1) -#define TLMI_HDD_PWD (1 << 2) -#define TLMI_SYS_PWD (1 << 3) -#define TLMI_CERT (1 << 7) +#define TLMI_POP_PWD (1 << 0) /* Supervisor */ +#define TLMI_PAP_PWD (1 << 1) /* Power-on */ +#define TLMI_HDD_PWD (1 << 2) /* HDD/NVME */ +#define TLMI_SMP_PWD (1 << 6) /* System Management */ +#define TLMI_CERT (1 << 7) /* Certificate Based */ #define to_tlmi_pwd_setting(kobj) container_of(kobj, struct tlmi_pwd_setting, kobj) #define to_tlmi_attr_setting(kobj) container_of(kobj, struct tlmi_attr_setting, kobj) @@ -1509,11 +1509,11 @@ static int tlmi_analyze(void) tlmi_priv.pwd_power->valid = true; if (tlmi_priv.opcode_support) { - tlmi_priv.pwd_system = tlmi_create_auth("sys", "system"); + tlmi_priv.pwd_system = tlmi_create_auth("smp", "system"); if (!tlmi_priv.pwd_system) goto fail_clear_attr; - if (tlmi_priv.pwdcfg.core.password_state & TLMI_SYS_PWD) + if (tlmi_priv.pwdcfg.core.password_state & TLMI_SMP_PWD) tlmi_priv.pwd_system->valid = true; tlmi_priv.pwd_hdd = tlmi_create_auth("hdd", "hdd"); From patchwork Thu May 25 19:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13255609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81859C7EE2C for ; Thu, 25 May 2023 19:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236550AbjEYTdk (ORCPT ); Thu, 25 May 2023 15:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240138AbjEYTdh (ORCPT ); Thu, 25 May 2023 15:33:37 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1ED1E6F; Thu, 25 May 2023 12:32:59 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5AA5C5C01E0; Thu, 25 May 2023 15:31:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 May 2023 15:31:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1685043097; x= 1685129497; bh=/PlZsAh2PqLyxP7nKoIuoVm4Q+hIJHqGY7bemnqtU0s=; b=T HNgAn0WGCwfIg3mv2F04i+N53xkJomReivfd2qvb6aTW9ddBOvGXiYwBIRtPfJfU bD3I/JOxPPolUr/CTzMDXuTLF+F3iWAeddO5hTTnn0ORt0xhVtmk7W6dGvAbp637 5x4/+2eltd0fzwzotdy4qXhrvdO5wnFYlfe/L+GcBhAquqso+kt+fZpgGLewmYUR cNziPS2BxFPWxOO6I4PN+4taEMsl0e+EK+BQUGhruUZbmrQGQ4EuGlaJwJcCNuTq Ikt5FMEoRQS+9NYmbsAy5l/6dFV5/4x0bQRjll2RE1WuAivlWDKlweLfDNs1FtJv mw7/fUlblSktu5In5WxdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685043097; x= 1685129497; bh=/PlZsAh2PqLyxP7nKoIuoVm4Q+hIJHqGY7bemnqtU0s=; b=u zALnOWf41Icac+jiYTnhJRqO0InA2TLlxOqrDOxlrlZMchAAlJwH4ytDmefjJyBL uVdp6kZVKeWs9BsA8M5/i+vLY97YtB1qRx6PeUN7EKF3f51gFxNmYIFcNjZ/3Zov CXn6mCn0a9Rf8aE8clrk6EJrdf94iErMaHyrHCluFuy/pdvxqN7bwrJ8pU24VvJh va7uR0suCZllXPrQXTKMDuoaNLeSyLB9WxEZi3afVSBa7+b+AyRS4zH5lX/ATWXE VGMFrM0hsz0LvO2/pVLQa2zK2M2iSFEovMiOEoL0AyxERUgFAjEDRCOloAX09D19 40NPXjGdEFRH1VqCilM3g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuogetfedtuddqtdduucdludehmdenucfjughrpe fhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforghrkhcurfgvrghr shhonhcuoehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggrqeenucggtf frrghtthgvrhhnpeeftddvjeefleffvefhgfejjeehudetteeigeeugfekhffhgeejudeu teehgfdvffenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhroh hmpehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 15:31:36 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] platform/x86: think-lmi: Correct NVME password handling Date: Thu, 25 May 2023 15:31:30 -0400 Message-Id: <20230525193132.3727-3-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> References: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org NVME passwords identifier have been standardised across the Lenovo systems and now use udrp and adrp (user and admin level) instead of unvp and mnvp. This should apparently be backwards compatible. Also cleaned up so the index is set to a default of 1 rather than 0 as this just makes more sense (there is no device 0). Signed-off-by: Mark Pearson --- Changes in V2: None. Version bumped in series drivers/platform/x86/think-lmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index c7e98fbe7c3d..1c02958035ad 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -456,9 +456,9 @@ static ssize_t new_password_store(struct kobject *kobj, sprintf(pwd_type, "mhdp%d", setting->index); } else if (setting == tlmi_priv.pwd_nvme) { if (setting->level == TLMI_LEVEL_USER) - sprintf(pwd_type, "unvp%d", setting->index); + sprintf(pwd_type, "udrp%d", setting->index); else - sprintf(pwd_type, "mnvp%d", setting->index); + sprintf(pwd_type, "adrp%d", setting->index); } else { sprintf(pwd_type, "%s", setting->pwd_type); } @@ -1524,6 +1524,10 @@ static int tlmi_analyze(void) if (!tlmi_priv.pwd_nvme) goto fail_clear_attr; + /* Set default hdd/nvme index to 1 as there is no device 0 */ + tlmi_priv.pwd_hdd->index = 1; + tlmi_priv.pwd_nvme->index = 1; + if (tlmi_priv.pwdcfg.core.password_state & TLMI_HDD_PWD) { /* Check if PWD is configured and set index to first drive found */ if (tlmi_priv.pwdcfg.ext.hdd_user_password || From patchwork Thu May 25 19:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13255612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA576C7EE29 for ; Thu, 25 May 2023 19:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241295AbjEYTmc (ORCPT ); Thu, 25 May 2023 15:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240262AbjEYTmb (ORCPT ); Thu, 25 May 2023 15:42:31 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13472E62; Thu, 25 May 2023 12:42:06 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2F33A5C0078; Thu, 25 May 2023 15:31:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 25 May 2023 15:31:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1685043098; x= 1685129498; bh=MfKBhMsQHnw3DcuLqhPdvyi5pANzNQBNxlUGbArluSQ=; b=N zjwyF8/NZVcWC9raID22jjq1rEnuRXJgOz+KOLpSP81sNLD5JUzIXUdDXqYu/tpY OUehGu/GhsEqWXmCOGwkU+GE+LptCPsRcxXIbMxwEOgRwXpjxMFNcKvTyiLyJQBF vHDJOARp6yPN7ZzQh+/0Jx0MYmSpRUZloNnauEw9sx7YlIJN7W4RwtRVXQxePyAi zqFQuYKVdq8LELuOZOxCnQLsoTVlkYe/far1/yyUP1EPpiufXlCzo07rdqE7F1oZ 3uaG/WJtSvglShPvAaDMY93/TgYQVuyFVT0J09fpL8VafGtC6E3ILAIkuIVRCOXQ 5ZM4o3DuXnySTfaci/78A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685043098; x= 1685129498; bh=MfKBhMsQHnw3DcuLqhPdvyi5pANzNQBNxlUGbArluSQ=; b=K 44SYzU4yCcDsy0bX7VZOQAsqpsaJPlfBB0YB4im6Z2PU/TWVmSPr1Bxly3OmTVr6 eSlU93cNvv/hFPv3V2Moi7mVOrgicgJ7yrte7hk9a8ZTrKWhFujWazlSYB8Tbglf 8VGRNT/o0RffZ+QXu6BXqc3XhHBAryW2+OuwavFwSieuZFWcVcB81cax20vTPZG6 5326P2Oe81sD1nx6y8lqZmjNchLJehf1cJwO7Q65GptNLFoGXuG2S5nepyQtmgGc AEOFk6L1FIlivTx6jPhWyiUgLAcp1QiGYUoXcmGeJBjspuGgCZSl1ERfvwIwR6LY a4ziOURcy1X3lcs3E4Dwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuogetfedtuddqtdduucdludehmdenucfjughrpe fhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforghrkhcurfgvrghr shhonhcuoehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggrqeenucggtf frrghtthgvrhhnpeeftddvjeefleffvefhgfejjeehudetteeigeeugfekhffhgeejudeu teehgfdvffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 15:31:37 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] platform/x86: think-lmi: Don't display unnecessary authentication settings Date: Thu, 25 May 2023 15:31:31 -0400 Message-Id: <20230525193132.3727-4-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> References: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org If Opcode support is available (which is the standard for all platforms going forward) then there is no need to have the encoding and kbdlang attributes visible Signed-off-by: Mark Pearson --- Changes in V2: None. Version bumped in series drivers/platform/x86/think-lmi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 1c02958035ad..64cd453d6e7d 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -879,6 +879,12 @@ static umode_t auth_attr_is_visible(struct kobject *kobj, return 0; } + /* Don't display un-needed settings if opcode available */ + if ((attr == &auth_encoding.attr || + attr == &auth_kbdlang.attr) && + tlmi_priv.opcode_support) + return 0; + return attr->mode; } From patchwork Thu May 25 19:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13255611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 779FCC7EE29 for ; Thu, 25 May 2023 19:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242138AbjEYTff (ORCPT ); Thu, 25 May 2023 15:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241981AbjEYTfa (ORCPT ); Thu, 25 May 2023 15:35:30 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19539E4B; Thu, 25 May 2023 12:34:58 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id C6B885C0084; Thu, 25 May 2023 15:31:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 25 May 2023 15:31:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1685043098; x= 1685129498; bh=vRdhAijcr+SqqHZKB0865doAzp+2d040yLp8Fj5LvAw=; b=K 4p2qBytCnfrw9jS/FittH63a+5p7qQwL1tWyxf02Dg14PwIexBVaY/tiXdzRvKng owhxti7tNgDDgtJsKeZwzQgRUF2YRiNDrJ0AbYagLjMaGFwABu+LNq7p4O8ve65w IA2jwvzYR0hsZwdYsdTr8xIHVtQYeaKEacqafKqk1qHhq3JSnmKiYg+0MYcP7lsC cVrjg4/kXiK0EGmjXzw1X/TZTKgpo+X6JORtgwuOwzEn8SVTkY/kPMnop6gd5uGZ DaZ2p0BDpl++n2y9PAu+7XSKCo7D5BT5or8Abi7/SfY0KukMf+8lMLR9YJo3ceQb m1vlOFPxGjQqpjpU5mYLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685043098; x= 1685129498; bh=vRdhAijcr+SqqHZKB0865doAzp+2d040yLp8Fj5LvAw=; b=A yaksA8veTA8EfyiyF7jlwflHdz1QAFH/7EV4oM7ipG4cLNjE+Q4nFZR0yylo7e7F rNeD41gf9qZYfary7fUVjsMXgmaYHBc/jmqBJ1ZIoNCP//cOyGd1OV2J2QyvZMiO 6rFIHVOuBAGkFalIwpN6H0s9KdBvbPpuzqP2plb6A1hToFMNQvBOXrO/Cxw96FMv fQxXE0LFJY5SHXtIVlzJ+PzTK1zfIvhU8rk9Et7AgeTPpJke7/LcXyui5wX5V9cL NZ9ZPQG3iKDXhoFqe+cSciy46LwUP2FqHCHwnl8j4DY9F+/qoGDjqGXlk19kJv+d IYF6x0ikk4uK04Q5igWoA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuogetfedtuddqtdduucdludehmdenucfjughrpe fhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforghrkhcurfgvrghr shhonhcuoehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggrqeenucggtf frrghtthgvrhhnpeeftddvjeefleffvefhgfejjeehudetteeigeeugfekhffhgeejudeu teehgfdvffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 15:31:38 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] platform/x86: think-lmi: mutex protection around multiple WMI calls Date: Thu, 25 May 2023 15:31:32 -0400 Message-Id: <20230525193132.3727-5-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> References: <20230525193132.3727-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add mutex protection around cases where an operation needs multiple WMI calls - e.g. setting password. Signed-off-by: Mark Pearson --- Changes in V2: New commit added after review of other patches in series. drivers/platform/x86/think-lmi.c | 46 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 64cd453d6e7d..f3e1e4dacba2 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,7 @@ static const char * const level_options[] = { }; static struct think_lmi tlmi_priv; static struct class *fw_attr_class; +static DEFINE_MUTEX(tlmi_mutex); /* ------ Utility functions ------------*/ /* Strip out CR if one is present */ @@ -463,23 +465,32 @@ static ssize_t new_password_store(struct kobject *kobj, sprintf(pwd_type, "%s", setting->pwd_type); } + mutex_lock(&tlmi_mutex); ret = tlmi_opcode_setting("WmiOpcodePasswordType", pwd_type); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; - + } if (tlmi_priv.pwd_admin->valid) { ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin", tlmi_priv.pwd_admin->password); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; + } } ret = tlmi_opcode_setting("WmiOpcodePasswordCurrent01", setting->password); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; + } ret = tlmi_opcode_setting("WmiOpcodePasswordNew01", new_pwd); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; + } ret = tlmi_simple_call(LENOVO_OPCODE_IF_GUID, "WmiOpcodePasswordSetUpdate;"); + mutex_unlock(&tlmi_mutex); } else { /* Format: 'PasswordType,CurrentPw,NewPw,Encoding,KbdLang;' */ auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s,%s,%s;", @@ -1000,11 +1011,16 @@ static ssize_t current_value_store(struct kobject *kobj, goto out; } + mutex_lock(&tlmi_mutex); ret = tlmi_simple_call(LENOVO_SET_BIOS_SETTING_CERT_GUID, set_str); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; + } ret = tlmi_simple_call(LENOVO_SAVE_BIOS_SETTING_CERT_GUID, tlmi_priv.pwd_admin->save_signature); + + mutex_unlock(&tlmi_mutex); if (ret) goto out; } else if (tlmi_priv.opcode_support) { @@ -1021,18 +1037,23 @@ static ssize_t current_value_store(struct kobject *kobj, goto out; } + mutex_lock(&tlmi_mutex); ret = tlmi_simple_call(LENOVO_SET_BIOS_SETTINGS_GUID, set_str); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; + } if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) { ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin", tlmi_priv.pwd_admin->password); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; + } } - ret = tlmi_save_bios_settings(""); + mutex_unlock(&tlmi_mutex); } else { /* old non opcode based authentication method (deprecated)*/ if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) { auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;", @@ -1056,14 +1077,17 @@ static ssize_t current_value_store(struct kobject *kobj, goto out; } + mutex_lock(&tlmi_mutex); ret = tlmi_simple_call(LENOVO_SET_BIOS_SETTINGS_GUID, set_str); - if (ret) + if (ret) { + mutex_unlock(&tlmi_mutex); goto out; - + } if (auth_str) ret = tlmi_save_bios_settings(auth_str); else ret = tlmi_save_bios_settings(""); + mutex_unlock(&tlmi_mutex); } if (!ret && !tlmi_priv.pending_changes) { tlmi_priv.pending_changes = true;