Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline

joaomoreira (Joao Moreira)
User

Projects

User does not belong to any projects.

User Details

User Since
Jul 29 2020, 8:27 AM (175 w, 2 d)

Recent Activity

Dec 22 2022

joaomoreira abandoned D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.
Dec 22 2022, 2:09 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.

Given https://reviews.llvm.org/D140363, this patch is being abandoned.

Dec 22 2022, 2:07 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D140363: Remove incorrectly implemented -mibt-seal.

FWIIW, agreed on removing this until we figure out how to make it work properly. Thanks for the patch @MaskRay.

Dec 22 2022, 2:05 PM · Restricted Project, Restricted Project, Restricted Project

Dec 15 2022

joaomoreira planned changes to D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.
Dec 15 2022, 1:52 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.

Regarding not being able to reproduce this in kernel -- never mind... I was misled by setup issues while running IBT kernels in QEMU. I managed to fix the setup and confirm that kernel won't boot.

OK, great. Thanks for double checking!

The patch itself looks good to me, but I suspect ibt-seal in general has the same issue as D138337 where it can drop endbr instructions from isUsedInRegularObj symbols that are not address-taken in the bitcode (e.g. functions whose address is only taken in stand-alone assembly). I saw this issue only in the arm64 Linux kernel, but there's always a chance a similar code pattern emerges on the x86 side at some point in future too. This can obviously be worked around in the kernel, but just something to keep in mind.

Dec 15 2022, 1:51 PM · Restricted Project, Restricted Project, Restricted Project

Dec 14 2022

joaomoreira added a comment to D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.

Weirdly enough, I double-tested the behavior for -flto=thin + -mibt-seal; the kernel did boot fine on my setup, but when dumped/grep'ed for ENDBRs, it had ~500 less ENDBRs throughout the binary

Did you confirm the issue with the reproducer in the CBL bug? It would be interesting to find out why you couldn't reproduce this in the kernel.

Dec 14 2022, 12:48 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.

Regarding https://github.com/ClangBuiltLinux/linux/issues/1737:

Dec 14 2022, 10:44 AM · Restricted Project, Restricted Project, Restricted Project
joaomoreira requested review of D140035: [X86] Prevent -mibt-seal to work together with -flto=thin.
Dec 14 2022, 10:32 AM · Restricted Project, Restricted Project, Restricted Project

Sep 30 2022

joaomoreira updated the diff for D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 2:49 PM · Restricted Project, Restricted Project
joaomoreira updated the diff for D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 2:45 PM · Restricted Project, Restricted Project
joaomoreira added inline comments to D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 2:39 PM · Restricted Project, Restricted Project
joaomoreira added inline comments to D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 2:32 PM · Restricted Project, Restricted Project
joaomoreira added inline comments to D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 12:36 PM · Restricted Project, Restricted Project
joaomoreira added inline comments to D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 12:28 PM · Restricted Project, Restricted Project
joaomoreira added inline comments to D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 12:17 PM · Restricted Project, Restricted Project
joaomoreira updated the diff for D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 12:17 PM · Restricted Project, Restricted Project
joaomoreira added inline comments to D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 12:02 PM · Restricted Project, Restricted Project
joaomoreira updated the diff for D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 30 2022, 12:01 PM · Restricted Project, Restricted Project

Sep 29 2022

joaomoreira requested review of D134915: [X86] Do not emit JCC to __x86_indirect_thunk.
Sep 29 2022, 3:22 PM · Restricted Project, Restricted Project

Aug 13 2022

joaomoreira added inline comments to D119296: KCFI sanitizer.
Aug 13 2022, 1:02 AM · Restricted Project, Restricted Project, Restricted Project

Aug 12 2022

joaomoreira added inline comments to D119296: KCFI sanitizer.
Aug 12 2022, 12:00 PM · Restricted Project, Restricted Project, Restricted Project

Jul 27 2022

joaomoreira accepted D119296: KCFI sanitizer.

I really like this revision. It removes the redundancy of having KCFI passes both in CodeGen and in the backend; it detangles CALL instructions from KCFI by creating a new MIR instruction; it fixes alignment while still supporting the -fpatchable-function-entry option; it doesn't add hashes/gadgets through the code as it was before needed by the use of cmp instructions. With all this said, the patch LGTM.

Jul 27 2022, 8:44 PM · Restricted Project, Restricted Project, Restricted Project

Jun 2 2022

joaomoreira added inline comments to D119296: KCFI sanitizer.
Jun 2 2022, 2:41 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added inline comments to D119296: KCFI sanitizer.
Jun 2 2022, 1:59 PM · Restricted Project, Restricted Project, Restricted Project

May 5 2022

joaomoreira added inline comments to D118355: Add -mmanual-endbr switch to allow manual selection of control-flow protection.
May 5 2022, 11:26 PM · Restricted Project, Restricted Project, Restricted Project

May 2 2022

joaomoreira added a comment to D119296: KCFI sanitizer.

I'm not an expert on LLVM's pipeline, but it just feels a little awkward and redundant that we need passes to fix what other passes messed up regarding a pass that executed before everything.

I don't think so. Consider DCE; other passes leave behind garbage all the time; DCE is expected to clean up after them.

May 2 2022, 9:35 AM · Restricted Project, Restricted Project, Restricted Project

Apr 28 2022

joaomoreira added a comment to D119296: KCFI sanitizer.

I looked at your code quickly and I wonder if using operand bundles would be better than adding an attribute. Thoughts?

Apr 28 2022, 11:57 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D119296: KCFI sanitizer.

I agree that a separate pass wasn't ideal, but InstCombine seems to be full of code to "fix what other passes messed up". :) I'm not sure if messed up is the correct term though, these are checks that were necessary before optimizations, but are no longer needed.

Apr 28 2022, 11:48 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira updated subscribers of D119296: KCFI sanitizer.

This seems like a reasonable approach, and was also the approach taken for the PAuth ABI. The PAuth ABI attaches an operand bundle to the call instruction and arranges for the code for the check to be generated together with the call. This helps with avoiding spills of the verified function pointer between the check and the call. The code isn't upstream but is available on this branch: https://github.com/pcc/llvm-project/tree/apple-pac4

Grep for something like undle.*ptrauth and you should find the relevant code.

Apr 28 2022, 6:26 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.

I think there are no more untied knots... @pengfei, do you think this is ready to merge? If yes, can you please merge it? tks!

Apr 28 2022, 10:34 AM · Restricted Project, Restricted Project

Apr 21 2022

joaomoreira added a comment to D119296: KCFI sanitizer.

Oh, one other tiny detail I forgot to mention. I noticed that the tag is pushing the functions 6 bytes forward, regardless of any prepending padding nops that were added to ensure 16b alignment. It would be cool to care about the proper function alignment and also to not emit dummy padding nops when the padding area can be filled with the tag itself.

Apr 21 2022, 5:15 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira added a comment to D119296: KCFI sanitizer.

I played a little bit with kcfi and here are some thoughts:

Apr 21 2022, 4:37 PM · Restricted Project, Restricted Project, Restricted Project

Apr 19 2022

joaomoreira updated the diff for D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.
Apr 19 2022, 5:14 PM · Restricted Project, Restricted Project

Apr 11 2022

joaomoreira added a comment to D122673: Add kcfi_unchecked attribute.

In the previous discussion, @joaomoreira pointed out that this is very similar to nocf_check and proposed reusing that attribute. In an offline discussion, @pcc was concerned that an attribute may not be the right approach here and suggested a __builtin_kcfi_unchecked(function(args)) built-in function to avoid changing the type system.

Apr 11 2022, 2:15 PM · Restricted Project, Restricted Project

Apr 5 2022

joaomoreira added inline comments to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.
Apr 5 2022, 3:02 PM · Restricted Project, Restricted Project

Apr 4 2022

joaomoreira planned changes to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.
Apr 4 2022, 6:25 PM · Restricted Project, Restricted Project

Mar 23 2022

joaomoreira updated the diff for D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.
Mar 23 2022, 2:26 AM · Restricted Project, Restricted Project
joaomoreira added a comment to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.

I did track down the problem to clang/lib/Frontend/CompilerInvocation.cpp -- RoundTrip method. There, we can se the following statement:

Mar 23 2022, 2:14 AM · Restricted Project, Restricted Project

Mar 3 2022

joaomoreira planned changes to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.
Mar 3 2022, 2:29 PM · Restricted Project, Restricted Project

Feb 25 2022

joaomoreira updated the diff for D120600: [ELF][X86] Don't create IBT .plt if there is no PLT entry.

No problem! And thanks! The test looks better than the one I had half-way implemented. I'm also updating the test which got broken by this fix... let me know if you see a problem with it!

Feb 25 2022, 7:54 PM · Restricted Project, lld
joaomoreira added a comment to D120600: [ELF][X86] Don't create IBT .plt if there is no PLT entry.

Hm. I got tests almost ready (fixed the broken one and am working on finishing a new one). I'll update the diff in a few minutes. I can also update the description, let me know if you have suggestions.

Feb 25 2022, 7:26 PM · Restricted Project, lld
joaomoreira requested review of D120600: [ELF][X86] Don't create IBT .plt if there is no PLT entry.
Feb 25 2022, 4:23 PM · Restricted Project, lld

Feb 8 2022

joaomoreira added inline comments to D119296: KCFI sanitizer.
Feb 8 2022, 9:17 PM · Restricted Project, Restricted Project, Restricted Project

Feb 1 2022

joaomoreira added a comment to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.

ping.

Feb 1 2022, 10:36 AM · Restricted Project, Restricted Project

Jan 27 2022

joaomoreira requested review of D118438: [X86] Implement -mibt-fix-direct=<aggressive,conservative,none>.
Jan 27 2022, 11:56 PM · Restricted Project

Jan 26 2022

joaomoreira added a comment to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.

Hi Gabriel, thanks for the updated review. Here are the cmake flags as you asked:

Jan 26 2022, 8:32 AM · Restricted Project, Restricted Project

Jan 25 2022

joaomoreira added a comment to D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.

Hm. First, thanks a lot for the detailed review. I double check on my end and I still don't get the flag as expected. Here are some of my outputs:

Jan 25 2022, 11:10 AM · Restricted Project, Restricted Project

Jan 24 2022

joaomoreira requested review of D118052: [X86] Fix CodeGen Module Flag for -mibt-seal.
Jan 24 2022, 9:38 AM · Restricted Project, Restricted Project

Jan 20 2022

joaomoreira added a comment to D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel.

@pengfei or @craig.topper perhaps one of you could merge this? please, let me know if I'm missing any obvious requirement or detail.

Jan 20 2022, 1:41 PM · Restricted Project, Restricted Project, Restricted Project

Jan 18 2022

joaomoreira added a comment to D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel.

Hi, is anything still preventing this from being merged?

Jan 18 2022, 1:31 PM · Restricted Project, Restricted Project, Restricted Project

Dec 21 2021

joaomoreira added inline comments to D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel.
Dec 21 2021, 5:54 PM · Restricted Project, Restricted Project, Restricted Project
joaomoreira updated the diff for D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel.

Modularized needsPrologueENDBR function and removed missed comment.

Dec 21 2021, 2:43 PM · Restricted Project, Restricted Project, Restricted Project

Dec 20 2021

joaomoreira requested review of D116070: [X86] Enable ibt-seal optimization when LTO is used in Kernel.
Dec 20 2021, 6:02 PM · Restricted Project, Restricted Project, Restricted Project

Dec 7 2021

joaomoreira added a comment to D111108: [X86] Fix fentry handling in X86IndirectBranchTracking.cpp.

FWIIW, looks correct to me too. Tks @DavidSpickett

Dec 7 2021, 12:12 PM · Restricted Project

Dec 6 2021

joaomoreira added a comment to D111108: [X86] Fix fentry handling in X86IndirectBranchTracking.cpp.

It seems this was not merged yet. Is there anything else needed?

Dec 6 2021, 2:13 PM · Restricted Project

Oct 4 2021

joaomoreira updated the summary of D111108: [X86] Fix fentry handling in X86IndirectBranchTracking.cpp.
Oct 4 2021, 6:59 PM · Restricted Project
joaomoreira requested review of D111108: [X86] Fix fentry handling in X86IndirectBranchTracking.cpp.
Oct 4 2021, 6:57 PM · Restricted Project

Oct 9 2020

joaomoreira added a comment to D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes.

I noticed that this commit breaks MUSL 1.2.0. Here is an isolated test-case that illustrates the issue:

Oct 9 2020, 3:05 PM · Restricted Project

Sep 18 2020

joaomoreira added a comment to D87320: [X86] Check if call is indirect before emitting NT_CALL.

The test was updated in the last revision, diff was also updated for context. Is there anything else needed for this?

Sep 18 2020, 12:30 PM · Restricted Project

Sep 10 2020

joaomoreira updated the diff for D87320: [X86] Check if call is indirect before emitting NT_CALL.
Sep 10 2020, 4:30 PM · Restricted Project

Sep 8 2020

joaomoreira updated the summary of D87320: [X86] Check if call is indirect before emitting NT_CALL.
Sep 8 2020, 12:01 PM · Restricted Project
joaomoreira requested review of D87320: [X86] Check if call is indirect before emitting NT_CALL.
Sep 8 2020, 11:59 AM · Restricted Project

Jul 30 2020

joaomoreira updated the diff for D84862: [X86] Make ENDBR instruction a scheduling boundary.

Fixes:

  • Applied suggestions made by @RKSimon,
  • Fixed "opcode" variable name capitalization.
Jul 30 2020, 3:29 PM · Restricted Project

Jul 29 2020

joaomoreira requested review of D84862: [X86] Make ENDBR instruction a scheduling boundary.
Jul 29 2020, 9:04 AM · Restricted Project