From nobody Mon Jun 29 18:40:00 2026 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 55FCAC433F5 for ; Fri, 4 Feb 2022 07:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351099AbiBDHWu (ORCPT ); Fri, 4 Feb 2022 02:22:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350564AbiBDHWr (ORCPT ); Fri, 4 Feb 2022 02:22:47 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E592BC06173D for ; Thu, 3 Feb 2022 23:22:47 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id d5so4708205pjk.5 for ; Thu, 03 Feb 2022 23:22:47 -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=+5LKPpbu5iKLCx8q3l3QTtraKDXoVw4tcaBCnigYFY0=; b=Ye1x1oKYhX/fuw433OWsCC+WYT2KJrWfEgXPhcjxbxm2hgAeS8b6jd3Ohjog74Pqyt u7OBe17I2pIXHHVTnuy2pG2RTYJqriTSaE/XLqZIj2SyZMCdOVvBOub3a2AMpl4aE263 8GD1zjPpHbEPPnKKn4f3ZM8gsIRx5X19bqdHZ5hWecZ0mzJtLHv7YsCNTrEOH1Zva/Mn lrDeZX8UdjFZwDG4vvwNfLluk6993FcAqLyoraf7XlI9WsZdpdCgCDdQkTyO7MHgrUfo Tw9owpoGiKWvql0zEBJgxUpIN2zZ+T8vy/fOMJs0eCOoET5U6ikWef3LbJAHBsyLwvZS TYig== 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=+5LKPpbu5iKLCx8q3l3QTtraKDXoVw4tcaBCnigYFY0=; b=hoAXnLYqapEAdTojavKkM29kKNdaaerdlTxsVS2oCkiEaX2oS6l9Ewvhv2gjRzf/JB ljK/qwZuLTj5RBe50DS67N76nVMQIRGxhGcqodp3QyW7soCP+dY5aR/r1Ru7UyYz08GL PkKGb+pH4lruiFVp2ScNvxb7yxKKU9CmIyFJhJYe9XssPu8Ri4N27X4Gmpf5nmOywxm/ +GCEnuzYDyjraPA4bi/wl/fh/PDpzHw0rrLlQVNskGKePNJJRjlhAIBScr/fZS6fAPqa 9vJNMZjgv0VzIjP2HyKhchp6mS49Ju0vgqePWwepAzEzNRs3usjy1luFLs3Jx+Rsuppn TZog== X-Gm-Message-State: AOAM530UIBAuuHc/UkbpfOTeMvQALmF9tNaTu5sZtLYeXESr1y+makHF hZRAhnvnesl+pnFb5RSkBDY= X-Google-Smtp-Source: ABdhPJxamqaX7dV6Xu5aIa9QaGzi6tPvLY26OfbUAcepJ1S0aH7GPsguPzJfyitNg9q10b9Pe55yDg== X-Received: by 2002:a17:902:b189:: with SMTP id s9mr1679695plr.112.1643959367334; Thu, 03 Feb 2022 23:22:47 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id t14sm11665328pjd.6.2022.02.03.23.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 23:22:46 -0800 (PST) Sender: "joel.stan@gmail.com" From: Joel Stanley To: Arnd Bergmann , Andrew Jeffery , Greg Kroah-Hartman , "Rafael J . Wysocki" , Robin Murphy Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org Subject: [PATCH v3 1/3] firmware: Add boot information to sysfs Date: Fri, 4 Feb 2022 17:52:32 +1030 Message-Id: <20220204072234.304543-2-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204072234.304543-1-joel@jms.id.au> References: <20220204072234.304543-1-joel@jms.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 properties that a system can choose to expose to describe how the system was started. Currently the intended use describes four files, relating to hardware root of trust configuration. These properties are populated by platform code at startup. Using fixed values is suitable as the state that the system booted in will not change after firmware has handed over. Signed-off-by: Joel Stanley --- v2: - Rewrite so properties are present in common code and are exposed based on the is_visible callback. - Use sysfs_emit v3: - drop uart_boot - Add kerneldoc to header - Rename en -> present - Rename val -> value - Drop unncessary __init from header - Wrap macro in do { } while(0) --- .../ABI/testing/sysfs-firmware-bootinfo | 37 +++++++++ drivers/base/firmware.c | 80 +++++++++++++++++++ include/linux/firmware_bootinfo.h | 48 +++++++++++ 3 files changed, 165 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/Documentat= ion/ABI/testing/sysfs-firmware-bootinfo new file mode 100644 index 000000000000..cd8eeaa49a00 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-firmware-bootinfo @@ -0,0 +1,37 @@ +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. diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c index 8dff940e0db9..8d1a7a36784c 100644 --- a/drivers/base/firmware.c +++ b/drivers/base/firmware.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #include "base.h" =20 @@ -24,3 +25,82 @@ int __init firmware_init(void) return -ENOMEM; return 0; } + +/* + * Exposes attributes documented in Documentation/ABI/testing/sysfs-firmwa= re-bootinfo + */ +static struct bootinfo bootinfo; + +static ssize_t abr_image_show(struct device *dev, struct device_attribute = *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.abr_image.value); +} +static DEVICE_ATTR_RO(abr_image); + +static ssize_t low_security_key_show(struct device *dev, struct device_att= ribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.low_security_key.value); +} +static DEVICE_ATTR_RO(low_security_key); + +static ssize_t otp_protected_show(struct device *dev, struct device_attrib= ute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.otp_protected.value); +} +static DEVICE_ATTR_RO(otp_protected); + +static ssize_t secure_boot_show(struct device *dev, struct device_attribut= e *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.secure_boot.value); +} +static DEVICE_ATTR_RO(secure_boot); + +#define ATTR_ENABLED(a) ((attr =3D=3D &dev_attr_##a.attr) && bootinfo.a.pr= esent) + +static umode_t bootinfo_attr_mode(struct kobject *kobj, struct attribute *= attr, int index) +{ + if (ATTR_ENABLED(abr_image)) + return 0444; + + if (ATTR_ENABLED(otp_protected)) + return 0444; + + if (ATTR_ENABLED(low_security_key)) + return 0444; + + if (ATTR_ENABLED(otp_protected)) + return 0444; + + if (ATTR_ENABLED(low_security_key)) + return 0444; + + if (ATTR_ENABLED(secure_boot)) + return 0444; + + return 0; +} + +static struct attribute *bootinfo_attrs[] =3D { + &dev_attr_abr_image.attr, + &dev_attr_low_security_key.attr, + &dev_attr_otp_protected.attr, + &dev_attr_secure_boot.attr, + NULL, +}; + +static const struct attribute_group bootinfo_attr_group =3D { + .attrs =3D bootinfo_attrs, + .is_visible =3D bootinfo_attr_mode, +}; + +int __init firmware_bootinfo_init(struct bootinfo *bootinfo_init) +{ + struct kobject *kobj =3D kobject_create_and_add("bootinfo", firmware_kobj= ); + if (!kobj) + return -ENOMEM; + + memcpy(&bootinfo, bootinfo_init, sizeof(bootinfo)); + + return sysfs_create_group(kobj, &bootinfo_attr_group); +} +EXPORT_SYMBOL_GPL(firmware_bootinfo_init); diff --git a/include/linux/firmware_bootinfo.h b/include/linux/firmware_boo= tinfo.h new file mode 100644 index 000000000000..237da83b673c --- /dev/null +++ b/include/linux/firmware_bootinfo.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright 2022 IBM Corp. */ + +#include +#include + +#define BOOTINFO_SET(b, n, v) do {b.n.present =3D true; b.n.value =3D v; }= while (0) + +/** + * struct bootinfo_entry - A bootinfo sysfs entry + * @present: true if the file should be present (visible) in sysfs + * @value: value of the entry, will be printed as 1 or 0 + * + * Contains the state of a given bootinfo sysfs file, to be filled out by = the + * platform that wishes it to be present. + * + * It is used by sysfs. The is_present callback tests .present indicate the + * attribute should be shown, and by the show callback tests .value to dis= play + * the value. + */ +struct bootinfo_entry { + bool present; + bool value; +}; + +/** + * struct bootinfo: A collection of bootinfo entries + * @abr_image: sysfs property + * @low_security_key: sysfs property + * @otp_protected: sysfs property + * @secure_boot: sysfs property + * + * The documented set of bootinfo entries to be displayed in + * /sys/firmware/bootinfo. Platform code populates a struct bootinfo and + * passes it to firmware_bootinfo_init, which takes a copy to be used at + * runtime. + * + * See struct bootinfo_entry for a description of the information each ent= ry + * contiains. + */ +struct bootinfo { + struct bootinfo_entry abr_image; + struct bootinfo_entry low_security_key; + struct bootinfo_entry otp_protected; + struct bootinfo_entry secure_boot; +}; + +int firmware_bootinfo_init(struct bootinfo *bootinfo_init); --=20 2.34.1 From nobody Mon Jun 29 18:40:00 2026 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 687E8C433F5 for ; Fri, 4 Feb 2022 07:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238629AbiBDHWz (ORCPT ); Fri, 4 Feb 2022 02:22:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351130AbiBDHWw (ORCPT ); Fri, 4 Feb 2022 02:22:52 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB9BDC061714 for ; Thu, 3 Feb 2022 23:22:51 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id d5so4708305pjk.5 for ; Thu, 03 Feb 2022 23:22:51 -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=r1QEEzychUMCoe5U0DSfc5Oq8DaKAXk74KjekRt/xBk=; b=W6qp7cTDZMWu2cumGId9gyog0wkFPZ6VWS/JnKyjaYHYoz5ep33RmlhmkdZHhrqMxf Rh037CyhguO34+KYPjPfU4Dhr8q1DIF1zY8bSTqPfX1WqonPbzPUALZIcz6s/Fo4T1b5 uejYahCQDjJ3kM2AfbMQkz1EW9pfzWz6cAt9P2XxhN/yDP9TymzKVCUvSc0Xq7aPQP/b Lf+oVCL/yWqKIb68vmDsFf6o2jEsjqxGQGh8qrDAnEW2NLSYv9R7w0cH+ngm1UNv0GUL YLLEuCvEJFgTrwEHJ8KJmLCnatwRzc9QhqifvLGkXoUP/YUkk+6kdkCj7rSFkePZtxOP T1qQ== 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=r1QEEzychUMCoe5U0DSfc5Oq8DaKAXk74KjekRt/xBk=; b=Bl9uHufLTzXpgk8/CSP63Wmo5Ci0aUGV//BmlTsOd3ftWhnYJNHZqYCipqDziirgMH 7bD7rj1fQ+4hGqV+H7I93/6WXGzOYSLu4dIEKMHuj4OOggmw2AImel+qGQWGBZUUe8kf 2W59JpSb386ruj8DrpUs/sPl3Ud8r48KkDxPcxPKs/F8+oWFTsPAuJpNjvjftrPKKcjH 12vLyC+ky0OKa2Ru2Hl+aDub19X6XCINiMjZo+S9ujrrym93yy9p2bY6zAImDE7YH+ZG +2dFT3BDd+7vQNHcRTNRfDXm8/WFWHLUX7wcjwGiJNC5d2s/fEUUWHpey9vtlzovHdIk iQCQ== X-Gm-Message-State: AOAM531lSzhzSwHmbzjokT9prKKUfDvO2QzC1PO43PxQ2ZGQIPO1E+XA n8kd3coHvU1N7+aOdtq66MU= X-Google-Smtp-Source: ABdhPJzv/S6WjXTCMee8NeOApFsHfvQNWaNzQQYEDOSomwHAyzQX+uirIatWiFPa/UeV9TWHfDvo/g== X-Received: by 2002:a17:90b:4c4a:: with SMTP id np10mr1694513pjb.164.1643959371345; Thu, 03 Feb 2022 23:22:51 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id t14sm11665328pjd.6.2022.02.03.23.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 23:22:50 -0800 (PST) Sender: "joel.stan@gmail.com" From: Joel Stanley To: Arnd Bergmann , Andrew Jeffery , Greg Kroah-Hartman , "Rafael J . Wysocki" , Robin Murphy Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org Subject: [PATCH v3 2/3] ARM: aspeed: Add secure boot controller support Date: Fri, 4 Feb 2022 17:52:33 +1030 Message-Id: <20220204072234.304543-3-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204072234.304543-1-joel@jms.id.au> References: <20220204072234.304543-1-joel@jms.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This reads out the status of the secure boot controller and exposes it in sysfs using the bootinfo sysfs api. An example on a AST2600A3 QEMU model: # grep -r . /sys/firmware/bootinfo/* /sys/firmware/bootinfo/abr_image:0 /sys/firmware/bootinfo/low_security_key:0 /sys/firmware/bootinfo/otp_protected:0 /sys/firmware/bootinfo/secure_boot:1 On boot the state of the system according to the secure boot controller will be printed: [ 0.037634] AST2600 secure boot enabled or [ 0.037935] AST2600 secure boot disabled The initialisation is changed from early_initcall to subsys_initcall because we need the firmware_kobj to be initialised, and because there's no requirement to print this information early. Signed-off-by: Joel Stanley --- v2: - Rewrite to new bootinfo api - Get rid of unused return values v3: - Drop uart_boot --- drivers/soc/aspeed/aspeed-socinfo.c | 44 ++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/soc/aspeed/aspeed-socinfo.c b/drivers/soc/aspeed/aspee= d-socinfo.c index 1ca140356a08..e5ced9bebfa2 100644 --- a/drivers/soc/aspeed/aspeed-socinfo.c +++ b/drivers/soc/aspeed/aspeed-socinfo.c @@ -8,6 +8,7 @@ #include #include #include +#include =20 static struct { const char *name; @@ -74,6 +75,45 @@ static const char *siliconid_to_rev(u32 siliconid) return "??"; } =20 +/* Secure Boot Controller register */ +#define SEC_STATUS 0x14 +#define ABR_IMAGE_SOURCE BIT(13) +#define OTP_PROTECTED BIT(8) +#define LOW_SEC_KEY BIT(7) +#define SECURE_BOOT BIT(6) +#define UART_BOOT BIT(5) + +static void __init aspeed_bootinfo_init(void) +{ + struct device_node *np; + void __iomem *base; + struct bootinfo bootinfo =3D {}; + u32 reg; + + /* AST2600 only */ + np =3D of_find_compatible_node(NULL, NULL, "aspeed,ast2600-sbc"); + if (!of_device_is_available(np)) + return; + + base =3D of_iomap(np, 0); + if (!base) + of_node_put(np); + + reg =3D readl(base + SEC_STATUS); + + iounmap(base); + of_node_put(np); + + BOOTINFO_SET(bootinfo, abr_image, reg & ABR_IMAGE_SOURCE); + BOOTINFO_SET(bootinfo, low_security_key, reg & LOW_SEC_KEY); + BOOTINFO_SET(bootinfo, otp_protected, reg & OTP_PROTECTED); + BOOTINFO_SET(bootinfo, secure_boot, reg & SECURE_BOOT); + + firmware_bootinfo_init(&bootinfo); + + pr_info("AST2600 secure boot %s\n", (reg & SECURE_BOOT) ? "enabled" : "di= sabled"); +} + static int __init aspeed_socinfo_init(void) { struct soc_device_attribute *attrs; @@ -148,6 +188,8 @@ static int __init aspeed_socinfo_init(void) attrs->revision, attrs->soc_id); =20 + aspeed_bootinfo_init(); + return 0; } -early_initcall(aspeed_socinfo_init); +subsys_initcall(aspeed_socinfo_init); --=20 2.34.1 From nobody Mon Jun 29 18:40:00 2026 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 E1C2EC433F5 for ; Fri, 4 Feb 2022 07:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234928AbiBDHXC (ORCPT ); Fri, 4 Feb 2022 02:23:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350564AbiBDHW4 (ORCPT ); Fri, 4 Feb 2022 02:22:56 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F579C06173D for ; Thu, 3 Feb 2022 23:22:56 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id h14so4426881plf.1 for ; Thu, 03 Feb 2022 23:22:56 -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=3NAuZUPwGF81ONxppx1B9B6iTuR1QuOpDIcTSst0sx0=; b=HmUyqiwJMKWnR7xJD07p4oXeNj9NB7fxabIkBU7eUvnS7cgvXWWegTDLLCfxRsQO0L bDTv0BDUlmGtIsho04tQU1mS+fFZs0lOi4IXKWd4u4jiaFmxFO1v6Uy5ykagjn1FfFkY ooJR2M+k3Ad2jnFTbCJzpLDQLmy8ctJ0d1cZASvSOVAMPqBYsT2rx6OIq8Wo+L3yZXJf HEE14JFihc1dS7hY07KRN2s3iv0iSOkvaS4TEAAjSULEjOuf0sbT8DSwqrP2AhTpoFoP li3jYYBBInfYPeEGtJS1Y8Q88AslwT6YmvKI7otNQFTjM30Mr1y/Cw8CixxwV40SbOoD cVWg== 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=3NAuZUPwGF81ONxppx1B9B6iTuR1QuOpDIcTSst0sx0=; b=02EjOrL/onTJI29nvAav1upg/jNY+sBP1SxG1/MJcxgoVgKW6LdSmqb/Q9D4w3whXR jcNxuK1K7BC4kUrN0uqhMTb5Yu/H9OyiEnlGo5i9/cBtBR76DS6ZGSEenleMiXXjf4yu j/4ZH4ncWLIObPLSbTshpOrzjOcIVz8fkx1EYrrgymtdxsTEjL24z8uj3JRchtpF78x2 B5D83GWm9FpNm6PSO1MiTW3Oi0u/JhFFhLgCaJNVvxp+ELKhuQCTUVbtd4CwnqFoh3E5 Q5Nsk6NTIYn1X6WS2dE4vOcUlqLeHUqePoj3HbGs2MlKCCVUYeiuV/y2ZX2TpRH6FPzY 8ZWA== X-Gm-Message-State: AOAM532qX9nmeQQmn9XmXp1krW6L+LZPk/NBpRoKHnOfMzOJFcGZc52I kjn/S8lD0AjU0ZAWnn2fFGkgA7D+uIM= X-Google-Smtp-Source: ABdhPJyVz5qfJzssRkzORV9t582XmgGtNGjvXlTFsPohRi5IjyDvNmGF+qtghzsEor7vO69s2ZW/Fg== X-Received: by 2002:a17:90a:6a4e:: with SMTP id d14mr1695587pjm.177.1643959375746; Thu, 03 Feb 2022 23:22:55 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id t14sm11665328pjd.6.2022.02.03.23.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 23:22:54 -0800 (PST) Sender: "joel.stan@gmail.com" From: Joel Stanley To: Arnd Bergmann , Andrew Jeffery , Greg Kroah-Hartman , "Rafael J . Wysocki" , Robin Murphy Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org Subject: [PATCH v3 3/3] x86/setup: Populate bootinfo with secure boot status Date: Fri, 4 Feb 2022 17:52:34 +1030 Message-Id: <20220204072234.304543-4-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204072234.304543-1-joel@jms.id.au> References: <20220204072234.304543-1-joel@jms.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" bootinfo indicates to userspace that firmware is configured to boot with secure boot. Signed-off-by: Joel Stanley --- v2: new v3: no change --- arch/x86/kernel/setup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f7a132eb794d..b805b758478f 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -23,6 +23,7 @@ #include #include #include +#include =20 #include =20 @@ -1100,17 +1101,22 @@ void __init setup_arch(char **cmdline_p) setup_log_buf(1); =20 if (efi_enabled(EFI_BOOT)) { + struct bootinfo bootinfo =3D {}; + switch (boot_params.secure_boot) { case efi_secureboot_mode_disabled: pr_info("Secure boot disabled\n"); + BOOTINFO_SET(bootinfo, secure_boot, false); break; case efi_secureboot_mode_enabled: pr_info("Secure boot enabled\n"); + BOOTINFO_SET(bootinfo, secure_boot, true); break; default: pr_info("Secure boot could not be determined\n"); break; } + firmware_bootinfo_init(&bootinfo); } =20 reserve_initrd(); --=20 2.34.1