From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87AFF3B5825 for ; Tue, 7 Apr 2026 13:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775567821; cv=none; b=L9mc96rQHuJzVfIe6sbs7SNVPU6T6bhH61hXLHi2Y1f3pgdpjTIuYIR5MTxrV1EbzmGuHDndDAVyA7P131xuxAEbcl5ZzB5VZdZ92pDvnVkl4R+1hzNcgfYw5x9OGF2crd3CxaFWeKtuBA4TzY4wDvYV+CBX32Qte2got0vMaV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775567821; c=relaxed/simple; bh=RC8MlZLQXOs/wu22se6QPuN34nBCxoXl+ve1eY4SviU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EGpziJppqAC2yYFs6YZUk7xrvX2LUnImDWECpxvRSXxE4ye2jaNRKb2GXg7/C33UXZlb5uA6pqR89okIg7Dd/92SXnYFVa25Yk6PRTV4MrNvqhEKqlJnPTBgATMw8gVxoXhZuPip/3qmWL4aRiOOvhfqfbRmZPOckwv5uI3EOSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=OmftG4XW; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="OmftG4XW" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2694A16F2; Tue, 7 Apr 2026 06:16:53 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 065A03F7D8; Tue, 7 Apr 2026 06:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1775567818; bh=RC8MlZLQXOs/wu22se6QPuN34nBCxoXl+ve1eY4SviU=; h=From:To:Cc:Subject:Date:From; b=OmftG4XWxu9BRZDz1jwAXLwP4FcvXPY9p5DaVEc3sxuMqTIpOBoXsc1qP2PFnLbDb 4QY79658o5BauA9Aq4VzY7avDQBuj9+tkSRP2TCMBbwT77oqf2b2kxJA76Q0Vutz/S /M4rcM9y2BmgUaoI4sJva87HW/FOQ3MPknnWc6mw= From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, Andy Lutomirski , Catalin Marinas , Peter Zijlstra , Thomas Gleixner , Will Deacon Cc: ada.coupriediaz@arm.com, linux-kernel@vger.kernel.org, mark.rutland@arm.com, ruanjinjie@huawei.com, vladimir.murzin@arm.com Subject: [PATCH 00/10] arm64/entry: Date: Tue, 7 Apr 2026 14:16:40 +0100 Message-Id: <20260407131650.3813777-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since the move to generic IRQ entry, arm64's involuntary kernel preemption logic has been subtly broken, and preemption can lead to tasks running with some exceptions masked unexpectedly. The gory details were discussed in the thread for my earlier attempt to fix this: https://lore.kernel.org/linux-arm-kernel/20260320113026.3219620-1-mark.rutland@arm.com/ https://lore.kernel.org/linux-arm-kernel/ab1prenkP-tFgUzK@J2N7QTR9R3.cambridge.arm.com/ https://lore.kernel.org/linux-arm-kernel/ab2EZAXvL6bYcuKt@J2N7QTR9R3.cambridge.arm.com/ https://lore.kernel.org/linux-arm-kernel/acPAzdtjK5w-rNqC@J2N7QTR9R3/ In summary, due to the way arm64's exceptions work architecturally, and due to some constraints on sequencing during entry/exit, fixing this properly requires tha arm64 handles more of the sequencing and (architectural) state management itself. This series attempts to make that possible by refactoring the generic irqentry kernel mode entry/exit paths to look more like the user mode entry/exit paths, with a separate 'prepare' step prior to return. The refactoring also allows more of the generic irqentry code to be inlined into architectural entry code, which can result in slightly better code generation. I've split the series into a prefix of changes for generic irqentry, followed by changes to the arm64 code. I'm hoping that we can queue the generic irqentry patches onto a stable branch, or take those via arm64. The patches are as follows: * Patches 1 and 2 are cleanup to the generic irqentry code. These have no functional impact, and I think these can be taken regardless of the rest of the series. * Patches 3 to 5 refactor the generic irqentry code as described above, providing separate irqentry_{enter,exit}() functions and providing a split form of irqentry_exit_to_kernel_mode() similar to what exists for irqentry_exit_to_user_mode(). These patches alone should have no functional impact. * Patch 6 is a minimal fix for the arm64 exception masking issues. This DOES NOT depend on the generic irqentry patches, and can be backported to stable. * Patches 7 to 9 refactor the arm64 entry code and provide a more optimal fix (which permits preemption in more cases). These are split into separate patches to aid bisection. * Patch 10 is a test which can detect exceptions being masked unexpectedly. I don't know whether we want to take this as-is, but I've included it here to aid testing and so that it gets archived for future reference. The series is based on v7.0-rc3. Thanks, Mark. Mark Rutland (10): entry: Fix stale comment for irqentry_enter() entry: Remove local_irq_{enable,disable}_exit_to_user() entry: Move irqentry_enter() prototype later entry: Split kernel mode logic from irqentry_{enter,exit}() entry: Split preemption from irqentry_exit_to_kernel_mode() arm64: entry: Don't preempt with SError or Debug masked arm64: entry: Consistently prefix arm64-specific wrappers arm64: entry: Use irqentry_{enter_from,exit_to}_kernel_mode() arm64: entry: Use split preemption logic arm64: Check DAIF (and PMR) at task-switch time arch/arm64/kernel/entry-common.c | 52 ++++---- arch/arm64/kernel/process.c | 25 ++++ include/linux/entry-common.h | 2 +- include/linux/irq-entry-common.h | 196 ++++++++++++++++++++++--------- kernel/entry/common.c | 107 ++--------------- 5 files changed, 202 insertions(+), 180 deletions(-) -- 2.30.2