From 9028b18f7587fe90a497f4762418a2cb3d478d4d Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 30 Jul 2015 13:59:38 +0000 Subject: [PATCH] Enable IRQ during syscalls on ARM64 FreeBSD provides a feature called Adaptive Mutexes, which allows a thread to spin for a while when the mutex is taken instead of immediately going to sleep. This causes issues when called from syscall handler if interrupts are masked. If every other core also attempts to access the same mutex there is a chance that all of them are spinning on the same lock at the same time. If interrupts are disabled, no kernel preemtion can occur and the system becomes unresponsive. This patch enables interrupts when syscall is being executed and masks them as soon as it is completed. Reviewed by: andrew Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3246 --- sys/arm64/arm64/trap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 89c104f214a1..a8a00d157dd1 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -319,6 +319,12 @@ do_el0_sync(struct trapframe *frame) #endif break; case EXCP_SVC: + /* + * Ensure the svc_handler is being run with interrupts enabled. + * They will be automatically restored when returning from + * exception handler. + */ + intr_enable(); svc_handler(frame); break; case EXCP_INSN_ABORT_L: