From patchwork Wed Nov 23 15:29:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053820 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 6CFCAC433FE for ; Wed, 23 Nov 2022 15:29:35 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.79]) by mx.groups.io with SMTP id smtpd.web10.22945.1669217370655511712 for ; Wed, 23 Nov 2022 07:29:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=WCCuj64j; spf=pass (domain: siemens.com, ip: 40.107.8.79, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8m15OqmevI2mY4uk0N0zR7jzZsUoTs4nzwvlI/+EgsAARB8yNNU30I/5wkBV/kuaff3/MhYfBEV2M8Zh6+XB/Xa5xs873Zk3j2Gi7UGelwtYAIosn7qZhOV3Q9Rd9y7u6ohtJSo5HFBNGUQFqEYiVA7bBF9PiV3BHf4OkhTOOnUlNK0JNIp7JT132xUdLDqJhdNeSJmlBK9/j9ACRaJ7yHcx1kQ5+S6vrtqF6Rw7QqDAmA6SFBkh5qiO1h/xrEfe3Ap+0tc4f7YUlaGLq89QCxvzmSyrWx9PmGw0No+/TJg+PJAHXXuF7zNggVfnJBUjW4WLCo18eIJdV6vJ0dEUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pL68QCWGeED+kpttQOM0+vg1Bg+XyDS1QDHV3W3qhF0=; b=Jf3h9gsDJHcu9REmkrL6XxiiY+E2e00y7QHfDuUzKm5bpkVqSuszUMAPEfx93OnrmIVKcF5p4CxYtf2Yxn3sf74/nKDdcIrq+X9Lu704TqsaE7OdDW7iPOIm9OfAHMokPHWpBCFvZZT4ZYUMSvUdXuj+gWH2lgHhLbeLiLEazrHAFQlWvLISLjMWGSVTojVKvbDauXhs6Drmtz4Uv/BbNbGJzWadX3htVTczVp75NBk4YQ3lCkaOrwFRz/fykHa5ZcNFasMyX4rqWXeU4/9JK4Gnf0K67a57iq7mLo0VDAc78mKnilSPFhWAWxDh2PzCeRI0RykqHQ4GtF4f9zeyEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pL68QCWGeED+kpttQOM0+vg1Bg+XyDS1QDHV3W3qhF0=; b=WCCuj64jxq6bRnrPR7ZvAdPOURJmkE6UmvjvMQfqYAErSk43LqZopjwqOXQuf2qzNWACQ5CmCbVlbsWauLeBUwev/FjGYF2sNs/x6AoJchNABhMEH7/qukXgYYuAdTqafiXAjy3mgK+wjfde3EvdLV10riEGntSdAhtC5H4Gi0qcJp5sZnip4V6EtLOVCvbgjZ29ojG9exULakT1gwsMVbDlQAgwPHJHHV7ChF5aJPdXFia4lj2cO2ZQ82E/9yHsoppRsImN+nreoMN+jpNE+j0Px4AwLQPkCSe+TG7eeqzpUShtIiHNfTsl7oLcEB9/+2h4kJjVR4zTSieO6GU1Ww== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DB9PR10MB7244.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:45e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.11; Wed, 23 Nov 2022 15:29:27 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:29:27 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 1/7] add recipe for edk2 Date: Wed, 23 Nov 2022 16:29:00 +0100 Message-ID: <20221123152906.75323-2-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FRYP281CA0016.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::26) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DB9PR10MB7244:EE_ X-MS-Office365-Filtering-Correlation-Id: 7287bfeb-a762-4fb3-a1c2-08dacd678235 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mUrV+agQGLBU2bcH4bG82b1TGi005BvDATaVZ/k/76Z1tW7hkcOFiBtcglyJEUngAyYeh247LhIDN4i1PjvAfnjBPAkmH45qAcAsbV1LuD1ySM0PBqF9FHziRK3hwMX7RV5+WxsYIyqY/YmQRU7ceKasZX/riwYXp8AVd8kaJDZwFuyj8+EKXhzbNwqZIZTDLUXnyeHbViz2PoZeOkj9MKsrZEf1iI2XpB/aA45okA1xgJnTkngIqOyX8/2mU/SWXimVQcXzg33j0nB4812601JwW50aN+dUbdk4/BuvZDdfaITa+ttTjWdAXH6zNaPELuJCrRj7ZP5S33okBZQ/p9uLJc5Yg9coikQHgK5bqG6PnvWq/LrsMK+mdnu3sazbhSq+PHOXuZkYOT5oczeZ59uzfxrnVw8PQEf/0S5N1LQyDsOIQWuroEVxvX/PIAyh9IAAIHRuACnaeesBAzYtbra/dSOUHNp2utPn6HfAoKl1CK6nNEcIDnWtx5aq8EeHlFXr/IA2AWrXFQlFJCMyRoBZ+HXfw0/W7b3H56F5tZG27yi6z/fbwtQGcm+2yFQdtXiUsLMZH0Tx2e8lKzMgasfw5XDFTvjfMjHdko0wk8FyJfU342V8iYGOaU7pmMZlAyfz2UbhPNH+1v/RWb2HMNksSfo2O9Wi9bsaL7M5wUwffGPKsTgGfj7DGtqQ71tca0C/JYTA0pw3MUb4OqQovw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(136003)(366004)(376002)(39860400002)(451199015)(478600001)(66476007)(26005)(6916009)(316002)(2616005)(6512007)(5660300002)(8676002)(9686003)(66946007)(4326008)(66556008)(6506007)(55236004)(82960400001)(186003)(41300700001)(1076003)(38100700002)(36756003)(8936002)(83380400001)(107886003)(6666004)(86362001)(2906002)(6486002)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dQHxLZp6PFOFWCPoTEC4abZOA/3dnT7tYPhXutOSgbWyxP/2RzUbgvNXap4fksRA3FG5Yvz2rtX2a0MobrG437DHT8xo4JHMit6NsFRnGQcWSFMfBZG3FbZ36M8coyAJNqwfVJB0X1yOQIEQlNhPFvJ+jYNtZAYaXKXNPjL8zXQM8u1YpcSXUliTv2ueT8cLUySCveVrdEYoAxkVR6StNdopG8uGJk/pwijiKIz5lcMih0dSoyQaxSq4KFDBFFCtoiliki2t4YgtQrJNImAvVKnHi2rkb+AjZRz+kk3lxnAMz83r0Y0dvT4KQAGTA3jgfr2WociwD5e5f6HW/uj3uO2r7PWZnzh9I07mEtvKNT3d6+ArYv235dYZHLv8ht5ECuHmlJDvvxJdWJ32KNrVp1yWLD5nip/LnO/A+X5BQB2QYq5hsR6tnEhMr6n/uZyShxWpu0YkMybUvqihzXyEj532y8DK2zrWnLJfvBaeCdhcV2uiJgqjby3d2V5Us1/7J2w/q9iL7roj6/KDh10HAW7eoFBedqNfXB9vGLp3scfksEG3NwjCE0mRKaDPGxbk91XJpZHp/C/OK0BABiGvpFoLCl2z3nT14erE86c+9Ti5Kt1ZW39Udw7GjRzcREj9Bq6t4/uL0P0cQnI8jPAgKMZ2//qEbdlBkVvUyjya2dDctIrxbJ8HwZYa6RiriP/Be+Xy7Phci2t/bmoGa8mpLeA38heKZp/S/6XsfSEGPAXNhyYjSfNhcMfOI2eJkGql1WAT4G6SHKvlbSVkMGDd93aaPYfICHGUp3Ohoq/NQpGin4DcB/LzN9jBxfnSILjzegNGgFvEGbIm9TGBbISdgqgiolVaNAVHnJkRvql6pERKlfwctvAoO/nC3oF+og5POG41yOTWlFioS1AwAutTgZUY46fukdkGiRTKo8qnJOYczMr/kEQQVWY2h3alZiGRAplC8hozK8L8oI5vS9esP6CrBKw8CHxSE/Tn1/LGOJdg0+3ehTFz/UHqNZbBm3tn7LF6fEba/z3CHvj+kR4kWQp7TpPN02wlM8WPcsEuqixLzUlWDutXgTP/De1YMuHw6Er99agyepm8eQrzhLe6UtzZQG0/qMrPyhYt7VP5GQu67Z2ARIFjsGMp9+UPF8lZpSBw/t5i6mvwkKVF503iZOaWTnN8RGZYZ3J1FEzqiprud2/+xE+l5gjCoQ+PzpTxDLOwZ1cJA64O3/Qk6OyqrLRdOunyBYs/YCPEJ1IMsuoSIzlikddWwLflzg6hI4R7LxU6mJL4fzu8J6lI5t2Fq9RRbvlv0zMn8pAF4affTNh0qoTEgTn05yOsFqKTTKtB2Q50V3wWbqxgwYy8XPnMrbUJKEeaWvbdtfhQAdmy+L8QQ/cvY0jYL6gbx2F9yuf58sUh0Z0GYbgWBL26iteP3yO2OF1GkaZF6XhLUaCoTRJT0bb3B89W7XU/eV7mdaIEfdQH/0AM86KIVY15Veg3j36YSJQeSkACnrItxqP+jk72z3oBZ6JvEARPYgcahx26yQKrmu0QzIWyOOHdOYMZrdIQV3BBT4UNdsARi9WmeJ3Gv3zfn85szUDDxgmXpOkYpIsAOfxKh4CN+fK4dgTvaw== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7287bfeb-a762-4fb3-a1c2-08dacd678235 X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:29:27.7162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0d8+nRTWD2o+MbfgbRgEBUHoNjofuAwWhmhj0iwYoPx4Ls/ZmI9JU0gaVmYFqPqqvI287g881kw3e20XXnd1bk8ydHFAIQnIRI4qycxtHB8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR10MB7244 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 ; Wed, 23 Nov 2022 15:29:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10091 From: Sven Schultschik provide a recipe to create the BL32_AP_MM.fd binary by edk2 which is needed for the qemu optee generation as dependency. Signed-off-by: Sven Schultschik --- .../edk2/edk2-platformstandalonemmrpmb.inc | 56 +++++++++++++++++ .../edk2-platformstandalonemmrpmb_202205.bb | 12 ++++ recipes-bsp/edk2/files/rules.tmpl | 61 +++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 recipes-bsp/edk2/edk2-platformstandalonemmrpmb.inc create mode 100644 recipes-bsp/edk2/edk2-platformstandalonemmrpmb_202205.bb create mode 100755 recipes-bsp/edk2/files/rules.tmpl diff --git a/recipes-bsp/edk2/edk2-platformstandalonemmrpmb.inc b/recipes-bsp/edk2/edk2-platformstandalonemmrpmb.inc new file mode 100644 index 0000000..3277cc8 --- /dev/null +++ b/recipes-bsp/edk2/edk2-platformstandalonemmrpmb.inc @@ -0,0 +1,56 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2022 +# +# Authors: +# Sven Schultschik +# +# SPDX-License-Identifier: MIT +# + +HOMEPAGE = "https://github.com/tianocore/edk2" +MAINTAINER = "Sven Schultschik " +LICENSE = "BSD-2-Clause-Patent" + +inherit dpkg + +SRC_URI = "https://github.com/tianocore/edk2/archive/refs/tags/edk2-stable${PV}.tar.gz;name=edk2 \ + https://github.com/google/brotli/archive/${SRC_REV_brotli}.tar.gz;name=brotli \ + https://github.com/openssl/openssl/archive/refs/tags/${SRC_REV_openssl}.tar.gz;name=openssl \ + git://github.com/tianocore/edk2-platforms.git;protocol=https;destsuffix=git/edk2-platforms;name=edk2-platforms \ + file://rules.tmpl \ + " +SRC_URI[edk2.sha256sum] = "e6cf93bae78b30a10732b8afb5cc438735dc9ec976ae65d12dab041c18bb7987" +SRC_URI[brotli.sha256sum] = "6d6cacce05086b7debe75127415ff9c3661849f564fe2f5f3b0383d48aa4ed77" +SRC_URI[openssl.sha256sum] = "6b2d2440ced8c802aaa61475919f0870ec556694c466ebea460e35ea2b14839e" + +SRC_REV_brotli = "f4153a09f87cbb9c826d8fc12c74642bb2d879ea" +SRC_REV_openssl = "OpenSSL_1_1_1n" +SRCREV_edk2-platforms = "3b896d1a325686de3942723c42f286090453e37a" + +S = "${WORKDIR}/git" + +DEBIAN_BUILD_DEPENDS = "python3:native, dh-python, uuid-dev:native" + +EDK2_BINARIES ?= "Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd" + +BUILD_DEPENDS += "" + +TEMPLATE_FILES = "rules.tmpl" + +do_prepare_build() { + deb_debianize + + mkdir -p ${S}/edk2 + cp -a ${WORKDIR}/edk2-edk2-stable${PV}/* "${S}/edk2/" + cp -a ${WORKDIR}/brotli-${SRC_REV_brotli}/* "${S}/edk2/BaseTools/Source/C/BrotliCompress/brotli" + cp -a ${WORKDIR}/brotli-${SRC_REV_brotli}/* "${S}/edk2/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli" + cp -a ${WORKDIR}/openssl-${SRC_REV_openssl}/* "${S}/edk2/CryptoPkg/Library/OpensslLib/openssl" + + rm -f ${S}/debian/edk2.install + for binary in ${EDK2_BINARIES}; do + echo "$binary /usr/lib/edk2/" >> \ + ${S}/debian/edk2-platformstandalonemmrpmb.install + done +} diff --git a/recipes-bsp/edk2/edk2-platformstandalonemmrpmb_202205.bb b/recipes-bsp/edk2/edk2-platformstandalonemmrpmb_202205.bb new file mode 100644 index 0000000..84761c9 --- /dev/null +++ b/recipes-bsp/edk2/edk2-platformstandalonemmrpmb_202205.bb @@ -0,0 +1,12 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2022 +# +# Authors: +# Sven Schultschik +# +# SPDX-License-Identifier: MIT +# + +require edk2-platformstandalonemmrpmb.inc diff --git a/recipes-bsp/edk2/files/rules.tmpl b/recipes-bsp/edk2/files/rules.tmpl new file mode 100755 index 0000000..388e49a --- /dev/null +++ b/recipes-bsp/edk2/files/rules.tmpl @@ -0,0 +1,61 @@ +#!/usr/bin/make -f +# +# Copyright (c) Siemens AG, 2022 +# +# SPDX-License-Identifier: MIT + +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- +endif + +export WORKSPACE=$(shell pwd) +export PACKAGES_PATH=$(WORKSPACE)/edk2:$(WORKSPACE)/edk2-platforms +export ACTIVE_PLATFORM="Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc" + +# https://github.com/tianocore/edk2-platforms/blob/master/Readme.md#if-cross-compiling +ifeq (arm64,$(DEB_TARGET_ARCH)) +export TARGET_ARCH = 'AARCH64' +else ifeq ((armhf,$(DEB_TARGET_ARCH)) +export TARGET_ARCH = 'ARM' +else ifeq ((amd64,$(DEB_TARGET_ARCH)) +export TARGET_ARCH = 'X64' +else ifeq ((i386,$(DEB_TARGET_ARCH)) +export TARGET_ARCH = 'IA32' +else +$(error DEB_TARGET_ARCH $(DEB_TARGET_ARCH) unsupported) +endif +# When cross-compiling, or building with a different version of the compiler than +# the default `gcc`, we additionally need to inform the +# build command which toolchain to use. We do this by setting the environment +# variable `{TOOL_CHAIN_TAG}_{TARGET_ARCH}_PREFIX` - in the case above, +# **GCC5_AARCH64_PREFIX**. +# export GCC5_AARCH64_PREFIX=aarch64-linux-gnu- +# using export here at TOP Level does not work, because +# GCC5_$(TARGET_ARCH)_PREFIX gets deleted again for what reason ever +# Therefore it is set right before the build command +# export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)- + + +export SHELL=/bin/bash + +# ENV Vars which should get set by edksetup.sh +export PYTHON_COMMAND=python3 +export PYTHONHASHSEED=1 +export CONF_PATH=$(WORKSPACE)/edk2/Conf +export EDK_TOOLS_PATH=$(WORKSPACE)/edk2/BaseTools +export PATH=$(WORKSPACE)/edk2/BaseTools/Bin/Linux-$(TARGET_ARCH):$(WORKSPACE)/edk2/BaseTools/BinWrappers/PosixLike::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +override_dh_auto_build: + source edk2/edksetup.sh --reconfig + + CFLAGS= LDFLAGS= make -C edk2/BaseTools + + (export GCC5_$(TARGET_ARCH)_PREFIX=$(DEB_HOST_GNU_TYPE)- && \ + build -p $(ACTIVE_PLATFORM) -b RELEASE -a $(TARGET_ARCH) -t GCC5 -n $(shell nproc)) + +override_dh_auto_install: + +override_dh_auto_test: + +%: + dh $@ --no-parallel From patchwork Wed Nov 23 15:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053821 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 65C7DC433FE for ; Wed, 23 Nov 2022 15:29:45 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (EUR02-AM0-obe.outbound.protection.outlook.com [40.107.247.62]) by mx.groups.io with SMTP id smtpd.web11.23210.1669217380593700312 for ; Wed, 23 Nov 2022 07:29:41 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=tfIFW5dw; spf=pass (domain: siemens.com, ip: 40.107.247.62, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XOLboHnaynamH5gE/sp/2jSWI4Z8C1wqNJdjCJcLY0b8X9cLZIqD4Ae3XNz+apQioW+aQbhc/9ze5o9FK+y1kf6tr6vz1Qa8DlmIyEow8GhOjI2jLR4nnds+ZcBC9ciX/4WertAFrE5FRoEIoXd2QNftCXzg9WdT6Dt+VA10Fs55o9YP2PXjIXVM5zGSP6IH2d0PNvuRhBvHMPly2TYGiJ4rVJ7qasl/+nYeHNgeKirPIbNZ5V82N/0lCuRokY0lyKXpmkOfttlYcOTSiVyr3FLtGt0YzvrSo8sNwcgHX1Q6YcnUtIckAbsTGXc3JNvM2HAsscOJ0HaNqejvSaWcYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oqfvyF6RD9nWdDYRry5FxZOhSCc5UYvo4G6EgFXT3Ms=; b=CTi9ZAg/t1cYf25qQH51mGj3nC2onV0fbTHEWO8JK1ChUkn+3v1hl3wKe9VrOK8fzBu3MZwqJmEDbrcWmAXGTYLUHQLX5PG/lalOH0IJIkJoEK+C+SVTQdgh+Cc+GPr3FQWxy2R5FDcjc661wq641HxCrEREP/xVqTMTHtnoX0e6AztN37NVq7Rth68hyVL32SjbuhuZNTeMtWaCgkSUfJJ0/HEFslW0gBrnlx4SokJtUNpj8w/H2kpF8e5eJqMd8QxUv4gnRtnGrAhMuT2Mv+Ho05C9FCVabvOEAman+ueYUarGqRE2GD0j9AKZ3nif3ExptdXai794YeRnyvRbSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oqfvyF6RD9nWdDYRry5FxZOhSCc5UYvo4G6EgFXT3Ms=; b=tfIFW5dwMdU7lpol6uEBHY9RAN0D+hAYj5DD0bui7D54WT1NjUU3GnvUiXm54MuFAuktWqt6JgQ8sNL+LLQNhSO88tW5hqXZnwu+w/Yc0QPxF0GRKOZLzthsbz6jt/LzaY+klbvC1acENEn1vVxqm/IyyihMyZ8ib7DLh5qHO/v9lFtPHMdT4Nj/cK6gk/6iFdQTvN6lTxhSvXhGmgNLcnEL9eBT/eNmeNkvjNOaBNYLUTudqrhLhUX/JkARfqyCWIPNQHdXdVB1JmXQxb1Dg3HTRssYOmwysadyDWJhlz71YBzy5qIcUg7YiAjGEjMywHKzqpsjMkMVNZesiAOnWg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DU0PR10MB6318.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 15:29:37 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:29:37 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 2/7] add recipe for optee qemu arm64 Date: Wed, 23 Nov 2022 16:29:01 +0100 Message-ID: <20221123152906.75323-3-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FR2P281CA0091.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9b::10) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DU0PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: 1774c422-3f3f-404b-cf37-08dacd678830 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ul4+LjKH6xWXRIJ9XfJ5lVJcN6kJm/cSlnR3vNGJ43vAS+Fx2PVUYptmHTygcPGU89ql9BQVM7MagAKA3YSf7+qZPOT3KZ40X+YHGkKYjAdE4gFYhEygDFQ6Oo/JE9aLI53GqCJc5wNXnuNmDWIIXeaFMFe3nJFu+f9qHjjG73HyNnLEWsJI4ogc++5z1As2WWc1whoGtxRO4BLuiAOKOH7p2k/eR19u4ohzHu1dRB/AXL/zYnS71w+p3vrs6n0Rl9Bm6UI+7JLJn0O2PaeUxub/aFZhieiRpXt2qCCr7BzCVm1q5lDZDK4QR62qG+J8CzZP5h/Pdgt0yrgoYzkL+FV5OtbGRLOLBqvkEdUVwdeJaUbD8yOKwYh804XXFVDUv/ftrW9VZyoPPDKKpssBsGDJuW68PygF681AZF9/LyljWeBG3Ell6sU22tyTwGsbO+wHg1SB1jLq34Dq12UfpzDbP8SnP7i7IDbUGJqMJA8/TTdPGwU8P9VYv4aC69KfYxg6bvv3a+9mkK2W1L2yOMi/2wsHXiPatZWodOYer8OhjY5TbM8ok3A61U7/mOW8w/45btvEdlcIf4YZGjcJGsiyM2EOdjBltagG97GA37qcgyB6JwdS0mYMKmylk/N2uq8ClvEnUVzs3Bl4rK3p3rLiWWPzsBRQ3K33oioDnY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(451199015)(6666004)(41300700001)(107886003)(478600001)(6486002)(9686003)(4326008)(66476007)(316002)(8676002)(1076003)(8936002)(26005)(66556008)(66946007)(186003)(5660300002)(36756003)(6506007)(82960400001)(6916009)(55236004)(2616005)(86362001)(2906002)(6512007)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vc73/GGM3Zie+dS0oWqjOnc8y9vWUlrq+yx4KxqpwGFL/VTPoQq+NGJBdanTBuYxPiXCvhgh5dE0THBlXu8MeWbsqjxE4kPseBRkXvtmzlV+jZFiNt7mG00qnOILrK3iZ6bKOEbA91KeAbxuzAmQXVzT+x6Wnqjd67a5gyj2RefeeivDlLeGMIHsYONv0jc1yyrP9kbDoMw9zdjvaOUb4138nRvfO6rVOwhVIDHB1tz1IvrSHuADN2rcRK8hkoY8oXwCY5zhLW8CDvjp6cJDn6bTKwUTTeUe4EnGWBRZybbFAVlKVQZ+KumocxwIj0QrqnwCIb+Sq77kAbVRxC6bO1PdRNCo7akh/2uMRwETkQUgU9JPW2ddEu/sEvvTRnqew0h8k0mJP0XcMogewdqt5/VGglrgZI/MsdXeSLi3F5BYb2Ru+qnzENF0YqYI1I7By3yGRZKhJ7HjmjPA/mjAhO2Ol+M7nvOro3+aDLFeZCtivmIDuyZdqtjHMI5ezBrwAUIknmdSJ0FD8diRn2BR8u7/SjYB4UyvqhCXmUKtyoeHuxxW4Oql/HGsOM6GZDfT4zKkYJbcQiPlkhAg6CHsJTNbKdhlJvVo7nLwnCwZvhrnNxvBm8GBfEeBLwA0BcaXv9zApXXDtp3g99TPqOTAfGhccSXN9ZP+WuNaK/wd8nZRuo+Sb7nOW7iDodAgudxSyzcwCsFCVxEhY7F4ocx3uOPHNOT6fQX8Y0GlLenLo6ValpOHXg1fJS1UAnHvOCVzJiUaxpWnDy/U9yvBG/UIO8+CDYZdYkZntrAPccnvLWGm1P70EExrwh1xkPBkPeSnlQcewzfNO2jRYYtIdWbYTTiiK4CMKuqPCQzue11qFdbONewL1u0BvHfZqJT0Ys76T4x10Kvd/ygcnjrQ7Olas2Y8RJZnKVuqio7pxn5ooIH+Xz8blpWsxiZpBRh6h/gDeNut4pHlczGzFJkeaSberrXRhFEsvdfLBgsC5rWscaVX6MXS9DCZK7Yk4jdXAjagU3QXIrcImWZBcRX+DLaQBhb9UkZG5raRA7+eDPMJx5CMJhYHTfKwu5q7wpHhxZbX0Pgtg6aB2mWAnHa9Tga4LQC3q5LL8nRXMykJ+DVVZIXWEPXn3iWOwvrqk0uhOG4ESLZ2vBrPRPSszLbrmGEr2Rd+zb72YmylwPKug4A46hWJN6DbH8g42AIXsNsiYIKYxFnFSTSk/TvQKaSuBJ9NI+GR77Isdm++nCqg3CGeFGBFGezrZc4mPAVQ/d8NcblNtzQpynjKD53q250/qsdmGJKV5+Bj+1KYGrIEUOfg9EsPVPWEA4mGm9jFwnmeiwtPh76ThaVcrxoNZ6uDqVAtagJjA+u0lk3p3DyX7vlEOZ1XBE8Ww06Xff6UJeWccMhA0rb0D+PRWA5kt08Vmo7AAc/XYXNE94LyZMBDBHzWx9K3l+O8KYHaxu0xH+opTOe1wLsA2HNY6MHvtme4sFfdJcbyGd6vuYXsvzlYjkExtHZToa6rDASzwYGxBsXW+2WjPYUDN875Rw4/An+2UmIqNOGyLJoJyqrZpB4QyK/d+BpuzV+FCpW0nk0x0LiPmKSqchcAoMmPXJkxQ4QPBaW9mw== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1774c422-3f3f-404b-cf37-08dacd678830 X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:29:37.7508 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /M+s8JFzcEHVSaAXI3KZG0zTuJubYP3v9P2swny7/21JMFknTmziRsNig8Ompq9422z1WDGzg0TbbR/ULAVm0i2SeI+DlTKCce/2wi7cbFk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6318 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 ; Wed, 23 Nov 2022 15:29:45 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10092 From: Sven Schultschik The recipe provides the possibility to create optee-os binaries for use inside of an qemu secureboot setup with edk2, rpmb, u-boot and uefi Signed-off-by: Sven Schultschik --- .../op-tee/optee-os-qemu-arm64_3.17.0.bb | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 recipes-bsp/op-tee/optee-os-qemu-arm64_3.17.0.bb diff --git a/recipes-bsp/op-tee/optee-os-qemu-arm64_3.17.0.bb b/recipes-bsp/op-tee/optee-os-qemu-arm64_3.17.0.bb new file mode 100644 index 0000000..2568c0a --- /dev/null +++ b/recipes-bsp/op-tee/optee-os-qemu-arm64_3.17.0.bb @@ -0,0 +1,54 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2022 +# +# Authors: +# Sven Schultschik +# +# SPDX-License-Identifier: MIT +# + +HOMEPAGE = "https://github.com/OP-TEE/optee_os" +MAINTAINER = "Sven Schultschik " +LICENSE = "BSD-2-Clause" + +require recipes-bsp/optee-os/optee-os-custom.inc + +SRC_URI += " \ + git://github.com/OP-TEE/optee_os.git;branch=master;protocol=https" +SRCREV = "${PV}" + +S = "${WORKDIR}/git" + +OPTEE_PLATFORM = "vexpress-qemu_armv8a" + +OPTEE_BINARIES = "tee-header_v2.bin \ + tee-pager_v2.bin \ + tee-pageable_v2.bin" + +DEPENDS = "edk2-platformstandalonemmrpmb" +DEBIAN_BUILD_DEPENDS += " ,\ + debhelper(>= 11~), \ + cpio, \ + python3-cryptography:native, \ + python3-serial:native, \ + device-tree-compiler, \ + edk2-platformstandalonemmrpmb, \ + gcc-arm-linux-gnueabihf," + +OPTEE_EXTRA_BUILDARGS = "CFG_STMM_PATH=/usr/lib/edk2/BL32_AP_MM.fd CFG_RPMB_FS=y \ + CFG_RPMB_FS_DEV_ID=0 CFG_CORE_HEAP_SIZE=524288 CFG_RPMB_WRITE_KEY=1 \ + CFG_CORE_DYN_SHM=y CFG_RPMB_TESTKEY=y \ + CFG_REE_FS=n\ + CFG_TEE_CORE_LOG_LEVEL=1 CFG_TEE_TA_LOG_LEVEL=1 CFG_SCTLR_ALIGNMENT_CHECK=n \ + CFG_ARM64_core=y CFG_CORE_ARM64_PA_BITS=48" + +do_prepare_build_append() { + # $(ARCH) is the CPU architecture to be built. + # Currently, the only supported value is arm for 32-bit or 64-bit Armv7-A or Armv8-A. + # Please note that contrary to the Linux kernel, $(ARCH) should not be set to arm64 for 64-bit builds. + sed -i \ + "s/\$(MAKE)/ARCH=\"arm\" CROSS_COMPILE32=arm-linux-gnueabihf- CROSS_COMPILE64=aarch64-linux-gnu- \$(MAKE)/g" \ + ${S}/debian/rules +} From patchwork Wed Nov 23 15:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053822 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 66EB0C4332F for ; Wed, 23 Nov 2022 15:29:55 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (EUR02-AM0-obe.outbound.protection.outlook.com [40.107.247.75]) by mx.groups.io with SMTP id smtpd.web11.23214.1669217390752011002 for ; Wed, 23 Nov 2022 07:29:51 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=X3sO1I/k; spf=pass (domain: siemens.com, ip: 40.107.247.75, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mcqhGM71c6xvPhFoxh9La2i2PQxfeMasV8U3ruqZJGwBbFTJ3OJmMNBNmSLPN0W1qs0LjMoc4bYW1xVXWno2ytaLdiBEQFAu0gIkNzBeIfwjDxtzHyV721TS1o/4XtC2TdCHGOhSCmTkfH9KiGzUtoe1TUZvTvSqTarhDEBmBL2k1FQeYqZJg+PNMS/TwgGhY9diTj1JsmNWtUSa72lOCpl8OQmI53ekQ4a2+odHdRzC1Sa4GhhLHG76Mucym14eFhCLzhgPtObCyQQ1bUkrxWa8Y5g4aUdMptYlDzpGUzDvQ9kDIo/XUt1vwt5m4qYz389D1NE6vigdD7+x10a09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OupTKXhYk9qDM1ix+oJWDCIw7U8jecNDIbZldGGWHDk=; b=mC46lCY59sg5ITXkVv9JpV8CkthtJ6gh3xda0bchAXVN9k0kNs9N4ZtKiATIT+f996Hbb2cLabfVjyA+KBNWA/5iolpFR8zlHtgdETIUc1Xb+mexZjI6O2zoBi0lXuvb5+jDl9negbEBARBVjedm+j7j45o+6oRTyaCx41KupHV80J9oZcpUnOtqwiENQFqaGHGSWYOVCCyCetZ+YVDXZT4V8f1KyIMKjDuyl3/Y9EY2GRJwKk7R9a5NwV78JJPWFmQ/tDNAK+3WTfUmaP876HuHfielbA1tl8DNIz6bC5fAlHuf/hs7DT+8Pm4OzF+CRwbAnLDioq5RM6+S/8C9Yw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OupTKXhYk9qDM1ix+oJWDCIw7U8jecNDIbZldGGWHDk=; b=X3sO1I/kFIx7WBdwCOXhHM9eSVcJumBOxkK8bXUIKqAbtM+6DZHMCiUt06OCiL1NUY57dk/KeCmZ3wtph+Hv1p4RTJY2D6sKYSVn/74Rr2SH+9odJYcURiq2sCZSujXBpnulPbfj91aflxjDPnjK5Hgo0g+30N24tQIBQlwFPTgUi8EHmYxvp4VGSDEfoeBZ4MslFn6Cz+tvZahbQuMFwNE9Us0kWB/rRDacignuw1h+SQVu/1KPEoDJZqQleKafPGT5RsHe/E32cUOGSXq7S7MMCyGfAMhMpKGLPZz4ZyvNztcq/r/T2y8npc9pM6aLFyulh3p24lSSBPLt5cpEWQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DU0PR10MB6318.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 15:29:47 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:29:47 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 3/7] Include optee into u-boot Date: Wed, 23 Nov 2022 16:29:02 +0100 Message-ID: <20221123152906.75323-4-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FR2P281CA0035.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::22) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DU0PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: b1538344-276f-4634-f31c-08dacd678e32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YzI4Gr9FpcvaW8fMIx4J4vfN2FFwEX2OEb4PkVoY+y5UwbUYsdbT5iqne9Iu49BZjHan+a4QO6/r3LZugQ8rbcItetxvKeIvex0HDWdRVnJdf8heGcOdyVYRI/RF4KGRMg8qRb+2SiNY6jTWbsuOaXSDnRPcf9tUTjXF9N5SeKbJ61fz5h/0n6v8wJIesf70a+85IshIPDnToexVBq1EP+dwJTdCZZnhuTVtNVrM8rl8ZwjV/uPxRbnFBdFBWQEzyiaXNylxfla4C6G/CZGW29qjfSfid1JmwuYgjBJRC3964w320BWAyRy2dHag6z1nXj24Hy66dO5p14hehYtlWvwU3um4HQy/EdFZ234OFccgZrKgy2UUJzYcF5fZDEFS1iYgRqHhLrt+XWzYaBxkCrHN4C6kh2U+KCeoyzmuhnHcEq3QghcO2EIxRU0aD/HauyMfQMkPtuzAxylV9g4wT6tgwUiO+eIV51hsuDTIG6dAURtCjhbTx5S+VUWjZibyZpB/wMHdRO7TmiV48PXARg+rqZ2uNRnhM/KszDV+QEI/nK7VJqd7ywbGSKn3lz2maKuL5SfIi1CQZd/m7f+2Z+ODg2l73j5YmPi647mVdWutuOWI3YPU+4c+I5vI1kefBJMNVhtWvYpkdQvcOG+AIw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(451199015)(6666004)(41300700001)(107886003)(478600001)(6486002)(9686003)(4326008)(66476007)(316002)(8676002)(1076003)(8936002)(26005)(66556008)(66946007)(186003)(5660300002)(36756003)(6506007)(82960400001)(6916009)(55236004)(83380400001)(2616005)(86362001)(2906002)(6512007)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tOIJLYNrboMuUya9ImJiPo/Vpiu5eBnF/rr5VVJy/Hy68K9mXTAKS5WVbOpO7A2e5j3b1tgAeVijzTa+ZJ0NK2JBEqRXdbSwQCIqDgivbkyyT61wZotvOkxDWaz+uVhIgm+GGO/atIsj9JU5UF267LGlAoGsvRcHHz+HpbVRHY0ejhkaLxq2CMuYz9WPCoTvtSxU00vvU4gDc2KuthQUu4aMLcRQdWVn4UegXY1Rcn/2lm12r3JqGvCeBejM/yl3sIZ99e+xVQtL2d/bsMEb0PdF12dcxUSyKIi5JvsQpr6TZBzK7Sj7Z5dC/Dle+hQIlFJP3RnZTNhttfsobuW8FlsyNcMoGlNqgWuLirvyulLb2r7PIoXa7Ep3ZpH9pprZ9b77dasRSuZNagGb110m1X6vzbeGNbs/jxYN8esRR6muTls82hqNyApON1Yb+cSzSntvRDr0OBXdDI1EpWTox0aEAAsm+Y1PRhSOtcGnqNXWZIjuOf4Jxk5+aEaqycdU2aULc5Ov1RgPmR8pTrNtrVTAJTCD66RIx87xxMSFuiCzDBydFG2Sekyq6dE0hLfzDp40exofR2qGK87s2vIpeKoPz+XiX6AHjf0jdVROoydILQXLAdxBT4bB2CNGfLTPJuW4qqCpdR1MJmOCXH+zlNo2TQcmI+RLsRr/3D+hiXt2MqZAnGz3M0fXauKTUOKgeGU3LFU4YWpeVZ6qwBOKvlDaHg9Tj1Ujy+xjPa9m4QGNq4eg1HhxvZBHMg+3Zztde1/skdiS6kBngJwjxfwOksIEzQVnzKrkDaxP/dScf/6WaQ3IThhPSGkUIQEHpFfWWkD0zcfUDmgOXmBk6NMSot52At7vceJtuyZ48/tRuavbpZb0JYv42f8rbOr5iDWuajlZ8+zKvOqKxsLOU4doAQlFNG7J14TRJJIo2jC5Lt3YWbpVvMJh9DbuTecaYRNIv/Yan5zGlwjxOnsM0c1PeDD8rykVkc3SW7DUcBXpej0lW6fQNcZzMNV23W+fpGOtMzUQX//KKwE0S+GXrvtiAdkSHAIaSa6Ul3Kp69ttC1GlhU85/ZaNwbgNURkPOvivKPCjeBmk6B4itXiSaa78+pWNg7WYCgi92DKA02Pr1vuWLCqi11IEAU1fr9bxhIwJ1fKBSUltMCcaGz00u3z8raBOBPQhDYytv7P0eA8mNRGTAuvVbTzgyMm62QX+apkMQ/1G+lPRStgvESQzGQH0APG7BIWIqS6qqFKEPyJTjEl1uk/iNtspW2X1j8tbqENOulEOLBSFBeWyRMrxwzHWUuj5kxoraN03oydG35xt8s5AyGlxgzuU8+8AO1g/N4atLVDKYuY6E5JblkQCgA0Qkw9ZaFfEVIfMnvi1UktiwFwW+jiBlEm1hL3FK8aup1RuCE8zLkCdcLphpyl/um1nQixZYpYOAgAIx5hHZbnmH68u6j1GGztF+BW1GAxbjn6HEQY5mZeoBgDMduAK5tS3hUkxsnrPoBQGc665sRhvMByou4G9ccU4/flscKb3S0zGMX16mAfuiJhR1muYhPX15J20H3GxR4I0o4u/Tlig/emq/hgJJAYfvw/xdVztfpp5XkCwdoJqUFfbFoEhYwNkJg== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1538344-276f-4634-f31c-08dacd678e32 X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:29:47.8313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zaAThFdNBk22OMJSrkUwFDcxoBfiJ3vm2e2e87saDmzqtvjkiKEYOsvn+0SABXLF1N7T7GhjfMeePnjPybc+xA2OKZVUaAw64+ELuca23ao= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6318 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 ; Wed, 23 Nov 2022 15:29:55 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10093 From: Sven Schultschik Optee is part of u-boot In the secureboot scenario to use optee and RPMB as secure storage. Signed-off-by: Sven Schultschik --- recipes-bsp/u-boot/files/secure-boot.cfg.tmpl | 9 ++++++++- recipes-bsp/u-boot/u-boot-qemu-common.inc | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/recipes-bsp/u-boot/files/secure-boot.cfg.tmpl b/recipes-bsp/u-boot/files/secure-boot.cfg.tmpl index 956dcbf..2b75988 100644 --- a/recipes-bsp/u-boot/files/secure-boot.cfg.tmpl +++ b/recipes-bsp/u-boot/files/secure-boot.cfg.tmpl @@ -2,5 +2,12 @@ CONFIG_BOOTDELAY=-2 CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="setenv scan_dev_for_boot 'if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/boot${EFI_ARCH}.efi; then load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/boot${EFI_ARCH}.efi; bootefi ${kernel_addr_r} ${fdtcontroladdr}; fi'; run distro_bootcmd; echo 'EFI Boot failed!'; sleep 1000; reset" -CONFIG_EFI_VARIABLES_PRESEED=y +CONFIG_EFI_VARIABLES_PRESEED=n CONFIG_EFI_SECURE_BOOT=y +### OPTEE config +CONFIG_CMD_OPTEE_RPMB=y +CONFIG_MMC=y +CONFIG_SUPPORT_EMMC_RPMB=y +CONFIG_TEE=y +CONFIG_OPTEE=y +CONFIG_EFI_MM_COMM_TEE=y diff --git a/recipes-bsp/u-boot/u-boot-qemu-common.inc b/recipes-bsp/u-boot/u-boot-qemu-common.inc index 0a9a15a..802fc50 100644 --- a/recipes-bsp/u-boot/u-boot-qemu-common.inc +++ b/recipes-bsp/u-boot/u-boot-qemu-common.inc @@ -13,6 +13,8 @@ require recipes-bsp/u-boot/u-boot-common.inc U_BOOT_BIN = "u-boot.bin" +DEPENDS_append_secureboot = " optee-os-${MACHINE}" + do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}" do_deploy() { dpkg --fsys-tarfile "${WORKDIR}/u-boot-${MACHINE}_${PV}_${DISTRO_ARCH}.deb" | \ From patchwork Wed Nov 23 15:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053823 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 90985C4332F for ; Wed, 23 Nov 2022 15:30:05 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (EUR02-AM0-obe.outbound.protection.outlook.com [40.107.247.55]) by mx.groups.io with SMTP id smtpd.web11.23223.1669217401764240586 for ; Wed, 23 Nov 2022 07:30:02 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=cRdIDGcy; spf=pass (domain: siemens.com, ip: 40.107.247.55, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ULkdd+QP3YAWITBHHi4UwoWo3gE2TauIuqHLL3vyPag5MjTxP/oHruZzRdSB6YB1Rs7XN82OnspR/NkdEWhevJBd9u3K+Bc66a5ljXrA8jpTe8lOd51ms5YJygppVJABoQBp4xIQjA/G7hhf5PPn1JA8Dg1mfXdKAQUX8Fq4F/R44R+GSUgQUCDpS2BWNJrRgI5HarjeFHcdt4Dp4XbImDzmzbXyJnuWPAdeNgfUWBn1IR/MgKE4na/msjTIrZO5D6U1NWrKM1vTsJv8gkVBc5bwnTm62qjerAnfdTU3l44VWRIkqQpa00m2sRocLziQw8T3xeVimhWmQiUHgVk7yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6Wo2Ra39gq/Pw+esZstrP0YXRbmJJKvHTKntf7zcmr4=; b=nCtt96jcal66Peg6MS3H++DHu172edqW/U11YRoq18QqMibQlsvkHc6HA6PoVaJVMJa02+b+t7dI058JO1yLfeCRV2W/L3y54pRhN+UugNk95KR5NQhQkPFHb4nB25FmCJyxFqnMVjPo4jGRjYG9Ey3hOGP8eivylaCU/CeBLf74Hskzb1idQnuOMF0NgAwmGTWbvtI2u3zTPik/PvxvrZFJaN4w/JJMM7yEy8d4HVeAJU8yX5TDG1oEe6CK7Uj7vc8Dc9sbfbR6780tC0AW7uyx51Z7qknAwAp1tLQtSH89JqtdHdfp0tAq92emjJxELKtGxCvjDQ9f1Gxaet7zpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Wo2Ra39gq/Pw+esZstrP0YXRbmJJKvHTKntf7zcmr4=; b=cRdIDGcyOJ1YLdYAbWsYjrP7n1UhvAwX3BFso0w8oafx4fAH9nfSA/Z91k2syKQ0eBJkj/0+zcNaO4PnYq6j+KTUImx080H887vK8sqf6cIo67zNJugrjonvtOsGMayBYDVYEga4oIkH4E80pifhmlGuVw0dO10kh56YogeOS+V73cCUP6gxBb7S+1PtyplJO/fhwwKHHghJSKdvCR6JLkWq2tSpKUYMDlSwJWPhqZ2I6JGDtQNNETjT2Sa4U7+bemH/WumQVuivTqTD/mBC+OLeJkrz66rn4qRVa9ZXhcSxjcc+9jx+E5sVPXkfyNa90gb1HN479AzrYyi6gws15w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DU0PR10MB6318.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 15:29:58 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:29:57 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 4/7] add u-boot patch for qemu to support RPMB Date: Wed, 23 Nov 2022 16:29:03 +0100 Message-ID: <20221123152906.75323-5-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FR2P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::10) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DU0PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: e7adf5f8-9756-4df5-623a-08dacd679428 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rtFB7iE8oAaM72QNL5YinJpT76NwweuiGxpYUC2rBne/FyibxsBeK1YORo02EiqglO01p7I4wFLrZ11/djs/Fxb2IMpwGf8L3GV0992Odd4hRsINmr+fF9XLiV3IxOj/mTVz+RiyVCqwEwwgFeraJWhxxNicjQyxT1Tk4ic35BqyONjLC6AlGRNEr5opT8GGuWmY8b7pXdv9r+vf551xQs0Lwe3Ee8apV1XUI8glittFgneM80lhZhHro/g49fzvlko1cWnjhSXCb74bltAAZnWhWTuLJYvfj+FS3hS4NhHzhyfAiphUBZb4w0VUOMPD3daO2cTkVl72BypCMphTIg8XALEfIPTVuiD5wJl/XPP9t3Z/QjO4qI4WQ2Xf902RuPltBMxp31H4w/TitRw1xTNtm5A+c5Ap6SFBnrW1YznbvFoNpQ6vBhfriqgHyYGH0/KMGQ64BJnDL0ZRpDaSq6R/sm/fx4x+s1q3tmBGYTk8Vn5VcmWW/HpdPBWYcerX1gDFRR7faGChfhC6+4Wwt/QKY6iL/MIzAQIsBrva0KeeskOMXh6AY3Sppy41S0sytdW64+kMKggeLm0yHuQiCfRRmtzP3oURULMsfjjKJTyMqLI08eMRRs37fr71aODkt+7qXbfw1klIVti7K3JEVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(451199015)(6666004)(41300700001)(107886003)(478600001)(6486002)(9686003)(4326008)(66476007)(30864003)(316002)(8676002)(1076003)(8936002)(26005)(66556008)(66946007)(186003)(5660300002)(36756003)(6506007)(82960400001)(6916009)(55236004)(83380400001)(2616005)(86362001)(2906002)(6512007)(38100700002)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oU6giRu40QoXE7xdviuNcdGjv2jaT3zABWgdZ+a7PiEnRxvItme9XbXe2gTwnfj9fXuim+uf71B2M439TWmOhauclLl6rO8ayDdCvJWzSBJ14/MlI9/+Fn9h8m83v84rCG2Iz5gHuOyX9/GIdwrYPbVPysfcMMpNxyLsTRLAgUVr8Vw2fP50zBJTP0jaxjbGdxUUDi/flsooUB+7vtNT1NOUUKIg4G4GoNiMWyeeEWByHo9Mo9EpLVcY7vFyTS5UEKKKL8z2XFAjvicbE3mMVZtGCHsGi0/8e3A9TDRHTVmkgDF2HKoKgWJXKK4pHZLpX1nG/tKQOcq5HXbbK6CrRJ+qeaZGJxalU476z/43/qNjlURN5sk/dfEZjygicvup/ztgtxOxJek85/Ep67+4VqQIy+6U/G4Zmvt3Gsb8alS1jd35BHtxoWrTDx+ia2K+01qPOdIkqEj1hffeETslQ/EWrkihq1yoeVljR0mji6vNnlKuA5UbQx0ndUBy8MYMfKZ5eGAEMQvWMZY1aKqqrQW7OVaxgVPZ+yIF7KkutbzMjGHa+dgL0yURUZIfS/Gj92TzNCJc2MXGpc0/8i7hlTWjCz0JWAhGU5GXOOQjJt2dKMoFJ9k5Hoo/CiXlZxzTQ3V9h4S2KYLYvS05qYKwhiYvJQ7IHtUy/RwEHwZgYHpqPI5sz8kiDcY905SQ3jzB0Ih9v63m96NN50WZQfc0vFfsVZjGvhtWhp3XpbP8bh/cvwfEpWP/8h5aABVKz+wcFwFjx1YcdSWCom3Xr58yeWzzfO6BKbU8uO7Q7lCKM4hB3CJINqkSKRP49WGZraBAHocQV5gXmOdjWNJWX4CGd6GlUpcw/rI3N6fnciWV4n1EZ5bc4OrfLLLdyk6Duxd1+Bt6dXAaS8aYITQUNqUy2I3OUyEMLfT+GbQuaNLM/7uTAVZuTR/tPNmxnJHKWQ2bB21wfAvY91PhwBSf+VqORri2DLNKp7dWBGsNuGXCxWtWejORY8k85NKsyxMkJylZo2o/ELjxPRVV82sPTPTxhsovPXw0gYSRywEb2yd4PTcYFClz2pCy7dQIQTw35hp/UeyWxQdYKeXlPW8ajiiIuh4FfhNBg+eRa4CEclcQ9cLi0momqdwXU7+fsfF0Umcl5vCtkKsA2HeOLAw3AArF+m/W9gEAQjD8geMy4JJiG6UiVJDtCc0enRzuLBg3WvhZiC9fgHdNBIeYBbMkmZS31x/785XLWam2VzSxmUCU2uwyaV52fQFb8ohaibjlhPQrQRUIlQcxhQNR2guXDUXqqDxzCFsqQkFqBwGjvwuxNW9yP6nrQITRK2atn0XUS8cPJNmhRyHF4YCBIqHEfOof7BR8TIkSC5TQAtYNb9lgxO50PdInXKNR8TMQ5vAvUkOsFIWhV2P9bXfjUCBXsDc+iLNs8M8P/MSwZxftiP7A+xWisoq3YxyHVgofpEhjmkZTMJuW0FWiS0bhN+tmyS+1ammr5oLFGGg4Drhe2Oco/5SJd83sJS8z8eNIcLas0zcnXj9aYj8mGuKdzl6+vueJWOCwT7D82U7FmPX9wr6MILtpSYCwdbisMHvwtHFnJ5gOVIN5eAVDCRc7KoLACK5dyQ== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7adf5f8-9756-4df5-623a-08dacd679428 X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:29:57.9377 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YqBruUUE26SOG/xpAN5glcyp+CkaomEDn+ysYXt7P0Fx676f4wFFu3Rg1RxVrSXT+Msqp+TfiFpjkrvN93+Sc4Kp0mQ9bPzq+R80TAHplws= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6318 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 ; Wed, 23 Nov 2022 15:30:05 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10094 From: Sven Schultschik Qemu itself is missing a implemented emulation of an RPBM (replay protected memory) which is part of an emmc. Therefore currently a u-boot patch, which adds a RPMB emulation, is needed which breaks the u-boot hardware support. The patch is only included into the qemu u-boot recipes and can be removed if there is an official qemu rpmb emulation, which currently does not have any ETA. Signed-off-by: Sven Schultschik --- ...hack.-Breaks-proper-hardware-support.patch | 1375 +++++++++++++++++ recipes-bsp/u-boot/u-boot-qemu-common.inc | 3 + 2 files changed, 1378 insertions(+) create mode 100644 recipes-bsp/u-boot/files/0002-rpmb-emulation-hack.-Breaks-proper-hardware-support.patch diff --git a/recipes-bsp/u-boot/files/0002-rpmb-emulation-hack.-Breaks-proper-hardware-support.patch b/recipes-bsp/u-boot/files/0002-rpmb-emulation-hack.-Breaks-proper-hardware-support.patch new file mode 100644 index 0000000..26266b5 --- /dev/null +++ b/recipes-bsp/u-boot/files/0002-rpmb-emulation-hack.-Breaks-proper-hardware-support.patch @@ -0,0 +1,1375 @@ +From a4179f663673dbfa48f79761acc3ff781ee9b2b8 Mon Sep 17 00:00:00 2001 +From: Ilias Apalodimas +Date: Thu, 12 Nov 2020 09:44:54 +0200 +Subject: [PATCH] irpmb patch hack + +Signed-off-by: Ilias Apalodimas +--- + arch/arm/include/asm/gpio.h | 3 +- + arch/arm/include/asm/ioctl.h | 1 + + configs/qemu_tfa_mm_defconfig | 53 ++++ + drivers/tee/optee/Makefile | 1 + + drivers/tee/optee/hmac_sha2.c | 126 ++++++++ + drivers/tee/optee/hmac_sha2.h | 74 +++++ + drivers/tee/optee/rpmb.c | 27 +- + drivers/tee/optee/rpmb.h | 1 + + drivers/tee/optee/rpmb_emu.c | 563 ++++++++++++++++++++++++++++++++++ + drivers/tee/optee/rpmb_emu.h | 141 +++++++++ + drivers/tee/optee/sha2.c | 249 +++++++++++++++ + drivers/tee/optee/sha2.h | 75 +++++ + 12 files changed, 1292 insertions(+), 22 deletions(-) + create mode 100644 arch/arm/include/asm/ioctl.h + create mode 100644 configs/qemu_tfa_mm_defconfig + create mode 100644 drivers/tee/optee/hmac_sha2.c + create mode 100644 drivers/tee/optee/hmac_sha2.h + create mode 100644 drivers/tee/optee/rpmb.h + create mode 100644 drivers/tee/optee/rpmb_emu.c + create mode 100644 drivers/tee/optee/rpmb_emu.h + create mode 100644 drivers/tee/optee/sha2.c + create mode 100644 drivers/tee/optee/sha2.h + +diff --git a/arch/arm/include/asm/ioctl.h b/arch/arm/include/asm/ioctl.h +new file mode 100644 +index 000000000000..b279fe06dfe5 +--- /dev/null ++++ b/arch/arm/include/asm/ioctl.h +@@ -0,0 +1 @@ ++#include +diff --git a/drivers/tee/optee/Makefile b/drivers/tee/optee/Makefile +index 928d3f80027f..28108536d231 100644 +--- a/drivers/tee/optee/Makefile ++++ b/drivers/tee/optee/Makefile +@@ -3,3 +3,4 @@ + obj-y += core.o + obj-y += supplicant.o + obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o ++obj-y += sha2.o hmac_sha2.o rpmb_emu.o rpmb.o +diff --git a/drivers/tee/optee/hmac_sha2.c b/drivers/tee/optee/hmac_sha2.c +new file mode 100644 +index 000000000000..61b24b128f1d +--- /dev/null ++++ b/drivers/tee/optee/hmac_sha2.c +@@ -0,0 +1,126 @@ ++/* ++ * HMAC-SHA-224/256/384/512 implementation ++ * Last update: 06/15/2005 ++ * Issue date: 06/15/2005 ++ * ++ * Copyright (C) 2005 Olivier Gay ++ * All rights reserved. ++ * ++ * Copyright (c) 2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the project nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#include ++ ++#include "hmac_sha2.h" ++ ++/* HMAC-SHA-256 functions */ ++ ++void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key, ++ unsigned int key_size) ++{ ++ unsigned int fill = 0; ++ unsigned int num = 0; ++ const unsigned char *key_used = NULL; ++ unsigned char key_temp[SHA256_DIGEST_SIZE] = { 0 }; ++ int i = 0; ++ ++ if (key_size == SHA256_BLOCK_SIZE) { ++ key_used = key; ++ num = SHA256_BLOCK_SIZE; ++ } else { ++ if (key_size > SHA256_BLOCK_SIZE){ ++ num = SHA256_DIGEST_SIZE; ++ sha256(key, key_size, key_temp); ++ key_used = key_temp; ++ } else { /* key_size > SHA256_BLOCK_SIZE */ ++ key_used = key; ++ num = key_size; ++ } ++ fill = SHA256_BLOCK_SIZE - num; ++ ++ memset(ctx->block_ipad + num, 0x36, fill); ++ memset(ctx->block_opad + num, 0x5c, fill); ++ } ++ ++ for (i = 0; i < (int) num; i++) { ++ ctx->block_ipad[i] = key_used[i] ^ 0x36; ++ ctx->block_opad[i] = key_used[i] ^ 0x5c; ++ } ++ ++ sha256_init(&ctx->ctx_inside); ++ sha256_update_tee(&ctx->ctx_inside, ctx->block_ipad, SHA256_BLOCK_SIZE); ++ ++ sha256_init(&ctx->ctx_outside); ++ sha256_update_tee(&ctx->ctx_outside, ctx->block_opad, ++ SHA256_BLOCK_SIZE); ++ ++ /* for hmac_reinit */ ++ memcpy(&ctx->ctx_inside_reinit, &ctx->ctx_inside, ++ sizeof(sha256_ctx)); ++ memcpy(&ctx->ctx_outside_reinit, &ctx->ctx_outside, ++ sizeof(sha256_ctx)); ++} ++ ++void hmac_sha256_reinit(hmac_sha256_ctx *ctx) ++{ ++ memcpy(&ctx->ctx_inside, &ctx->ctx_inside_reinit, ++ sizeof(sha256_ctx)); ++ memcpy(&ctx->ctx_outside, &ctx->ctx_outside_reinit, ++ sizeof(sha256_ctx)); ++} ++ ++void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message, ++ unsigned int message_len) ++{ ++ sha256_update_tee(&ctx->ctx_inside, message, message_len); ++} ++ ++void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac, ++ unsigned int mac_size) ++{ ++ unsigned char digest_inside[SHA256_DIGEST_SIZE] = { 0 }; ++ unsigned char mac_temp[SHA256_DIGEST_SIZE] = { 0 }; ++ ++ sha256_final(&ctx->ctx_inside, digest_inside); ++ sha256_update_tee(&ctx->ctx_outside, digest_inside, SHA256_DIGEST_SIZE); ++ sha256_final(&ctx->ctx_outside, mac_temp); ++ memcpy(mac, mac_temp, mac_size); ++} ++ ++void hmac_sha256(const unsigned char *key, unsigned int key_size, ++ const unsigned char *message, unsigned int message_len, ++ unsigned char *mac, unsigned mac_size) ++{ ++ hmac_sha256_ctx ctx; ++ ++ memset(&ctx, 0, sizeof(ctx)); ++ ++ hmac_sha256_init(&ctx, key, key_size); ++ hmac_sha256_update(&ctx, message, message_len); ++ hmac_sha256_final(&ctx, mac, mac_size); ++} +diff --git a/drivers/tee/optee/hmac_sha2.h b/drivers/tee/optee/hmac_sha2.h +new file mode 100644 +index 000000000000..1044524d75c5 +--- /dev/null ++++ b/drivers/tee/optee/hmac_sha2.h +@@ -0,0 +1,74 @@ ++/* ++ * HMAC-SHA-224/256/384/512 implementation ++ * Last update: 06/15/2005 ++ * Issue date: 06/15/2005 ++ * ++ * Copyright (C) 2005 Olivier Gay ++ * All rights reserved. ++ * ++ * Copyright (c) 2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the project nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#ifndef HMAC_SHA2_H ++#define HMAC_SHA2_H ++ ++#include "sha2.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++typedef struct { ++ sha256_ctx ctx_inside; ++ sha256_ctx ctx_outside; ++ ++ /* for hmac_reinit */ ++ sha256_ctx ctx_inside_reinit; ++ sha256_ctx ctx_outside_reinit; ++ ++ unsigned char block_ipad[SHA256_BLOCK_SIZE]; ++ unsigned char block_opad[SHA256_BLOCK_SIZE]; ++} hmac_sha256_ctx; ++ ++void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key, ++ unsigned int key_size); ++void hmac_sha256_reinit(hmac_sha256_ctx *ctx); ++void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message, ++ unsigned int message_len); ++void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac, ++ unsigned int mac_size); ++void hmac_sha256(const unsigned char *key, unsigned int key_size, ++ const unsigned char *message, unsigned int message_len, ++ unsigned char *mac, unsigned mac_size); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* !HMAC_SHA2_H */ ++ +diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c +index 0804fc963cf5..275f2112f102 100644 +--- a/drivers/tee/optee/rpmb.c ++++ b/drivers/tee/optee/rpmb.c +@@ -12,35 +12,15 @@ + + #include "optee_msg.h" + #include "optee_private.h" ++#include "rpmb_emu.h" + + /* + * Request and response definitions must be in sync with the secure side of + * OP-TEE. + */ + +-/* Request */ +-struct rpmb_req { +- u16 cmd; +-#define RPMB_CMD_DATA_REQ 0x00 +-#define RPMB_CMD_GET_DEV_INFO 0x01 +- u16 dev_id; +- u16 block_count; +- /* Optional data frames (rpmb_data_frame) follow */ +-}; +- + #define RPMB_REQ_DATA(req) ((void *)((struct rpmb_req *)(req) + 1)) + +-/* Response to device info request */ +-struct rpmb_dev_info { +- u8 cid[16]; +- u8 rpmb_size_mult; /* EXT CSD-slice 168: RPMB Size */ +- u8 rel_wr_sec_c; /* EXT CSD-slice 222: Reliable Write Sector */ +- /* Count */ +- u8 ret_code; +-#define RPMB_CMD_GET_DEV_INFO_RET_OK 0x00 +-#define RPMB_CMD_GET_DEV_INFO_RET_ERROR 0x01 +-}; +- + static void release_mmc(struct optee_private *priv) + { + int rc; +@@ -175,8 +155,13 @@ void optee_suppl_cmd_rpmb(struct udevice *dev, struct optee_msg_arg *arg) + rsp_buf = (u8 *)rsp_shm->addr + arg->params[1].u.rmem.offs; + rsp_size = arg->params[1].u.rmem.size; + ++#ifdef EMU + arg->ret = rpmb_process_request(dev_get_priv(dev), req_buf, req_size, + rsp_buf, rsp_size); ++#else ++ arg->ret = rpmb_process_request_emu(req_buf, req_size, rsp_buf, ++ rsp_size); ++#endif + } + + void optee_suppl_rpmb_release(struct udevice *dev) +diff --git a/drivers/tee/optee/rpmb.h b/drivers/tee/optee/rpmb.h +new file mode 100644 +index 000000000000..8b137891791f +--- /dev/null ++++ b/drivers/tee/optee/rpmb.h +@@ -0,0 +1 @@ ++ +diff --git a/drivers/tee/optee/rpmb_emu.c b/drivers/tee/optee/rpmb_emu.c +new file mode 100644 +index 000000000000..629f36ee6b29 +--- /dev/null ++++ b/drivers/tee/optee/rpmb_emu.c +@@ -0,0 +1,563 @@ ++// SPDX-License-Identifier: BSD-2-Clause ++/* ++ * Copyright (c) 2020 Linaro Limited ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "optee_msg.h" ++#include "optee_private.h" ++#include "sha2.h" ++#include "hmac_sha2.h" ++#include "rpmb_emu.h" ++ ++static struct rpmb_emu rpmb_emu = { ++ .size = EMU_RPMB_SIZE_BYTES ++}; ++ ++static struct rpmb_emu *mem_for_fd(int fd) ++{ ++ static int sfd = -1; ++ ++ if (sfd == -1) ++ sfd = fd; ++ if (sfd != fd) { ++ printf("Emulating more than 1 RPMB partition is not supported\n"); ++ return NULL; ++ } ++ ++ return &rpmb_emu; ++} ++ ++#if (DEBUGLEVEL >= TRACE_FLOW) ++static void dump_blocks(size_t startblk, size_t numblk, uint8_t *ptr, ++ bool to_mmc) ++{ ++ char msg[100] = { 0 }; ++ size_t i = 0; ++ ++ for (i = 0; i < numblk; i++) { ++ snprintf(msg, sizeof(msg), "%s MMC block %zu", ++ to_mmc ? "Write" : "Read", startblk + i); ++ //print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, 256); ++ ptr += 256; ++ } ++} ++#else ++static void dump_blocks(size_t startblk, size_t numblk, uint8_t *ptr, ++ bool to_mmc) ++{ ++ (void)startblk; ++ (void)numblk; ++ (void)ptr; ++ (void)to_mmc; ++} ++#endif ++ ++#define CUC(x) ((const unsigned char *)(x)) ++static void hmac_update_frm(hmac_sha256_ctx *ctx, struct rpmb_data_frame *frm) ++{ ++ hmac_sha256_update(ctx, CUC(frm->data), 256); ++ hmac_sha256_update(ctx, CUC(frm->nonce), 16); ++ hmac_sha256_update(ctx, CUC(&frm->write_counter), 4); ++ hmac_sha256_update(ctx, CUC(&frm->address), 2); ++ hmac_sha256_update(ctx, CUC(&frm->block_count), 2); ++ hmac_sha256_update(ctx, CUC(&frm->op_result), 2); ++ hmac_sha256_update(ctx, CUC(&frm->msg_type), 2); ++} ++ ++static bool is_hmac_valid(struct rpmb_emu *mem, struct rpmb_data_frame *frm, ++ size_t nfrm) ++{ ++ uint8_t mac[32] = { 0 }; ++ size_t i = 0; ++ hmac_sha256_ctx ctx; ++ ++ memset(&ctx, 0, sizeof(ctx)); ++ ++ if (!mem->key_set) { ++ printf("Cannot check MAC (key not set)\n"); ++ return false; ++ } ++ ++ hmac_sha256_init(&ctx, mem->key, sizeof(mem->key)); ++ for (i = 0; i < nfrm; i++, frm++) ++ hmac_update_frm(&ctx, frm); ++ frm--; ++ hmac_sha256_final(&ctx, mac, 32); ++ ++ if (memcmp(mac, frm->key_mac, 32)) { ++ printf("Invalid MAC\n"); ++ return false; ++ } ++ return true; ++} ++ ++static uint16_t gen_msb1st_result(uint8_t byte) ++{ ++ return (uint16_t)byte << 8; ++} ++ ++static uint16_t compute_hmac(struct rpmb_emu *mem, struct rpmb_data_frame *frm, ++ size_t nfrm) ++{ ++ size_t i = 0; ++ hmac_sha256_ctx ctx; ++ ++ memset(&ctx, 0, sizeof(ctx)); ++ ++ if (!mem->key_set) { ++ printf("Cannot compute MAC (key not set)\n"); ++ return gen_msb1st_result(RPMB_RESULT_AUTH_KEY_NOT_PROGRAMMED); ++ } ++ ++ hmac_sha256_init(&ctx, mem->key, sizeof(mem->key)); ++ for (i = 0; i < nfrm; i++, frm++) ++ hmac_update_frm(&ctx, frm); ++ frm--; ++ hmac_sha256_final(&ctx, frm->key_mac, 32); ++ ++ return gen_msb1st_result(RPMB_RESULT_OK); ++} ++ ++static uint16_t ioctl_emu_mem_transfer(struct rpmb_emu *mem, ++ struct rpmb_data_frame *frm, ++ size_t nfrm, int to_mmc) ++{ ++ size_t start = mem->last_op.address * 256; ++ size_t size = nfrm * 256; ++ size_t i = 0; ++ uint8_t *memptr = NULL; ++ ++ if (start > mem->size || start + size > mem->size) { ++ printf("Transfer bounds exceeed emulated memory\n"); ++ return gen_msb1st_result(RPMB_RESULT_ADDRESS_FAILURE); ++ } ++ if (to_mmc && !is_hmac_valid(mem, frm, nfrm)) ++ return gen_msb1st_result(RPMB_RESULT_AUTH_FAILURE); ++ ++ //printf("Transferring %zu 256-byte data block%s %s MMC (block offset=%zu)", ++ //nfrm, (nfrm > 1) ? "s" : "", to_mmc ? "to" : "from", start / 256); ++ for (i = 0; i < nfrm; i++) { ++ memptr = mem->buf + start + i * 256; ++ if (to_mmc) { ++ memcpy(memptr, frm[i].data, 256); ++ mem->write_counter++; ++ frm[i].write_counter = htonl(mem->write_counter); ++ frm[i].msg_type = ++ htons(RPMB_MSG_TYPE_RESP_AUTH_DATA_WRITE); ++ } else { ++ memcpy(frm[i].data, memptr, 256); ++ frm[i].msg_type = ++ htons(RPMB_MSG_TYPE_RESP_AUTH_DATA_READ); ++ frm[i].address = htons(mem->last_op.address); ++ frm[i].block_count = nfrm; ++ memcpy(frm[i].nonce, mem->nonce, 16); ++ } ++ frm[i].op_result = gen_msb1st_result(RPMB_RESULT_OK); ++ } ++ dump_blocks(mem->last_op.address, nfrm, mem->buf + start, to_mmc); ++ ++ if (!to_mmc) ++ compute_hmac(mem, frm, nfrm); ++ ++ return gen_msb1st_result(RPMB_RESULT_OK); ++} ++ ++static void ioctl_emu_get_write_result(struct rpmb_emu *mem, ++ struct rpmb_data_frame *frm) ++{ ++ frm->msg_type = htons(RPMB_MSG_TYPE_RESP_AUTH_DATA_WRITE); ++ frm->op_result = mem->last_op.op_result; ++ frm->address = htons(mem->last_op.address); ++ frm->write_counter = htonl(mem->write_counter); ++ compute_hmac(mem, frm, 1); ++} ++ ++static uint16_t ioctl_emu_setkey(struct rpmb_emu *mem, ++ struct rpmb_data_frame *frm) ++{ ++ if (mem->key_set) { ++ printf("Key already set\n"); ++ return gen_msb1st_result(RPMB_RESULT_GENERAL_FAILURE); ++ } ++ print_hex_dump_bytes("Setting Key:", DUMP_PREFIX_OFFSET, frm->key_mac, ++ 32); ++ memcpy(mem->key, frm->key_mac, 32); ++ mem->key_set = true; ++ ++ return gen_msb1st_result(RPMB_RESULT_OK); ++} ++ ++static void ioctl_emu_get_keyprog_result(struct rpmb_emu *mem, ++ struct rpmb_data_frame *frm) ++{ ++ frm->msg_type = ++ htons(RPMB_MSG_TYPE_RESP_AUTH_KEY_PROGRAM); ++ frm->op_result = mem->last_op.op_result; ++} ++ ++static void ioctl_emu_read_ctr(struct rpmb_emu *mem, ++ struct rpmb_data_frame *frm) ++{ ++ printf("Reading counter\n"); ++ frm->msg_type = htons(RPMB_MSG_TYPE_RESP_WRITE_COUNTER_VAL_READ); ++ frm->write_counter = htonl(mem->write_counter); ++ memcpy(frm->nonce, mem->nonce, 16); ++ frm->op_result = compute_hmac(mem, frm, 1); ++} ++ ++static uint32_t read_cid(uint16_t dev_id, uint8_t *cid) ++{ ++ /* Taken from an actual eMMC chip */ ++ static const uint8_t test_cid[] = { ++ /* MID (Manufacturer ID): Micron */ ++ 0xfe, ++ /* CBX (Device/BGA): BGA */ ++ 0x01, ++ /* OID (OEM/Application ID) */ ++ 0x4e, ++ /* PNM (Product name) "MMC04G" */ ++ 0x4d, 0x4d, 0x43, 0x30, 0x34, 0x47, ++ /* PRV (Product revision): 4.2 */ ++ 0x42, ++ /* PSN (Product serial number) */ ++ 0xc8, 0xf6, 0x55, 0x2a, ++ /* ++ * MDT (Manufacturing date): ++ * June, 2014 ++ */ ++ 0x61, ++ /* (CRC7 (0xA) << 1) | 0x1 */ ++ 0x15 ++ }; ++ ++ (void)dev_id; ++ memcpy(cid, test_cid, sizeof(test_cid)); ++ ++ return TEE_SUCCESS; ++} ++ ++static void ioctl_emu_set_ext_csd(uint8_t *ext_csd) ++{ ++ ext_csd[168] = EMU_RPMB_SIZE_MULT; ++ ext_csd[222] = EMU_RPMB_REL_WR_SEC_C; ++} ++ ++/* A crude emulation of the MMC ioctls we need for RPMB */ ++static int ioctl_emu(int fd, unsigned long request, ...) ++{ ++ struct mmc_ioc_cmd *cmd = NULL; ++ struct rpmb_data_frame *frm = NULL; ++ uint16_t msg_type = 0; ++ struct rpmb_emu *mem = mem_for_fd(fd); ++ va_list ap; ++ ++ if (request != MMC_IOC_CMD) { ++ printf("Unsupported ioctl: 0x%lx\n", request); ++ return -1; ++ } ++ if (!mem) ++ return -1; ++ ++ va_start(ap, request); ++ cmd = va_arg(ap, struct mmc_ioc_cmd *); ++ va_end(ap); ++ ++ switch (cmd->opcode) { ++ case MMC_SEND_EXT_CSD: ++ ioctl_emu_set_ext_csd((uint8_t *)(uintptr_t)cmd->data_ptr); ++ break; ++ ++ case MMC_WRITE_MULTIPLE_BLOCK: ++ frm = (struct rpmb_data_frame *)(uintptr_t)cmd->data_ptr; ++ msg_type = ntohs(frm->msg_type); ++ ++ switch (msg_type) { ++ case RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM: ++ mem->last_op.msg_type = msg_type; ++ mem->last_op.op_result = ioctl_emu_setkey(mem, frm); ++ break; ++ ++ case RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE: ++ mem->last_op.msg_type = msg_type; ++ mem->last_op.address = ntohs(frm->address); ++ mem->last_op.op_result = ++ ioctl_emu_mem_transfer(mem, frm, ++ cmd->blocks, 1); ++ break; ++ ++ case RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ: ++ case RPMB_MSG_TYPE_REQ_AUTH_DATA_READ: ++ memcpy(mem->nonce, frm->nonce, 16); ++ mem->last_op.msg_type = msg_type; ++ mem->last_op.address = ntohs(frm->address); ++ break; ++ default: ++ break; ++ } ++ break; ++ ++ case MMC_READ_MULTIPLE_BLOCK: ++ frm = (struct rpmb_data_frame *)(uintptr_t)cmd->data_ptr; ++ msg_type = ntohs(frm->msg_type); ++ ++ switch (mem->last_op.msg_type) { ++ case RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM: ++ ioctl_emu_get_keyprog_result(mem, frm); ++ break; ++ ++ case RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE: ++ ioctl_emu_get_write_result(mem, frm); ++ break; ++ ++ case RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ: ++ ioctl_emu_read_ctr(mem, frm); ++ break; ++ ++ case RPMB_MSG_TYPE_REQ_AUTH_DATA_READ: ++ ioctl_emu_mem_transfer(mem, frm, cmd->blocks, 0); ++ break; ++ ++ default: ++ printf("Unexpected\n"); ++ break; ++ } ++ break; ++ ++ default: ++ printf("Unsupported ioctl opcode 0x%08x\n", cmd->opcode); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int mmc_rpmb_fd(uint16_t dev_id) ++{ ++ (void)dev_id; ++ ++ /* Any value != -1 will do in test mode */ ++ return 0; ++} ++ ++static int mmc_fd(uint16_t dev_id) ++{ ++ (void)dev_id; ++ ++ return 0; ++} ++ ++static void close_mmc_fd(int fd) ++{ ++ (void)fd; ++} ++ ++/* ++ * Extended CSD Register is 512 bytes and defines device properties ++ * and selected modes. ++ */ ++static uint32_t read_ext_csd(int fd, uint8_t *ext_csd) ++{ ++ int st = 0; ++ struct mmc_ioc_cmd cmd = { ++ .blksz = 512, ++ .blocks = 1, ++ .flags = MMC_RSP_R1 | MMC_CMD_ADTC, ++ .opcode = MMC_SEND_EXT_CSD, ++ }; ++ ++ mmc_ioc_cmd_set_data(cmd, ext_csd); ++ ++ st = IOCTL(fd, MMC_IOC_CMD, &cmd); ++ if (st < 0) ++ return TEE_ERROR_GENERIC; ++ ++ return TEE_SUCCESS; ++} ++ ++static uint32_t rpmb_data_req(int fd, struct rpmb_data_frame *req_frm, ++ size_t req_nfrm, struct rpmb_data_frame *rsp_frm, ++ size_t rsp_nfrm) ++{ ++ int st = 0; ++ size_t i = 0; ++ uint16_t msg_type = ntohs(req_frm->msg_type); ++ struct mmc_ioc_cmd cmd = { ++ .blksz = 512, ++ .blocks = req_nfrm, ++ .data_ptr = (uintptr_t)req_frm, ++ .flags = MMC_RSP_R1 | MMC_CMD_ADTC, ++ .opcode = MMC_WRITE_MULTIPLE_BLOCK, ++ .write_flag = 1, ++ }; ++ ++ for (i = 1; i < req_nfrm; i++) { ++ if (req_frm[i].msg_type != msg_type) { ++ printf("All request frames shall be of the same type\n"); ++ return TEE_ERROR_BAD_PARAMETERS; ++ } ++ } ++ ++ //printf("Req: %zu frame(s) of type 0x%04x", req_nfrm, msg_type); ++ //printf("Rsp: %zu frame(s)", rsp_nfrm); ++ ++ switch(msg_type) { ++ case RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM: ++ case RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE: ++ if (rsp_nfrm != 1) { ++ printf("Expected only one response frame\n"); ++ return TEE_ERROR_BAD_PARAMETERS; ++ } ++ ++ /* Send write request frame(s) */ ++ cmd.write_flag |= MMC_CMD23_ARG_REL_WR; ++ /* ++ * Black magic: tested on a HiKey board with a HardKernel eMMC ++ * module. When postsleep values are zero, the kernel logs ++ * random errors: "mmc_blk_ioctl_cmd: Card Status=0x00000E00" ++ * and ioctl() fails. ++ */ ++ cmd.postsleep_min_us = 20000; ++ cmd.postsleep_max_us = 50000; ++ st = IOCTL(fd, MMC_IOC_CMD, &cmd); ++ if (st < 0) ++ return TEE_ERROR_GENERIC; ++ cmd.postsleep_min_us = 0; ++ cmd.postsleep_max_us = 0; ++ ++ /* Send result request frame */ ++ memset(rsp_frm, 0, 1); ++ rsp_frm->msg_type = htons(RPMB_MSG_TYPE_REQ_RESULT_READ); ++ cmd.data_ptr = (uintptr_t)rsp_frm; ++ cmd.write_flag &= ~MMC_CMD23_ARG_REL_WR; ++ st = IOCTL(fd, MMC_IOC_CMD, &cmd); ++ if (st < 0) ++ return TEE_ERROR_GENERIC; ++ ++ /* Read response frame */ ++ cmd.opcode = MMC_READ_MULTIPLE_BLOCK; ++ cmd.write_flag = 0; ++ cmd.blocks = rsp_nfrm; ++ st = IOCTL(fd, MMC_IOC_CMD, &cmd); ++ if (st < 0) ++ return TEE_ERROR_GENERIC; ++ break; ++ ++ case RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ: ++ if (rsp_nfrm != 1) { ++ printf("Expected only one response frame\n"); ++ return TEE_ERROR_BAD_PARAMETERS; ++ } ++//#if __GNUC__ > 6 ++ //__attribute__((fallthrough)); ++//#endif ++ ++ case RPMB_MSG_TYPE_REQ_AUTH_DATA_READ: ++ if (req_nfrm != 1) { ++ printf("Expected only one request frame\n"); ++ return TEE_ERROR_BAD_PARAMETERS; ++ } ++ ++ /* Send request frame */ ++ st = IOCTL(fd, MMC_IOC_CMD, &cmd); ++ if (st < 0) ++ return TEE_ERROR_GENERIC; ++ ++ /* Read response frames */ ++ cmd.data_ptr = (uintptr_t)rsp_frm; ++ cmd.opcode = MMC_READ_MULTIPLE_BLOCK; ++ cmd.write_flag = 0; ++ cmd.blocks = rsp_nfrm; ++ st = IOCTL(fd, MMC_IOC_CMD, &cmd); ++ if (st < 0) ++ return TEE_ERROR_GENERIC; ++ break; ++ ++ default: ++ printf("Unsupported message type: %d", msg_type); ++ return TEE_ERROR_GENERIC; ++ } ++ ++ return TEE_SUCCESS; ++} ++ ++static uint32_t rpmb_get_dev_info(uint16_t dev_id, struct rpmb_dev_info *info) ++{ ++ int fd = 0; ++ uint32_t res = 0; ++ uint8_t ext_csd[512] = { 0 }; ++ ++ res = read_cid(dev_id, info->cid); ++ if (res != TEE_SUCCESS) ++ return res; ++ ++ fd = mmc_fd(dev_id); ++ if (fd < 0) ++ return TEE_ERROR_BAD_PARAMETERS; ++ ++ res = read_ext_csd(fd, ext_csd); ++ if (res != TEE_SUCCESS) ++ goto err; ++ ++ info->rel_wr_sec_c = ext_csd[222]; ++ info->rpmb_size_mult = ext_csd[168]; ++ info->ret_code = RPMB_CMD_GET_DEV_INFO_RET_OK; ++ ++err: ++ close_mmc_fd(fd); ++ return res; ++} ++ ++ ++/* ++ * req is one struct rpmb_req followed by one or more struct rpmb_data_frame ++ * rsp is either one struct rpmb_dev_info or one or more struct rpmb_data_frame ++ */ ++uint32_t rpmb_process_request_emu(void *req, size_t req_size, ++ void *rsp, size_t rsp_size) ++{ ++ struct rpmb_req *sreq = req; ++ size_t req_nfrm = 0; ++ size_t rsp_nfrm = 0; ++ uint32_t res = 0; ++ int fd = 0; ++ ++ if (req_size < sizeof(*sreq)) ++ return TEE_ERROR_BAD_PARAMETERS; ++ ++ switch (sreq->cmd) { ++ case RPMB_CMD_DATA_REQ: ++ req_nfrm = (req_size - sizeof(struct rpmb_req)) / 512; ++ rsp_nfrm = rsp_size / 512; ++ fd = mmc_rpmb_fd(sreq->dev_id); ++ if (fd < 0) ++ return TEE_ERROR_BAD_PARAMETERS; ++ res = rpmb_data_req(fd, RPMB_REQ_DATA(req), req_nfrm, rsp, ++ rsp_nfrm); ++ break; ++ ++ case RPMB_CMD_GET_DEV_INFO: ++ if (req_size != sizeof(struct rpmb_req) || ++ rsp_size != sizeof(struct rpmb_dev_info)) { ++ printf("Invalid req/rsp size"); ++ return TEE_ERROR_BAD_PARAMETERS; ++ } ++ res = rpmb_get_dev_info(sreq->dev_id, ++ (struct rpmb_dev_info *)rsp); ++ break; ++ ++ default: ++ printf("Unsupported RPMB command: %d", sreq->cmd); ++ res = TEE_ERROR_BAD_PARAMETERS; ++ break; ++ } ++ ++ return res; ++} +diff --git a/drivers/tee/optee/rpmb_emu.h b/drivers/tee/optee/rpmb_emu.h +new file mode 100644 +index 000000000000..3471eecf63b5 +--- /dev/null ++++ b/drivers/tee/optee/rpmb_emu.h +@@ -0,0 +1,141 @@ ++#include ++ ++/* mmc_ioc_cmd.opcode */ ++#define MMC_SEND_EXT_CSD 8 ++#define MMC_READ_MULTIPLE_BLOCK 18 ++#define MMC_WRITE_MULTIPLE_BLOCK 25 ++ ++#define IOCTL(fd, request, ...) ioctl_emu((fd), (request), ##__VA_ARGS__) ++#define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long) ptr ++#define MMC_CMD23_ARG_REL_WR (1 << 31) /* CMD23 reliable write */ ++ ++/* Emulated rel_wr_sec_c value (reliable write size, *256 bytes) */ ++#define EMU_RPMB_REL_WR_SEC_C 1 ++/* Emulated rpmb_size_mult value (RPMB size, *128 kB) */ ++#define EMU_RPMB_SIZE_MULT 2 ++ ++#define EMU_RPMB_SIZE_BYTES (EMU_RPMB_SIZE_MULT * 128 * 1024) ++ ++struct mmc_ioc_cmd { ++ /* Implies direction of data. true = write, false = read */ ++ int write_flag; ++ ++ /* Application-specific command. true = precede with CMD55 */ ++ int is_acmd; ++ ++ uint32_t opcode; ++ uint32_t arg; ++ uint32_t response[4]; /* CMD response */ ++ unsigned int flags; ++ unsigned int blksz; ++ unsigned int blocks; ++ ++ /* ++ * Sleep at least postsleep_min_us useconds, and at most ++ * postsleep_max_us useconds *after* issuing command. Needed for ++ * some read commands for which cards have no other way of indicating ++ * they're ready for the next command (i.e. there is no equivalent of ++ * a "busy" indicator for read operations). ++ */ ++ unsigned int postsleep_min_us; ++ unsigned int postsleep_max_us; ++ ++ /* ++ * Override driver-computed timeouts. Note the difference in units! ++ */ ++ unsigned int data_timeout_ns; ++ unsigned int cmd_timeout_ms; ++ ++ /* ++ * For 64-bit machines, the next member, ``__u64 data_ptr``, wants to ++ * be 8-byte aligned. Make sure this struct is the same size when ++ * built for 32-bit. ++ */ ++ uint32_t __pad; ++ ++ /* DAT buffer */ ++ uint32_t data_ptr; ++}; ++#define MMC_BLOCK_MAJOR 179 ++#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd) ++ ++/* Request */ ++struct rpmb_req { ++ uint16_t cmd; ++#define RPMB_CMD_DATA_REQ 0x00 ++#define RPMB_CMD_GET_DEV_INFO 0x01 ++ uint16_t dev_id; ++ uint16_t block_count; ++ /* Optional data frames (rpmb_data_frame) follow */ ++}; ++#define RPMB_REQ_DATA(req) ((void *)((struct rpmb_req *)(req) + 1)) ++ ++/* Response to device info request */ ++struct rpmb_dev_info { ++ uint8_t cid[16]; ++ uint8_t rpmb_size_mult; /* EXT CSD-slice 168: RPMB Size */ ++ uint8_t rel_wr_sec_c; /* EXT CSD-slice 222: Reliable Write Sector */ ++ /* Count */ ++ uint8_t ret_code; ++#define RPMB_CMD_GET_DEV_INFO_RET_OK 0x00 ++#define RPMB_CMD_GET_DEV_INFO_RET_ERROR 0x01 ++}; ++/* mmc_ioc_cmd.flags */ ++#define MMC_RSP_PRESENT (1 << 0) ++#define MMC_RSP_136 (1 << 1) /* 136 bit response */ ++#define MMC_RSP_CRC (1 << 2) /* Expect valid CRC */ ++#define MMC_RSP_OPCODE (1 << 4) /* Response contains opcode */ ++ ++#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) ++ ++#define MMC_CMD_ADTC (1 << 5) /* Addressed data transfer command */ ++ ++ ++/* Emulated eMMC device state */ ++struct rpmb_emu { ++ uint8_t buf[EMU_RPMB_SIZE_BYTES]; ++ size_t size; ++ uint8_t key[32]; ++ bool key_set; ++ uint8_t nonce[16]; ++ uint32_t write_counter; ++ struct { ++ uint16_t msg_type; ++ uint16_t op_result; ++ uint16_t address; ++ } last_op; ++}; ++ ++/* ++ * This structure is shared with OP-TEE and the MMC ioctl layer. ++ * It is the "data frame for RPMB access" defined by JEDEC, minus the ++ * start and stop bits. ++ */ ++struct rpmb_data_frame { ++ uint8_t stuff_bytes[196]; ++ uint8_t key_mac[32]; ++ uint8_t data[256]; ++ uint8_t nonce[16]; ++ uint32_t write_counter; ++ uint16_t address; ++ uint16_t block_count; ++ uint16_t op_result; ++#define RPMB_RESULT_OK 0x00 ++#define RPMB_RESULT_GENERAL_FAILURE 0x01 ++#define RPMB_RESULT_AUTH_FAILURE 0x02 ++#define RPMB_RESULT_ADDRESS_FAILURE 0x04 ++#define RPMB_RESULT_AUTH_KEY_NOT_PROGRAMMED 0x07 ++ uint16_t msg_type; ++#define RPMB_MSG_TYPE_REQ_AUTH_KEY_PROGRAM 0x0001 ++#define RPMB_MSG_TYPE_REQ_WRITE_COUNTER_VAL_READ 0x0002 ++#define RPMB_MSG_TYPE_REQ_AUTH_DATA_WRITE 0x0003 ++#define RPMB_MSG_TYPE_REQ_AUTH_DATA_READ 0x0004 ++#define RPMB_MSG_TYPE_REQ_RESULT_READ 0x0005 ++#define RPMB_MSG_TYPE_RESP_AUTH_KEY_PROGRAM 0x0100 ++#define RPMB_MSG_TYPE_RESP_WRITE_COUNTER_VAL_READ 0x0200 ++#define RPMB_MSG_TYPE_RESP_AUTH_DATA_WRITE 0x0300 ++#define RPMB_MSG_TYPE_RESP_AUTH_DATA_READ 0x0400 ++}; ++ ++uint32_t rpmb_process_request_emu(void *req, size_t req_size, ++ void *rsp, size_t rsp_size); +diff --git a/drivers/tee/optee/sha2.c b/drivers/tee/optee/sha2.c +new file mode 100644 +index 000000000000..a9acd7244947 +--- /dev/null ++++ b/drivers/tee/optee/sha2.c +@@ -0,0 +1,249 @@ ++/* ++ * FIPS 180-2 SHA-224/256/384/512 implementation ++ * Last update: 02/02/2007 ++ * Issue date: 04/30/2005 ++ * ++ * Copyright (C) 2005, 2007 Olivier Gay ++ * All rights reserved. ++ * ++ * Copyright (c) 2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the project nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#include ++#include "sha2.h" ++ ++#define SHFR(x, n) (x >> n) ++#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n))) ++#define ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n))) ++#define CH(x, y, z) ((x & y) ^ (~x & z)) ++#define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z)) ++ ++#define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) ++#define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) ++#define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3)) ++#define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10)) ++ ++#define UNPACK32(x, str) \ ++{ \ ++ *((str) + 3) = (uint8) ((x) ); \ ++ *((str) + 2) = (uint8) ((x) >> 8); \ ++ *((str) + 1) = (uint8) ((x) >> 16); \ ++ *((str) + 0) = (uint8) ((x) >> 24); \ ++} ++ ++#define PACK32(str, x) \ ++{ \ ++ *(x) = ((uint32) *((str) + 3) ) \ ++ | ((uint32) *((str) + 2) << 8) \ ++ | ((uint32) *((str) + 1) << 16) \ ++ | ((uint32) *((str) + 0) << 24); \ ++} ++ ++#define UNPACK64(x, str) \ ++{ \ ++ *((str) + 7) = (uint8) ((x) ); \ ++ *((str) + 6) = (uint8) ((x) >> 8); \ ++ *((str) + 5) = (uint8) ((x) >> 16); \ ++ *((str) + 4) = (uint8) ((x) >> 24); \ ++ *((str) + 3) = (uint8) ((x) >> 32); \ ++ *((str) + 2) = (uint8) ((x) >> 40); \ ++ *((str) + 1) = (uint8) ((x) >> 48); \ ++ *((str) + 0) = (uint8) ((x) >> 56); \ ++} ++ ++#define PACK64(str, x) \ ++{ \ ++ *(x) = ((uint64) *((str) + 7) ) \ ++ | ((uint64) *((str) + 6) << 8) \ ++ | ((uint64) *((str) + 5) << 16) \ ++ | ((uint64) *((str) + 4) << 24) \ ++ | ((uint64) *((str) + 3) << 32) \ ++ | ((uint64) *((str) + 2) << 40) \ ++ | ((uint64) *((str) + 1) << 48) \ ++ | ((uint64) *((str) + 0) << 56); \ ++} ++ ++#define SHA256_SCR(i) \ ++{ \ ++ w[i] = SHA256_F4(w[i - 2]) + w[i - 7] \ ++ + SHA256_F3(w[i - 15]) + w[i - 16]; \ ++} ++ ++uint32 sha256_h0[8] = ++ {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, ++ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; ++ ++uint32 sha256_k[64] = ++ {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, ++ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, ++ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, ++ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, ++ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, ++ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, ++ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, ++ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, ++ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, ++ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, ++ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, ++ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, ++ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, ++ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, ++ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, ++ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; ++ ++/* SHA-256 functions */ ++ ++static void sha256_transf(sha256_ctx *ctx, const unsigned char *message, ++ unsigned int block_nb) ++{ ++ uint32 w[64] = { 0 }; ++ uint32 wv[8] = { 0 }; ++ uint32 t1 = 0; ++ uint32 t2 = 0; ++ const unsigned char *sub_block = NULL; ++ int i = 0; ++ int j = 0; ++ ++ for (i = 0; i < (int) block_nb; i++) { ++ sub_block = message + (i << 6); ++ ++ for (j = 0; j < 16; j++) { ++ PACK32(&sub_block[j << 2], &w[j]); ++ } ++ ++ for (j = 16; j < 64; j++) { ++ SHA256_SCR(j); ++ } ++ ++ for (j = 0; j < 8; j++) { ++ wv[j] = ctx->h[j]; ++ } ++ ++ for (j = 0; j < 64; j++) { ++ t1 = wv[7] + SHA256_F2(wv[4]) + CH(wv[4], wv[5], wv[6]) ++ + sha256_k[j] + w[j]; ++ t2 = SHA256_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]); ++ wv[7] = wv[6]; ++ wv[6] = wv[5]; ++ wv[5] = wv[4]; ++ wv[4] = wv[3] + t1; ++ wv[3] = wv[2]; ++ wv[2] = wv[1]; ++ wv[1] = wv[0]; ++ wv[0] = t1 + t2; ++ } ++ ++ for (j = 0; j < 8; j++) { ++ ctx->h[j] += wv[j]; ++ } ++ } ++} ++ ++void sha256(const unsigned char *message, unsigned int len, ++ unsigned char *digest) ++{ ++ sha256_ctx ctx; ++ ++ memset(&ctx, 0, sizeof(ctx)); ++ ++ sha256_init(&ctx); ++ sha256_update_tee(&ctx, message, len); ++ sha256_final(&ctx, digest); ++} ++ ++void sha256_init(sha256_ctx *ctx) ++{ ++ int i = 0; ++ ++ for (i = 0; i < 8; i++) { ++ ctx->h[i] = sha256_h0[i]; ++ } ++ ++ ctx->len = 0; ++ ctx->tot_len = 0; ++} ++ ++void sha256_update_tee(sha256_ctx *ctx, const unsigned char *message, ++ unsigned int len) ++{ ++ unsigned int block_nb = 0; ++ unsigned int new_len = 0; ++ unsigned int rem_len = 0; ++ unsigned int tmp_len = 0; ++ const unsigned char *shifted_message = NULL; ++ ++ tmp_len = SHA256_BLOCK_SIZE - ctx->len; ++ rem_len = len < tmp_len ? len : tmp_len; ++ ++ memcpy(&ctx->block[ctx->len], message, rem_len); ++ ++ if (ctx->len + len < SHA256_BLOCK_SIZE) { ++ ctx->len += len; ++ return; ++ } ++ ++ new_len = len - rem_len; ++ block_nb = new_len / SHA256_BLOCK_SIZE; ++ ++ shifted_message = message + rem_len; ++ ++ sha256_transf(ctx, ctx->block, 1); ++ sha256_transf(ctx, shifted_message, block_nb); ++ ++ rem_len = new_len % SHA256_BLOCK_SIZE; ++ ++ memcpy(ctx->block, &shifted_message[block_nb << 6], ++ rem_len); ++ ++ ctx->len = rem_len; ++ ctx->tot_len += (block_nb + 1) << 6; ++} ++ ++void sha256_final(sha256_ctx *ctx, unsigned char *digest) ++{ ++ unsigned int block_nb = 0; ++ unsigned int pm_len = 0; ++ unsigned int len_b = 0; ++ int i = 0; ++ ++ block_nb = (1 + ((SHA256_BLOCK_SIZE - 9) ++ < (ctx->len % SHA256_BLOCK_SIZE))); ++ ++ len_b = (ctx->tot_len + ctx->len) << 3; ++ pm_len = block_nb << 6; ++ ++ memset(ctx->block + ctx->len, 0, pm_len - ctx->len); ++ ctx->block[ctx->len] = 0x80; ++ UNPACK32(len_b, ctx->block + pm_len - 4); ++ ++ sha256_transf(ctx, ctx->block, block_nb); ++ ++ for (i = 0 ; i < 8; i++) { ++ UNPACK32(ctx->h[i], &digest[i << 2]); ++ } ++} +diff --git a/drivers/tee/optee/sha2.h b/drivers/tee/optee/sha2.h +new file mode 100644 +index 000000000000..4ce0f3cd5231 +--- /dev/null ++++ b/drivers/tee/optee/sha2.h +@@ -0,0 +1,75 @@ ++/* ++ * FIPS 180-2 SHA-224/256/384/512 implementation ++ * Last update: 02/02/2007 ++ * Issue date: 04/30/2005 ++ * ++ * Copyright (C) 2005, 2007 Olivier Gay ++ * All rights reserved. ++ * ++ * Copyright (c) 2016, Linaro Limited ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the project nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#ifndef SHA2_H ++#define SHA2_H ++ ++#define SHA256_DIGEST_SIZE ( 256 / 8) ++#define SHA256_BLOCK_SIZE ( 512 / 8) ++ ++#ifndef SHA2_TYPES ++#define SHA2_TYPES ++typedef unsigned char uint8; ++typedef unsigned int uint32; ++typedef unsigned long long uint64; ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++typedef struct { ++ unsigned int tot_len; ++ unsigned int len; ++ unsigned char block[2 * SHA256_BLOCK_SIZE]; ++ uint32 h[8]; ++} sha256_ctx; ++ ++typedef sha256_ctx sha224_ctx; ++ ++void sha256_init(sha256_ctx * ctx); ++void sha256_update_tee(sha256_ctx *ctx, const unsigned char *message, ++ unsigned int len); ++void sha256_final(sha256_ctx *ctx, unsigned char *digest); ++void sha256(const unsigned char *message, unsigned int len, ++ unsigned char *digest); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* !SHA2_H */ ++ +-- +2.29.2 + diff --git a/recipes-bsp/u-boot/u-boot-qemu-common.inc b/recipes-bsp/u-boot/u-boot-qemu-common.inc index 802fc50..6e7158b 100644 --- a/recipes-bsp/u-boot/u-boot-qemu-common.inc +++ b/recipes-bsp/u-boot/u-boot-qemu-common.inc @@ -13,6 +13,9 @@ require recipes-bsp/u-boot/u-boot-common.inc U_BOOT_BIN = "u-boot.bin" +SRC_URI_append_secureboot = " \ + file://0002-rpmb-emulation-hack.-Breaks-proper-hardware-support.patch;patch=1" + DEPENDS_append_secureboot = " optee-os-${MACHINE}" do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}" From patchwork Wed Nov 23 15:29:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053824 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 66DBCC4332F for ; Wed, 23 Nov 2022 15:30:15 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (EUR02-AM0-obe.outbound.protection.outlook.com [40.107.247.51]) by mx.groups.io with SMTP id smtpd.web11.23234.1669217410236547308 for ; Wed, 23 Nov 2022 07:30:10 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=JjkNg0oQ; spf=pass (domain: siemens.com, ip: 40.107.247.51, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mJ/JDtKv1FfbEDUxwfEo9O6yfxbe841vns94WVorlM4UTIPPS+LjFSTYkrp5KrLyiuyNrlICd7AvDBMPEve8rC/u3xEhw4+VFTB+UX59FBvrjj090MXA4vwQlHoW5ppr9YGcCAbH9L9Pq3ycobLvWZXoRYdLN4BrIdxl3eF+PDnXFEdZbLhelA1tDRtF6LzZ//byaFSNDhvb1wXQiqGcG2MNIk2+wQN1WJYUHCzZU772qar9yY3SyQ2l/H9CzqJ+8n1fY3E5Yg1cFs1r2rOQZ0c5E92skBl2qvEgYyIDOKxHRbXw6DLWzqcLXiDizdfxv/xaB35Ybo+JRXeV3ZVV8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qVV0ib9XRhyO+bm66mtM2NOd7l1HRjVAWcICguQiQks=; b=iaiUmc0JNn7m86/APbac6p+gx5RUmeZ8tU9rQyyZu/wyOI7+D38g3bHB12fFlWcgKexHVSFFXYrplSkSGfxG45JH17H+lhrkeQIwD8dMW1RbEIFDo1grmgfaDOtluea7WGhm6nsPUJlu14YXcxbV52Wdd2aRSSB89PGo03bLdz21MjtYg3N7wg+4vcDpF5z89fwYfvKvdWjbTpvc6lFx9M0z0esiz7XJgej8ztml9PNJqa6y5i4e6tsU8JhYrPJrzXXk6PWZUg5tJGhiqNBQFW9KP7MX7eNi52uEXZgTWxxXjX0lhZYQEO6Qq/KJIPz2ssI4Wkv/VGjA+Zvlc34+XQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qVV0ib9XRhyO+bm66mtM2NOd7l1HRjVAWcICguQiQks=; b=JjkNg0oQhqFsRRdLl6GodbRCLLC82i940/MAD2hLJySOFGRZcaCmm6WcH4VOFKTPTqhWC8xT4AlDX3uoSPvhKOfneVh9HPTYwgj/9GM/ry5bQbqpTbsliYGvwuX8nQywY6oWU9pH96Tm5o5Sw3pebyG5jv3FGGrQu1X9DcrFP3BZaAmf+y2Kl0e6VT3KJwLeyhHz+1DsadLP0twvj4OjZUK7UPCiz/ojetHljIbTlDER0wLZH/SD2xmRUxR+I7d6ftt8ckfjINOQhcyq538rWuH60V/dqdqFAs1O7ie/6iFpd0FPyt9p3E8INjVmvlGUD7zWVEuksxLQFTaYTscOjA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DU0PR10MB6318.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 15:30:08 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:30:08 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 5/7] add recipe for trusted firmware a qemu arm64 Date: Wed, 23 Nov 2022 16:29:04 +0100 Message-ID: <20221123152906.75323-6-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FRYP281CA0016.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::26) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DU0PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: bd711f92-5dd7-456b-02a6-08dacd679a40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nv2vQu7asSJkcRhejCsEJD70ENCHnRmQgHyFYDomHKa3g8aBknCU7YEYN5t+sTR2gPsqWkFRjzN8ybH6vlWb3fHaw/f4ySn2F5tNU+ZZgpdBchF3toK3mtBhZokhua3rLIXT/QOf52obqv943kaIxZcUHtucn8sSjt44Ep8ejDeXLM+79JbH4q+aUyWt1+EfEIPk1aDN7yCM7mSd9FY0TyTjbL4L/tgYGr8qSCkFiXueI8Rc6MxfpnZ/5ApdYT5eVmgt6hNwDlAEwq7NmW2Iw4efU3HGdJXmeF3v6MjBpA8QiI+fLVvv16Y/eqRNZ54XTlBdvXCVBRPH0Rh2smXZaOya3ULWB/S9u7yl0UcqUaDeeHaP1YVQ6ZFuFzpBgzWVFKv7vt5HNUO9ZglhWvstv4CQTIntdEuUX+A9cFvHf+XvIqJdk9nCv8wIJXhxCMULbQ2zBjleZSg2KTiT1FkYtySLXBlVShKa+yk155F56DvpZzSfTwRNYGXwQbejeAv0lFIBHBG9+7hOue6/j8iQT7ZcjowKN6R4zSzd+b7DsU+UBkXCoBO4yrjDZsCTsBReZpn68q+tKBzwxHBAHKOz8XI3TKO1GmELbj+Cq1pHyrIPc6rM3d8bzpMQtBLmnezcY57NDZhY7+4FUXujMXUz22rumpQ7T370Lyp5eUfTvGs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(451199015)(6666004)(41300700001)(107886003)(478600001)(6486002)(966005)(9686003)(4326008)(66476007)(316002)(8676002)(1076003)(8936002)(26005)(66556008)(66946007)(186003)(5660300002)(36756003)(6506007)(82960400001)(6916009)(55236004)(2616005)(86362001)(2906002)(6512007)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J1OgrXRYjPbhIuUuRyy6gjbahoyHapAoGfyWd1oBLiE2+Bdk/yU2cmkf7eLUdMONDRLSCTUKXUm/26rCXeMVMIbiGipWiW6sv8Puc2SNzrV3LZfYB/Yo33fCNUKibiGLDz5RuO0k9wW+ziSzdEpGB9Pk4FrNoWRs1HvVOcowx0Ou4O8Lxf1T6hl5VP11evDuKyX+tucJbV3yxPAhYqoOkZs48sM9ljJ3hM50nBq2Wro+Nq5KAv+HhNZv00/tL9q5C9WcKUfL5CPigzI+fZxM4dCvQZclIF0wUhRN9ootX3bmpo5yYEbaw+Ka8MrWZlfWB3aWiOtHbWDrGqPJjArYPiELJz7BwFLFaocd1fgCwODMyxkQchsPJ8b73QcAFmhhizgj/IItrtHs0mMgGGGnZfxY4c2pG6MA1CKWfBpTmRtZ6ssHHiw64/94H4JRUIv3DZay7xATqtxXqoDaOwTc5aIVRdW+OJtHCbP1UcN0ud22y93LbXNdmyNGO/fGq3QtpHou+tZuBtrgGTYc5s8sP97U9EGAXIZPVqIyVU37ffUfxSm5ENtTHmy+fKMaIQntXhT+vsknEN1XFiia/LANHfmm4+f9UGKMUK6t08qS9/rLL5qKwi2AOp4hmBsSMRfUzHJnY1u1NT6vf19HEA1Vcx8RRZpoehjnmdwqx3uPqdzfSwjSbO1hWnEndrAQml3NeTKOmpc2tBvlXLIr2+AZYSGPDShFxEC0FDVjMt0+UiYVK/9HBDy+jfn7FOvf7EeU0SMp3Ue4ieS3/KTrXbN42nCr426n1DUIvuXGI1Iu5uUnr76ZZwleJFo23yP1O/BjbVNvr28MESI3evvm5yWXp7JorgYWFVpWsityOf4wkm8/Zg2uUPNcEQYoT25bRhtTWruUOap9InothY4yok2o1H4VpjbQj8+1E02gsMnLI3A1CiDB8oitzVyzcS985R0FMoKLumJVqtDqrjxcb3KjIJ801NE+JXAR9eCLVetSPgwKcKLTkXzb9KsYQvdc+fg8vXEKZVccUbZqcAQYfNAt862dTfbRXgf1REjnf6RkQiyyo24VcSIFxqKwXvjFTE/V0Y4J175pQwdmTk/nkvX6f7Gnwr7hP/WdPccu6d18bNHtFpRKujzb3gzOVaE/fMJ+PNL0vew7YhkyJcAskA+/m2en7JTPi3JxPVoHC0z9Gt/UE+xUXnoiD405fprIyZXsfARjQl7FGEZosJJB5HxObn3OAiomj0aYyTCSPrtOa7xu5a4klkEVeSRlD5GOOjHk6nAdYZmIHSPVW0AvOsVeep95DGJZC+UjxYs9coLbjZFsIFwgnbmxceTMyFtY5xusyOdtEhHiLiQakb4i72u+C95hqbw0TmE5RiJ3LuwpOONdmh7eyMl+hqVceOWOaGtf342aVBAG2pTqMomZLSf266W4v82KuWRgrp0oHIfVpd3f7grPRYTcQCRa784zXc7Z/yhrQK2t5wQS9+t6CnTIXA83o/T+3zkXAscSyeWeJa2ZDwLqhpEIbTZvHVuNq2SyukLsA+oKccqKBPnQiSJgeTOfHTzfM22ZjBRnuPdl6yjS44uKGr/mZE8qGXtHZr2tFq7e4gEr5TYr3/6XvEcGyg== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd711f92-5dd7-456b-02a6-08dacd679a40 X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:30:08.0339 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 35wRBCMsUT5/qUsuu5NgWbrpbktx7G/ph19y1LrvkLp+jC0hzRWPARcw4ZFc4FX9uu2CnNgisn2SPx7Nzy6XHLLqk3DfMdg5DPMhYCM9s3M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6318 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 ; Wed, 23 Nov 2022 15:30:15 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10095 From: Sven Schultschik provide a recipe to generate the needed binary to start a secure boot qemu with integrated optee and active RPMB replay protected memory emulation within u-boot Signed-off-by: Sven Schultschik --- kas/opt/ebg-secure-boot-snakeoil.yml | 1 + .../trusted-firmware-a/files/rules.tmpl | 22 +++++++ .../trusted-firmware-a-qemu-arm64_2.7.0.bb | 62 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100755 recipes-bsp/trusted-firmware-a/files/rules.tmpl create mode 100644 recipes-bsp/trusted-firmware-a/trusted-firmware-a-qemu-arm64_2.7.0.bb diff --git a/kas/opt/ebg-secure-boot-snakeoil.yml b/kas/opt/ebg-secure-boot-snakeoil.yml index e92ea5e..6732095 100644 --- a/kas/opt/ebg-secure-boot-snakeoil.yml +++ b/kas/opt/ebg-secure-boot-snakeoil.yml @@ -26,6 +26,7 @@ local_conf_header: secure-boot: | IMAGER_BUILD_DEPS += "ebg-secure-boot-signer" + IMAGER_BUILD_DEPS_append_qemu-arm64 = " trusted-firmware-a-qemu-arm64" IMAGER_INSTALL += "ebg-secure-boot-signer" # Use snakeoil keys PREFERRED_PROVIDER_secure-boot-secrets = "secure-boot-snakeoil" diff --git a/recipes-bsp/trusted-firmware-a/files/rules.tmpl b/recipes-bsp/trusted-firmware-a/files/rules.tmpl new file mode 100755 index 0000000..45eb00b --- /dev/null +++ b/recipes-bsp/trusted-firmware-a/files/rules.tmpl @@ -0,0 +1,22 @@ +#!/usr/bin/make -f + +# Debian rules for custom Trusted Firmware A build +# +# This software is a part of ISAR. +# Copyright (c) Siemens AG, 2020 +# +# SPDX-License-Identifier: MIT + +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- +endif + +override_dh_auto_build: + CFLAGS= LDFLAGS= $(MAKE) $(PARALLEL_MAKE) PLAT=${TF_A_PLATFORM} \ + ${TF_A_EXTRA_BUILDARGS} + + dd if="build/${TF_A_PLATFORM}/release/bl1.bin" of="build/${TF_A_PLATFORM}/release/flash.bin" bs=4096 conv=notrunc + dd if="build/${TF_A_PLATFORM}/release/fip.bin" of="build/${TF_A_PLATFORM}/release/flash.bin" seek=64 bs=4096 conv=notrunc + +%: + dh $@ diff --git a/recipes-bsp/trusted-firmware-a/trusted-firmware-a-qemu-arm64_2.7.0.bb b/recipes-bsp/trusted-firmware-a/trusted-firmware-a-qemu-arm64_2.7.0.bb new file mode 100644 index 0000000..fcb2729 --- /dev/null +++ b/recipes-bsp/trusted-firmware-a/trusted-firmware-a-qemu-arm64_2.7.0.bb @@ -0,0 +1,62 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2022 +# +# Authors: +# Sven Schultschik +# +# SPDX-License-Identifier: MIT +# + +HOMEPAGE = "https://www.trustedfirmware.org/projects/tf-a/" +MAINTAINER = "Sven Schultschik " +LICENSE = "BSD-3-Clause" + +require recipes-bsp/trusted-firmware-a/trusted-firmware-a-custom.inc + +SRC_URI += " \ + https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/snapshot/trusted-firmware-a-${PV}.tar.gz \ + file://rules.tmpl" + +SRC_URI[sha256sum] = "553eeca87d4296cdf37361079d1a6446d4b36da16bc25feadd7e465537e7bd4d" + +S = "${WORKDIR}/trusted-firmware-a-${PV}" + +DEPENDS = "optee-os-${MACHINE} u-boot-qemu-arm64" +DEBIAN_BUILD_DEPENDS += " \ + debhelper(>= 11~), \ + optee-os-${MACHINE}, \ + u-boot-qemu-arm64, \ + libssl-dev:native, " + +TEMPLATE_FILES += "rules.tmpl" + +TEEHEADER = "/usr/lib/optee-os/${MACHINE}/tee-header_v2.bin" +TEEPAGER = "/usr/lib/optee-os/${MACHINE}/tee-pager_v2.bin" +TEEPAGEABLE = "/usr/lib/optee-os/${MACHINE}/tee-pageable_v2.bin" +BL33 = "/usr/lib/u-boot/${MACHINE}/u-boot.bin" + +TF_A_EXTRA_BUILDARGS = "BL32=${TEEHEADER} \ + BL32_EXTRA1=${TEEPAGER} \ + BL32_EXTRA2=${TEEPAGEABLE} \ + BL33=${BL33} \ + BL32_RAM_LOCATION=tdram SPD=opteed ${DEBUG} all fip" + +TF_A_PLATFORM = "qemu" + +TF_A_BINARIES = "release/flash.bin" + +do_prepare_build_append() { + rm -f ${S}/rules + cp ${WORKDIR}/rules ${S}/debian/ +} + +do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}" +do_deploy() { + dpkg --fsys-tarfile "${WORKDIR}/trusted-firmware-a-${MACHINE}_${PV}_${DISTRO_ARCH}.deb" | \ + tar xOf - "./usr/lib/trusted-firmware-a/${MACHINE}/flash.bin" \ + > "${DEPLOY_DIR_IMAGE}/flash.bin" +} + +addtask deploy after do_dpkg_build before do_deploy_deb \ No newline at end of file From patchwork Wed Nov 23 15:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053825 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 66319C4332F for ; Wed, 23 Nov 2022 15:30:25 +0000 (UTC) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (EUR02-DB5-obe.outbound.protection.outlook.com [40.107.249.45]) by mx.groups.io with SMTP id smtpd.web11.23243.1669217420752158832 for ; Wed, 23 Nov 2022 07:30:21 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=RSESjxtL; spf=pass (domain: siemens.com, ip: 40.107.249.45, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gp1dSxCoMOvRjashMIR8WMUpKEWIXTQetj3+I7rQFQHB3DOjGgkVdibn5whKl1WrYCHpnCDxaoZzcmJjanth6YyC4vk2wJVVDXUapBRjoDCL2vvy9fbN7l87DQ3xzJeU1ef+pdPiJPQXhWW2MgsF/Frf3BoEytjkIDk1VEYaamARb7Nug8lmk6aaf8s2ut0Rvrb8RGcGxQP6wUA6kcdB7TgZvsHbGy2VmiqkwEd9dpmcX9As/B9zHlZPjvoOf+kgTL4VXOor0iuO6+PaQr91qjUYZ/SyOby0eP7yxYr3uPJn+iZfiI4imU/ZjhPBfNfqVXYp0J75DVDxakEErjKqMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=68ObBLUGmv0zSm3gIMEVogaSsDbNOabZGMdqIwrYN/E=; b=nUMt0wlGxnY0bGtKHHC9Jjy0S/q1jYFIIWo9aoDD7e2jeHp8REBd38C9aQl9UZw13TA4jrVMssXoxoY2zIT2DVU+8u+Ox2ST9JzPRN4SPGoWlZm2JCQJa+z7KUdw0RGTGDA4DDmnsrD9pnoqhldah0owYzv4PuCIGKyIBZuCY6wgTlkUmqbKlqbs4co3lSLjFb1JrfJwWlm9Io/QYE3JCukYOHPlyUmCXK5X1vZriHK92t6BjcUIpLfm8ZZpOgGKtpCDS22Mb0UOqpQmc8bcdad8JS9XlsI1H8M7y6B3GDCQexm20+wPq1t03T86EJhKONOruuuCuEtSG3YHZfSj6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=68ObBLUGmv0zSm3gIMEVogaSsDbNOabZGMdqIwrYN/E=; b=RSESjxtLdO36ID4kMbTdJysQJKQTrLnTIV6qXiFLH7LH0mlfMz+V46BUEyfopG4piCIUcaigohmaVK/DaFBkcxnkZq/q2eSt0yj4fyY+SK/z1Akmwd/ivMcL2MOBE0dDcfML2b6qtrKxcELhpId57aTr18tW2KRfkvDKGpNdEWquD6SihbRmCPeXcP0C/Wblpf7koQyATcbJQ/Y1ipR3NbrCj3gVYjwu6vme2R0q0+/OCUBV8NoVg79o3HiC3heReNr2FG7zHhr1aD8jJZMDEtsmEzaLY15W3TjPTtXx/bl87btHIHpL6nupkdiG0oTkhgkaGTC1lyoUE3ACxvII9w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DU0PR10MB6318.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 15:30:18 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:30:18 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 6/7] enhance start-qemu.sh for arm64 secure boot Date: Wed, 23 Nov 2022 16:29:05 +0100 Message-ID: <20221123152906.75323-7-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FR2P281CA0075.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9a::17) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DU0PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: 19cde1ec-e49a-4b2c-3022-08dacd67a05a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: auLyEou5M4s/+rzux1Vg7oEbqbgUm3UwEvoTkNUQY27Hc5nvEu3BPiXRkPgljJPauYk0VpRHBbc1UpS+EU/d2MWXT3L2OCU9akx9MRHSC5XQoZWBASZjcC5YaKR0pIfc85bMwmxTlybkfBT0HIy1mFG/bi2okfHm1pjmLsWxYE6eDod5OhfB8HhsyqY2kC7kzuBYlAdTsOdz6E3efEmml4x6wLFvZbp9FWzlJlsno+2AMNGQLGBa4mMsTnOVjngIdVarOniOWVr58VIfnk9GWeuuvYRV0B4U7KkvL4LhIx44aZN20+qWJtzKiakaDC+ixGMr39fw5U/PIU93AnmAHX13VQ26XPw9TGWP99lHLwZGLtrgFCQSd0F6yU1+iIYNCCGplD8RxDXjanmZgPJzajP3vSEC5Nv/xzERnOZI4JKQDggf9z7Kg8cdI9YRQUyOPrcKfr93pdsJOtgoU5qI/3ZqoFmk9crmUJNqBEQ/BkzIDGP/mWMetrOtscDtNgR2Qnpee5I/iBsIVFUnoPLU4Ua0Xs2AD9d+fIQCPDiie9hQFqbFMrCSE2ubNEJ17OIXVw7vuPs7IoRaSYYH5EWX76ISLn0XAwC19x9/I9d1MK+sgalo6FXsPSgSMIBmdD6BjZqNLq7pZSpGNTbuT/2/SQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(451199015)(6666004)(41300700001)(107886003)(478600001)(6486002)(9686003)(4326008)(66476007)(316002)(8676002)(1076003)(8936002)(26005)(66556008)(66946007)(186003)(5660300002)(36756003)(6506007)(82960400001)(6916009)(55236004)(83380400001)(2616005)(86362001)(2906002)(6512007)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9S1CVvQ1AX3UKOGbf5d+4Vt031WmLM4j+P4cw8lWliHGivTyo9WbzjEkqUMgW1Wg+iWxQHw/u7s+mv1YCFBCaVhklM0mB3YoRhNQpDqv3SoIVsWhbeRJvMYCp1kgJk4tYuznEM4oqkvMiLvL2k5pFpZyXZjUyqyrSdx+PSTifdb7PLvrdwW5R/dOoF5n+zY1ExX1Bs5cEZTfrews3mdwZRHP2KY1PmGhukAPaHID8Y5WFiyuMKpBQdeDKUmK7mrQh4am7qx0UUEwLVY7B0UKZ5x8QeseBD5biYFzg9Vlgt/03YWAgqe614YU4OPkMKuDjSsSW9B6q9YVRriXyPDOwW4kvCjbzNqb2ynz4kjqUT+bNvHlh9ZVqMpC2cu6F9cDRE6LejpvxSsSl3DSRfHCfk1yV3BM3EvfqFnIjHVTDQPj7PfbANioRs8KaCS35M1004ovIdDI2tzqJ3fJRseiwSHRtvdwdTGJXeoW6oDK9dlg8uWL+FkfaTH9daA8n4ZQdSE9krMmL2zZRVVD87bCHbtn7nBb9zDBzT0NF10BJFtGJ5R8K8SEWeyIV9gRhj9NkjEZPp2098jao7eAo6M1SGC8Chj3AnvqWofY8FAql8+RrWcxNfos7dnQIz22s3VwAUtcPq0b5x+z+4qzhLDeIHcftgqjzBgCJbIyNxvlcVbevselebcHaMRhS6MeWnhwGQVlzXvn+770HWJrx6anBLDHl1rRS7pAD1i7XMIh7HC894w6SDc/5Utz0qKClGuLcpeBvUa3nPrkEbYrNW0+a7Ts4oNil/Y9jybsKY2UoLZKtEebx3lJvqDELNYq0csmlWdvyCQ1mYbnwoTjYTPf61rHD7M/qcZDapMN04fOBMuz1sturuC4fUqgQN2/I2YV+XupHtuwCML7Ad9qvpCXhTr5JuyT6DXHcsbGGkPqIVbcnhRWo+rswp1vUvuFSVZpCgd7ClTvvrPCLMEfdeXakgw4J8kqlOoHrgIFdPXDMSKvZurip4wQ9AMaRUVPiXM8kYlO3zT8rg80wESGB4uLBEH04AmI3Zk5FgDz4cAIlgp6lqMDtRDdQOVtMv/b7SEOgo+kaH1yThFPY6L5cfftIHLIkDGiQVfUnJcug8czO2knVow1dsVwUmvDtxTO33hw7HcvBZeVOqG3PbqPL5LhYwhHXpCX7ToqJ61eXx19r/bv9XTNn9DMSt213idO4MBXJdphkDq5haWRtaIwRJJ5pVMkDY/mb0w6uvqM2F2WFzrEmOo3fqfRKXHllxhft2bclUxZnwllD7C17/ArwgShz9QH0EhJBc/3Tjk15+ct/rt+7tAdaX1bAUt7EHetbrfTf6uiRx9X32GuR42Pfn8EiOIE+GSEdRw8CXWtqrQDIo06HxYRl2DybO3nU3uO0fv954TNGIyOKp0/f9+nAW+A/tlfdBmpb7Pngk+mTM+xPTAuUDGm7fw39mvrcF4zSiWg1rPrhYwTStjMP3VTfWSek8Qr0hDAFCR9jkAGchh5nbdZwszIEk2aFV5ngvey3072UcZe5WBZmLGRlEqEnwV7dhDC9qlikTSymJN6DeBA6IcISDpiagAF6sAHN8SKV6SIbFrieMRC6/P8Zy3T3alVdw== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19cde1ec-e49a-4b2c-3022-08dacd67a05a X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:30:18.2874 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /0UNte908G+cPRojU1F651zEVF8QLYh4DKN48ZHwJwd/4WX/qcb2FV7a7VHJFXmpaTZbt/6TwjaotjTFNAGvk8InyiZQITTs5r+XHxiROtY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6318 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 ; Wed, 23 Nov 2022 15:30:25 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10096 From: Sven Schultschik The start-qemu shell script need some adjustments to switch on secure in the machine statement and adds the virtual random number generator if secure boot is enabled. Signed-off-by: Sven Schultschik --- start-qemu.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/start-qemu.sh b/start-qemu.sh index dd16aed..5617a2a 100755 --- a/start-qemu.sh +++ b/start-qemu.sh @@ -80,13 +80,22 @@ case "${arch}" in QEMU_EXTRA_ARGS=" \ -cpu cortex-a57 \ -smp 4 \ - -machine virt \ -device virtio-serial-device \ -device virtconsole,chardev=con -chardev vc,id=con \ -device virtio-blk-device,drive=disk \ -device virtio-net-device,netdev=net" KERNEL_CMDLINE=" \ root=/dev/vda rw" + if [ -n "${SECURE_BOOT}" ]; then + QEMU_EXTRA_ARGS=" \ + ${QEMU_EXTRA_ARGS} \ + -machine virt,secure=on \ + -device virtio-rng-device" + else + QEMU_EXTRA_ARGS=" \ + ${QEMU_EXTRA_ARGS} \ + -machine virt" + fi ;; arm|armhf) QEMU_ARCH=arm @@ -165,7 +174,11 @@ if [ -n "${SECURE_BOOT}${SWUPDATE_BOOT}" ]; then fi ;; arm64|aarch64|arm|armhf) - u_boot_bin=${FIRMWARE_BIN:-./build/tmp/deploy/images/qemu-${QEMU_ARCH}/firmware.bin} + if [ -n "${SECURE_BOOT}" ]; then + u_boot_bin=${FIRMWARE_BIN:-./build/tmp/deploy/images/qemu-${QEMU_ARCH}/flash.bin} + else + u_boot_bin=${FIRMWARE_BIN:-./build/tmp/deploy/images/qemu-${QEMU_ARCH}/firmware.bin} + fi ${QEMU_PATH}${QEMU} \ -drive file=${IMAGE_PREFIX}.wic,discard=unmap,if=none,id=disk,format=raw \ From patchwork Wed Nov 23 15:29:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schultschik, Sven" X-Patchwork-Id: 13053826 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 7A13AC433FE for ; Wed, 23 Nov 2022 15:30:35 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (EUR02-AM0-obe.outbound.protection.outlook.com [40.107.247.69]) by mx.groups.io with SMTP id smtpd.web10.22975.1669217430360388794 for ; Wed, 23 Nov 2022 07:30:30 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=J/aGFArG; spf=pass (domain: siemens.com, ip: 40.107.247.69, mailfrom: sven.schultschik@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q6/0r4MkuyegVu18zjBmSUuFt2bdki8/D38CrWxUiXIuBIXHbLQN7AhjxewRav0fWAqb7Xo27VcLEcLQocrlxKXZ3fPsdhzmXNjt4uqDH+nJRYRcH7S9agraYrE3AnFTOveHKEKHh//Js7uSOGnj6+cmHNHbmJmtZ6hWvRdPa3iwX/7/uQDKioErOJ6Fo/CygDWMrIsCp4Xo8k5a9WICjOBM5ASZBKvp66+cnvjMmel9PjZfOB3cLH/Bv0zZ4sKpTsbfz1AcoNTj0VtlKjBP8+H876tnDJ2c9SG2TRZk+hMn6FhXCWWTU7mEpG1huSIf7Ke2DG0ai/yL0ENcv0kgSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WKcrdAiNwufxGz2Wt6F0vWBl3Vvm+2Dsu5U007LIbfM=; b=YJcF5EA0lUz31H24J3QXFKa9a7PeP669o2QGwN6OfBkniWHC6L3RPMIYy9JLzkoDcZGUKwm61HqQg9eqpPTCIedVY0N1SC57t9uag6HNXYLa+7B1TXVpxkZgfKYmlbzq7nFfJVWlyLXnYdFR4kz8VlDBo4sRkcyJNQ/syyLvHiFo79pYZOZrKntLIC+2lsfUwvhvYygf1d0x3Kx/gOMDB4kR+1wkP5rIrqBBSCwcKBY/RIIJxRvR4Q2HXhQrJUZrTtZC1X3CcP3ZXw9v1geuloiqHl4q5gDY1QUZ3wE78Kq+qA594/cjTpzR8h4o1wn7dLpXQLDdCBuMO0zfYAjEGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WKcrdAiNwufxGz2Wt6F0vWBl3Vvm+2Dsu5U007LIbfM=; b=J/aGFArGrAvCYT2MqnVtR//hIoDZgmsO1yTGZHLT+3H5Dknls+CcrQZZ436hnKSXDrcpLKJ43UfIywsCghkyK6NiN5EFNkli7soOGvaGZy+ZloA6zOUYLXg+jDwdP6FfrugXHgSKTaL6NWUp5hKaCwox8F82dMHnK/rjgJD489SArF6xGybMrOTrKVsFDRg8N5UKDWBA7s/E7Hw6gnMfnT0nxCAZuP2lwhFKutwBtDENk0pRoRPXDmkFGXSFHVHhzg0yOJTwbxHLK3lBhR92S4pUPwwSp3zg97xMEuiNB4EYjuTsnm20KHh1lNpwv/Y19TpQRgzMWfIrFf4b1jJ/rA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) by DU0PR10MB6318.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Wed, 23 Nov 2022 15:30:28 +0000 Received: from PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933]) by PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM ([fe80::955a:f715:5319:7933%9]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 15:30:28 +0000 From: sven.schultschik@siemens.com To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, Sven Schultschik Subject: [isar-cip-core][PATCH 7/7] Use of snakeoil keys for qemu use case Date: Wed, 23 Nov 2022 16:29:06 +0100 Message-ID: <20221123152906.75323-8-sven.schultschik@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123152906.75323-1-sven.schultschik@siemens.com> References: <20221123152906.75323-1-sven.schultschik@siemens.com> X-ClientProxiedBy: FR2P281CA0022.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::9) To PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:210::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR10MB5037:EE_|DU0PR10MB6318:EE_ X-MS-Office365-Filtering-Correlation-Id: 19ac3a55-264f-48d0-536d-08dacd67a65c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AQVeaErf42Nn4zoMwHxgJwglrZ14oIS86CUSsjTAm72My+RBf2lN/Msfv+y7vZfTL9tdn6t3cHywmZ+UoBYFQIBWf+tLCOzTBPMK1rqAWOj8BnT3p9Imyg83PaDmw4B4EkDCXBzm3qZm/j6F/OIdCPY9o5xja5a++IEYi5vQz+EIFAcwMWbQzFTuxc0Yk5wmPFga7IcIakZp0fNOifE6llPTOo3JI97mMvMAtzeGul5D4H1lvz6ghi/FUffOQVaxD6c1ZBqtHjQLI+HxIzcwlD8wzAFoWOyFyS1ijo7yD3F58DpOfShbU77UHDRJeIGiG7tKkLmacmhtQene9uT1tOqcdRhsYYP8f73wUtZZBho8h2ape6zd2Jmo95e8rggrvIZelhMa+QTTUdj6kmzwmwaAI6z+6FtOme0ZSeQCG8gC6q0TlBcvk9Oc8y2obpy1zELlPMOayqFT8bcpHjwhZl6Bwd/NJ10a+aC4dPhkUR7vGH03+hA0hpeRkf4DmLdh8CbvmgkcUNx3gc33ozApqfcyW4xDTjp+8TLR4XiCKaypmonGkvZvNPylXnUWlDUi4fb2iwI89SLWM+n1DcPGHEeYuZoFtGYvZZNFhwMZgFBRn50kI4c9QodY04uoqa8xbSfc2Q7pLWHzL4yx2b5T+A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(451199015)(6666004)(41300700001)(107886003)(478600001)(6486002)(9686003)(4326008)(66476007)(316002)(8676002)(1076003)(8936002)(26005)(66556008)(66946007)(186003)(5660300002)(36756003)(6506007)(82960400001)(6916009)(55236004)(83380400001)(2616005)(86362001)(2906002)(6512007)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vwqQJPBZ6pMPnA8W85cDGuKrt60t9OMgcTm2sm62yHw6aZJoSizfFDwjMerEHZWBeUgBRlKuoOnZEdbTc7WPQsogoabnTAg060dcmccEw7DwvUYGFfii9imVDU9jsHdekNuX3Vo1mybVj2goSWYHTugTPppzyLSmiy1uksTHHaYADMbLnBDJVuMJ4OziEho0B/Zq+mfnqQXNTdIL6esBt/h/Ye+A3UsUhAWMMFuIbCtUHYzTRgmPawilhMtFs4Uqki/bjigaj0pNTDTlvtxg6qpeaG/J13vf/a2BepbDDPT3ir9MN13ptCydvBtP2YltBbVVf207ai9Vmr01Vee1XUt67Z61a90vM3S67qBBpKzYnCatbjZ7ZcB0Mc3DzaTmoK2wJT93yye0syb+NlP3KrSgz7D8Gm9XLgElmpuumifrRjuVy/YmUgZ1w8a8sMmyexCbj/7e+3MFKEJV5nAlGtC2HVZNGfcfgDB6Efx+KQUP8MnHxqOEYJTpCam2OMzNWyn+7wHZi3RwCJVMkm+7DlRYDKx1UndExVwL1jGer1SYB8MMy0gJdGCT5aLBlW6/he/1UZ8gQ0ZxQYxCJ+dJciR1Cp86YUldy2dnIuL6QOgQqWOa6LGDTiMEn1xYe7dY8CQ5wvE6n61YaZVzsNPHmcfy+2empstEQICqYn11vIJZjGpKjUxQvZiXJ7J3CwoybLWKRBbpO2GRlhiAmmd/KZ2BgpumS7T7MXaU+6cMpVYudS4kOAcfU+RiRyTWlNmKCCTFawXGHaWyCbf8u1jVAUe2PdP0SEr7OOIxb8/DsoRCZInA6dlE46x/0NA1SmI4XakKkfMVOKYWkwn3NuXIPOhQH13yIFJiRxZJn8uhhLtHu+6TdfENGVcwVloaccqEySXQ5VCz/mAbpPACnKoT0qXqwz69Aj7Qmx8C0zKlngpY2GDc3IH5s3uxUDzfwF6D5OWXrO593CnfETfRJPTUBNbA63AXuXAY2I1/jSqJL3vGRz7kyGYlVH7tuESRx1o+vD65mqf0YOlroNux0FwnkhdwTfisoxqfOkiyUxgkg8OnWwBEMBwbjJZke8Wd0R8XKKNh+MySyej4opIkJO9kAXZPc5RUJHqGVFaurAwtpM7bJIBbd/vrBxeH9kYruNBZDAQvFU0E+hK+t8wvZ4Lm3oHBVGbcEA1A+d8GARZ3PEkoPpZvda3z6hPUp+7xtnkh0wsJJ5hqJRSpcrHW21jvF9N9w82vXVrFculy/lxwjoHF12X7OMSwq2C+YWESv+omG3C+9ED8MlU6/X+WPdpr/ov2+4IxH/3dNF6vUJTuuHYrX16zOhtL+ixApUAHkc50ehHrOt2U8NTIxXY3u/nOp1J95wjajWTCBGqIMxW6TjXsYYXsHXIUeRqF190Lr/tXY43sks1IWgd1sPuGta/4BsHjqfqnlliUoZ51n1Jb2N83naZvrOviS3cuKQyXkj/Ge9VYxECd5cH0lBi0XbU60KXZZvcKpR4+9MNClpZgY8AA6q6Q+XxyU7FEJ6CSKjWcEzT3vkXSPA3BuqLQPTpfw2sas7gsXZX1PIp+dHF3q6J2/Qxhqdv1labTuOY7ah/E+C+TKNvUcsANhsqUkBWTKQ== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19ac3a55-264f-48d0-536d-08dacd67a65c X-MS-Exchange-CrossTenant-AuthSource: PAXPR10MB5037.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 15:30:28.3521 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2ShkzeYh6+NzRUPb9X/ThboUfLH2nLMUjDkBFeMCztvlnIRA5GYjO6rwkVFFEtsUxm4kUhs+0Ec2IZ/avVJAkeYCVQw3I/P1YxVW/gS6MbY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6318 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 ; Wed, 23 Nov 2022 15:30:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/10097 From: Sven Schultschik The snakeoil keys are copied to the deploy folder if machine is qemu-arm64. The RPMB qemu workaround is not persistent and for that the keys need to be provisioned on every boot of quemu. Therefor the keys are copied to the deploy folder, mounted into the qemu as virtual memory and the boot command automatically loads them on every boot. Signed-off-by: Sven Schultschik --- recipes-bsp/u-boot/u-boot-qemu-common.inc | 4 ++++ .../secure-boot-secrets.inc | 19 +++++++++++++++++++ start-qemu.sh | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/recipes-bsp/u-boot/u-boot-qemu-common.inc b/recipes-bsp/u-boot/u-boot-qemu-common.inc index 6e7158b..36e4dbd 100644 --- a/recipes-bsp/u-boot/u-boot-qemu-common.inc +++ b/recipes-bsp/u-boot/u-boot-qemu-common.inc @@ -18,6 +18,10 @@ SRC_URI_append_secureboot = " \ DEPENDS_append_secureboot = " optee-os-${MACHINE}" +do_prepare_build_append_secureboot() { + sed -i 's/CONFIG_BOOTCOMMAND="/CONFIG_BOOTCOMMAND="fatload virtio 1:1 40000000 db\.auth; setenv -e -nv -bs -rt -at -i 40000000:\$filesize db; /g' ${S}/configs/${U_BOOT_CONFIG} +} + do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}" do_deploy() { dpkg --fsys-tarfile "${WORKDIR}/u-boot-${MACHINE}_${PV}_${DISTRO_ARCH}.deb" | \ diff --git a/recipes-devtools/secure-boot-secrets/secure-boot-secrets.inc b/recipes-devtools/secure-boot-secrets/secure-boot-secrets.inc index f53435a..196d798 100644 --- a/recipes-devtools/secure-boot-secrets/secure-boot-secrets.inc +++ b/recipes-devtools/secure-boot-secrets/secure-boot-secrets.inc @@ -32,3 +32,22 @@ do_install() { do_prepare_build_append() { echo "Provides: secure-boot-secrets" >> ${S}/debian/control } + +do_build_append() { + if [ "${MACHINE}" = "qemu-arm64" ]; then + cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc "${WORKDIR}/${SB_CERT}" "${WORKDIR}/secure-boot.esl" + sign-efi-sig-list -c "${WORKDIR}/${SB_CERT}" -k "${WORKDIR}/${SB_KEY}" db "${WORKDIR}/secure-boot.esl" "${WORKDIR}/db.auth" + fi +} + +do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}" +do_deploy() { + if [ "${MACHINE}" = "qemu-arm64" ]; then + DTARGET=${DEPLOY_DIR_IMAGE}/keys + mkdir -p ${DTARGET} + + cp ${WORKDIR}/db.auth ${DTARGET}/db.auth + fi +} + +addtask deploy after do_dpkg_build before do_deploy_deb \ No newline at end of file diff --git a/start-qemu.sh b/start-qemu.sh index 5617a2a..f29b57d 100755 --- a/start-qemu.sh +++ b/start-qemu.sh @@ -183,7 +183,8 @@ if [ -n "${SECURE_BOOT}${SWUPDATE_BOOT}" ]; then ${QEMU_PATH}${QEMU} \ -drive file=${IMAGE_PREFIX}.wic,discard=unmap,if=none,id=disk,format=raw \ -bios ${u_boot_bin} \ - ${QEMU_COMMON_OPTIONS} "$@" + ${QEMU_COMMON_OPTIONS} "$@" \ + -hdb fat:rw:./build/tmp/deploy/images/qemu-${QEMU_ARCH}/keys ;; *) echo "Unsupported architecture: ${arch}"