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

aarch64-dit: safe, high-level API #1108

Merged
merged 1 commit into from
Sep 6, 2024
Merged

aarch64-dit: safe, high-level API #1108

merged 1 commit into from
Sep 6, 2024

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Sep 6, 2024

Removes the previous low-level unsafe API and wraps it up instead in a safe API which automatically performs runtime CPU feature detection and RAII guards for enabling DIT and restoring its previous state when done.

Removes the previous low-level unsafe API and wraps it up instead in a
safe API which automatically performs runtime CPU feature detection and
RAII guards for enabling DIT and restoring its previous state when done.
@tarcieri tarcieri merged commit 8bdc7cb into master Sep 6, 2024
4 checks passed
@tarcieri tarcieri deleted the aarch64-dit/safe-api branch September 6, 2024 13:25
pub fn enable(&self) -> Guard<'_> {
let was_enabled = if self.is_supported() {
let was_enabled = unsafe { get_dit_enabled() };
unsafe { set_dit_enabled() };
Copy link
Member

Choose a reason for hiding this comment

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

This will result in two separate function calls because #[target_feature(enable = "dit")] prevents inlining. It may be worth to tweak set_dit_enabled to return DIT state flag and write here let was_enabled = unsafe { set_dit_enabled() };

Copy link
Member Author

Choose a reason for hiding this comment

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

Aah, good point

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.

2 participants