Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4176968rwl; Tue, 27 Dec 2022 23:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXuJHOAM4tiE5d4lSJb8k+oZp7NGOdCACQjjEMYcMBj+xV8W5BWNEVIR3HKrzrWs+1EZsGle X-Received: by 2002:a17:90b:3c81:b0:223:acc1:837e with SMTP id pv1-20020a17090b3c8100b00223acc1837emr27149271pjb.31.1672214057542; Tue, 27 Dec 2022 23:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672214057; cv=none; d=google.com; s=arc-20160816; b=Zeab2UFahkirPQ/BU2C8wfrQAC+OHl3u+Agn9dZdGuKA9kq+/igDrRr/JBJ5vpW3Jf 1ZdoslUb6W0FupjKoe4ssXLNB8ndJHI+sPEOKIiXeR3NbQZKczrInx5ADix8sig0tlH1 WxQcpGJCphe9KorXHKZN3Om8jei25j9jEESu4T2pcn4Z2HxitXJJ2ptz0OYUGCR4n+hZ nL5BeQ4/vQTkdsW4NzRRyYX3QveqqJoF8SylzrOgW3eW6jMK2ne5whe2hL+yg1aaihjG z6XSqW7WAQhO09huibbZMgGnfVu4f5JHAss7etXfO57i46tCc6adAYBbZ7u2jhBHcLuC a8sw== 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=G1FeSOpt3gkzQCJztNRktkYJbX5ca/fOhO+UA6pN5AU=; b=iCSLwyro0WIoZTDM5k6HwgtosUzJssAKqnL403J71TnGFGr0aSqDLM7yvUPjoZplj8 RirGj5M6YMr56+gp7G6s/IhYu+GH4rWEfa5Qt3jDiGe0sEzEA9pTSEr45L5rOdxaGs7+ B/TrO1rAJ92oTH4TYtUi9AZL6A2444GlN4kM2qNea1lsr8C6gCxFywuZryo5hGswn0vk Z0UkmAyAwxN6MbLMoYOkvM0LtGp7WGPBOLaBkp1oqLaP5zzy4JIxEX1KNlas2nG4e4vR 1ZNi0+ZjJtaSTEcdLMOqMO9XrvCO7g90MezTpPsr1f/loMjU3f70hz6L6k3QrcWC4dgT U+hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@russell.cc header.s=fm3 header.b="mh9/6rSE"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MWaK4nmW; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a656897000000b0047958831653si15763855pgt.525.2022.12.27.23.54.08; Tue, 27 Dec 2022 23:54:17 -0800 (PST) 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=@russell.cc header.s=fm3 header.b="mh9/6rSE"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MWaK4nmW; 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 S232542AbiL1HbN (ORCPT + 65 others); Wed, 28 Dec 2022 02:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232554AbiL1Haq (ORCPT ); Wed, 28 Dec 2022 02:30:46 -0500 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEB0BF63 for ; Tue, 27 Dec 2022 23:30:45 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 797A53200922; Wed, 28 Dec 2022 02:30:44 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 28 Dec 2022 02:30:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=russell.cc; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672212644; x=1672299044; bh=G1 FeSOpt3gkzQCJztNRktkYJbX5ca/fOhO+UA6pN5AU=; b=mh9/6rSE2bVsR8C4sw EDzrkZNmhqkIuMfUaiLxuNFhb+ggTkQgy0TvRXbw6qhuPoj5IesXT9LTJaEAPwz7 cFtfWnvbaw4bjN30xBQyq2I0KN7K6VoAIr9Gn9BXq6XYVisN1uVdXeAdS/LgDPSv X1mO/QhXYMtS4eKQvPAYO06V1ErBIn9NFSGrQvSpn0Jb630kdbNkqylcmhgoFMcP uQ70xe+NgM4Mu5HJHI2Ym/WpNcX9iU/geAiKhGSPjmKoO+QUbR6QEzN4bdET2vGi PIShy06MArXLiElxMwESSjrtakrUW1dT6UqLYwFs5X5WIHCsT6mQbh22NSiGn8Sc sFfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding: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=fm2; t=1672212644; x=1672299044; bh=G1FeSOpt3gkzQ CJztNRktkYJbX5ca/fOhO+UA6pN5AU=; b=MWaK4nmWLmaNoMmWgKHQoR7GQULUh CWwwqk/SzY8uE3iCO6KJU9K715Ajp/CQ5Mo0RCIqV1ycqmrd8cAX6RjBplM2L3yW 3qNqDU/fMhxuRpibHPd/ygOviiRkm2dlrpi75kQwojniRaJX3U1v5LE5yK88HOlM JWyqK3oH4ADNCwRf4t4vjBpTulDTa9b1Ty1tOICXlLI/hbBxmd9r2KdThJ/NIRcl wK9YIeSUSDLYVTgu08SvE0l+831aF2u5BxzC5qxmx6vC3ZvM68Q8f+we43P6Clln vSws+ZOyheSNswQoOrUu/yihJect4H2yrRdIZK/OjLsd+ZGVysPA1a54g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedriedugdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdlfedtmdenucfjughrpefhvf evufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeftuhhsshgvlhhlucevuhhr rhgvhicuoehruhhstghurhesrhhushhsvghllhdrtggtqeenucggtffrrghtthgvrhhnpe fhvdeugfdtvdeiieegffefffekieegvdfgiedtjeetffevfefhtdehjeffieeivdenucev lhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehruhhstghurh esrhhushhsvghllhdrtggt X-ME-Proxy: Feedback-ID: i4421424f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Dec 2022 02:30:41 -0500 (EST) From: Russell Currey To: linuxppc-dev@lists.ozlabs.org Cc: gregkh@linuxfoundation.org, gcwilson@linux.ibm.com, linux-kernel@vger.kernel.org, nayna@linux.ibm.com, ajd@linux.ibm.com, zohar@linux.ibm.com, mpe@ellerman.id.au, Russell Currey Subject: [PATCH 5/6] powerpc/secvar: Extend sysfs to include config vars Date: Wed, 28 Dec 2022 18:29:42 +1100 Message-Id: <20221228072943.429266-6-ruscur@russell.cc> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221228072943.429266-1-ruscur@russell.cc> References: <20221228072943.429266-1-ruscur@russell.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 The forthcoming pseries consumer of the secvar API wants to expose a number of config variables. Allowing secvar implementations to provide their own sysfs attributes makes it easy for consumers to expose what they need to. This is not being used by the OPAL secvar implementation at present, and the config directory will not be created if no attributes are set. Signed-off-by: Russell Currey --- I played around with adding an API call to facilitate a more generic key/value interface for config variables and it seemed like unnecessary complexity. I think this is cleaner. If there was ever a secvar interface other than sysfs we'd have to rework it, though. arch/powerpc/include/asm/secvar.h | 3 +++ arch/powerpc/kernel/secvar-sysfs.c | 40 ++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/secvar.h b/arch/powerpc/include/asm/secvar.h index 92d2c051918b..250e7066b6da 100644 --- a/arch/powerpc/include/asm/secvar.h +++ b/arch/powerpc/include/asm/secvar.h @@ -10,6 +10,7 @@ #include #include +#include extern const struct secvar_operations *secvar_ops; @@ -27,10 +28,12 @@ struct secvar_operations { #ifdef CONFIG_PPC_SECURE_BOOT extern void set_secvar_ops(const struct secvar_operations *ops); +extern void set_secvar_config_attrs(const struct attribute **attrs); #else static inline void set_secvar_ops(const struct secvar_operations *ops) { } +static inline void set_secvar_config_attrs(const struct attribute **attrs) { } #endif diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c index ea408763dc78..0c3790345403 100644 --- a/arch/powerpc/kernel/secvar-sysfs.c +++ b/arch/powerpc/kernel/secvar-sysfs.c @@ -15,9 +15,17 @@ #define NAME_MAX_SIZE 1024 +const struct attribute **secvar_config_attrs __ro_after_init = NULL; + static struct kobject *secvar_kobj; static struct kset *secvar_kset; +void set_secvar_config_attrs(const struct attribute **attrs) +{ + WARN_ON_ONCE(secvar_config_attrs); + secvar_config_attrs = attrs; +} + static ssize_t format_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -134,6 +142,16 @@ static int update_kobj_size(void) return 0; } +static int secvar_sysfs_config(struct kobject *kobj) +{ + struct attribute_group config_group = { + .name = "config", + .attrs = (struct attribute **)secvar_config_attrs, + }; + + return sysfs_create_group(kobj, &config_group); +} + static int secvar_sysfs_load(void) { char *name; @@ -196,26 +214,38 @@ static int secvar_sysfs_init(void) rc = sysfs_create_file(secvar_kobj, &format_attr.attr); if (rc) { - kobject_put(secvar_kobj); - return -ENOMEM; + pr_err("secvar: Failed to create format object\n"); + rc = -ENOMEM; + goto err; } secvar_kset = kset_create_and_add("vars", NULL, secvar_kobj); if (!secvar_kset) { pr_err("secvar: sysfs kobject registration failed.\n"); - kobject_put(secvar_kobj); - return -ENOMEM; + rc = -ENOMEM; + goto err; } rc = update_kobj_size(); if (rc) { pr_err("Cannot read the size of the attribute\n"); - return rc; + goto err; + } + + if (secvar_config_attrs) { + rc = secvar_sysfs_config(secvar_kobj); + if (rc) { + pr_err("secvar: Failed to create config directory\n"); + goto err; + } } secvar_sysfs_load(); return 0; +err: + kobject_put(secvar_kobj); + return rc; } late_initcall(secvar_sysfs_init); -- 2.38.1