/* Flush FPU content and disable access. This is called locally and also from flush_fpu_ipi_handler().  */
void arch_flush_local_fpu(void)
/* Flush FPU content and disable access. This is called locally and also from flush_fpu_ipi_handler().  */
void arch_flush_local_fpu(void)
{
	__ASSERT(read_daif() & DAIF_IRQ_BIT, "must be called with IRQs disabled");
	struct k_thread *owner = atomic_ptr_get(&_current_cpu->arch.fpu_owner);
	if (owner != NULL) {
		uint64_t cpacr = read_cpacr_el1();
		write_cpacr_el1(cpacr | CPACR_EL1_FPEN_NOTRAP);
		barrier_isync_fence_full();
		z_arm64_fpu_save(&owner->arch.saved_fp_context);
		barrier_dsync_fence_full();
		atomic_ptr_clear(&_current_cpu->arch.fpu_owner);
		DBG("disable", owner);
		write_cpacr_el1(cpacr & ~CPACR_EL1_FPEN_NOTRAP);
		barrier_isync_fence_full();
	}
}