<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Expanding audience to the full dev list…</p>
<p class="MsoNormal">See below… </p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:thomas.abraham@arm.com">Thomas Abraham</a><br>
<b>Sent: </b>Wednesday, July 7, 2021 11:07 PM<br>
<b>To: </b><a href="mailto:Bret.Barkelew@microsoft.com">Bret Barkelew</a>; <a href="mailto:ardb+tianocore@kernel.org">
Ard Biesheuvel (TianoCore)</a>; <a href="mailto:leif@nuviainc.com">Lindholm, Leif</a>;
<a href="mailto:lersek@redhat.com">Laszlo Ersek</a>; <a href="mailto:mhaeuser@posteo.de">
Marvin Häuser</a>; <a href="mailto:sami.mujawar@arm.com">Sami Mujawar</a><br>
<b>Cc: </b><a href="mailto:nd@arm.com">nd</a><br>
<b>Subject: </b>[EXTERNAL] RE: ArmVirt and Self-Updating Code</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">+ Sami<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Bret Barkelew <Bret.Barkelew@microsoft.com> <br>
<b>Sent:</b> Thursday, July 8, 2021 11:05 AM<br>
<b>To:</b> Thomas Abraham <thomas.abraham@arm.com>; Ard Biesheuvel (TianoCore) <ardb+tianocore@kernel.org>; Lindholm, Leif <leif@nuviainc.com>; Laszlo Ersek <lersek@redhat.com>; Marvin Häuser <mhaeuser@posteo.de><br>
<b>Subject:</b> ArmVirt and Self-Updating Code<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">All,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Marvin asked me a question on the UEFI Talkbox Discord that’s a little beyond my ken…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">“There is self-relocating code in ArmVirtPkg:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Fedk2%2Fblob%2F17143c4837393d42c484b42d1789b85b2cff1aaf%2FArmVirtPkg%2FPrePi%2FPrePi.c%23L133-L165&data=04%7C01%7CBret.Barkelew%40microsoft.com%7C7f8b266a81d44c853f6108d941d6a804%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637613212486760659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Qe54pIgdrQiP%2Bb9WNOhSRqbWWsJ8FG4ukaYvjRYGfig%3D&reserved=0"><span style="color:#0563C1">https://github.com/tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff1aaf/ArmVirtPkg/PrePi/PrePi.c#L133-L165</span></a><o:p></o:p></p>
<p class="MsoNormal">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 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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">“Now, StandaloneMmPkg has similar (self-)relocation code too:
<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Fedk2%2Fblob%2F17143c4837393d42c484b42d1789b85b2cff1aaf%2FStandaloneMmPkg%2FLibrary%2FStandaloneMmCoreEntryPoint%2FAArch64%2FStandaloneMmCoreEntryPoint.c%23L379-L386&data=04%7C01%7CBret.Barkelew%40microsoft.com%7C7f8b266a81d44c853f6108d941d6a804%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637613212486770613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=HwixIAI%2FnnBRL4lWtdbooRRwps9gOj%2FEekr55DtXE44%3D&reserved=0">
<span style="color:#0563C1">https://github.com/tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff1aaf/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c#L379-L386</span></a><o:p></o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Fedk2%2Fblob%2F17143c4837393d42c484b42d1789b85b2cff1aaf%2FStandaloneMmPkg%2FLibrary%2FStandaloneMmCoreEntryPoint%2FAArch64%2FSetPermissions.c%23L131-L158&data=04%7C01%7CBret.Barkelew%40microsoft.com%7C7f8b266a81d44c853f6108d941d6a804%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637613212486770613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=YcA%2B9yB8lHvCCSMOK8jbfxLXuO1KReB2zjNn9Jcqmc0%3D&reserved=0"><span style="color:#0563C1">https://github.com/tianocore/edk2/blob/17143c4837393d42c484b42d1789b85b2cff1aaf/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c#L131-L158</span></a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">“This yields the following questions to me:<o:p></o:p></p>
<p class="MsoNormal">1) What even invokes Standalone MM on ARM? It is documented it is spawned during SEC, but I could not find any actual invocation.<o:p></o:p></p>
<p class="MsoNormal">2) Why does Standalone MM (self-)relocation locate SecCore? Should it not already have been relocated with the code from ArmPlatformPkg? Is Standalone MM embedded into ARM SecCore?<o:p></o:p></p>
<p class="MsoNormal">3) Why is SecCore the only module relocated? Are all others guaranteed to be "properly" loaded?<o:p></o:p></p>
<p class="MsoNormal">4) Is there maybe some high-level documented about the ARM boot flow? It seems to be significantly different from the x86 routes quite vastly.”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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’d avoid churn.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance!<o:p></o:p></p>
<p class="MsoNormal">- Bret<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/78093">View/Reply Online (#78093)</a> |    |  <a target="_blank" href="https://groups.io/mt/84380729/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>