Skip to content

Commit

Permalink
[arch][arm64] disable EL1 FPU traps even when starting at EL1
Browse files Browse the repository at this point in the history
It is possible for early initialization functions such as lk_main()
to contain NEON instructions because we don't build the kernel with
-mgeneral-regs-only. As a result we can end up taking an FPU exception
before we are ready to handle it.

We didn't have this problem when starting at a higher exception level
than EL1 because we turned off FPU traps in arm64_elX_to_el1(). But we
neglected to do so when starting at EL1. Fix the problem by moving the
CPACR_EL1 manipulation out of arm64_elX_to_el1() and into arm_reset().
  • Loading branch information
pcc authored and travisg committed Mar 30, 2022
1 parent 6ad3643 commit bce9599
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions arch/arm64/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ FUNCTION(arm64_elX_to_el1)
mov x4, #(1<<31)
msr hcr_el2, x4

/* disable EL1 FPU traps */
mov x4, #(0b11<<20)
msr cpacr_el1, x4

/* set up the EL1 bounce interrupt */
mov x4, sp
msr sp_el1, x4
Expand Down
4 changes: 4 additions & 0 deletions arch/arm64/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ arm_reset:
/* if we came in at higher than EL1, drop down to EL1 */
bl arm64_elX_to_el1

/* disable EL1 FPU traps */
mov tmp, #(0b11<<20)
msr cpacr_el1, tmp

#if WITH_KERNEL_VM
/* enable caches so atomics and spinlocks work */
mrs tmp, sctlr_el1
Expand Down

0 comments on commit bce9599

Please sign in to comment.