<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
+ <a id="OWAAM996403" class="J9Y1oNF3ZpoR5LC3M2PHm mention ms-bgc-nlr ms-fcl-b" href="mailto:Samer.El-Haj-Mahmoud@arm.com">
@Samer El-Haj-Mahmoud</a></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello Leif/Ard/Sami/Samer,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Can you please look at this patch and provide some feedback?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Ashish</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Ashish Singhal <ashishsingha@nvidia.com><br>
<b>Sent:</b> Monday, February 21, 2022 7:42 PM<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io>; sami.mujawar@arm.com <sami.mujawar@arm.com>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>; quic_llindhol@quicinc.com <quic_llindhol@quicinc.com><br>
<b>Cc:</b> Ashish Singhal <ashishsingha@nvidia.com><br>
<b>Subject:</b> [PATCH] ArmPkg: Invalidate Instruction Cache On MMU Enable</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Even with MMU turned off, instruction cache can speculate<br>
and fetch instructions. This can cause a crash if region<br>
being executed has been modified recently. With this patch,<br>
we ensure that instruction cache is invalidated right after<br>
MMU has been enabled and any potentially stale instruction<br>
fetched earlier has been discarded.<br>
<br>
This is specially helpful when the memory attributes of a<br>
region in MMU are being changed and some instructions<br>
operating on the region are prefetched in the instruction<br>
cache.<br>
<br>
Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com><br>
---<br>
 ArmPkg/Library/ArmLib/AArch64/AArch64Support.S           | 4 +++-<br>
 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S | 2 ++<br>
 2 files changed, 5 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S<br>
index d3cc1e8671..9648245182 100644<br>
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S<br>
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S<br>
@@ -89,7 +89,9 @@ ASM_FUNC(ArmEnableMmu)<br>
    dsb     nsh<br>
    isb<br>
    msr     sctlr_el3, x0       // Write back<br>
-4: isb<br>
+4: ic      iallu<br>
+   dsb     sy<br>
+   isb<br>
    ret<br>
 <br>
 <br>
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S<br>
index 66ebca571e..56cc2dd73f 100644<br>
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S<br>
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S<br>
@@ -37,6 +37,8 @@<br>
 <br>
   // re-enable the MMU<br>
   msr   sctlr_el\el, x8<br>
+  ic    iallu<br>
+  dsb   sy<br>
   isb<br>
   .endm<br>
 <br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></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/86881">View/Reply Online (#86881)</a> |    |  <a target="_blank" href="https://groups.io/mt/89309504/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>