From patchwork Thu Oct 10 11:34:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13830020 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 56066CF11D0 for ; Thu, 10 Oct 2024 12:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bckn3YFGIgJxyi6JuzR+D6XCfS8U3/QVQiTYkjNWbHI=; b=QOzIFshtabAAuftkY/Tg4lWW5M viSm/fsnPSRoKwV/PrkdjIUz+nuTs7Fqa5GA7qUlxLTwb/+lsiuG+1ADVRMwOjzQblV6wr3ATHVpr kOuPuCKx2wCSDUXCB9qlcYZKFOUEjoUdenkGAnd0heganAwn/76DaIDoMdRWFlgRW9yZi6FrpbyZ2 YmvGcllIdprVrjx77ggTpZqdthqc9SITbseyY+fLtPs2bN1fYat8T/PtbnUNO0Q0MVNz0BGa+LLDM KoiC6cn6TMOl/Op9UERgAKSGcf2fkVGO9NTUi9Lcv/BW0FkcC00Ehb9VB+D8tqcZsGt2aaZk6h2RI IBli0SQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syry3-0000000CesP-03FI; Thu, 10 Oct 2024 12:08:31 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syrR2-0000000CYPK-0UwU for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 11:34:30 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a7aa086b077so115805766b.0 for ; Thu, 10 Oct 2024 04:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728560062; x=1729164862; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bckn3YFGIgJxyi6JuzR+D6XCfS8U3/QVQiTYkjNWbHI=; b=mgCTZ/44EutcGKcUII1en5JHBXRPfjEPmkG0jKD1jJxbDrhF+iTKNHqa74aHd3YnEK j21QZwdBKZgyRMgg52Q/RPj8BFTR05hH9aSTlHPHGP28crNp/DoaQh2/1Fef0e3Q21e0 mI1b7CO0HZKYRmrH9wtzW8k4oEczq4hf+VEIG4Yfuxm6dOmbU/pTWb18FGw3Ef1q5sb1 jTS9Jeo6/xP222+DTy49QghJPAQTXmO+xplvsJ7IKkwTRv9NLpYf02NH13cEzlF+RSMW umKMszUJ8AoR70wCS7svhXRPcYGdr8rDIYW6+xxDKZxDz8HYmWfTIVQpHuEY/YckJx6w RdKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728560062; x=1729164862; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bckn3YFGIgJxyi6JuzR+D6XCfS8U3/QVQiTYkjNWbHI=; b=iByZFmegQwZvrMuuqUMyicV+iDrMLIFOeFS2WGlUpCs19CnFw/pOFrnCvx3/uI5LZR 2lSwzWkaCGkfNq63jnWnlsu/OErrVWXZYwN28VcEjE8SWujSdvb8vbASNWpanXbw6y0T pXOgPys4M/3Lw4G3VqqWTq7s+KieDSTUooisrbAGs6Cg3kFJRbymc6XS1L2L3pUA+04r YyOD5ZZDD9FTQKH3wNAG4J1tNvNbgDLtoUFHFJco6omTmQUrS93zXzK26r9/h5cYpium GSsSNVjC6mo2RrFd+ZcSzfyfeoYZnhSTOWU2Lpmx0y3ggsjp3aLKR+HUEq9+2fdVfvVJ R/Mw== X-Gm-Message-State: AOJu0YyR8HKGdlCU9UsFgMY02gwWGrqiwmW9zFnpdqtC5Hus2b3JjOc5 k0U1TojA1F/Ci5WsozwQD/bMTNf4/MaJZJgMxAnYPVr/Ymy99htcR3hVIyn23IU= X-Google-Smtp-Source: AGHT+IFigyJ/4+OGI1gC8uCP0lgfYv0O7YK2EBVE6+TDguBMfdVneKhgbLHN8YNte2qxqNUZjO00NA== X-Received: by 2002:a17:907:944d:b0:a99:5baf:12a4 with SMTP id a640c23a62f3a-a999e695b35mr298335366b.17.1728560062133; Thu, 10 Oct 2024 04:34:22 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7f25406sm77619066b.69.2024.10.10.04.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 04:34:20 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 13:34:01 +0200 Subject: [PATCH RFC 23/28] ARM: entry: Stop exiting syscalls like IRQs MIME-Version: 1.0 Message-Id: <20241010-arm-generic-entry-v1-23-b94f451d087b@linaro.org> References: <20241010-arm-generic-entry-v1-0-b94f451d087b@linaro.org> In-Reply-To: <20241010-arm-generic-entry-v1-0-b94f451d087b@linaro.org> To: Oleg Nesterov , Russell King , Kees Cook , Andy Lutomirski , Will Drewry , Frederic Weisbecker , "Paul E. McKenney" , Jinjie Ruan , Arnd Bergmann , Ard Biesheuvel , Al Viro Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_043424_227961_07F80777 X-CRM114-Status: GOOD ( 14.91 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The syscalls are issued as software interrupts, and to this point they were sharing code with the other exception handlers, but this does not work with generic entry. Make syscall_exit_to_user_mode do what irqentry_exit_to_user_mode does at it's tail, and drop the invocations of irqentry_exit_to_user_mode from the syscall path so that these are now exception-exclusive. Split ret_to_user and ret_to_user_from_irq into two distinct execution paths. Signed-off-by: Linus Walleij --- arch/arm/kernel/entry-common.S | 14 ++++++++++++-- arch/arm/kernel/entry.c | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 5385574c4339..e2ac6d3216b6 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -42,7 +42,6 @@ ret_fast_syscall: /* do_rseq_syscall needs interrupts enabled. */ mov r0, sp @ 'regs' bl syscall_exit_to_user_mode - asm_irqentry_exit_to_user_mode #ifdef CONFIG_GCC_PLUGIN_STACKLEAK bl stackleak_erase_on_task_stack @@ -62,6 +61,18 @@ ENTRY(ret_to_user) enable_irq_notrace @ enable interrupts mov r0, sp @ 'regs' bl syscall_exit_to_user_mode + ldr r1, [tsk, #TI_FLAGS] + movs r1, r1, lsl #16 + beq 1f + mov r0, sp @ 'regs' + bl do_work_pending +1: +#ifdef CONFIG_GCC_PLUGIN_STACKLEAK + bl stackleak_erase_on_task_stack +#endif + restore_user_regs +ENDPROC(ret_to_user) + ENTRY(ret_to_user_from_irq) ldr r1, [tsk, #TI_FLAGS] movs r1, r1, lsl #16 @@ -76,7 +87,6 @@ no_work_pending: #endif restore_user_regs ENDPROC(ret_to_user_from_irq) -ENDPROC(ret_to_user) /* * This is how we return from a fork. diff --git a/arch/arm/kernel/entry.c b/arch/arm/kernel/entry.c index 0e3960844b94..88a7a699306a 100644 --- a/arch/arm/kernel/entry.c +++ b/arch/arm/kernel/entry.c @@ -30,6 +30,10 @@ void syscall_exit_to_user_mode(struct pt_regs *regs) local_irq_disable(); if (has_syscall_work(flags)) do_work_pending(regs, flags); + + trace_hardirqs_on(); + /* This context tracking call has inverse naming */ + user_enter_callable(); } noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)