From patchwork Tue Feb 1 05:05:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 12731397 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D247DC433EF for ; Tue, 1 Feb 2022 05:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zPl7TIE7E7b0gaWt9IIJwfrZsxttdl8iWMWzpaWQBjc=; b=z7Igi85GlcTuGd WjuD3Jm7hATH+kHpJnEu7/7bO/9BX4nrr7nTu1XhD8FwjO/4nb90TYlCGnP6ZI3ZHxnlxb7Zk9k+G HYraJelJ0Ot2In8Az4UfSJkIAvMUWU5wKI3ilmlG7Fo8ZxvcaxdHt0QEk0K/wCRVtuvmHBWIcI00j Xzv33N+hu7Rxpk6UfbnEScbwTTFOrYTtP885IDfRyrnDty4wwh+KrgIn0YNUTkvTDIEzz60c0SAPg Lk8tF9M2yFtuxTlD47W/FCqJy3EJ/TmqQ4opff0nrFOmG7Hjl2ojtGq+34qVxkpMkD4ZdsHmjlAD/ zIA2DpMYOeqtUJ+8Z9SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nElM6-00B9al-QR; Tue, 01 Feb 2022 05:05:26 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nElLu-00B9YN-I1 for linux-arm-kernel@lists.infradead.org; Tue, 01 Feb 2022 05:05:16 +0000 Received: by mail-pl1-x635.google.com with SMTP id k17so14529777plk.0 for ; Mon, 31 Jan 2022 21:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8HhN0Mo5AAEuJ7GLyfzVMfqoylDTPvGZrezMx4WuD1Y=; b=pQcqzwBzTMUt9lhcStTT9fwKTd+uM9KFGW/Xynp4UnrxScTW2VG33Teyi7PCL+v98j 6POqQnKQFswISlLtU1hDylQGsrJ0qYsaq8Fp6JhEs66Of+MKNRPSZneIImArPfuYgUn+ zdaF5/zKLPBZ77KtJF6uiTeUHGew/VLxlM3EFtTaz4Z926PX9SiXhaXButFkPqlVyWng 3eNlSiowJnArQTA46mnNNUkJtYWdXFQmJmkDIVTUrr7omZAivB/M4amoSlDdUx1iVUPa yAv9WWxSRi3tnMczSWHJyHkwcEhuIRWpBwSaoSDhBHx8pXgsfZK97aGdfPRMhVKs1Ect RQuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8HhN0Mo5AAEuJ7GLyfzVMfqoylDTPvGZrezMx4WuD1Y=; b=0nZnnReIItEHegmmDgDdtDtPXfjWcPAwespPwLn14qBYVW3UrwzPklsGpjC4OhBCph /jqL5J4XSpIkBpvbKZjWO65iWcghFg80Rq1HzcWO3fjo1agujp34nK+QHSN06hLYF6Lw D1EVbi7qtZ9ONc+3cZfd7s8CWOEfoaCG3rbDgU/Seo5KZzyMEfS0eJooq2HbRZukYRr5 ExFML4Hzge9d89V/GaiNz4itmFUo1J5P6OrqmRsSF1fWNPDG4z0SZoyr7voc+gQVAj5l 1ChDBNSirdNl/qke3a1YHuFTBL32BQIKlr51OLubL6BTLN5k7+xDz00lC0YQW06FQkeG BoYw== X-Gm-Message-State: AOAM533Sxez2lAUNWMDrgmDD0+5rrnFFfbWer8kXDz3S4oWEDgsuy/Us G9Em3QV7ZWl3PDSubHpxb7P8UwzV3LrKyA== X-Google-Smtp-Source: ABdhPJz5avUIU4+X4vd3nMCzoEWBcmSaRvczxUqWfR52EfwhLQGqxyCpeHdGLQIZDWK9NzHJ6jgwxQ== X-Received: by 2002:a17:90a:f298:: with SMTP id fs24mr350977pjb.75.1643691913680; Mon, 31 Jan 2022 21:05:13 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id u37sm6181991pga.2.2022.01.31.21.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 21:05:13 -0800 (PST) From: Joel Stanley To: Arnd Bergmann , Andrew Jeffery , Greg Kroah-Hartman , "Rafael J . Wysocki" Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org Subject: [PATCH 1/2] firmware: Add boot information sysfs Date: Tue, 1 Feb 2022 15:35:00 +1030 Message-Id: <20220201050501.182961-2-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220201050501.182961-1-joel@jms.id.au> References: <20220201050501.182961-1-joel@jms.id.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220131_210514_620860_D5F297C8 X-CRM114-Status: GOOD ( 21.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Machines often have firmware that perform some action before Linux is loaded. It's useful to know how this firmware is configured, so create a sysfs directory and some example properties that a system can choose to expose to describe how the system was started. Currently the intended use describes five files, relating to hardware root of trust configuration. Signed-off-by: Joel Stanley --- .../ABI/testing/sysfs-firmware-bootinfo | 43 +++++++++++++++++++ drivers/base/firmware.c | 14 ++++++ include/linux/firmware_bootinfo.h | 8 ++++ 3 files changed, 65 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-firmware-bootinfo create mode 100644 include/linux/firmware_bootinfo.h diff --git a/Documentation/ABI/testing/sysfs-firmware-bootinfo b/Documentation/ABI/testing/sysfs-firmware-bootinfo new file mode 100644 index 000000000000..cd6c42316345 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-firmware-bootinfo @@ -0,0 +1,43 @@ +What: /sys/firmware/bootinfo/* +Date: Jan 2022 +Description: + A system can expose information about how it was started in + this directory. + + This information is agnostic as to the firmware implementation. + + A system may expose a subset of these properties as applicable. + + +What: /sys/firmware/bootinfo/secure_boot +Date: Jan 2022 +Description: + Indicates the system was started with secure boot enabled in + the firmware. + + +What: /sys/firmware/bootinfo/abr_image +Date: Jan 2022 +Description: + Indicates the system was started from the alternate image + loaded from an Alternate Boot Region. Often this is a result of + the primary firmware image failing to start the system. + + +What: /sys/firmware/bootinfo/low_security_key +Date: Jan 2022 +Description: + Indicates the system's secure boot was verified with a low + security or development key. + +What: /sys/firmware/bootinfo/otp_protected +Date: Jan 2022 +Description: + Indicates the system's boot configuration region is write + protected and cannot be modified. + +What: /sys/firmware/bootinfo/uart_boot +Date: Jan 2022 +Description: + Indicates the system firmware was loaded from a UART instead of + an internal boot device. diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c index 8dff940e0db9..2a6478aa178d 100644 --- a/drivers/base/firmware.c +++ b/drivers/base/firmware.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "base.h" @@ -24,3 +25,16 @@ int __init firmware_init(void) return -ENOMEM; return 0; } + +/* + * Exposes attributes documented in Documentation/ABI/testing/sysfs-firmware-bootinfo + */ +int __init firmware_bootinfo_init(const struct attribute_group *attr_group) +{ + struct kobject *kobj= kobject_create_and_add("bootinfo", firmware_kobj); + if (!kobj) + return -ENOMEM; + + return sysfs_create_group(kobj, attr_group); +} +EXPORT_SYMBOL_GPL(firmware_bootinfo_init); diff --git a/include/linux/firmware_bootinfo.h b/include/linux/firmware_bootinfo.h new file mode 100644 index 000000000000..581b68508ec8 --- /dev/null +++ b/include/linux/firmware_bootinfo.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright 2022 IBM Corp + +#include +#include + +int __init firmware_bootinfo_init(const struct attribute_group *attr_group); +