Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add -fIBT switch and emit ENDBR for function and thunk prologs #15415

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

WalterBright
Copy link
Member

See https://news.ycombinator.com/item?id=36722823 for more information on IBT.

For the ENDBR32/64 instructions:

https://www.felixcloutier.com/x86/endbr32
https://www.felixcloutier.com/x86/endbr64

I still need to add support for switch jump tables.

I have no way to test this, as my machines don't use IBT. All I can say is disassembly shows the instruction is generated, and the programs still run.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#15415"

@WalterBright
Copy link
Member Author

@thewilsonator
Copy link
Contributor

is this the same or similar to ldc-developers/ldc#4437 ?
I feel we should try to have a consistent interface for this stuff.

cc @ibuclaw @JohanEngelen

@ErnyTech
Copy link

ErnyTech commented Jul 15, 2023

is this the same or similar to ldc-developers/ldc#4437 ? I feel we should try to have a consistent interface for this stuff.

cc @ibuclaw @JohanEngelen

This is the same as -fcf-protection=branch in GDC and LDC (after the PR).
Note that the current PR for DMD does not implement all Intel CET but only IBT (-fcf-protection=branch) which is sufficient for OpenBSD but is not a complete implementation of CET as it lacks the shadow stack (-fcf-protection=return).

It would be good to adopt the -fcf-protection flags in DMD as well

@ibuclaw
Copy link
Member

ibuclaw commented Jul 15, 2023

Wouldn't this be a -gxxx option to be consistent with other dmd options?

@ErnyTech I'd expect dub to be a common front for all command-line differences.

@JohanEngelen
Copy link
Contributor

In the LDC PR I have also implemented __traits(getTargetInfo, "CET") == 0 normally == 1 when IBT is turned on.

@dkorpel
Copy link
Contributor

dkorpel commented Jul 15, 2023

I'd expect dub to be a common front for all command-line differences.

It's still convenient to have consistent naming of flags across compilers, and there's no advantage of naming it differently.

@WalterBright
Copy link
Member Author

-fcf-protection=branch

It's just too long and clunky and un-memorable.

@WalterBright
Copy link
Member Author

I fixed switch code generation so it'll work with IBT.

@ErnyTech
Copy link

ErnyTech commented Jul 16, 2023

-fcf-protection=branch

It's just too long and clunky and un-memorable.

Maybe, but that's what the market has chosen and what all programmers expect, GCC and Clang use -fcf-protection=branch, Rustc use cf-protection=branch

Ok to have a different flag to keep consistency with the other flags, but I don't think the memory issues are applicable here as anyone who needs Intel CET IBT already knows -fcf-protection=branch

@ibuclaw
Copy link
Member

ibuclaw commented Jul 16, 2023

I'd expect dub to be a common front for all command-line differences.

It's still convenient to have consistent naming of flags across compilers, and there's no advantage of naming it differently.

I'd rather just let dmd be consistent with itself, as it has no incentive to copy from others in a really inconsistent way. (ie: the gcc-style prefixing letters -[fmW] refer to specific parts of the compiler which dmd doesn't really have the same separation).

@ibara
Copy link
Contributor

ibara commented Jul 16, 2023

Hi Walter --

Thanks for this. It works for me.

@WalterBright
Copy link
Member Author

@ibara wonderful!

@WalterBright WalterBright merged commit f0b891f into dlang:master Jul 19, 2023
40 checks passed
ErnyTech pushed a commit to ErnyTech/dmd that referenced this pull request Jul 19, 2023
This follows PR dlang#15415 which added Intel CET IBT support and
LDC PR dlang#4437 to add support for the new CET target in order
to maintain a common interface between DMD and LDC.

Later it would be useful to do the same for GDC as well.
ErnyTech pushed a commit to ErnyTech/dmd that referenced this pull request Jul 20, 2023
This follows PR dlang#15415 which added Intel CET IBT support and
LDC PR dlang#4437 to add support for the new CET target in order
to maintain a common interface between DMD and LDC.

Later it would be useful to do the same for GDC as well.
ErnyTech pushed a commit to ErnyTech/dmd that referenced this pull request Jul 20, 2023
This follows PR dlang#15415 which added Intel CET IBT support and
LDC PR dlang#4437 to add support for the new CET target in order
to maintain a common interface between DMD and LDC.

Later it would be useful to do the same for GDC as well.
ErnyTech pushed a commit to ErnyTech/dmd that referenced this pull request Jul 20, 2023
This follows PR dlang#15415 which added Intel CET IBT support and
LDC PR dlang#4437 to add support for the new CET target in order
to maintain a common interface between DMD and LDC.

Later it would be useful to do the same for GDC as well.
dkorpel pushed a commit that referenced this pull request Aug 27, 2023
This follows PR #15415 which added Intel CET IBT support and
LDC PR #4437 to add support for the new CET target in order
to maintain a common interface between DMD and LDC.

Later it would be useful to do the same for GDC as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants