<div dir="ltr">Another thing to consider about your feature idea is that the output may be noisy depending on what you were hoping for.<div><br></div><div>SLH tries to mitigate anything that could potentially be a problem and thus it instruments almost every branch, load, and function entry, for example. There isn't a lot of signal about what is really a gadget among the code instrumented by SLH. It really tries to be comprehensive and to avoid missing anything even when that means protecting things that can't realistically be used for a Spectre v1 gadget.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Zola Bridges</div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 23, 2020 at 12:59 PM Zola Bridges <<a href="mailto:zbrid@google.com">zbrid@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi milsegv,<div><br></div><div>I work on SLH. I haven't thought about the feature you'd like to see. It sounds pretty interesting. What would you like to use it for? Are you trying to learn more about how SLH works or are you hoping to use this feature for your project? I'm also interested in what you're working on for Spectre v1 detection if you'd like to share!</div><div><br></div><div>I'm not sure how to go from the Machine IR that the SLH pass works on to the original C++ source code, so I can't give you advice on implementing that in LLVM. Hopefully someone else can chime in who understands the LLVM stack better than me.</div><div><br></div><div><b>If you'd like to get a better understanding of how SLH works:<br></b><div><br></div><div>Have you looked into using the LLVM_DEBUG macro? You can use it to print where you want from the SLH pass.<br>Check it out here: <a href="https://llvm.org/docs/ProgrammersManual.html#the-llvm-debug-macro-and-debug-option" target="_blank">https://llvm.org/docs/ProgrammersManual.html#the-llvm-debug-macro-and-debug-option</a> You'll have to add it where you want to see what SLH is doing in the X86SpeculativeLoadHardening.cpp file and rebuild from source to get the new error messages.</div><div><br></div><div>Another useful thing for you might be to pass either of these to clang when you enable -mspeculative-load-hardening</div><div><ul><li>-mllvm -print-after-all</li><li>-mllvm -print-after="x86-slh"</li></ul></div><div>This will let you look at the code before and after the SLH transformations.</div><div><br></div><div><b>If you want to implement this new feature that you want to build on:</b></div><div><b><br></b></div><div>One thing about your question to print where SLH applies the mitigation. I'd say the mitigation has multiple parts and it may be easier to understand your problem if you get more granular about what you mean. Do you want to know which loads in the C++ source get hardened? Or which conditions had instrumentation added? There are the instruction sequences that are added to track the predicate state and there are the instruction sequences that are added to mask data dependent loads and probably other parts that I can't think of off the top of my head. To figure out what you want to print it might be helpful to read this design doc if you haven't seen it: <a href="https://llvm.org/docs/SpeculativeLoadHardening.html" target="_blank">https://llvm.org/docs/SpeculativeLoadHardening.html</a>.</div><div><br></div><div><div><div dir="ltr"><div dir="ltr">Zola Bridges</div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 22, 2020 at 9:52 AM Praveen Velliengiri via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi<div>I think llvm-dev list (CC'ed) have more visibility in this.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 22 Apr 2020 at 22:18, milsegv via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hello everyone,<br></div><div><br></div><div>It may not be the best place to ask this but I found nothing on the internet about it. <br></div><div>I'm working on Spectre V1 detection and stumbled upon the mitigation provided by clang, the "-mspeculative-load-hardening" option. I found it really interesting, and my question is the following: is there a way to tweak the compiler to print a message whenever it applies the mitigation, telling the user at which line of its code it applied the patch ?<br></div><div>I have no idea of the difficulty of such a feature, but I'm ready to learn how to do it myself if anybody has time to tell me how to !<br></div><div><br></div><div>Thanks for any help,<br></div><div>milsegv<br></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</blockquote></div>