On 09.12.2025 01:37, Saman Dehghan wrote:
> This patch enables building Xen on arm64 architecture using the Clang
> compiler.
> Changes include:
> - Add explicit -march=armv8 flag for arm64 builds.
> - Add `__attribute__((target("fp-armv8")))` to `vfp_save_state` and
> `vfp_restore_state` functions when building with Clang to allow
> FP instructions despite `-mgeneral-regs-only`.
>
> Signed-off-by: Saman Dehghan <[email protected]>
> ---
> xen/arch/arm/arch.mk | 1 +
> xen/arch/arm/arm64/vfp.c | 6 ++++++
> 2 files changed, 7 insertions(+)
Please also update ./README then accordingly.
> --- a/xen/arch/arm/arm64/vfp.c
> +++ b/xen/arch/arm/arm64/vfp.c
> @@ -46,6 +46,9 @@ static inline void restore_state(const uint64_t *fpregs)
> : : "Q" (*fpregs), "r" (fpregs));
> }
>
> +#if defined(CONFIG_CC_IS_CLANG)
> +__attribute__((target("fp-armv8")))
> +#endif
> void vfp_save_state(struct vcpu *v)
> {
> if ( !cpu_has_fp )
> @@ -62,6 +65,9 @@ void vfp_save_state(struct vcpu *v)
> v->arch.vfp.fpexc32_el2 = READ_SYSREG(FPEXC32_EL2);
> }
>
> +#if defined(CONFIG_CC_IS_CLANG)
> +__attribute__((target("fp-armv8")))
> +#endif
> void vfp_restore_state(struct vcpu *v)
> {
> if ( !cpu_has_fp )
Aren't it save_state() and restore_state() which actually use FP registers?
Applying such attributes in too wide a fashion risks the compiler using FP
registers also for other purposes. On x86 we were hit by such when we
suppressed use of SSE registers while not suppressing use of MMX ones. In
some configuration, after many years of this having gone fine, the compiler
chose to use MMX insns for some odd reason.
Seeing that save_state() and restore_state() are a single asm() statement
each, any reason not to actually have them in an assembly file, just like
their SVE counterparts are?
Jan