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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2CB3C433F5 for ; Tue, 5 Oct 2021 12:14:34 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0795961166 for ; Tue, 5 Oct 2021 12:14:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0795961166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B7ED81E14; Tue, 5 Oct 2021 14:14:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="oJKDc9mK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBBBD8203C; Tue, 5 Oct 2021 14:14:27 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::61b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 72CB18169E for ; Tue, 5 Oct 2021 14:14:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michals@xilinx.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aKW7HiLYvrcw5qCryzjoZBdozTDC2PMuWmEhLXPvhChIYfZ4kTzXUaA9L054hE7g6Ybnb7gjOyV/op/Z35a1YCs/TYz5pCy8Uq/lE+mhwne90w5MR+DmH3RoGP+dswWFHA+z98JiZKZxiOKZHF9LPbb0k1HbnhW0YMwLWpTZv8uw7GbeLKQBC8Qbm+8Rpr6NFYfANBjnBQnOvsQmWp543lnWtu2ww0r7old6lQbX+R/kZ/oUclngHpk/qy21lAoWsIFOGbrpndDGr8JE3xnSCZXDSsRKaHur/UgqTRS4IPZkVIK5L1Re88jc6O7F3O/4jIy1XKJUNeoxiu0QILvelg== 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=s5Xyw9cKTUDzhFMi5Gr/ih8HfOPgM3xuhqXlwmj+9CI=; b=l1rNCmwJYsJCdtyqRicsQu1QAqPmkKyaB7l9QmOfmqkdYX0t1pToOiuGuEVdyTK6ApnsRpnrSL0fLnCTc5Hof1SGCRW3DFxKSro6LEPxHtvd5WiaU37x7ujIbONhudgE/KzEKwtQGtpQJGlHR9NsY44G+rB57SCkBgg1usOLXEdAiQAEOFiMXxXgQOpdM8HUkbRWK5v1zpgXlF1OF/YS4ADTe6hvwwQhKpfiB5JFQHPoG/hka3/xT2YaZJMmRtbcWf0F1SmHPj1pOWpMmT/9PDS+Zb+IFxNLNYVt/FVF6pf7CIGCUL+2i1UXy4hMX4+d8V98Ejg7urZhCCqN/sBLbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=foundries.io smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s5Xyw9cKTUDzhFMi5Gr/ih8HfOPgM3xuhqXlwmj+9CI=; b=oJKDc9mKC7EyUnVX1XvCZ5kmsCVsMHfVZqrLAy/HKZIqGn2VGm7zTwk9ko3buJNk7HmgmHEOpr30A3po2MkQf9f4Lde6liYk0X7p7kEAvQPIP3tP4oYpI3fz4/OZ1mSalyuzHZzZNfyydIPAx/fYCisQTrw5qP2LZ4NAQk5BRbM= Received: from DM6PR08CA0027.namprd08.prod.outlook.com (2603:10b6:5:80::40) by MWHPR02MB3328.namprd02.prod.outlook.com (2603:10b6:301:6a::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Tue, 5 Oct 2021 12:14:19 +0000 Received: from DM3NAM02FT025.eop-nam02.prod.protection.outlook.com (2603:10b6:5:80:cafe::b8) by DM6PR08CA0027.outlook.office365.com (2603:10b6:5:80::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Tue, 5 Oct 2021 12:14:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; foundries.io; dkim=none (message not signed) header.d=none;foundries.io; dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT025.mail.protection.outlook.com (10.13.4.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Tue, 5 Oct 2021 12:14:19 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 5 Oct 2021 05:14:19 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 5 Oct 2021 05:14:19 -0700 Envelope-to: igor.opaniuk@foundries.io, mike@foundries.io, ricardo@foundries.io, u-boot@lists.denx.de, sjg@chromium.org, trini@konsulko.com, mr.nuke.me@gmail.com, jorge@foundries.io Received: from [10.254.241.49] (port=59518) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mXjKs-000Eag-Nh; Tue, 05 Oct 2021 05:14:19 -0700 Subject: Re: FIT image: load secure FPGA To: "Jorge Ramirez-Ortiz, Foundries" CC: Alex G. , , , , , , , References: <20211004203226.GA4704@trex> <20211005054543.GA4478@trex> <20211005060855.GA9066@trex> From: Michal Simek Message-ID: <90bc4580-4f34-af12-ee14-80d40bf18e25@xilinx.com> Date: Tue, 5 Oct 2021 14:14:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211005060855.GA9066@trex> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 203abc9b-52d9-4292-c093-08d987f9a8a2 X-MS-TrafficTypeDiagnostic: MWHPR02MB3328: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wsC1zRIWS7uU6ilUqlkwL/knRpNojNwQ6Cih3YPOA8z/8lrFUT9iihkdrzPuRFY3cBS6TcNsSiSM3LIRTH61jOa8Gcqmx3rcbz/Z2qHnY46ohIFycibIFQMe2CccK5p1v4vq0depo0MfSJ4iZRL9VghpoDYgCBwAEgSmOmaHG/IZePfw63f3NXJKfB7OaQ76uI9IlaKX3Oiv2LkXzN1tNfKX+WjzVV9NM34wCAR//FJ6oqD7Q+ifr1etsmePe/5K64iazBCmOYaPLBr98h/0ogikV16s/HCi0TdYFx7iswatFh1LSA6yqxZLS41YDc1/C1IaF/fcQ9PSccJwIJtonv++xKREO05wz3RqbEuze7MF3e4yrRyyN3KT/d9CRO17NMo3lIBsBQycIShAAEBCZagWin9tulzqCuWD12t6nJiBnVhQjUKry+36j3vTC6jFvt9e3LkIzorIpnbNTvW8R5EB6tARYeVBTK/7syPCBs6dDdlacmVm4CzkMpS4NG5c//awPLm5LZrPbYMzAmJuo4uKMu9aDpytRQYl06ghk+jWnr976RIUAyvqNBvPkSdlRJk5pe6kfasc/MWZQqi0sWX7UCTyUAZqZaRFUy2uWYECWdpv3MLvh2V4iS3s15SfUKKbcAZ7biJ/SkXNBmGe1doN/82xZ8BY2KozUXbUEtDX58jo+6FHMQRXac2ixdzXBJAB7IOQ1utUNCCL/iT82OVn/rRnYSYR/52DO2HkFEu0Ueg80cCerdyDx6eNeofsfSHYegdx3kxmikHayP1IyA== X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch01.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(46966006)(36840700001)(82310400003)(7636003)(36860700001)(36756003)(316002)(356005)(508600001)(47076005)(83380400001)(426003)(31686004)(2616005)(336012)(8936002)(8676002)(53546011)(36906005)(70586007)(54906003)(31696002)(9786002)(6916009)(44832011)(26005)(4326008)(2906002)(186003)(70206006)(5660300002)(6666004)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2021 12:14:19.4581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 203abc9b-52d9-4292-c093-08d987f9a8a2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT025.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB3328 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi, On 10/5/21 8:08 AM, Jorge Ramirez-Ortiz, Foundries wrote: > On 05/10/21, Jorge Ramirez-Ortiz, Foundries wrote: >> On 04/10/21, Alex G. wrote: >>> On 10/4/21 3:32 PM, Jorge Ramirez-Ortiz, Foundries wrote: >>>> Hello, >>>> >> >> hi Alex, >> >>>> We are enabling secure boot on Zynqmp with SPL. >>>> >>>> The issue however is that during secure boot, the bootrom not only >>>> validates the first loader (SPL and PMUFW combo) but it will also >>>> expect a signed bitstream during load(FPGA). >>>> >>>> Since currently the SPL load of an FPGA image from FIT does not >>>> support loading images for authentication (fpga_loads), I'd like to >>>> discuss how to best implement such support. >>> >>> What do you mean by "loading images for authentication" ? >> >> right, it eventually means executing fpga_loads insted of fpga_load ( >> a function that will provide additional params to the PMUFW. >> >> "loads" will load FPGA bitstreams that are either signed, encrypted or >> both. When they are only signed, they are first authenticated by the >> PMUFW and then loaded. >> >>>> >>>> A pretty standard file.its description of the FPGA loadable looks like >>>> this: >>>> >>>> fpga { >>>> description = "FPGA binary"; >>>> data = /incbin/("${DEPLOY_DIR_IMAGE}/${SPL_FPGA_BINARY}"); >>>> type = "fpga"; >>>> arch = "${UBOOT_ARCH}"; >>>> compression = "none"; >>>> load = <${fpgaloadaddr}>; >>>> hash-1 { >>>> algo = "${FIT_HASH_ALG}"; >>>> }; >>>> }; >>>> >>>> We could extend imagetool.h struct image_tool_params to add more >>>> params or perhpas just define different 'types' of fpga? >>> >>> >>> Check "4) '/images' node" >>> in doc/uImage.FIT/source_file_format.txt >>> >>> The intent is to give either: >>> * loadaddr="$(addr)" : copy image to $(addr), Done >>> * compatible="": Use this driver to upload the FPGA >>> >>> It seems to me like the right way to go is to make a new compatible="" FPGA >>> loader is for fpga_load(): >>> >>> fpga { >>> description = "FPGA binary"; >>> data = /incbin/("${YOCTO_BS_PATH}"); >>> type = "fpga"; >>> compression = "none"; >>> compatible = "zynqmp-fancy-fpga", >> >> so you think we should capture on compatible the characteristics of the FPGA image? > > > um, right, makes sense then, thanks. > > - compatible : compatible method for loading image. > Mandatory for types: "fpga", and images that do not specify a load address. > To use the generic fpga loading routine, use "u-boot,fpga-legacy" > >> >>> hash-1 { >>> algo = "${FIT_HASHISH}"; >>> }; >>> }; >>> >>> >>>> Something like: >>>> "fpga" >>>> "fpga-auth" : authenticated >>>> "fpga-enc" : encrypted >>>> "fpga-sec" : encrypted and authenticated >>> >>> Can these properties be inferred from the FPGA image? If not, they could be >>> required when using a new fpga loader. I don't think they should be added to >>> "fpga-legacy". >> >> maybe.. with a bit of boot header parsing... But doing so would >> deviate from the current approach making it somewhat inconsistent: ie, >> there is no a common "fpga load" command but instead we have "fpga >> load" and "fpga loads" as separate commands so perhaps the parsing is >> not that obvious or it would have been done differently. >> I'd rather follow the current approach and just explicitly qualify the >> bitstream. >> In past when I was adding support for bitstreams in 2016 by commit 62afc601883e ("image: Add boot_get_fpga() to load fpga with bootm") you can see that the problem was sort of the same as this one. But with handling different bitstream types. Because there are two types of bistreams in bin format and bit format. At that time I solved it by calling function in bit format first. If failed in bin format. And by comparing sizes it was determined if bitstream is in bit or bin format. I would say that this algorithm is not valid anymore because you can also have compressed bistreams which are smaller then device itself but still they are full bistreams. That being said I think when new types should be defined we should also optimized origin code for fpga loading to cover also partial bistreams and bistreams in bin and bit formats. Thanks, Michal