From patchwork Thu Feb 3 11:53:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 12734062 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 2DF02C433EF for ; Thu, 3 Feb 2022 11:55:40 +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=nDwGwe0mhU5aDMQK6GnD8512cCS+JqN9lFp8CD60Udw=; b=NqnvoMoG/fu5Cg RVW9Bh5WkCsZdwRtsNi5LlEv4EKpQmUwFhsTC2xzeDDm3d+mxMUccmL/hL++InitzDo1yPYmPecWr ttszqnAr2KeGGYvAhGhdsq9/qfDvWY0g6kpAnrD+/zvemxTmc9/5FPAfKA07Rk7rBl6gwbpW9LtLw Lew9dKFlkOO1d0uqZiupQxrCYa/fRZScpMR2M0CBa/oja5ONlbE/m8dC4Lnl4rWg5T7NdSQcaePtf uif1M6kUTJiqL38Y4sXJEUj2JGqb2RVz7Ycw4kUKBbpjn6Z93envFbQdORHbQ/7KHZR0mrOMBVRTO IdVyFzi1W6ObmqNBx97w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFah3-0013ah-2r; Thu, 03 Feb 2022 11:54:29 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFaga-0013SB-DQ for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 11:54:02 +0000 Received: by mail-pf1-x42c.google.com with SMTP id c194so1999726pfb.12 for ; Thu, 03 Feb 2022 03:54:00 -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=dAqSf/tyCwdsZHkiyWbb3eiNXltTa0d1QVuYusLc2f0=; b=lEefzxPqPP58T2ta4bd1mVNE9Swkps/YStQ5ytP+dHpxeWeIBqbiai52u5LlNp6LLi kJIZlf1iyqU6qogMnjxpX3nC87Y4QK2DimNOtC69jLWO/jAsAG9R6LnmAbIperFt2bhh zLAq1VhpMJmNh2OLyjrZEKku+BKuzmdISuiOXPNOs1yxUi6hv24dKotuEP1YiG3MlKWP d04B05m34XKNPG3hP+WhUOYLsVegFC7kKD+kvh0L3z3k31B7HTaM6QTf8UPtyY4x9yvz rIGAOxh+MotKoCfiw8quYHOMCk2arbIcZnIXYpVm173U4puSr4c8GUllSO4F1uFx+m/2 bL9w== 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=dAqSf/tyCwdsZHkiyWbb3eiNXltTa0d1QVuYusLc2f0=; b=DGrLwgyh/lXYFlTjPoJ0TF8p5lQAZ9s/3BZy64pZUFacaXhbHlAIrdZ6XygsJAADGN ZTf2bQdn7CZ/DcTuBXV6K21dIa1g7Hwmh0DObYbckOY2+EM4sCHErb+T+1o0jZ4/Shzj zGk0glTqvIfvb2yS10OewU77YKLQYIvfuWXzfXH0a3DMp6AmGkXPPnDn+QwBBj3UJKQO 0ToHOjVzITo07Pn96QgX4qf7rUiaDtWDI3b1EKml8ck/bQ19f6bqaiQVPomdMMywUR6v TJAj/bLIfOOwPHUsQvMVUNyPchXta7h5Y8TDQ2Kq8Tljmqb9ZCPRKQp3llDqHo50mCeI fwfw== X-Gm-Message-State: AOAM533pbt7GvrL36+KjG9nuXYyVIUbsdaMG9Kt/QG/eV2l4n6a9ppRU iXfgSyIF9bLRU6A6oBjVqys= X-Google-Smtp-Source: ABdhPJxFEVOWHb3iWJqOFPjq9HC5m+R+EmkHDyHp9hzqEiU5T/OeGD1iK/5rq7whyILLd9P3KudZ8Q== X-Received: by 2002:a05:6a00:24c8:: with SMTP id d8mr33627605pfv.60.1643889239499; Thu, 03 Feb 2022 03:53:59 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id mp22sm9586389pjb.28.2022.02.03.03.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 03:53:58 -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 v2 1/3] firmware: Add boot information to sysfs Date: Thu, 3 Feb 2022 22:23:42 +1030 Message-Id: <20220203115344.267159-2-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203115344.267159-1-joel@jms.id.au> References: <20220203115344.267159-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-20220203_035400_485869_DC44C3ED X-CRM114-Status: GOOD ( 24.82 ) 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 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. 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 Reviewed-by: Daniel Axtens --- v2: - Rewrite so properties are present in common code and are exposed based on the is_visible callback. - Use sysfs_emit --- .../ABI/testing/sysfs-firmware-bootinfo | 43 +++++++++ drivers/base/firmware.c | 90 +++++++++++++++++++ include/linux/firmware_bootinfo.h | 22 +++++ 3 files changed, 155 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..24b931232eb2 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,92 @@ int __init firmware_init(void) return -ENOMEM; return 0; } + +/* + * Exposes attributes documented in Documentation/ABI/testing/sysfs-firmware-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.val); +} +static DEVICE_ATTR_RO(abr_image); + +static ssize_t low_security_key_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.low_security_key.val); +} +static DEVICE_ATTR_RO(low_security_key); + +static ssize_t otp_protected_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.otp_protected.val); +} +static DEVICE_ATTR_RO(otp_protected); + +static ssize_t secure_boot_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.secure_boot.val); +} +static DEVICE_ATTR_RO(secure_boot); + +static ssize_t uart_boot_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", bootinfo.uart_boot.val); +} +static DEVICE_ATTR_RO(uart_boot); + +#define ATTR_ENABLED(a) ((attr == &dev_attr_##a.attr) && bootinfo.a.en) + +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; + + if (ATTR_ENABLED(uart_boot)) + return 0444; + + return 0; +} + +static struct attribute *bootinfo_attrs[] = { + &dev_attr_abr_image.attr, + &dev_attr_low_security_key.attr, + &dev_attr_otp_protected.attr, + &dev_attr_secure_boot.attr, + &dev_attr_uart_boot.attr, + NULL, +}; + +static const struct attribute_group bootinfo_attr_group = { + .attrs = bootinfo_attrs, + .is_visible = bootinfo_attr_mode, +}; + +int __init firmware_bootinfo_init(struct bootinfo *bootinfo_init) +{ + struct kobject *kobj = 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_bootinfo.h new file mode 100644 index 000000000000..3fe630b061b9 --- /dev/null +++ b/include/linux/firmware_bootinfo.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright 2022 IBM Corp. */ + +#include +#include + +#define BOOTINFO_SET(b, n, v) b.n.en = true; b.n.val = v + +struct bootinfo_entry { + bool en; + bool val; +}; + +struct bootinfo { + struct bootinfo_entry abr_image; + struct bootinfo_entry low_security_key; + struct bootinfo_entry otp_protected; + struct bootinfo_entry secure_boot; + struct bootinfo_entry uart_boot; +}; + +int __init firmware_bootinfo_init(struct bootinfo *bootinfo_init); From patchwork Thu Feb 3 11:53:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 12734063 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 5F9A9C433EF for ; Thu, 3 Feb 2022 11:55:59 +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=B+/c9299fseN9SPPXZ4BI7qTidaLocvtvbuZPsuDTVw=; b=3RoakOHQIVrvgt fj6gtdAV5aI6SEVkKkUP9lAlYh8EnROskklALPMtooF0IJfEd924BfN4MMg7N6feTz9cKTtbi8uc5 dZmtC33Vh1rYugfZqNk3fhjk49FmjPxLkh4mIsElvYFQIiParBGTG6Bh5VnCnmxJzjVtTeHFowNF5 MH3PFuTQRnuLAF6mHj+oPEsrXXAfznhmhBU4kqBVwLHF4F64bbWYD2Wr3Z/t+k4Pqk09aeZeB2/Ec hl+/qxunY6ZSzVs7HBxbmD164DJEOwSXUo3jYzUWM1qMg1/yJBN1xVSiH67c+Ex2KINmU9IUDcP3R JJpZrhU5CXa9fahL4K+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFahF-0013g7-8Y; Thu, 03 Feb 2022 11:54:41 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFage-0013U7-8m for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 11:54:05 +0000 Received: by mail-pg1-x52f.google.com with SMTP id d186so2072045pgc.9 for ; Thu, 03 Feb 2022 03:54:03 -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=y24EP6xKeEvQOAjkdyxZutWXu4m6B4k+YDqTIaEEINs=; b=bzyKo9LHZxuywZ/Lpjaf+94nxTw259Cln/iVI82pP+PjBcxhKdD8DexmKafK+gizYv uARgrFIK04qrjpwyvnYXazPXOjeOJHy43FfOC4Bfi/1lcNls/5j7g1zs+4DpTCP5wDhb QtbHk/4RQQuRx2HQx0vPulkcoVyIfq8tKiLjXV4XREQ/rrPS6HqIXCArBuQ4WdS1oko/ oCa5nUnENvmUrV+kZ21wuIMIuNfppLYVdwrK848DccuRcOsZh+0IvrfDh5HjhDXXDmru ilhBR4JnSFXIE46L+No+vigF+0dbkXxD3Qem/NmmLGxGxy+ctMxEl4gk7bNrHoQ/u3Oz yPsA== 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=y24EP6xKeEvQOAjkdyxZutWXu4m6B4k+YDqTIaEEINs=; b=gzdvMa3uP5qZ/7mHvrV3vK7D605Hp9IBzDY1OY4e07AeapkvUu5XWHsv02TYSUvMmp U3o6cKB7z/GFk4Du8zo5RQyRBwRGv76nOLAL0R/W+STB5hcDFcQk0JGqURmSS8nL8v3h S0bGJ8v4VK3IinIzdJFcr9/mq/bZ4wMlzS31w5h0HStrXZKISxgYyejUOvHFnDYb6sYO 22NhWMJXp8LXRJA/I4pDLYSYaZALimffp5vpmC4jUO3RgqVrf3hHPJnp4vii2WSkBmaP yzTJroyumlbGdvsWdLaopMCjhrZz9HAKGuZcPlZ+O0GyXF9u8S0bkb70SmFxMNSBKGuw BJ/g== X-Gm-Message-State: AOAM530qRxOytKoWUZBlHRCrPhAPnmm1Ij07k0mnhavwLLCWXz8h3uuc 70OlA/bDo7n3bzMtEJx2Gng= X-Google-Smtp-Source: ABdhPJwtY9ZHwe8+DA5oX4k6u3MXHenJR9U4RjnvG/Nbl5tLA8d1Q7wrRjYWEupqZ5sEJdkknt7Smw== X-Received: by 2002:a65:4bc9:: with SMTP id p9mr27620862pgr.168.1643889243359; Thu, 03 Feb 2022 03:54:03 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id mp22sm9586389pjb.28.2022.02.03.03.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 03:54:02 -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 v2 2/3] ARM: aspeed: Add secure boot controller support Date: Thu, 3 Feb 2022 22:23:43 +1030 Message-Id: <20220203115344.267159-3-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203115344.267159-1-joel@jms.id.au> References: <20220203115344.267159-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-20220203_035404_378111_90023AFA X-CRM114-Status: GOOD ( 17.64 ) 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 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 /sys/firmware/bootinfo/uart_boot:0 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 --- drivers/soc/aspeed/aspeed-socinfo.c | 46 ++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/soc/aspeed/aspeed-socinfo.c b/drivers/soc/aspeed/aspeed-socinfo.c index 1ca140356a08..dc4dfd3df55f 100644 --- a/drivers/soc/aspeed/aspeed-socinfo.c +++ b/drivers/soc/aspeed/aspeed-socinfo.c @@ -8,6 +8,7 @@ #include #include #include +#include static struct { const char *name; @@ -74,6 +75,47 @@ static const char *siliconid_to_rev(u32 siliconid) return "??"; } +/* 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 = {}; + u32 reg; + + /* AST2600 only */ + np = of_find_compatible_node(NULL, NULL, "aspeed,ast2600-sbc"); + if (!of_device_is_available(np)) + return; + + base = of_iomap(np, 0); + if (!base) + of_node_put(np); + + reg = 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); + /* Invert the bit; as 1 is boot from SPI/eMMC */ + BOOTINFO_SET(bootinfo, uart_boot, !(reg & UART_BOOT)); + + firmware_bootinfo_init(&bootinfo); + + pr_info("AST2600 secure boot %s\n", (reg & SECURE_BOOT) ? "enabled" : "disabled"); +} + static int __init aspeed_socinfo_init(void) { struct soc_device_attribute *attrs; @@ -148,6 +190,8 @@ static int __init aspeed_socinfo_init(void) attrs->revision, attrs->soc_id); + aspeed_bootinfo_init(); + return 0; } -early_initcall(aspeed_socinfo_init); +subsys_initcall(aspeed_socinfo_init); From patchwork Thu Feb 3 11:53:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 12734064 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 C9029C433EF for ; Thu, 3 Feb 2022 11:56:03 +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=hySXCl4ApFDI9wqQ4rIaCpuKydqllMA3AcHyo+21hIg=; b=AwE1RjOzrxPYo6 ZV5WEiuUEwV6qjzrPI4PQ1ZOFiEgvHxlqlxeTmt8JCBp4gqfXSWxYN7h/20BSvzUx5Z4Pk/y3khAT sNbewc46pviqnP0U14w2ZUNxfL/CSN7bFh6Xm1T/PK13h9iTvF3xJAR25cAgJ79lEkTarZ1UlE7+g ChLn8TNZ9Ziuj9GnFm87GSksSHrLskY8udq5RnWqdgOk/ebEDrDZB/e9Nh92oUL5FI1o6IpLT5Ewe Ug+iEaqvA6RJ7EyZ8m06uTyylQevsep4beX27hY2JpKGQlydV+THT63EbD6HU/gKnxuFLtEAbNPZp WISXAQAcGq0II7xuBrrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFahS-0013mt-Dz; Thu, 03 Feb 2022 11:54:54 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFagh-0013VH-PE for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 11:54:09 +0000 Received: by mail-pg1-x534.google.com with SMTP id v3so2101561pgc.1 for ; Thu, 03 Feb 2022 03:54:07 -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=GYksfqXaPV/dh2hqgLls7NY6zYw6qDongmSSBZKsfsc=; b=BjG3aUuaDcR15UUUbWnRHZMmAfImhR37OOfIAEbDVyEBG3bMLKPk0AMcZE709hkDmC wrCKej65+toxCE+wJdzgUF5XTyrA748FK9AxG2OmmfbOTDcv5Bhyzovi2BmsPUHYKRle ggzENsYakkmYRtuxOc1oxcGJDkIZJfXdRmjJM1/F0+G16m7/X3TuYo5cyWYFyIfduX4N /K0S7U+/BiohQf4LLkUZnMhwEfP3FkpZTn1JJe+lzi5wdvazzZf49aLs7CKPfH7tdI/4 WtOUGysft1QKT8VES0RtPg0l9QTamPNmFOJ7a4zQ+5PTu441LZBfHrAIwyAa1sS9pV/0 Zn3Q== 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=GYksfqXaPV/dh2hqgLls7NY6zYw6qDongmSSBZKsfsc=; b=3cunIPkvLPBnKrCMGKEATSVpWnnBflrgtjmkU0xfa9aBTzA0ODos5LPjNklQ9N9x82 qlirmAJqlI1sBAlVkcfi3Vmm/QFZpR2aZIyQDXIMR1xGr7KkGThqP8Y3gvtyIQLawPTk rBN0Pp9Q4A3MwT0tAtpZJWebaSUNtRcBR8bbmOdBhVYKp6+iW1tpYYgjgTDh5lLzzsRR kwf8OagbE7HlfXgaxuz6CvYnS2C8HxVr0KApzVLuWlUjaYTJoyt89EySBQiYfVqoaMrx vLyM2GVHibDw1q3M1/G9Z845DfpP3Ldp/WnysGo4gybKM9+zmb3HRZuM19nYEFimLETJ UFzA== X-Gm-Message-State: AOAM53162rTtqb+9leEGkYV1UlPBI3Tr7Mkoq+Xv/9OH2ltorczLS93B AXxrpWJx+evFzv5OLpteITw= X-Google-Smtp-Source: ABdhPJypXHtSz1IUsmMH9S/+owRsut30+8ayH1fpDzvTpQE50paUnOxndIO3XEwgBjUCoguuAArtmg== X-Received: by 2002:a63:80c8:: with SMTP id j191mr20235458pgd.8.1643889247028; Thu, 03 Feb 2022 03:54:07 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id mp22sm9586389pjb.28.2022.02.03.03.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 03:54:06 -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 v2 3/3] x86/setup: Populate bootinfo with secure boot status Date: Thu, 3 Feb 2022 22:23:44 +1030 Message-Id: <20220203115344.267159-4-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203115344.267159-1-joel@jms.id.au> References: <20220203115344.267159-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-20220203_035407_844714_191652B1 X-CRM114-Status: GOOD ( 12.28 ) 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 bootinfo indicates to userspace that firmware is configured to boot with secure boot. Signed-off-by: Joel Stanley --- v2: new --- 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 #include @@ -1100,17 +1101,22 @@ void __init setup_arch(char **cmdline_p) setup_log_buf(1); if (efi_enabled(EFI_BOOT)) { + struct bootinfo bootinfo = {}; + 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); } reserve_initrd();