From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DE26C5518F for ; Tue, 4 Aug 2026 17:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date :Subject:To:From:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3YU33lJPUS9lf8DqdiIyUWB4R4smDUmz/akkVs1omrw=; b=yw0m+RUlLqLVho e+efURaIm3rUACibfMiGDp1bG3quJ1nRlnN/HnX3MJNqzr4JcgQ+KuJdkJVtcnkf8r5D4LDT9dbj/ hqYb1hpaLZFZz6vz3ghlUS89+/TAyciFrf2y81GcP5e+wMlAfXkGxSwTlakf0Ko96womZPhmW0zzT Qt0Sd9DYRUVBS2IiKyHi0YtsPdnHe0gxu7rukMe34iX6qBEiUp7crih7yprLHU7/ciKTtasieWs7t L2kTp59YAM+zVxZr6Tq2GiR5phFZziMhyi2tDp+PWM/ISq5CVixPInEshFRZaV6An8oVMIqaZbUuP 5k+LOJ6Wpw+8Yoj/L/cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wrIah-00000002QPL-0VRP; Tue, 04 Aug 2026 17:06:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wrIae-00000002QMa-2eRg for linux-arm-kernel@lists.infradead.org; Tue, 04 Aug 2026 17:06:09 +0000 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 C14CF168F; Tue, 4 Aug 2026 10:06:02 -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 CE4DF3F632; Tue, 4 Aug 2026 10:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1785863166; bh=l6V0gdyQVLiuFV34wfUAHvBWEK9j3znHuHfws+Z7rhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqcbSZJGNmNDoLYAe9CagUEDKdBHuuZ1MCOE0DB/ArBKSE+OQyP+V+jD1DZcdDhGW QJjmhFp2MGBkxFLhKFmz/unsflctzbehOsKuB/cCcPBbmrt6t5geEySCUbZ3e2ZlvX SRhIklTV88hvTfRGbW1S51IyqDHFOPeDE3qh3hhQ= From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 12/20] arm64: entry: sdei: Make 'tsk' available Date: Tue, 4 Aug 2026 18:04:55 +0100 Message-Id: <20260804170503.3513916-13-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20260804170503.3513916-1-mark.rutland@arm.com> References: <20260804170503.3513916-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260804_100608_753252_25C8C13E X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, vladimir.murzin@arm.com, ryan.roberts@arm.com, peterz@infradead.org, catalin.marinas@arm.com, david.laight.linux@gmail.com, stable@vger.kernel.org, ruanjinjie@huawei.com, james.morse@arm.com, yang@os.amperecomputing.com, cl@gentwo.org, maz@kernel.org, david@kernel.org, ljs@kernel.org, will@kernel.org, ardb@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For regular entry/exit sequences, we use 'tsk' (x28) to hold the current task pointer, allowing this to be used by various assembly macros. The SDEI entry/exit sequence uses x28 to hold the value of the interrupted sp_el0, and doesn't retain the current task pointer in a register. These differences makes it awkward to share assembly macros across regular entry/exit and SDEI entry/exit, and risk surprises. Align the SDEI entry/exit sequence with regular entry/exit, keeping the current task pointer in 'tsk', and preserving the interrupted sp_el0 in another (callee-saved) register. I've used x20 as x19 was already in used for the relevant sdei_registered_event, and these are the lowest-numbered registers above x18 (which we must preserve for shadow call stack). Signed-off-by: Mark Rutland Cc: Ada Couprie Diaz Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Cc: Jinjie Ruan Cc: Marc Zyngier Cc: Peter Zijlstra Cc: Vladimir Murzin Cc: Will Deacon Cc: Yang Shi --- arch/arm64/kernel/entry.S | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index eadf4e74e72a8..1b4cd70515550 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1027,11 +1027,12 @@ SYM_CODE_START(__sdei_asm_handler) /* * We may have interrupted userspace, or a guest, or exit-from or - * return-to either of these. We can't trust sp_el0, restore it. + * return-to either of these. Preserve the interrupted sp_el0, and + * initialize sp_el0 to the current task. */ - mrs x28, sp_el0 - ldr_this_cpu dst=x0, sym=__entry_task, tmp=x1 - msr sp_el0, x0 + mrs x20, sp_el0 + ldr_this_cpu dst=tsk, sym=__entry_task, tmp=x1 + msr sp_el0, tsk /* If we interrupted the kernel point to the previous stack/frame. */ and x0, x3, #0xc @@ -1047,7 +1048,7 @@ SYM_CODE_START(__sdei_asm_handler) mov x1, x19 bl __sdei_handler - msr sp_el0, x28 + msr sp_el0, x20 /* restore regs >x17 that firmware won't restore */ mov x4, x19 // keep x4 for __sdei_asm_exit_trampoline ldp x18, x19, [x4, #SDEI_EVENT_INTREGS + 16 * 9] -- 2.30.2