From patchwork Thu Jul 18 20:35:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46633 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F04C3DA7F for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by mx.groups.io with SMTP id smtpd.web10.4183.1721334952411141470 for ; Thu, 18 Jul 2024 13:35:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=z0u3eQKw; spf=pass (domain: linaro.org, ip: 209.85.128.180, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-65f9b244018so12717287b3.3 for ; Thu, 18 Jul 2024 13:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334951; x=1721939751; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M6Zr6NSCymDnggv3lRQvMlTI2sUOIxCsHB1wjfnRh54=; b=z0u3eQKwbruegY/1SLt/uB/Xevt4k8dqQ4PKuDVLzlJGFQ8H+exQRLqeKztcYrs6Im V3uZ1W211Gqa0+2fVRJZc8CCPekUf3b07pO/WwVGIgZELrNL9NYcqXDePopQGLf3eYYR jVdG/n66pruKzCC4HXZx2rP0S5PJMTM2GVEN4o6r6zFS8GV9MGj/05JCC5OYjLacDB3e JZJpfxg5KE+PPyawhZp8mLJSeOG3UXNz+AHZ1x2kphg3GghdwvrXwd/yOzVT4J5uS6Yt u2t5V1ZHqa8+OKGPPHcxRaoWeI2JjDhwFuFLpbzJRxyg5k+kKvY8tXH0R++pmQSgPYyG iLEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334951; x=1721939751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M6Zr6NSCymDnggv3lRQvMlTI2sUOIxCsHB1wjfnRh54=; b=FsKreSYXYzI0tMR9g9GeaVa+mATlQAltgdbC2c08I+bf3owXnTJfMVNklrs6SmcuCi LQlDEVZFakL8/wNdd4RS3B7aRWiuW4PrBs9MLI+pSNiFbPItO7Y6uoca4sYYOtWfnvQk zwgK93Uw0NBkMMuCLiLWFAJzBhJqr2LvcgAhXJlc1x8SI/CfZ99pPCCQv5gC+EelvUwE sGZB908f6FguIqYiVkk5W8Wb0oRi6VY+NuaAaeNUmhShkGeSmeL21lPvd0PAylGUGNfH VbckGwtLG46XVMWWMOnHtaX1aPGnv9y7jve2Zj3Baz+M2HORyyJDXr2DjvNe2/appla4 Qbww== X-Gm-Message-State: AOJu0YxJW+OVvuYo3+OtvdqL5mhYyCCkZ21L0DA3atC/JsZw5Sreye02 zKPHrQ7JT9Zprg/KCFHbVBOvJTDWeWpuzuQtKC0j2c89+euDiTxVdfcaanD/XNEx2GYDKcOPaVz +O6s= X-Google-Smtp-Source: AGHT+IGZWSqirOOD/zaGFMmnV1AaqPXmTJTlE/EYpuCcNDrvCorDpVX59BbPCr8A8+hr7MbwHP/Mhw== X-Received: by 2002:a81:ae23:0:b0:619:da17:87be with SMTP id 00721157ae682-666a6dafaa8mr31629237b3.42.1721334951255; Thu, 18 Jul 2024 13:35:51 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:50 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 1/7] qemuarm64-secureboot: Add poky machine UEFI settings Date: Thu, 18 Jul 2024 14:35:20 -0600 Message-ID: <20240718203526.52214-2-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5900 - Introduce uefi-secureboot poky machine feature. - Replace qemuarm64.wks with efi-disk-no-swap.wks.in disk definition to add expected UEFI disk partitions configuration. - Enable poky machine feature and grub UEFI support. - Remove hard-coded root partition as it will be detected based on GUID part. - Use systemd as Init manager to auto-mount efivarfs required by efivar. - Install additional userspace software required by Linux kernel and systemd. - Set root password. Signed-off-by: Javier Tia --- .../core-image-base-uefi-secureboot.inc | 21 +++++++++++++++++++ .../images/core-image-base.bbappend | 1 + .../conf/machine/qemuarm64-secureboot.conf | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc create mode 100644 meta-arm-bsp/recipes-bsp/images/core-image-base.bbappend diff --git a/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc b/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc new file mode 100644 index 00000000..9f20e3f4 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc @@ -0,0 +1,21 @@ +# Detected by passing kernel parameter +QB_KERNEL_ROOT = "" + +# kernel is in the image, should not be loaded separately +QB_DEFAULT_KERNEL = "none" + +KERNEL_IMAGETYPE = "Image" + +WKS_FILE = "efi-disk-no-swap.wks.in" + +MACHINE_FEATURES += "efi" + +EFI_PROVIDER = "grub-efi" +IMAGE_INSTALL += "grub-efi" + +IMAGE_INSTALL += "systemd util-linux bash coreutils efivar" + +inherit extrausers +EXTRA_IMAGE_FEATURES += "allow-root-login" +# Set the root password to toor +EXTRA_USERS_PARAMS += "usermod -p '\$6\$cnS1MQVd07.jLdkj\$NgXwgR.LWtbi4qD3Drn6x0AQtVtX/CdfKPy1eJzuUC0YdD8s54fLAlsLm8vaoacAoqq6BHYGTAbUnAUNJKTOb1' root;" diff --git a/meta-arm-bsp/recipes-bsp/images/core-image-base.bbappend b/meta-arm-bsp/recipes-bsp/images/core-image-base.bbappend new file mode 100644 index 00000000..1f6dbd24 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/images/core-image-base.bbappend @@ -0,0 +1 @@ +require ${@bb.utils.contains('MACHINE_FEATURES', 'uefi-secureboot', 'core-image-base-uefi-secureboot.inc', '', d)} \ No newline at end of file diff --git a/meta-arm/conf/machine/qemuarm64-secureboot.conf b/meta-arm/conf/machine/qemuarm64-secureboot.conf index 78a39c03..27581941 100644 --- a/meta-arm/conf/machine/qemuarm64-secureboot.conf +++ b/meta-arm/conf/machine/qemuarm64-secureboot.conf @@ -22,3 +22,6 @@ WKS_FILE_DEPENDS = "trusted-firmware-a" IMAGE_BOOT_FILES = "${KERNEL_IMAGETYPE}" MACHINE_FEATURES += "optee-ftpm" +MACHINE_FEATURES += "uefi-secureboot" + +INIT_MANAGER = "systemd" \ No newline at end of file From patchwork Thu Jul 18 20:35:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46635 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96B86C52CD8 for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by mx.groups.io with SMTP id smtpd.web11.4151.1721334953266332467 for ; Thu, 18 Jul 2024 13:35:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=qUfYVXDm; spf=pass (domain: linaro.org, ip: 209.85.128.171, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-66108213e88so12086477b3.1 for ; Thu, 18 Jul 2024 13:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334952; x=1721939752; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fsqt7llxekc2W5nszGnzv5KjpZccTr4WLkYLzg1W4TQ=; b=qUfYVXDmS7qfUO41gIrP5JBIv+qafDpelCmLlahZpzTTcaOjHsLHGL1pyeVry4I6PK 4wUCXEC2VTOAsGNhXDsHKm4STTw3z9m1l1aWg87F632YBb+7ZcHGHlaB4ZZCtadFCTu8 aSwG7gZK94iYeXAACEvWM0JCrwefIEt/s9UnHw3/BIQQB6TQF6kqmixskFZvl4pu4PyS 6zE3qZaioKJ6/EFiTi0NNjNhd+ur1xEaYsiB1DJagNkKNlL4y7VIeinJA8463leLTb7C GsA7w/Jd7pstCSqlBrtoIApsiB9A8qbpD7qmVoGMgFIxHVkZ7JJLWIw0N41kqrS0Wy1W MM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334952; x=1721939752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fsqt7llxekc2W5nszGnzv5KjpZccTr4WLkYLzg1W4TQ=; b=Jk5fB9uVE5LpMypCvdyb66p++HsLQWu4A5X2nKkPn4JSRftTfu7cA/kabiPR2FbJTz 3AC0SQNjiEU/G9ZQF9VdnOHJuTAc3J6kJamtnHdJTj1diE+LyKvZURrI7APOZeaMP9Jy /wKfuM7Lnw60nWKlgfDh4OTVDqCTCMuGjNIWK8H7P+xMLbUtstX9WZOqfETF9gJ8U9Wg sSx2e2ptFocBU8fI1PP6mtaEV/KuVFuG4TlmbgvpXJLH3m2PuUNIwrHQYZXCKXh4U8JO sEsyWZs6ToLYco5AQogqsXjXrZrDQjlTbvFdfSKOxVskl7Ljvf+3Y+B7CxgQpVqo5CPN poAA== X-Gm-Message-State: AOJu0YxI2o0xf2UxWKnYoIj+6sfunk6/WwLmEwC5eSGXF6MFXsyqM4IK //Mwvz4wfyvWUW7XvYkIcZpCrGreXAcs8/Dul9JpOOg/liu/nTIlBSCC1Brs7tZ2p0qKBs7JPFa JYSQ= X-Google-Smtp-Source: AGHT+IECoviJcCG9GdwM0O3xxP9978JXpGeVTjXc5XgdhWQUy/aqENSBFOlWFkxGNk6DGngD8JUsxw== X-Received: by 2002:a05:690c:6512:b0:615:2a14:4ea6 with SMTP id 00721157ae682-664fd98a8c2mr81572987b3.8.1721334952355; Thu, 18 Jul 2024 13:35:52 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:51 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 2/7] qemuarm64-secureboot: Introduce UEFI_SB_KEYS_DIR Date: Thu, 18 Jul 2024 14:35:21 -0600 Message-ID: <20240718203526.52214-3-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5901 UEFI_SB_KEYS_DIR saves UEFI keys path. To avoid security issues, UEFI keys are not provided and they can be generated by gen_uefi_keys.sh script. Signed-off-by: Javier Tia --- meta-arm/conf/layer.conf | 2 ++ meta-arm/uefi-sb-keys/gen_uefi_keys.sh | 35 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 meta-arm/uefi-sb-keys/gen_uefi_keys.sh diff --git a/meta-arm/conf/layer.conf b/meta-arm/conf/layer.conf index 9e9c9dbd..2854dd69 100644 --- a/meta-arm/conf/layer.conf +++ b/meta-arm/conf/layer.conf @@ -21,3 +21,5 @@ HOSTTOOLS_NONFATAL += "telnet" addpylib ${LAYERDIR}/lib oeqa WARN_QA:append:layer-meta-arm = " patch-status" + +UEFI_SB_KEYS_DIR ??= "${LAYERDIR}/uefi-sb-keys" \ No newline at end of file diff --git a/meta-arm/uefi-sb-keys/gen_uefi_keys.sh b/meta-arm/uefi-sb-keys/gen_uefi_keys.sh new file mode 100755 index 00000000..fc7f25c9 --- /dev/null +++ b/meta-arm/uefi-sb-keys/gen_uefi_keys.sh @@ -0,0 +1,35 @@ +#/bin/sh + +set -eux + +#Create PK +openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=Linaro_LEDGE/ -keyout PK.key -out PK.crt -nodes -days 3650 +cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc PK.crt PK.esl +sign-efi-sig-list -c PK.crt -k PK.key PK PK.esl PK.auth + +#Create KEK +openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=Linaro_LEDGE/ -keyout KEK.key -out KEK.crt -nodes -days 3650 +cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc KEK.crt KEK.esl +sign-efi-sig-list -c PK.crt -k PK.key KEK KEK.esl KEK.auth + +#Create DB +openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=Linaro_LEDGE/ -keyout db.key -out db.crt -nodes -days 3650 +cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc db.crt db.esl +sign-efi-sig-list -c KEK.crt -k KEK.key db db.esl db.auth + +#Create DBX +openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=Linaro_LEDGE/ -keyout dbx.key -out dbx.crt -nodes -days 3650 +cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc dbx.crt dbx.esl +sign-efi-sig-list -c KEK.crt -k KEK.key dbx dbx.esl dbx.auth + +#Sign image +#sbsign --key db.key --cert db.crt Image + +#Digest image +#hash-to-efi-sig-list Image db_Image.hash +#sign-efi-sig-list -c KEK.crt -k KEK.key db db_Image.hash db_Image.auth + +#Empty cert for testing +touch noPK.esl +sign-efi-sig-list -c PK.crt -k PK.key PK noPK.esl noPK.auth + From patchwork Thu Jul 18 20:35:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46629 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58A2CC3DA63 for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by mx.groups.io with SMTP id smtpd.web11.4158.1721334954307240111 for ; Thu, 18 Jul 2024 13:35:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=v9PouM1T; spf=pass (domain: linaro.org, ip: 209.85.128.175, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-662dc911cf2so12467847b3.1 for ; Thu, 18 Jul 2024 13:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334953; x=1721939753; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YOvRUm1ARNIkb1HW47YskDYrcmWvMwF9wX7v1a1IC7s=; b=v9PouM1TAjrtHdlDjbgEyQmmOPRWwGIut2Ktq4CfhsCFs2g9RB2YDtXUSSVTftatEc tTkWUpSvB/skJCzkUwv8G5mBl9rWPuU8jnCMzZ8+aP8B6wRSOqqPoEvxOMbgOMtjrzpw 63jrLXga8B0Lijox0C/t/4xqT+AAJ6e3kLtMf/e4fm8/SMv7dn2FzotGq66da3MYb0Q+ O74nskMPH5JnVB6o4S5V1pURsKVydvfcW5PszM/m9WS8UujvWD34xWw24JuPqxDx1nJ3 MQ9u0QivK39IjKlYGV6SKWouRBdqcrGECQqujv3jm4oygZLoFz5EP/fQxVJimzIIzzLt wVeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334953; x=1721939753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YOvRUm1ARNIkb1HW47YskDYrcmWvMwF9wX7v1a1IC7s=; b=PIakgH4UpcEepvpA1+sMBs9R0Wtt4tXqHYpKb7ZZ0+AmtgZb1/H1X5Nz3s4KHKGfEe 37O6+00fQr3pvQHzCpf8207gvh/V5fEpuB7N8GeqA7WXAA8xqoFy/LKydaxRRo2BB1cX MjJzLL2jCZIrn0MxndSNo/fk2JzuEDU+BhYA72Q29tl1TPq4Q2y3pAeMvIRdWL/Iyw1+ 34MXRTQ2H2dffAeag2L4RquNZHQ2hYIXL/ATeo2j/6rbo5/iLtlTJk/UVsAQa/0xRyGH igSkGFJdvme9AE1uOW/Nj0EAmxQEGRN943fIF1ErmVT0B6G79WpVmUlp/6BQxqWopND0 0Gag== X-Gm-Message-State: AOJu0YwB95qKpchIIQ9A24+QbJHh4H0enCuKJh/4id2n1bd93yw9HdoZ +E3tdkBWXCuRSIPxc+0crr8w6Y5JSV4FIqT0W5cU24DfqREcBEv97v7hKkYlkwO/UK59fdaRZ1H cRFA= X-Google-Smtp-Source: AGHT+IGrblPRx3fkyzDMqOPFOFWDG1m7ugM7j6jGw1V463+lYtbnAgu9PaJ8e+wQ3lgNY2SJ4qL+5w== X-Received: by 2002:a05:690c:4712:b0:65f:d82c:af86 with SMTP id 00721157ae682-66601ccd6admr46913487b3.16.1721334953302; Thu, 18 Jul 2024 13:35:53 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:53 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 3/7] qemuarm64-secureboot: Validate UEFI keys exist Date: Thu, 18 Jul 2024 14:35:22 -0600 Message-ID: <20240718203526.52214-4-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5902 Without UEFI keys, signing will fail and UEFI Secure Boot will be disabled. Signed-off-by: Javier Tia --- .../core-image-base-uefi-secureboot.inc | 2 ++ meta-arm/classes/uefi-sb-keys.bbclass | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 meta-arm/classes/uefi-sb-keys.bbclass diff --git a/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc b/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc index 9f20e3f4..4ab3ecf9 100644 --- a/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc +++ b/meta-arm-bsp/recipes-bsp/images/core-image-base-uefi-secureboot.inc @@ -1,3 +1,5 @@ +inherit uefi-sb-keys + # Detected by passing kernel parameter QB_KERNEL_ROOT = "" diff --git a/meta-arm/classes/uefi-sb-keys.bbclass b/meta-arm/classes/uefi-sb-keys.bbclass new file mode 100644 index 00000000..e800b4c6 --- /dev/null +++ b/meta-arm/classes/uefi-sb-keys.bbclass @@ -0,0 +1,24 @@ +# Validate UEFI keys +python __anonymous () { + if d.getVar("UEFI_SB_KEYS_DIR", False) is None: + raise bb.parse.SkipRecipe("UEFI_SB_KEYS_DIR is not set.") + + # keys used for UEFI secure boot + uefi_sb_keys = d.getVar("UEFI_SB_KEYS_DIR") + + keys_to_check = [ + uefi_sb_keys + "/PK.esl", + uefi_sb_keys + "/KEK.esl", + uefi_sb_keys + "/dbx.esl", + uefi_sb_keys + "/db.esl", + uefi_sb_keys + "/db.key", + uefi_sb_keys + "/db.crt", + ] + + missing_keys = [f for f in keys_to_check if not os.path.exists(f)] + + if missing_keys: + raise bb.parse.SkipRecipe("Required missing keys: %s" % (", ".join(missing_keys), ) + + ".\nRun %s/gen_uefi_keys.sh to generate missing keys." % uefi_sb_keys) + +} From patchwork Thu Jul 18 20:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46634 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CE9CC41513 for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by mx.groups.io with SMTP id smtpd.web10.4184.1721334955306142850 for ; Thu, 18 Jul 2024 13:35:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=SVpfsg68; spf=pass (domain: linaro.org, ip: 209.85.128.180, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-661d7e68e89so9729487b3.0 for ; Thu, 18 Jul 2024 13:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334954; x=1721939754; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5ijs/PqslDJCjWaUWOXOubABw9algRuVzD/iiwfcaJI=; b=SVpfsg68z2XjIQLW2LVCLttQ9mgUL3E80uk1DyxVUBXbt9iazmjP0+RBpHgPIMwLXi Jyu1EritmxCMjzDxoIGX//gswmp7WYx6wCxZcQA1S5fbc1ETDSoCapQF5UUnAZ12LjLx S6Gfp5JJOpCO8G8uQEhg6bH0F8NU6mN8CWTenQguKCxYtgUtLU5WEkYLvbE6ISo0vLln wHMgn1VujHPVpQG2aCnJPUundzvNhThHKjBtSDZOzH+dvI2bK4JQv5u6KQa0fXJhS9FL QYuZJf5Nap2bcSrlz7xpbAjZoFek4xzw8vsCItnLYNXTqK/XWI97wDapTH55Xzq2fQK/ LhrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334954; x=1721939754; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5ijs/PqslDJCjWaUWOXOubABw9algRuVzD/iiwfcaJI=; b=pytL18OrhddhpI2qLPhhwCFtcI1xAeAPXk68DO/dNQtm2Hfw5+LiAsSU8oCjRuO7MP B9N+YqXi7RSQZ/cpu58x5cugD6NEXuYPiN8CFJoS0VjgJq+8ddAkivZIQPYf4hBgTIWs ZQ6T+H5XqsxTSNZFQ/n04dwnXFjeaKrWP8t+SJcTxUg4zpZQqgvzRedncAO+mw+zn9iw HwNdG6GXqyzRyt1jGzcwULIfPYb09Qd2DXY04HlWtzrEkV8nXYtXz1oYb+bezAq6UgnS Ns7GI638OlPmJAdJ6EDYtit4kAbNj7HYVNy6FSD5YNMn7W12YxrRN0QLpZJJfF03IDnX z+Sw== X-Gm-Message-State: AOJu0Yx9O5W0dHa4e5JMWJ00+2V5y99vcmPlLWTMOkjDf+6zyF11q+1S Xq2jp/j5iH1KQn/VAswZSscD9Gv5AmARBO1xWddzlI0rP8KwlRkttoMc00QfvXe/0XXG4fhSaLE 5wDQ= X-Google-Smtp-Source: AGHT+IHWE8RTlipkVR/rrPMHHZHRaetrxS9OmNe8brRDpa/F/eRvksblcWJkiKAOQoauj0henlKbxg== X-Received: by 2002:a05:690c:298:b0:644:4a1c:1868 with SMTP id 00721157ae682-6660f319993mr28502237b3.24.1721334954294; Thu, 18 Jul 2024 13:35:54 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:54 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 4/7] qemuarm64-secureboot: Setup UEFI and Secure Boot in u-boot Date: Thu, 18 Jul 2024 14:35:23 -0600 Message-ID: <20240718203526.52214-5-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5903 Add u-boot minimal UEFI definitions. Setup UEFI variables with the keys previously generated. Signed-off-by: Javier Tia --- .../u-boot/u-boot-qemuarm64-secureboot.inc | 18 ++++++++++++++++++ .../qemuarm64-secureboot.cfg | 10 ++++++++++ .../recipes-bsp/u-boot/u-boot_%.bbappend | 1 + 3 files changed, 29 insertions(+) create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot-qemuarm64-secureboot.inc create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/qemuarm64-secureboot/qemuarm64-secureboot.cfg diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-qemuarm64-secureboot.inc b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-qemuarm64-secureboot.inc new file mode 100644 index 00000000..0a0accd1 --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-qemuarm64-secureboot.inc @@ -0,0 +1,18 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}/${MACHINE}:" + +SRC_URI += "file://${MACHINE}.cfg" + +UBOOT_BOARDDIR = "${S}/board/emulation/qemu-arm" +UBOOT_ENV_NAME = "qemu-arm.env" + +DEPENDS += 'python3-pyopenssl-native' + +do_compile:prepend() { + export CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1 + + "${S}"/tools/efivar.py set -i "${S}"/ubootefi.var -n pk -d "${UEFI_SB_KEYS_DIR}"/PK.esl -t file + "${S}"/tools/efivar.py set -i "${S}"/ubootefi.var -n kek -d "${UEFI_SB_KEYS_DIR}"/KEK.esl -t file + "${S}"/tools/efivar.py set -i "${S}"/ubootefi.var -n db -d "${UEFI_SB_KEYS_DIR}"/db.esl -t file + "${S}"/tools/efivar.py set -i "${S}"/ubootefi.var -n dbx -d "${UEFI_SB_KEYS_DIR}"/dbx.esl -t file + "${S}"/tools/efivar.py print -i "${S}"/ubootefi.var +} diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot/qemuarm64-secureboot/qemuarm64-secureboot.cfg b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/qemuarm64-secureboot/qemuarm64-secureboot.cfg new file mode 100644 index 00000000..d2edb5fb --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/qemuarm64-secureboot/qemuarm64-secureboot.cfg @@ -0,0 +1,10 @@ +CONFIG_CMD_BOOTMENU=y +CONFIG_USE_BOOTCOMMAND=y +CONFIG_BOOTCOMMAND="bootmenu" +CONFIG_USE_PREBOOT=y +CONFIG_EFI_VAR_BUF_SIZE=65536 +CONFIG_FIT_SIGNATURE=y +CONFIG_EFI_SECURE_BOOT=y +CONFIG_EFI_VARIABLES_PRESEED=y +CONFIG_PREBOOT="setenv bootmenu_0 UEFI Boot Manager=bootefi bootmgr; setenv bootmenu_1 UEFI Maintenance Menu=eficonfig" +CONFIG_PREBOOT_DEFINED=y \ No newline at end of file diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend index 11f332ad..8df993ae 100644 --- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend +++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend @@ -5,6 +5,7 @@ MACHINE_U-BOOT_REQUIRE:corstone1000 = "u-boot-corstone1000.inc" MACHINE_U-BOOT_REQUIRE:fvp-base = "u-boot-fvp-base.inc" MACHINE_U-BOOT_REQUIRE:juno = "u-boot-juno.inc" MACHINE_U-BOOT_REQUIRE:tc = "u-boot-tc.inc" +MACHINE_U-BOOT_REQUIRE:qemuarm64-secureboot = "${@bb.utils.contains('MACHINE_FEATURES', 'uefi-secureboot', 'u-boot-qemuarm64-secureboot.inc', '', d)}" require ${MACHINE_U-BOOT_REQUIRE} From patchwork Thu Jul 18 20:35:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46631 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B493C3DA61 for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by mx.groups.io with SMTP id smtpd.web11.4161.1721334956543979045 for ; Thu, 18 Jul 2024 13:35:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=LJLECWbF; spf=pass (domain: linaro.org, ip: 209.85.128.175, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6561850a7bcso13895537b3.3 for ; Thu, 18 Jul 2024 13:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334955; x=1721939755; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E35ejzlXeD/67/aumw5V+DwkjGSuPq5GnUIlN8Yu4mg=; b=LJLECWbFn7uZcBQ6j+hXaUFkvblGWGbmLZ//65OKOATitn9INenu2yye1bMFAl0GXI gO8jUW2yRZ+2z9piUqKeg8rT3uiyHgrfakvR2TwigOIULZaeo3LGobnzznVleOCLqSgn s83J9d3IjE70paaG8k4rxq1KQZm3YZeIFQrzTxMoGwAv3GIgUlDpJy53zIOUU87UfKqw aeMzbFIDoj7DYBtztQ042pBvUcM8pzyTe0YsXjGvSotZt47TO3nBBtJQwhBLRYuvDCFd MhWHl9XvX19mJkWV9n8L91xlv0EAbcQqJ3NdJAyDq6lyIphOW9M4zmivbHHXorO5yBg7 Sk4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334955; x=1721939755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E35ejzlXeD/67/aumw5V+DwkjGSuPq5GnUIlN8Yu4mg=; b=neVTVqurDLIp5ZHM4NTnCrZSVJDYIjky+NQ4NKteVT7emR8RFlm7tnaStIaNysbhfP bZbsBtE4/J/OOSN8bDadmK70hzaPTn3eYLpnn+jgK6sMlpj2dgH9anIBbRPlfmsjRuhP HLt14QV2xIPyg39DrYv8EONxzPXvuPP013LXpyrl/ErzKEGGtlOYHIw99B3fbP1D6Hvl VWV3V16+Ce8EIIHq2j/hhM1wkynSf5G7b9dnHdCN2tC3fUHtP8JsaoHUUefRaMrRCXtJ kQqyHg5Xkb4zIpFm4eVF3eUSzUc3OIHXJF4LlDHYHfzhbpA7tiB/XHHrNk0N9SehvBFT 38jg== X-Gm-Message-State: AOJu0Yw51zaV+DQEAvmnClKGCBCw7MdQqFOBHdcddXTIoBIH4U+56bRs SpbGAk2Z/IoP6EvIaW22VgfvLGJPEQ+V4U7Rwq5D4OMa8jiQ2redq2CF37shzMOh/L026kFuHss 7RXk= X-Google-Smtp-Source: AGHT+IH/C5hVyccGMpkDtd4AE5T1Zriibbw8iLibcvtFVnhimOcFw2r6B/9+QEbB4XywVMy3bw0mxw== X-Received: by 2002:a81:9302:0:b0:646:53ce:b365 with SMTP id 00721157ae682-66500c3a8d4mr73390047b3.42.1721334955516; Thu, 18 Jul 2024 13:35:55 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:55 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 5/7] qemuarm64-secureboot: Setup UEFI grub and sign EFI grub binary Date: Thu, 18 Jul 2024 14:35:24 -0600 Message-ID: <20240718203526.52214-6-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5904 meta-secure-core is required because of sbsigntool. Signed-off-by: Javier Tia --- ci/qemuarm64-secureboot.yml | 12 +++-- ...on-t-return-error-for-deferred-image.patch | 48 +++++++++++++++++++ .../recipes-bsp/grub/files/grub-initial.cfg | 8 ++++ .../grub/grub-efi-uefi-secureboot.inc | 40 ++++++++++++++++ meta-arm/recipes-bsp/grub/grub-efi_%.bbappend | 1 + 5 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 meta-arm/recipes-bsp/grub/files/0001-verifiers-Don-t-return-error-for-deferred-image.patch create mode 100644 meta-arm/recipes-bsp/grub/files/grub-initial.cfg create mode 100644 meta-arm/recipes-bsp/grub/grub-efi-uefi-secureboot.inc create mode 100644 meta-arm/recipes-bsp/grub/grub-efi_%.bbappend diff --git a/ci/qemuarm64-secureboot.yml b/ci/qemuarm64-secureboot.yml index b26941e0..958a1ff1 100644 --- a/ci/qemuarm64-secureboot.yml +++ b/ci/qemuarm64-secureboot.yml @@ -4,13 +4,15 @@ header: version: 14 includes: - ci/base.yml - -machine: qemuarm64-secureboot - -target: - - core-image-base + - ci/meta-openembedded.yml + - ci/meta-secure-core.yml local_conf_header: optee: | IMAGE_INSTALL:append = " optee-test optee-client optee-os-ta" TEST_SUITES:append = " optee ftpm" + +machine: qemuarm64-secureboot + +target: + - core-image-base diff --git a/meta-arm/recipes-bsp/grub/files/0001-verifiers-Don-t-return-error-for-deferred-image.patch b/meta-arm/recipes-bsp/grub/files/0001-verifiers-Don-t-return-error-for-deferred-image.patch new file mode 100644 index 00000000..e55128df --- /dev/null +++ b/meta-arm/recipes-bsp/grub/files/0001-verifiers-Don-t-return-error-for-deferred-image.patch @@ -0,0 +1,48 @@ +From 70fe34e1e61e0560af8a2018c5486b07b217f7fc Mon Sep 17 00:00:00 2001 +From: Leo Yan +Date: Thu, 22 Dec 2022 15:28:12 +0800 +Subject: [PATCH] verifiers: Don't return error for deferred image + +When boot from menu and the flag GRUB_VERIFY_FLAGS_DEFER_AUTH is set, +grub returns error: + + Booting a command list + + error: verification requested but nobody cares: (hd0,gpt1)/Image. + + Press any key to continue... + +In this case, the image should be deferred for authentication, grub +should return the file handle and pass down to later firmware (e.g. +U-Boot, etc) for authentication. + +For this purpose, rather than returning error, this patch prints log +and returns file handler. + +Upstream-Status: Submitted + +Signed-off-by: Leo Yan +--- + grub-core/kern/verifiers.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/grub-core/kern/verifiers.c b/grub-core/kern/verifiers.c +index 75d7994cf..ada753e69 100644 +--- a/grub-core/kern/verifiers.c ++++ b/grub-core/kern/verifiers.c +@@ -115,11 +115,7 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type) + if (!ver) + { + if (defer) +- { +- grub_error (GRUB_ERR_ACCESS_DENIED, +- N_("verification requested but nobody cares: %s"), io->name); +- goto fail_noclose; +- } ++ grub_printf("%s verification is deferred\n", io->name); + + /* No verifiers wanted to verify. Just return underlying file. */ + return io; +-- +2.35.1 + diff --git a/meta-arm/recipes-bsp/grub/files/grub-initial.cfg b/meta-arm/recipes-bsp/grub/files/grub-initial.cfg new file mode 100644 index 00000000..1da15480 --- /dev/null +++ b/meta-arm/recipes-bsp/grub/files/grub-initial.cfg @@ -0,0 +1,8 @@ +# First partition on first disk, most likely EFI system partition. Set it here +# as fallback in case the search doesn't find the given UUID. +set root='hd0,gpt1' +search --no-floppy --fs-uuid --set=root 7819-74F8 + +configfile /EFI/BOOT/grub.cfg + +# If fail to load config file, it runs into GRUB shell. diff --git a/meta-arm/recipes-bsp/grub/grub-efi-uefi-secureboot.inc b/meta-arm/recipes-bsp/grub/grub-efi-uefi-secureboot.inc new file mode 100644 index 00000000..e218cb50 --- /dev/null +++ b/meta-arm/recipes-bsp/grub/grub-efi-uefi-secureboot.inc @@ -0,0 +1,40 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI += "file://grub-initial.cfg" +SRC_URI += "file://0001-verifiers-Don-t-return-error-for-deferred-image.patch" + +DEPENDS += "sbsigntool-native" + +GRUB_PREFIX_DIR ?= "/EFI/BOOT" +EFI_BOOT_PATH ?= "/boot/efi/EFI/BOOT" + +do_mkimage() { + install -d "${D}${EFI_BOOT_PATH}" + install -m 0600 "${UNPACKDIR}/grub-initial.cfg" "${D}${EFI_BOOT_PATH}/grub.cfg" + + grub-mkimage --disable-shim-lock \ + --prefix="${GRUB_PREFIX_DIR}" \ + --format="${GRUB_TARGET}-efi" \ + --directory="${B}/grub-core" \ + --output="${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE}" \ + ${GRUB_BUILDIN} +} + +fakeroot do_sign() { + "${STAGING_BINDIR_NATIVE}/sbsign" \ + --key "${UEFI_SB_KEYS_DIR}/db.key" \ + --cert "${UEFI_SB_KEYS_DIR}/db.crt" \ + "${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE}" \ + --output "${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE}.signed" + + install -m 0644 "${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE}.signed" "${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE}" + + install -d "${D}${EFI_BOOT_PATH}" + install -m 0644 "${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE}.signed" "${D}${EFI_BOOT_PATH}/${GRUB_IMAGE}" +} + +addtask sign after do_install before do_deploy do_package + +FILES:${PN} += "${EFI_BOOT_PATH}" + +CONFFILES:${PN} += "${EFI_BOOT_PATH}/grub.cfg" diff --git a/meta-arm/recipes-bsp/grub/grub-efi_%.bbappend b/meta-arm/recipes-bsp/grub/grub-efi_%.bbappend new file mode 100644 index 00000000..fd3baba0 --- /dev/null +++ b/meta-arm/recipes-bsp/grub/grub-efi_%.bbappend @@ -0,0 +1 @@ +require ${@bb.utils.contains('MACHINE_FEATURES', 'uefi-secureboot', 'grub-efi-uefi-secureboot.inc', '', d)} \ No newline at end of file From patchwork Thu Jul 18 20:35:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46630 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87CB0C3DA70 for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by mx.groups.io with SMTP id smtpd.web11.4163.1721334957481977299 for ; Thu, 18 Jul 2024 13:35:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=RaIeSrTC; spf=pass (domain: linaro.org, ip: 209.85.128.174, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-65f852c82fcso15111107b3.1 for ; Thu, 18 Jul 2024 13:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334956; x=1721939756; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EF/jHFr4+j/iET/dg5nrT225Ug6C2AkUqA3MaVXogBI=; b=RaIeSrTCOWOqD/ePSHoGYUEpRNPpjEuVfzZOtpfTIUKKLehSrfqKk/ACAgrX0yJSnT WcsOXkhoJXtj/cQVzjBl9J/q3EO4KgJYq4VHb+ZjEFjoM/d3mbv4oZGlcf/ITkIm0v21 M3nXMvIHylQUt3NC/elE+2OoSrgoicYOF6xVTNN7LEtj53vQMCICCQV4J6nsVC8Aso1i oRY4PA/BXj3oDp3pXqQBtv2w4kDzZKOK3OCiNP+WgISKityDBq9l1lRpqyqCLQ4yn9tE bcc4rmERBVEcVK3/y+g05fyLxoDtsOgmqkgK94HzpVvssJtHLuqCyCVdGxjIfpf8+onq MnmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334956; x=1721939756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EF/jHFr4+j/iET/dg5nrT225Ug6C2AkUqA3MaVXogBI=; b=IjAJ3gSS/lO3uRadekh04e5ZKKkHI/tMYffmwkgXwNiokJg+2wSV6GPLhOBxDoO+Ca 0R9OCsw1f2R8N3/ov2MGWz7QQTAneCpRoVMBG4UqOOpHPXJYgO86BiiMm5hHdOzqy+t8 drUMPDQLVTW/m6QNft0tC80tux3WxjM3YlppyktHQ+8d1hh25UXKIWmC/PrexVmhfj4h RcrspULtg/eMAT+p11lOgYBamGsz0oO014QFFqZZsAzGcs2NLVBcmRBJp9kto1ElfpFS eNKumrFsD2fXqw7lDm+hEwB+tuhG9aEXiYBtZqPetx1kqm7zlKtgTkvlQkGy88wMgqKP 8aHw== X-Gm-Message-State: AOJu0YwsbkvJvHDMSYmUijBiyQSKOc3wUpVrUf0OwIMr5Qx6IaR2ChfA KofdTxH1Sa4h99t6ylL/QxQok0598eQSuOVUXCumABvIKB6ooeAm9WrQSJyG2JGCVb/JPJSf0Ll zSwU= X-Google-Smtp-Source: AGHT+IG1sBljx0cXqrS2OK9Te+xzoo6ZJsBHQBvZUO80Xxr3NchcpIkscctD4LzGj64nlCibYbIb7Q== X-Received: by 2002:a81:840c:0:b0:649:fa54:1f8c with SMTP id 00721157ae682-6650028c1a2mr71774167b3.48.1721334956489; Thu, 18 Jul 2024 13:35:56 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:56 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 6/7] qemuarm64-secureboot: Setup UEFI linux-yocto and sign kernel image Date: Thu, 18 Jul 2024 14:35:25 -0600 Message-ID: <20240718203526.52214-7-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5905 efivarfs kernel module is required to access EFI vars. Signed-off-by: Javier Tia --- .../recipes-kernel/linux/linux-yocto%.bbappend | 2 ++ .../linux/linux-yocto-uefi-secureboot.inc | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 meta-arm/recipes-kernel/linux/linux-yocto-uefi-secureboot.inc diff --git a/meta-arm/recipes-kernel/linux/linux-yocto%.bbappend b/meta-arm/recipes-kernel/linux/linux-yocto%.bbappend index a287d0e1..29c21355 100644 --- a/meta-arm/recipes-kernel/linux/linux-yocto%.bbappend +++ b/meta-arm/recipes-kernel/linux/linux-yocto%.bbappend @@ -25,3 +25,5 @@ SRC_URI:append:qemuarm = " \ FFA_TRANSPORT_INCLUDE = "${@bb.utils.contains('MACHINE_FEATURES', 'arm-ffa', 'arm-ffa-transport.inc', '' , d)}" require ${FFA_TRANSPORT_INCLUDE} + +require ${@bb.utils.contains('MACHINE_FEATURES', 'uefi-secureboot', 'linux-yocto-uefi-secureboot.inc', '', d)} \ No newline at end of file diff --git a/meta-arm/recipes-kernel/linux/linux-yocto-uefi-secureboot.inc b/meta-arm/recipes-kernel/linux/linux-yocto-uefi-secureboot.inc new file mode 100644 index 00000000..3784b3d1 --- /dev/null +++ b/meta-arm/recipes-kernel/linux/linux-yocto-uefi-secureboot.inc @@ -0,0 +1,18 @@ +KERNEL_FEATURES += "cfg/efi-ext.scc" + +DEPENDS += "sbsigntool-native" + +do_compile:append() { + KERNEL_IMAGE=$(find "${B}" -name "${KERNEL_IMAGETYPE}" -print -quit) + + "${STAGING_BINDIR_NATIVE}/sbsign" \ + --key "${UEFI_SB_KEYS_DIR}/db.key" \ + --cert "${UEFI_SB_KEYS_DIR}/db.crt" \ + "${KERNEL_IMAGE}" \ + --output "${KERNEL_IMAGETYPE}.signed" + + install -m 0644 "${KERNEL_IMAGETYPE}.signed" "${KERNEL_IMAGE}" +} + +RRECOMMENDS:${PN} += "kernel-module-efivarfs" +RRECOMMENDS:${PN} += "kernel-module-efivars" \ No newline at end of file From patchwork Thu Jul 18 20:35:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 46632 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95EEFC49EA1 for ; Thu, 18 Jul 2024 20:35:59 +0000 (UTC) Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by mx.groups.io with SMTP id smtpd.web11.4164.1721334958497486417 for ; Thu, 18 Jul 2024 13:35:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=f3KX/iaP; spf=pass (domain: linaro.org, ip: 209.85.128.172, mailfrom: javier.tia@linaro.org) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-65fdfd7b3deso13201297b3.0 for ; Thu, 18 Jul 2024 13:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721334957; x=1721939757; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jDGqvjEL+9UIxamUQxP5sgH5iddm+9P5Jr141AAsmsw=; b=f3KX/iaPdTjSJ4OkYcDFJB7thyc9Db3xXZD/Rkrpw9ilHF9ZuKQ33nCHk5nHI4i6y+ kY20G06ziFjMALvbegPeQTSEOsBileJtXFwEgitUlLVd/HmUzWtw31Kqer2/RccRF2gm lZRATqEo195Ty6Hg2cJsZGiqfL8osfBxFoX9CcjevdBXAnZu+/Y8Ptmo06SbOjQOMwMp 9CudC0Ga7Q18OYSUHmslECppMeO+Wid5XNAnP6zVYcy/2DuUVb7hqYQtxsNJJXR43OHf 0MEm99GHzextQE9fAFHnnUU4Egswzrl4twzw/R6rCDzKreXDl7IyVCdqr2ryoo/mpTE8 5JkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721334957; x=1721939757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jDGqvjEL+9UIxamUQxP5sgH5iddm+9P5Jr141AAsmsw=; b=XLuFtDpjIp8oixxrZ82Asq2452i49I1nRzqG0v6+1/ZWj+0xlbqzKVtesv1Ul2LtOn ckP8MuaDuESxEAMnIzPnnNJ7In0jrJrVdE8MY8fKCLKqrMVSoQYZ8FVO3uDtKLnjlzUm RMYM0DQeP7zrdY12KSqVRX5/gI48GLVWvmyYlyc65Rat+3OOY7hY+2lKgKwKGkXnmDvq zKeXs51j0MgNES7wazNfZyB6j2pY0WJc/vO8K5jY8Z6KEM1GB/Jem23mDzJEeWSpDGxy 5xJCOcPuT4HgCYrWOQVLttQczOL6BXUy9q5yKIO+DwP1yg/ww3Ci/qkxwMuJI4k+lSuc B4zg== X-Gm-Message-State: AOJu0YyVkdfsO08O+VVw5meT6alfq1gUkmAu7miowEOMwx31tNW0HOQS epQbOty+8kjmz1ZDDB8QdGuAhNaM0nqYFpxZBjZQ4N/AcjpMRfZmpsFAgBeTK/BYVzzm76kdtDO nkSA= X-Google-Smtp-Source: AGHT+IGkSNCTn4NDg2jmtCBO/0+NlCNWxChXvKovCY/3FggdhFQkT6yzwmaGvJTh1Y3UCIpdccPPfQ== X-Received: by 2002:a05:690c:e0e:b0:65f:9b24:7883 with SMTP id 00721157ae682-664fde7fdbcmr82993017b3.1.1721334957460; Thu, 18 Jul 2024 13:35:57 -0700 (PDT) Received: from localhost.localdomain ([190.171.102.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695245a1dasm171657b3.53.2024.07.18.13.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 13:35:57 -0700 (PDT) From: Javier Tia To: meta-arm@lists.yoctoproject.org Cc: Mikko Rapeli , Ross Burton , Javier Tia Subject: [PATCH v1 7/7] qemuarm64-secureboot: Add UEFI systemd support Date: Thu, 18 Jul 2024 14:35:26 -0600 Message-ID: <20240718203526.52214-8-javier.tia@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718203526.52214-1-javier.tia@linaro.org> References: <20240718203526.52214-1-javier.tia@linaro.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 18 Jul 2024 20:35:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5906 Signed-off-by: Javier Tia --- meta-arm/recipes-core/systemd/systemd-uefi-secureboot.inc | 1 + meta-arm/recipes-core/systemd/systemd_%.bbappend | 1 + 2 files changed, 2 insertions(+) create mode 100644 meta-arm/recipes-core/systemd/systemd-uefi-secureboot.inc create mode 100644 meta-arm/recipes-core/systemd/systemd_%.bbappend diff --git a/meta-arm/recipes-core/systemd/systemd-uefi-secureboot.inc b/meta-arm/recipes-core/systemd/systemd-uefi-secureboot.inc new file mode 100644 index 00000000..5572e51a --- /dev/null +++ b/meta-arm/recipes-core/systemd/systemd-uefi-secureboot.inc @@ -0,0 +1 @@ +PACKAGECONFIG:append = " efi" diff --git a/meta-arm/recipes-core/systemd/systemd_%.bbappend b/meta-arm/recipes-core/systemd/systemd_%.bbappend new file mode 100644 index 00000000..577c4f0c --- /dev/null +++ b/meta-arm/recipes-core/systemd/systemd_%.bbappend @@ -0,0 +1 @@ +require ${@bb.utils.contains('MACHINE_FEATURES', 'uefi-secureboot', 'systemd-uefi-secureboot.inc', '', d)}