From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.101]) by mx.groups.io with SMTP id smtpd.web10.8912.1626965686826795656 for ; Thu, 22 Jul 2021 07:54:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=dpYGNpEm; spf=pass (domain: microsoft.com, ip: 40.107.92.101, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mq9lQh+zbFjuM9q+iqpgm+3SbANdYAwKJRyU2gfxJmBE4ognKZLacDp533FxwEOCQcKmCRbdrfi+tAWY+PreE/SY39KVpqsUJF0bwhBjqsa6CDmbQ5BzkpzxBRkyzETwWYGehLWZNQqglcV5dBpI98EnaVXLwFxu9BtflsP5ouYNfHQ59eYB2kqcdp5yEW456Pv3d5P44vxJPJsxDe0/25nH8/6pvyjwSNcHj+uRdzbTBNBaNRCJKxfbFX1o9afxlW0BKn6u+AG39IwFyPGa9eG+Db4NRsy+SnvFvnA7cZmus29QhVrdSbOA5/TXWAQBT1FuPeGdU2AA9eHJXYmSAw== 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-SenderADCheck; bh=e0hCNBdSpODnJj2BrJLHCD7u2Kx5y/l2lHW5pm4MA20=; b=T8TIPT2CSZgb/13SmNemyPm0tV2/yWli88cNzrsdqrPN+1MMQqcAS0ZNULl6cmH8u9xmGk3Z2LWTeaXWl7mL50QVjEQZ2aCOWFFsU9OLBldVNs642sxHC+jUtvHg2Vhn3epTAlZFRFdOdnwwQhnsRAC65uVx8lECGsyKTklDU0B6kam9rqqbp1+Aej99x+6/6q96Eguo77kiElvY6U4JcyjHPkquNRAAUwiZitW9ep7HIghFToJBXXxRjC6v0aQC/FJbITTj26k8UxDdveiDlyRcLKkOYq/eYQYZvM3yU8fuRp41vOZVufjVYfV7oGJe3oGKyVjH3iigdGLdsTrIfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e0hCNBdSpODnJj2BrJLHCD7u2Kx5y/l2lHW5pm4MA20=; b=dpYGNpEmHrO7PCIjxbxPhSxSjdmN6psWy97PenI4KlDe4PPcPHslm4ESlYyk3548LpqSQPZ+pYqTX5mn/yt0q6oIMWOfF+a1DPPRcla0pvoF4sAI//n0Tdd1lQx38kRuSc5cPYCVYxXEOu3AiIq4slhIRZbbA/n95InAowI7jVs= Received: from MW4PR21MB1907.namprd21.prod.outlook.com (2603:10b6:303:71::8) by MWHPR21MB0141.namprd21.prod.outlook.com (2603:10b6:300:78::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.2; Thu, 22 Jul 2021 14:54:39 +0000 Received: from MW4PR21MB1907.namprd21.prod.outlook.com ([fe80::2cfe:511c:cc17:e5e0]) by MW4PR21MB1907.namprd21.prod.outlook.com ([fe80::2cfe:511c:cc17:e5e0%4]) with mapi id 15.20.4373.006; Thu, 22 Jul 2021 14:54:39 +0000 From: "Bret Barkelew" To: Thomas Abraham , "Ard Biesheuvel (TianoCore)" , "Lindholm, Leif" , Laszlo Ersek , =?Windows-1252?Q?Marvin_H=E4user?= , Sami Mujawar , "devel@edk2.groups.io" CC: nd Subject: Re: ArmVirt and Self-Updating Code Thread-Topic: ArmVirt and Self-Updating Code Thread-Index: AQHXc7nkTmXVoBeJMkqO00bYHUh/Vas4l1PAgBaTlrg= Date: Thu, 22 Jul 2021 14:54:39 +0000 Message-ID: References: , In-Reply-To: Accept-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_SetDate=2021-07-08T05:27:06.4002898Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4287b277-ba3a-4262-e230-08d94d20a171 x-ms-traffictypediagnostic: MWHPR21MB0141: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: 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: Nj0Qiwu8JkVXl4r5nvGh9G46Q/SG2bQmAHRONugKkuwuLPQAaYEH2v7KriS8FOIz68XxZYxk267dRoh0iWPq1Vh1vCznsNpQJxh67mdzAMAdhcxEIcb7sxWEfHOtRaNLbejZmKfPqVerioIrXA5PHG0zOeVVIScKWNTSrFPHaytzFq6Cmo8szfB0PyTYPMT4EJ1j+cZ8gfw1WcZIdYgXDVufumUFZN/yaATJ18xzPPCiijW+PZoOg8uCUOOWvbP/G4cudrZ4i3TankjDmMr6v7rKP1egoGVwOZh4WvRIfAft7zqYazSwh+XKy5QbxOFsZCKvoqGjDncRYNpaXCNvblw54dwaYu8cEk20TbFPJXJntBAAhB3qNowYkOeFXrfy7ERFfwgG4Wyglz7aPCqPdPH3xU4odq5d+8ae9fN+6okt2vpHkQMJA1U3yhfOxbbHBasnx4w5zz+Lzu8vMTV5zQnZ9FHlTl8WUUPxYe7+Yhb5EjIJyLQCq4mfb4oQRCqizumkSi5WeW7SXtiX0xjkHVK0WgywQ8outcO+tlfPoErRsJJGLj1Xbsfnr9zve3zUNKemoychCjfu5cMYOIrlznNahK0YQfOSfoLY97pd+ljCWcjza7jxNWjGSfy8T2w/B3is2/e8mlR6ihJpRss9JD0wQWwG7Dy/MMl097t8G2c8hdbXjee4QpEQf8161Vnm8tQMwp2TEt95Z9H9jMKv7pa+gfnJ+fQkN0apE74muvF/4B6ieqkZU2LyIp3Q186JWLtSIt/s5QbNQ4o0TmdD7ZCEjgrAj0WH5Q8s8tlJz153qDcWnBsQf+bsjKTI/Ev6Vp5wi3xltCKDw7dO7s98Zw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR21MB1907.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(71200400001)(6506007)(53546011)(26005)(508600001)(186003)(76116006)(66476007)(66446008)(166002)(64756008)(83380400001)(2906002)(3480700007)(66556008)(82960400001)(316002)(66946007)(82950400001)(33656002)(5660300002)(66574015)(55016002)(122000001)(7696005)(10290500003)(110136005)(86362001)(38100700002)(52536014)(8936002)(966005)(8676002)(9686003)(8990500004)(4326008)(38070700004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?uyDtEOs9SHVznfDocrJ2MVlymhI40kehF4rav7cxX1sewUYbGpgn98wt?= =?Windows-1252?Q?8f8cWjfYQKTzJyCKzjLCGO4XkPydcawCK0X1hMVviAAJvEJkG+sRoPwQ?= =?Windows-1252?Q?eGV4l78Kr8RBCK8pfByltOBeEAMls7qu4/DiwlZV7yBvSBcVnh/NEQN+?= =?Windows-1252?Q?mdFOkZ5CQOneUOk5OO60xcDVTx+0+eoFC7UYgfS+6CTH3s6AIIw+BbBo?= =?Windows-1252?Q?BnXRjhQEuedrDDvw6ciLDaGLDRdgAPE1JBd4BG/Emhlqe2EmlKV6mAb3?= =?Windows-1252?Q?6JvNeZnAsGPs/XAtV2j/XqtZjwWzFaHE4B2mfiluscDr9S4tv9PP3CGY?= =?Windows-1252?Q?/b8T+W5biQt1MYWA3+i4zeUtxsZUytwj72pkhkr/RHEEFuLEsUHdEmFV?= =?Windows-1252?Q?2kP5RRhSa8B/grYBv9BLAPyQqk3wfUsi90vBn7+2OR5pMQoOiLtZX9ow?= =?Windows-1252?Q?IdUtdVEIUmPXFF0nwyGhWhJiZWXg/6PTVP0c9gE6LZFHnBYnH03mx23r?= =?Windows-1252?Q?wOSeEv/Il0Tbtqj2ecd/OYtCOhnnDcxPd9JAuc85TKiaom1NID7NqWxw?= =?Windows-1252?Q?1CncEYfsWHXxeJcw3igm59U+AYHj6ntvtuKlTs7lrcrOzRa2pPUiYlC4?= =?Windows-1252?Q?FPvxTOon4X7jWp3JwpJgdGZJAqG1ph24hweQmk6oiQufQFof2VIuk1A1?= =?Windows-1252?Q?rf/W9RYtWA0308pxv1cJX7+QGKgQHzEEqV9jIJxXlin4fyzMiwDPs/yn?= =?Windows-1252?Q?jD4tbxqFQ940m2bxoPYY9AjETAQ3x4ZoHsz1msplxxWcbizY/N9ODUeD?= =?Windows-1252?Q?SltR5zPkIG1CZTVF9WKO8SvqY20P4/0vw6d2pNkLNWP4EntJAV2ZGeY7?= =?Windows-1252?Q?tM5TkWtSTkT2JKwkZ+ZevC7xbf1qI9SMMLHcIwer0t16mrGda1roG0sf?= =?Windows-1252?Q?ZRqo8BEglvxMexCGkmMBq2vV5bSARdzlcudhC7sW+Lu8MuFpxevPm8+I?= =?Windows-1252?Q?moZhdyUfgNFQrls6UFh25cPqCGg/fUq6weCJ9+5PlovPWBLK4FEt5wP3?= =?Windows-1252?Q?YJPy0aF2vA8FyRHynMl4B9tkytlXmT9+swaiSlB1WybkfbOVbzlqD0ku?= =?Windows-1252?Q?X5AtG/qLJ2gIu7+PFiAiXVP/nvt3E/LVhN+9lW51/mZuoMKe8yJM1g1J?= =?Windows-1252?Q?gTQg120AtfkBKO7Xi/MeNyWF/ZL5pju37EfAIwV5qfm0ZctW75o1whIg?= =?Windows-1252?Q?1fwa4T2uh83IJULNbdU+fNApD5LFayjCo16Xu0YoJUitwfHsIct6lEgK?= =?Windows-1252?Q?FhyG5LTtaApYtgJluUb8qFfE6t5mN7pK1TCdXy/4AHhEtBd1vet3cufO?= =?Windows-1252?Q?kLAyMprXgTyW7m5q+2B70h3kMG7rVARUV1qFQKRlycQRYGMlKZHYlz67?= =?Windows-1252?Q?uzaUBiNp55/dZL4FPA+Omw=3D=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR21MB1907.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4287b277-ba3a-4262-e230-08d94d20a171 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jul 2021 14:54:39.0820 (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-CrossTenant-userprincipalname: 8PqHOkCDj4TjQiXevEKXe7BEeiROCLSn5xEt7dOXb+YJesljawAA5hqS71i3EL/HI2B6elRJcZdzB1yQgqLf0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0141 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MW4PR21MB190749749FEFB4E5343D2FB9EFE49MW4PR21MB1907namp_" --_000_MW4PR21MB190749749FEFB4E5343D2FB9EFE49MW4PR21MB1907namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Expanding audience to the full dev list=85 See below=85 - Bret From: Thomas Abraham Sent: Wednesday, July 7, 2021 11:07 PM To: Bret Barkelew; Ard Biesheuvel (Tian= oCore); Lindholm, Leif; Laszlo Ersek; Marvin H=E4user; Sami Mujawar Cc: nd Subject: [EXTERNAL] RE: ArmVirt and Self-Updating Code + Sami From: Bret Barkelew Sent: Thursday, July 8, 2021 11:05 AM To: Thomas Abraham ; Ard Biesheuvel (TianoCore) ; Lindholm, Leif ; Laszlo Ersek = ; Marvin H=E4user Subject: ArmVirt and Self-Updating Code All, Marvin asked me a question on the UEFI Talkbox Discord that=92s a little be= yond my ken=85 =93There is self-relocating code in ArmVirtPkg: https://github.com/tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff= 1aaf/ArmVirtPkg/PrePi/PrePi.c#L133-L165 According to comments in the ASM, it seems like this is for Linux-based RAM= boot (I saw further stuff for KVM, so it makes sense I guess?). It seems u= nfortunate it cannot be mapped into a known address range so that self-relo= cation is not necessary, but that's out of my scope to understand. =93Now, StandaloneMmPkg has similar (self-)relocation code too: https://git= hub.com/tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff1aaf/Standa= loneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryP= oint.c#L379-L386 Because I cannot find such elsewhere, I assume it must be for the same ARM = virtualised environment as above. The binary it applies the Relocations to = is documented to be the Standalone MM core, but in fact SecCore is located: https://github.com/tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff= 1aaf/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissi= ons.c#L131-L158 =93This yields the following questions to me: 1) What even invokes Standalone MM on ARM? It is documented it is spawned d= uring SEC, but I could not find any actual invocation. 2) Why does Standalone MM (self-)relocation locate SecCore? Should it not a= lready have been relocated with the code from ArmPlatformPkg? Is Standalone= MM embedded into ARM SecCore? 3) Why is SecCore the only module relocated? Are all others guaranteed to b= e "properly" loaded? 4) Is there maybe some high-level documented about the ARM boot flow? It se= ems to be significantly different from the x86 routes quite vastly.=94 Hoping that one of you could get me closer to an answer for him. Also happy= to take this to the greater mailing list, but thought I=92d avoid churn. Thanks in advance! - Bret --_000_MW4PR21MB190749749FEFB4E5343D2FB9EFE49MW4PR21MB1907namp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Expanding audience to the full dev list=85

See below=85

 

- Bret

 

From: Thomas Abraham
Sent: Wednesday, July 7, 2021 11:07 PM
To: Bret Barkelew= ; Ard Biesheuvel (TianoCore); Lindho= lm, Leif; Laszlo Ersek; Marvin H=E4user; Sami Mujawar
Cc:
nd
Subject: [EXTERNAL] RE: ArmVirt and Self-Updating Code

 

+ Sami

 

From: Bret Barkelew <Bret.Barkelew@microso= ft.com>
Sent: Thursday, July 8, 2021 11:05 AM
To: Thomas Abraham <thomas.abraham@arm.com>; Ard Biesheuvel (T= ianoCore) <ardb+tianocore@kernel.org>; Lindholm, Leif <leif@nuviai= nc.com>; Laszlo Ersek <lersek@redhat.com>; Marvin H=E4user <mha= euser@posteo.de>
Subject: ArmVirt and Self-Updating Code

 

All,

 

Marvin asked me a question on the UEFI Talkbox Disco= rd that=92s a little beyond my ken=85

 

=93There is self-relocating code in ArmVirtPkg:=

https://github.com= /tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff1aaf/ArmVirtPkg/Pr= ePi/PrePi.c#L133-L165

According to comments in the ASM, it seems like this= is for Linux-based RAM boot (I saw further stuff for KVM, so it makes sens= e I guess?). It seems unfortunate it cannot be mapped into a known address = range so that self-relocation is not necessary, but that's out of my scope to understand.

 

=93Now, StandaloneMmPkg has similar (self-)relocatio= n code too: https://github.com/tianocore/edk2/blob/17143c= 4837393d42c484b42d1789b85b2cff1aaf/StandaloneMmPkg/Library/StandaloneMmCore= EntryPoint/AArch64/StandaloneMmCoreEntryPoint.c#L379-L386

Because I cannot find such elsewhere, I assume it mu= st be for the same ARM virtualised environment as above. The binary it appl= ies the Relocations to is documented to be the Standalone MM core, but in f= act SecCore is located:

https://github.com/tianocore/edk2/blob= /17143c4837393d42c484b42d1789b85b2cff1aaf/StandaloneMmPkg/Library/Standalon= eMmCoreEntryPoint/AArch64/SetPermissions.c#L131-L158<= /p>

 

=93This yields the following questions to me:

1) What even invokes Standalone MM on ARM? It is doc= umented it is spawned during SEC, but I could not find any actual invocatio= n.

2) Why does Standalone MM (self-)relocation locate S= ecCore? Should it not already have been relocated with the code from ArmPla= tformPkg? Is Standalone MM embedded into ARM SecCore?

3) Why is SecCore the only module relocated? Are all= others guaranteed to be "properly" loaded?

4) Is there maybe some high-level documented about t= he ARM boot flow? It seems to be significantly different from the x86 route= s quite vastly.=94

 

Hoping that one of you could get me closer to an ans= wer for him. Also happy to take this to the greater mailing list, but thoug= ht I=92d avoid churn.

 

Thanks in advance!

- Bret

 

 

--_000_MW4PR21MB190749749FEFB4E5343D2FB9EFE49MW4PR21MB1907namp_--