Skip to content

[ATfE] Implement __arm_sme_state in LLVM libc bootcode#849

Merged
voltur01 merged 3 commits into
arm:arm-softwarefrom
voltur01:libc_sme_bootcode
May 18, 2026
Merged

[ATfE] Implement __arm_sme_state in LLVM libc bootcode#849
voltur01 merged 3 commits into
arm:arm-softwarefrom
voltur01:libc_sme_bootcode

Conversation

@voltur01

@voltur01 voltur01 commented May 8, 2026

Copy link
Copy Markdown
Contributor

This adds LLVM libc bootcode support for __arm_sme_state as per https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#811__arm_sme_state to match this LLVM change llvm/llvm-project#191434

@voltur01 voltur01 requested a review from a team as a code owner May 8, 2026 11:39
@voltur01

voltur01 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@MacDue @sdesmalen-arm please review __arm_sme_state for LLVM libc, thanks!

@MacDue MacDue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems reasonable to me (though I've not worked on LLVM libc)

" /* Check whether SME or SME2 is present. */\n"
" mrs x16, id_aa64pfr1_el1\n"
" tst w16, #0x3000000\n"
" b.eq .L__arm_sme_state_no_sme\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to TODO/FIXME to handle this similar to picolibc/newlib? i.e., avoiding re-checking id_aa64pfr1_el1 in user code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO.

Comment on lines +43 to +45
asm volatile("mrs %0, s3_4_c1_c2_6" : "=r"(smcr));
smcr = (smcr & ~0xfUL) | 0xfUL;
asm volatile("msr s3_4_c1_c2_6, %0\n\tisb" : : "r"(smcr) : "memory");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Should picolib/newlib also handle the EL2 case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

picolibc assumes it is running at EL1, LLVM libc boot code here can run at EL2 and EL3.

Comment thread arm-software/embedded/llvmlibc-support/crt0/misc_a.h Outdated
Comment thread arm-software/embedded/llvmlibc-support/crt0/misc_a.h Outdated
Comment thread arm-software/embedded/llvmlibc-support/crt0/misc_a.h
Comment thread arm-software/embedded/llvmlibc-support/crt0/misc_a.h Outdated
Comment thread arm-software/embedded/llvmlibc-support/crt0/sme_abi.cpp
@voltur01 voltur01 requested a review from vhscampos May 18, 2026 08:12

@vhscampos vhscampos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks really good now. Thanks for the updates

@voltur01

Copy link
Copy Markdown
Contributor Author

Thank you for the review and confirmation!

@MacDue any more comments from your side?

@MacDue MacDue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@voltur01 voltur01 merged commit 146009b into arm:arm-software May 18, 2026
2 checks passed
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.

3 participants