[PATCH v6 2/3] aarch64: clear ZA state of SME before clone and clone3 syscalls

Yury Khrustalev yury.khrustalev@arm.com
Wed Oct 8 11:32:29 GMT 2025


On Wed, Oct 08, 2025 at 08:25:01AM -0300, Adhemerval Zanella Netto wrote:
> 
> ...
> >>> I think there is no need to constrait the temporary to x13, we can let
> >>> compiler pick it instead:
> >>>
> >>> #define CALL_LIBC_ARM_ZA_DISABLE()                              \
> >>> ({                                                              \
> >>>   unsigned long int __tmp;                                      \
> >>>   asm volatile (                                                \
> >>>   "     mov             %0, x30\n"                              \
> >>>   "     .cfi_register   x30, %0\n"                              \
> >>>   "     bl              __libc_arm_za_disable\n"                \
> >>>   "     mov             x30, %0\n"                              \
> >>>   "     .cfi_register   %0, x30\n"                              \
> >>>   : "=r" (__tmp)                                                \
> >>>   :                                                             \
> >>>   : "x14", "x15", "x16", "x17", "x18", "memory" );              \
> >>> })
> >>
> >> Compiler might not know the calling convention of__libc_arm_za_disable().
> >> It's a private Glibc function and a compiler might treat it as such
> >> applying common rules. I think it's safer to force use of x13 that we
> >> know will stay unchanged.
> > 
> > But x13 is temporary register to save the stack pointer, afaiu there is no
> > need to be x13 in C code.
> 
> I mean, the inline asm already define the clobbered registers so compiler
> should pick one that is no suppose to pick.

I agree that it would probably be OK but I also feel like we don't gain
much by allowing a compiler to pick a register. On the other hand, using
a specific register makes it consistent with other usages of this
function and guarantees it will always work. I don't have strong opinion
on this though.

Yury



More information about the Libc-alpha mailing list