From nobody Thu Oct 24 10:36:38 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XZ2Qb52xsz5bKjw; Thu, 24 Oct 2024 10:36:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZ2Qb0Qf3z4pWy; Thu, 24 Oct 2024 10:36:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729766199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wU7bUADimgBxtKPSz7jWItm86P1f7r87U0X+RPsyqFc=; b=Eml2PhJVrWVNKBkqsHclWKzCa9v9L/eWb5fVN+6OFLTroqqdf1cyLHGfRBPcul86esdP7t sYZy8XNOGUUkuuV7mA4zuVBt0ROkQF3KtAbv2HTP4UeAs8mhQzidxgofjKEPc93V0KJKEu 8pYuMMn6Swguvx5qCfdgYRzTGjq4ZfdPqcBPNthy4HMw/jNfhJ9PG0Uud/TDzmXX0dLqyf s4J4S7KpX43O3XyeQrmtUYIpuJBTbrGOvRw8nXtrIe0kqMMKb1f46MG/WodUrHqjl5sgbw MbhtbQyX3bfH4Rm7GIGmj+uVSAbQeQZE4V0HNk0pxVjnvVbq9fTaEpTY9kl9RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729766199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wU7bUADimgBxtKPSz7jWItm86P1f7r87U0X+RPsyqFc=; b=GA5vcHSvYjOMz4x2QyjJEvbteAsUvaq4AuovBgypr+uzsT9ncegof984CtZo45w22DC0Yn hcquKThP6c/b4OWBcoK2T0Z87KECMOadbtnJpk7eI7N7TsLVvc3sigeA5+/jHC8mnxaWtT IsEknI/r1Bt8fstNscnEyGX9uv6uMtAGWYkXgpT1cpGXYskddBXcs1OSG5MPyu1UIA5IqE +NBjWlTpJVQBIenhdf0UFKZp9FYLbwn7qynEa5l4ETjTi5TGh2lpXkotRby/yJ/2zFAQG3 j1BSz+FARa8ilLji+VTD9lvd10LyU+4ORePUZkM0DWJxy1Sw6IwTHyJx+fjouQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729766199; a=rsa-sha256; cv=none; b=s4RvFC+FJMIEpc+VlhsmTuUIuELUxVwXBMcxv1gonWqCxI2wRcBsTACqf4B3cbdCblwqu5 IGD4ZtSZIPBxF9paafZpCY/PVnxsrW2D1BZ74uxpmHpKToD5IR/nMRHo3hcxXoDc2cSFcS IBKO7LIXIaqOvHuB7qIYuFQYDqYmspNFcD7P3qeNvKWmvz7MYsYwGM1DcIYryBSMv5za3d g4CwpV2uR+jvH5uZP+468D/F+HlgkIUoIvq4ECpcufESoSVn65lCS+lpsVXI/I88dTDaL2 x1Rsi/EQVxR+BbruN/MlZEBIdJoLAVVm6f7JRew8oIoVTKWNbyQlS9/voPvK9A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XZ2Qb037bzfGX; Thu, 24 Oct 2024 10:36:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49OAacno059107; Thu, 24 Oct 2024 10:36:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49OAacub059104; Thu, 24 Oct 2024 10:36:38 GMT (envelope-from git) Date: Thu, 24 Oct 2024 10:36:38 GMT Message-Id: <202410241036.49OAacub059104@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: a84653c5db25 - main - arm64: Don't enable interrupts when in a spinlock List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a84653c5db255bf28c19b64dd6ac20009ebcbce3 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a84653c5db255bf28c19b64dd6ac20009ebcbce3 commit a84653c5db255bf28c19b64dd6ac20009ebcbce3 Author: Andrew Turner AuthorDate: 2024-10-24 09:52:37 +0000 Commit: Andrew Turner CommitDate: 2024-10-24 10:20:48 +0000 arm64: Don't enable interrupts when in a spinlock 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. Reviewed by: mmel, kib, markj Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46816 --- sys/arm64/arm64/trap.c | 12 ++++++++++-- sys/arm64/include/armreg.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index d6e316e7ae0a..544189964ef0 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -308,10 +308,18 @@ data_abort(struct thread *td, struct trapframe *frame, uint64_t esr, break; } } - intr_enable(); + if (td->td_md.md_spinlock_count == 0 && + (frame->tf_spsr & PSR_DAIF_INTR) != PSR_DAIF_INTR) { + MPASS((frame->tf_spsr & PSR_DAIF_INTR) == 0); + intr_enable(); + } map = kernel_map; } else { - intr_enable(); + if (td->td_md.md_spinlock_count == 0 && + (frame->tf_spsr & PSR_DAIF_INTR) != PSR_DAIF_INTR) { + MPASS((frame->tf_spsr & PSR_DAIF_INTR) == 0); + intr_enable(); + } map = &td->td_proc->p_vmspace->vm_map; if (map == NULL) map = kernel_map; diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index e26f9859947e..5e87fafbec31 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -2569,6 +2569,7 @@ #define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F) /* The default DAIF mask. These bits are valid in spsr_el1 and daif */ #define PSR_DAIF_DEFAULT (0) +#define PSR_DAIF_INTR (PSR_I | PSR_F) #define PSR_BTYPE 0x00000c00UL #define PSR_SSBS 0x00001000UL #define PSR_ALLINT 0x00002000UL