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 BTI landing pads to the AArch64 SHA2 assembly #15339

Merged
merged 1 commit into from
Oct 3, 2023

Conversation

zxombie
Copy link
Contributor

@zxombie zxombie commented Oct 2, 2023

Motivation and Context

When booting on AArch64 hardware with the Branch Target Identification (BTI) extension the kernel can panic as the SHA256 and SHA512 assembly functions don't have the needed landing pad instructions.

Description

This adds the needed BTI C instruction, encoded using the hint variant so old assemblers will understand it. On hardware that doesn't understand BTI, or where BTI is not enabled this is a nop so is safe.

How Has This Been Tested?

I booted on an Arm simulator with a kernel that enabled BTI for the ZFS module and ran the FreeBSD testsuite. Without this change the kernel will panic due to the lack of BTI instructions, with this change the test suite completes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

The Arm Branch Target Identification (BTI) extension guards against
branching to an unintended instruction.

To support BTI add the landing pad instructions to the SHA2 functions.
These are from the hint space so are a nop on hardware that lacks BTI
support or if BTI isn't enabled.

Signed-off-by: Andrew Turner <[email protected]>
@allanjude
Copy link
Contributor

Thanks for the fix Andy

Copy link
Contributor

@allanjude allanjude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Allan Jude <[email protected]>

Copy link
Contributor

@mcmilk mcmilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Oct 3, 2023
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for running this down.

@behlendorf behlendorf merged commit f795e90 into openzfs:master Oct 3, 2023
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Oct 4, 2023
The Arm Branch Target Identification (BTI) extension guards against
branching to an unintended instruction.

To support BTI add the landing pad instructions to the SHA2 functions.
These are from the hint space so are a nop on hardware that lacks BTI
support or if BTI isn't enabled.

Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Signed-off-by: Andrew Turner <[email protected]>
Closes openzfs#14862
Closes openzfs#15339
@zxombie zxombie deleted the bti branch October 4, 2023 08:45
behlendorf pushed a commit that referenced this pull request Oct 4, 2023
The Arm Branch Target Identification (BTI) extension guards against
branching to an unintended instruction.

To support BTI add the landing pad instructions to the SHA2 functions.
These are from the hint space so are a nop on hardware that lacks BTI
support or if BTI isn't enabled.

Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Signed-off-by: Andrew Turner <[email protected]>
Closes #14862
Closes #15339
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Dec 12, 2023
The Arm Branch Target Identification (BTI) extension guards against
branching to an unintended instruction.

To support BTI add the landing pad instructions to the SHA2 functions.
These are from the hint space so are a nop on hardware that lacks BTI
support or if BTI isn't enabled.

Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Signed-off-by: Andrew Turner <[email protected]>
Closes openzfs#14862
Closes openzfs#15339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants