u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	u-boot@lists.denx.de
Cc: Simon Glass <sjg@chromium.org>, York Sun <york.sun@nxp.com>,
	Priyanka Jain <priyanka.jain@nxp.com>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH 6/6] net: fm: Add support for FIT firmware
Date: Thu, 24 Mar 2022 14:23:05 -0400	[thread overview]
Message-ID: <20220324182306.2037094-7-sean.anderson@seco.com> (raw)
In-Reply-To: <20220324182306.2037094-1-sean.anderson@seco.com>

Fman microcode is executable code (AFAICT) loaded into a
coprocessor. As such, if verified boot is enabled, it must be verified
like other executable code. However, this is not currently done.

This commit adds verified boot functionality by encapsulating the
microcode in a FIT, which can then be signed/verified as normal. By
default we allow fallback to unencapsulated firmware, but if
CONFIG_FIT_SIGNATURE is enabled, then we make it mandatory. Because
existing Layerscape do not use this config (instead enabling
CONFIG_CHAIN_OF_TRUST), this should not break any existing boards.

An example (mildly-abbreviated) its is provided below:

/ {
    #address-cells = <1>;

    images {
        firmware {
            data = /incbin/(/path/to/firmware);
            type = "firmware";
            arch = "arm64";
            compression = "none";
	    signature {
                algo = "sha256,rsa2048";
                key-name-hint = "your key name";
            };
        };
    };

    configurations {
        default = "conf";
        conf {
            description = "Load FMAN microcode";
            fman = "firmware";
        };
    };
};

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 drivers/net/fm/fm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 39b939cb97..09e13506bf 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <env.h>
 #include <fs_loader.h>
+#include <image.h>
 #include <malloc.h>
 #include <asm/io.h>
 #include <dm/device_compat.h>
@@ -537,6 +538,23 @@ int fm_init_common(int index, struct ccsr_fman *reg, const char *firmware_name)
 	void *addr = NULL;
 #endif
 
+	rc = fit_check_format(addr, CONFIG_SYS_QE_FMAN_FW_LENGTH);
+	if (!rc) {
+		size_t unused;
+		const void *new_addr;
+
+		rc = fit_get_data_conf_prop(addr, "fman", &new_addr, &unused);
+		if (rc)
+			return rc;
+		addr = (void *)new_addr;
+	} else if (CONFIG_IS_ENABLED(FIT_SIGNATURE)) {
+		/*
+		 * Using a (signed) FIT wrapper is mandatory if we are
+		 * doing verified boot.
+		 */
+		return rc;
+	}
+
 	/* Upload the Fman microcode if it's present */
 	rc = fman_upload_firmware(index, &reg->fm_imem, addr);
 	if (rc)
-- 
2.25.1


      parent reply	other threads:[~2022-03-24 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 18:22 [PATCH 0/6] net: fm: Verify Fman microcode Sean Anderson
2022-03-24 18:23 ` [PATCH 1/6] ARMv8/sec_firmware: Remove SEC_FIRMWARE_FIT_CNF_NAME Sean Anderson
2022-03-24 18:23 ` [PATCH 2/6] image: fit: Add some helpers for getting data Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-03-28 15:33     ` Sean Anderson
2022-03-24 18:23 ` [PATCH 3/6] misc: fs_loader: Add function to get the chosen loader Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-03-24 18:23 ` [PATCH 4/6] net: fm: Add firmware name parameter Sean Anderson
2022-03-24 18:23 ` [PATCH 5/6] net: fm: Support loading firmware from a filesystem Sean Anderson
2022-03-24 18:23 ` Sean Anderson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220324182306.2037094-7-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=joe.hershberger@ni.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=york.sun@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).