From patchwork Thu Jun 1 20:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 102168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp586316vqr; Thu, 1 Jun 2023 13:11:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VRs5PcWolA7ziSxRBBEO9qtY16hWepWNyb/bIyxxE+EQvlq2cgNWgJzNfrdbpntLkfVv1 X-Received: by 2002:a05:6a00:2450:b0:63f:2f00:c6d with SMTP id d16-20020a056a00245000b0063f2f000c6dmr10387099pfj.2.1685650270477; Thu, 01 Jun 2023 13:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685650270; cv=none; d=google.com; s=arc-20160816; b=fpEI+ggxIcVUmRuXTrWVDtMnhPFP+N7Ipwm416FSdRtGCWpQavKoIItkyV21EiS3cF 6GovpvOp1uPOtGJIJtNWZb2bpYYzJAQuRb2ZzoALNxCtTmU5RpqDi4fBI8ECFXIrdw3f 8NlleJxRTiwLHuR8RA+g0coJ9kCUOINg/ejbE7rm4B+Z7YQ9gZ8fBzvPZYs5pgxyQko6 WJEWV7n3iARcgmoT2KtkGtp4MVVaPN8IZfjFnP/myxcXZMqBLeqTKLm4e9hLVrylTvF0 OvId5wBtP9Pvdcdgaj9na1ecuvXHQX7AnGWAxljZhINYlN+6khlMbZmFmx6wwIcW0NrL W7yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=BuihjXCY0FZRPM1FRQ1H6wx+Ft5lKyW8JMDLJbKUpdE=; b=SY2B/vg6tyLh6nGC9m3+OtOLuDeU16GeKHR+Q34w9Q6NFEHJ6A8eL1FppGaYlulyVW P3vascCCWY8ZGflksEFZiMS49GsLO+oY/ucSO1/m9ERz62rf5atTxr00kYL2k7G5RM6Z hj5la4V7VxAAcOQLo+auslqpzE0jWrJfgQlgnLEaKH6uA3vLl59QUjAqEmrWOCM9Az1Y SirjGx7euewIydH4vwuaShYQlOt64QvAy8DfCFFt+aPKwJ84fd9JuSVzjgiDQFxXzWnY qQeNguQ7I4IY2dD6ihm6gb6QCvdvy1dFvJpo7Px6mxnLQoy42TEXQ8056k9vpCvPnxUk J8qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@squebb.ca header.s=fm2 header.b=pTFEbXB2; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=g3aoVubI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r201-20020a632bd2000000b005347d6bd7eesi3411923pgr.141.2023.06.01.13.10.52; Thu, 01 Jun 2023 13:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@squebb.ca header.s=fm2 header.b=pTFEbXB2; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=g3aoVubI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230410AbjFAUGD (ORCPT + 99 others); Thu, 1 Jun 2023 16:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbjFAUGB (ORCPT ); Thu, 1 Jun 2023 16:06:01 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E8C134; Thu, 1 Jun 2023 13:05:59 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 6EB7C32001FC; Thu, 1 Jun 2023 16:05:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 01 Jun 2023 16:05:58 -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=1685649958; x= 1685736358; bh=BuihjXCY0FZRPM1FRQ1H6wx+Ft5lKyW8JMDLJbKUpdE=; b=p TFEbXB2nZmJpBzR2g/prdstVVpfbEzaj0wJ+vCmlyrCotpnJ0G8igJajZ4DojHKh jez4xHv2Fx9WV0jggwH0FRO7vRhqTuveCjU6cif3iLa9wgkpxO0c4IcU+tSbVOk5 CqWECsJzplVCsGSYOYQsVc3tiBb0lrKs8wiGQAaTZx+w58wswgpgqh8+5Jya0YSM rQpZmVqszmP6uWqgjXJqjPJofHHifPzr+KAyNEXfu+RgZ/Mbp6itog3L6+J3UGiH PsBO34LrY8WFxTS9nAh44VeLhs3yQ3NtBd2ykDjY9z/ffr0U2MTIFsk8M95VSLjn nakJIIhLnIX1Yap9usQ2w== 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=1685649958; x= 1685736358; bh=BuihjXCY0FZRPM1FRQ1H6wx+Ft5lKyW8JMDLJbKUpdE=; b=g 3aoVubITj4Yqj+bVpLgZA+HbXFBGAKK87N1jZ84aYdeYO60D/NlOYIfe+hMGaK/H Z+TnLHdUAIdWY96g0zSNU46LbTYJGLBDy6BeUS0x5Fq9pIs280qnsBMDFEwHbDB8 AVBviyOr0Enw9y627yU14MEnz/DGTyawEM+UC1wDnvVuTpYs88Z1D7GktrLd9SpI cHAhJaCjaDD6QxLGH7w+AaXkDgKBkqpA4i2M2DIoU1wvXECyDvsnh22CLUGecKxC XlV9S5Lr58b+cKTAzTdkfe9pFkas8ayBN77mM65xqCjARtVQAMCkAeUACF0SBsRR UtdBq+Ng6hu6yyuBZlIag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeghecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuogetfedtuddqtdduucdludehmdenucfjughrpe fhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforghrkhcurfgvrghr shhonhcuoehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggrqeenucggtf frrghtthgvrhhnpeeftddvjeefleffvefhgfejjeehudetteeigeeugfekhffhgeejudeu teehgfdvffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmphgvrghrshhonhdqlhgvnhhovhhosehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 16:05:57 -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, ilpo.jarvinen@linux.intel.com Subject: [PATCH v4 2/8] platform/x86: think-lmi: Enable opcode support on BIOS settings Date: Thu, 1 Jun 2023 16:05:46 -0400 Message-Id: <20230601200552.4396-2-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601200552.4396-1-mpearson-lenovo@squebb.ca> References: <20230601200552.4396-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766167530633866281?= X-GMAIL-MSGID: =?utf-8?q?1767532417861839260?= 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. Changes in v3: - None. Version bump with rest of series. Changes in v4: - Fixed code alignment as requested. - changed 'non opcode' to 'non-opcode'. - Missing space added at end of comment. - This patch was previously #1 and is now #2 in series. 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 6cf77bc26b05..80a5c989db03 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1010,7 +1010,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,