Re: [Suit] Introducing draft-moran-suit-manifest-04

Martin Pagel <Martin.Pagel@microsoft.com> Fri, 15 March 2019 23:24 UTC

Return-Path: <Martin.Pagel@microsoft.com>
X-Original-To: suit@ietfa.amsl.com
Delivered-To: suit@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B1BAC131095 for <suit@ietfa.amsl.com>; Fri, 15 Mar 2019 16:24:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=microsoft.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bMusNj3JGTx6 for <suit@ietfa.amsl.com>; Fri, 15 Mar 2019 16:24:22 -0700 (PDT)
Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-eopbgr780112.outbound.protection.outlook.com [40.107.78.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2531512787D for <suit@ietf.org>; Fri, 15 Mar 2019 16:24:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5M1D5GWNN8MNlORyI/MLYr4r1qr0Om6vRnnEZGjt8Gk=; b=PQGA1M+VWAlN62YDm0mLVtcnNFoyYz2gcuWLjdDlTI/GtBvRTnsKKegjX6yUJftVFTwjgdftfrowMt21BZQDIp8Y/7kpKiorAqtuCFiBB63NflCmTXJUie3+MxOnn4cvkw5g1Li0cCaWJE3efFs6inkSqzED8Ml3X/mYC3oIi8k=
Received: from BYAPR21MB1317.namprd21.prod.outlook.com (20.179.60.199) by BYAPR21MB1350.namprd21.prod.outlook.com (20.179.60.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.0; Fri, 15 Mar 2019 23:24:19 +0000
Received: from BYAPR21MB1317.namprd21.prod.outlook.com ([fe80::a89a:5b8a:e27c:ec15]) by BYAPR21MB1317.namprd21.prod.outlook.com ([fe80::a89a:5b8a:e27c:ec15%7]) with mapi id 15.20.1730.000; Fri, 15 Mar 2019 23:24:19 +0000
From: Martin Pagel <Martin.Pagel@microsoft.com>
To: David Brown <david.brown@linaro.org>, Brendan Moran <Brendan.Moran@arm.com>
CC: "suit@ietf.org" <suit@ietf.org>
Thread-Topic: [Suit] Introducing draft-moran-suit-manifest-04
Thread-Index: AQHU2L81dzELNCQKcEaCHfQ8cPehA6YM6E0AgABx0iA=
Date: Fri, 15 Mar 2019 23:24:19 +0000
Message-ID: <BYAPR21MB1317D154B6AE48E33D8B237A9D440@BYAPR21MB1317.namprd21.prod.outlook.com>
References: <16EC7DB9-1649-4A86-A370-F77CB03305AC@arm.com> <20190315163402.GA25574@davidb.org>
In-Reply-To: <20190315163402.GA25574@davidb.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=mapagel@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-03-15T23:24:18.3751278Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=e6677e54-59fe-4c64-9cb8-227a37a8ebbf; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic
x-originating-ip: [97.113.77.118]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 62a2bba2-2632-4353-2de2-08d6a99d5981
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:BYAPR21MB1350;
x-ms-traffictypediagnostic: BYAPR21MB1350:
x-ms-exchange-purlcount: 2
x-microsoft-antispam-prvs: <BYAPR21MB135070FA54CBCAFA64AB84E99D440@BYAPR21MB1350.namprd21.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:10000;
x-forefront-prvs: 09778E995A
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(396003)(346002)(136003)(366004)(39860400002)(199004)(13464003)(189003)(186003)(76176011)(53936002)(2906002)(478600001)(25786009)(26005)(110136005)(53546011)(6506007)(6116002)(6246003)(3846002)(66066001)(256004)(966005)(102836004)(81166006)(22452003)(81156014)(316002)(6346003)(106356001)(97736004)(8676002)(99286004)(14444005)(105586002)(10290500003)(4326008)(6436002)(9686003)(6306002)(14454004)(229853002)(55016002)(7696005)(7736002)(72206003)(305945005)(446003)(86362001)(11346002)(74316002)(8936002)(86612001)(5660300002)(476003)(71190400001)(52536014)(68736007)(10090500001)(8990500004)(71200400001)(486006)(33656002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR21MB1350; H:BYAPR21MB1317.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1;
received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts)
authentication-results: spf=none (sender IP is ) smtp.mailfrom=Martin.Pagel@microsoft.com;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: yq+fFpbpqdchf0RfmbU58klu7KR7fa7Y7+ACZ49fR1PFV3+Zg8Qyw8aIfGd6jb+UP75xQXPpI8qT6NbR5LxsOdIsMIC8gcMBZTQt+nZT0j2vaxaWqM++6rJN3xRvWJDVGMergrzP8sVJH/Xro2oX7Fu5i4dFsxYeQf0fOI89Sfsgr3Uhhdhthbu3eouUL7z8jZZ+ygx97R53kXqmV79R0lcW6L2X5bS7niLk/NTwgXSSOeq5k8HtTKh6xjHNluDhCqKrQSCV5QiqMz1H0WsggxaihU7/vIOmOVaVHpmqiH9jEdz5CVwoj9sHTQqTxcor7wCF+bsSiGDd7VyiNTsSUFknJRARmEbvjWQcbc+IoseWcO00qLw3T/wnLHYzLTFZBCHECQO2TgeDzXf5zwgy3XC7VGObmh4J9rtbwVj5MH8=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: microsoft.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 62a2bba2-2632-4353-2de2-08d6a99d5981
X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Mar 2019 23:24:19.4747 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR21MB1350
Archived-At: <https://mailarchive.ietf.org/arch/msg/suit/iWZYZP1K_an8sEJJO-oOwM4Y5WA>
Subject: Re: [Suit] Introducing draft-moran-suit-manifest-04
X-BeenThere: suit@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Software Updates for Internet of Things <suit.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/suit>, <mailto:suit-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/suit/>
List-Post: <mailto:suit@ietf.org>
List-Help: <mailto:suit-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/suit>, <mailto:suit-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 15 Mar 2019 23:24:25 -0000

David, 
I don't think that copying to RAM is mandatory or even recommended.
Example 1 should be all you need.
Martin

-----Original Message-----
From: Suit <suit-bounces@ietf.org> On Behalf Of David Brown
Sent: Friday, March 15, 2019 9:34 AM
To: Brendan Moran <Brendan.Moran@arm.com>
Cc: suit@ietf.org
Subject: Re: [Suit] Introducing draft-moran-suit-manifest-04

On Tue, Mar 12, 2019 at 10:34:44AM +0000, Brendan Moran wrote:
>draft-moran-suit-manifest-04 has now been published.
>
>https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftools
>.ietf.org%2Fhtml%2Fdraft-moran-suit-manifest-04&amp;data=02%7C01%7Cmart
>in.pagel%40microsoft.com%7Ccfe120c246fd48faecff08d6a9641143%7C72f988bf8
>6f141af91ab2d7cd011db47%7C1%7C0%7C636882644594352532&amp;sdata=eWHvkKwY
>sXddzBMjbNpDlT9%2FQwshteFLmbU3bIiKwk4%3D&amp;reserved=0

One point I wanted to bring up on-list was that this draft seems to have a bit of a bias toward devices that execute programs by copying them from flash to RAM and executing them out of RAM.

Given the class of devices that we are targeting, I would suggest that this is actually fairly uncommon, and most of these types of devices will generally be set up to execute directly out of flash, so called XIP or eXecute In Place.  For these kinds of devices, the directives in the draft are a little bit of a mismatch with how upgrades happen on these kinds of devices.

To clarify, I will explain how upgrades currently work for devices targeted by MCUboot (and by extension TF-M):

  - The flash is divided into a series of slots.  For a device with a
    single process and image, it will be something like:

    +------------+
    | bootloader |
    +------------+
    | Primary    |
    +------------+
    | Secondary  |
    +------------+
    | Scratch    |
    +------------+
    | Storage    |
    +------------+

    For a multi-CPU/image device, there will be a pair of primary and
    secondary slots.  To simplify, I will make this example just for a
    single-image device.

  - For normal execution, the bootloader validates the image in the
    "primary" slot, and if it is valid, jumps directly to its start
    address within flash.

  - The download part of an upgrade happens while the application is
    running, and this code is contained within the code currently
    running in the primary image.  It downloads the upgrade into the
    "secondary" slot.  This new code cannot execute at this address,
    but is placed here as the image is downloaded.  The assumption is
    that their isn't sufficient RAM to hold the entire image, and that
    a download may be interrupted.

  - Once the application has finished downloading the new image, it
    writes a special marker to the end of the "secondary" slot and
    causes a reboot.

  - The bootloader detects this upgrade request in the secondary slot
    and begins a series of steps:

    - Verify the image in the secondary slot.

    - Using the scratch area exchange the images in the primary and
      secondary slot

    - Verify the new primary slot.

    - Jump to the new primary image

    This is designed in such a way that it can resume after any
    untimely interruption.

  - If the new image boots successfully, it writes a marker at the end
    of the "primary" slot to indicate that the image is correct.
    Otherwise, if the bootloader boots without seeing this marker, it
    will exchange the primary and secondary images again to undo the
    upgrade.

Within either the primary or secondary slot, the image has a format similar to:

    +------------+
    | Header     |
    +------------+
    | Executable |
    +------------+
    | Manifest   |
    +------------+

there is no real separate place to store the manifest.  This does mean that during an upgrade the manifest for both the old and the new image are present in flash.

I'm curious what thoughts people have on how to apply the draft 4 manifest to the above scenario.  Operations such as "load" aren't really meaningful, but apply-image would certainly make sense.
However, the installation of a new image is partially initiated by a different piece of code than the bootloader which is responsible for actually installing the image.  This state has to be managed carefully in a way that works with NOR flash, and therefore will probably live outside of the manifest.

Thanks,
David

_______________________________________________
Suit mailing list
Suit@ietf.org
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ietf.org%2Fmailman%2Flistinfo%2Fsuit&amp;data=02%7C01%7Cmartin.pagel%40microsoft.com%7Ccfe120c246fd48faecff08d6a9641143%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636882644594352532&amp;sdata=271MhUpRnQbktJs5CgZfjLBYPbVkMXnPE80wSZL%2BrDY%3D&amp;reserved=0