Page MenuHomeFreeBSD

arm64: Don't enable interrupts when in a spinlock
ClosedPublic

Authored by andrew on Sep 27 2024, 3:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 9 2024, 8:54 PM
Unknown Object (File)
Nov 3 2024, 11:02 AM
Unknown Object (File)
Oct 31 2024, 3:31 PM
Unknown Object (File)
Oct 24 2024, 1:54 PM
Unknown Object (File)
Oct 23 2024, 5:37 PM
Unknown Object (File)
Oct 22 2024, 4:19 AM
Unknown Object (File)
Oct 9 2024, 2:46 AM
Unknown Object (File)
Oct 9 2024, 2:45 AM
Subscribers

Details

Summary

When we receive an exception while in a spinlock we shouldn't enable
interrupts. When entering a spinlock we disable interrupts so enabling
them here could cause surprising results.

The three cases that could cause this are:

  1. A break-before-make sequence
  2. Accessing possibly unmapped code with a fault handler
  3. Buggy code

1 and 2 are supported later in the data abort handler, and 3 should be
fixed when found.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added inline comments.
sys/arm64/arm64/trap.c
345

IMO this shouldn't be conditional on INVARIANTS...

This revision is now accepted and ready to land.Sep 30 2024, 9:00 AM
sys/arm64/arm64/trap.c
345

I think it was a KASSERT earlier, so was changes to be this to add the registers.

sys/arm64/arm64/trap.c
345

Sure, I'm just saying that the whole block should be unconditional.

imho, arm32 has slightly more correct code/condition, see|: https://cgit.freebsd.org/src/tree/sys/arm/arm/trap-v6.c#n403

spinlock_count > 0 implies that interrupts were disabled, so that code is a bit redundant - it could just check whether PSR_I is clear. But yes, I agree it's more correct.

Also check I and F flags before enabling interrupts

This revision now requires review to proceed.Oct 23 2024, 1:43 PM
This revision is now accepted and ready to land.Oct 23 2024, 6:58 PM