From patchwork Thu Oct 10 11:33:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13830013 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 B67A9CF11D0 for ; Thu, 10 Oct 2024 12:04:35 +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=hWWOf9VRKfs2/tqyRJcdO75r8/gLb8BcoV6DE9Ay3YY=; b=BQG/JLUZVeJ3k8//8AcTDdS8WN dadNPkuac70G/4XzEqxK0MyrN8xRNnBIYv6dvNZgT/PsubsnR8N6mWkW74DEtKe8DVBYM9bBsB9D0 UP+Smlyew9Vqq7m16QhX7G8AYeWq/gyLNp3BHpaAeQxVc2dgU9kpYGHsY821MYtQfI7H5ZzU7A7O6 txyBHVOVDYWTJ5BBevbrxx4lty9z3Zen4TqvPtJoYQmmnd+633efmDcgRbRB7Q9FFi8xYrvtvG9py ZEZiqL2exPeNTrDRczR6t8I0uaihOdhiGBGtgrELGXCN0ZaarjIl2qNDlSu3ft9KyBIiEV79GvBe1 PtIJIM2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syru3-0000000Ce7y-1kl5; Thu, 10 Oct 2024 12:04:23 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syrQv-0000000CYLy-2AFN for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 11:34:21 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a994c322aefso354142866b.1 for ; Thu, 10 Oct 2024 04:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728560056; x=1729164856; 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=hWWOf9VRKfs2/tqyRJcdO75r8/gLb8BcoV6DE9Ay3YY=; b=qQsZA1GyKnA8N2dhMSzCgGAZWfS999We8sHtljyW8YQsTl64afAof5KfbaXl8/zesv jv0YZ0ZuTQ8oPcKb6cO2qK9WWN2AhWYAC/7q6DCZw2t6VIwadS92xtKWfJS49IAxfu4K 5YJBFs7BROHXQNrl02EDaGyi+XH2htlXuAy3cPlaXpGimtCHQ6yh7Vtol/qasKr6nSFs 6s/gKWXESRkFQDlSHuBZGQn7+hcmUOHqAjmBo5IYR7LSwl722tS4zYePwh3MRw4JqSBX Ww3YC8Cu90rhfuSIcI2vjOzuVUxwRPgYuRwrAy/xdRkUj549qivotokbd2/ko8iIg1bc vLkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728560056; x=1729164856; 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=hWWOf9VRKfs2/tqyRJcdO75r8/gLb8BcoV6DE9Ay3YY=; b=YkhuUkAHoRvYyX5XuCXO//6D6XguApyxBUOcfkQzmZYzYp6WqfuAedLQbjvBhtVDnY U1GxiPsh4qhRP9rSgUiBv2ofCsCik0Ttu6LhbsMbhMEal7trFJVsdgEZipkj6c0BmlqI ExXqk/K3Qe/yx0QlkTgqEq6MRxXH3cu+F9N0dUwiuKZMWl8oo5OeHP6uib4xHmlPKMBe E/sdDWi/N6Xkdxl4vPAsxFyxRi+maaTFKDdfvhSpMv9bwaMh7DUixJkJeJm+6ramlsxc 6HXZqHvOl9KOcx4Q6uvzd6xV6qsU8YW6QK5RdEfX7TOKrO2Ay8Y5zVBJAtci1rtW7Q9R cKsg== X-Gm-Message-State: AOJu0YyVYAG3j1rtEqBPMFolsIXCLCtFQBaTPN83ibYYNBXh5Q9hSBYa ianbwtLr8c+GC5PHpJ1d3D7TO7fysPyQwL/YH2NnWKZCA0RUcAfUub3p9oMgBxs= X-Google-Smtp-Source: AGHT+IEHCTRRp7fVGYbHaZJRdCWztPF5Cmz1ArhsR37YdkkUHo8yQ2UvzGBEaqZF9J54+PdeX3iD/A== X-Received: by 2002:a17:906:eec7:b0:a77:ab9e:9202 with SMTP id a640c23a62f3a-a99a0eb9349mr287624366b.4.1728560056112; Thu, 10 Oct 2024 04:34:16 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 04:34:15 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 13:33:58 +0200 Subject: [PATCH RFC 20/28] ARM: entry: Untangle ret_fast_syscall/to_user MIME-Version: 1.0 Message-Id: <20241010-arm-generic-entry-v1-20-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_043417_628698_04AAE082 X-CRM114-Status: GOOD ( 12.26 ) 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 return to userspace is a bit hard to follow. To prepare the ground for further refactorings we rewrite the functions to ret_fast_syscall and ret_to_user are mostly stand-alone symbols. Signed-off-by: Linus Walleij --- arch/arm/kernel/entry-common.S | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index d27e34d7e97a..ece921571714 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -44,20 +44,23 @@ ret_fast_syscall: bl syscall_exit_to_user_mode ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing movs r1, r1, lsl #16 - beq no_work_pending - UNWIND(.fnend ) -ENDPROC(ret_fast_syscall) - - /* Slower path - fall through to work_pending */ + beq 2f tst r1, #_TIF_SYSCALL_WORK - beq slow_work_pending + beq 1f + b ret_to_user -slow_work_pending: - mov r0, sp @ 'regs' +1: mov r0, sp @ 'regs' bl do_work_pending - b no_work_pending + +2: asm_irqentry_exit_to_user_mode + +#ifdef CONFIG_GCC_PLUGIN_STACKLEAK + bl stackleak_erase_on_task_stack +#endif + restore_user_regs + UNWIND(.fnend ) ENDPROC(ret_fast_syscall) /* @@ -74,7 +77,9 @@ ENTRY(ret_to_user) ENTRY(ret_to_user_from_irq) ldr r1, [tsk, #TI_FLAGS] movs r1, r1, lsl #16 - bne slow_work_pending + beq no_work_pending + mov r0, sp @ 'regs' + bl do_work_pending no_work_pending: asm_irqentry_exit_to_user_mode