From patchwork Thu Oct 10 11:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13830019 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 51F16CF11D0 for ; Thu, 10 Oct 2024 12:07:17 +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=Gi2KcUYCbZkPlsUdwrNEo9QLrpmnXM+YJIWNYO7+o8Y=; b=vOLRv7uH5+QrpdYTL00Z8agWUj 3Wr8Spzmz+hdsYuYesCuj53r/y8sJqeAIT8isFwbzYIQYyTQU/N8Gk0DfXN8PnmXHgJBIxXDkXdqj wuwDEhRMS46tS5oRY0ZIKhP4Vm5BSLa9/4gx3P3nYBSEq7eE9e5uQlHxvFLswSwgFYXO9sSSJbuXX 8pwdFhGWXfeLKmQN8We3WtaUypv7vVB94Iyhl+dI70IV5Ao85SXr9a7gAIM5tWTLRHM0nSOdU1RU2 5PxmjQowUMwX3Q2aTfSbaNbxS4mXmywhr11/Bk/eciaeC7Cb76Miaj1joufDt1/JjRfZaUBAyYGd6 uPUeintA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syrwh-0000000Cehj-3W7L; Thu, 10 Oct 2024 12:07:07 +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 1syrQz-0000000CYOg-21WO for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 11:34:25 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a995ec65c35so137451866b.1 for ; Thu, 10 Oct 2024 04:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728560060; x=1729164860; 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=Gi2KcUYCbZkPlsUdwrNEo9QLrpmnXM+YJIWNYO7+o8Y=; b=Cl4AQ5W3CEI30Xf/9u0Blu4ZEYReGpBAhkLrN8g4SduZyUzB2CdzN50tKgeTiEZhxL 8yRG7ZT63it9uSPHTsvGVcprTo2IHZhuFoK8Av5N4vi0tcYrQXu3mfESJrXVelKJUJWX jRFIBR+R681TJgd4W9/HCLo07GcNdUECneFNGutNf5CB66OE9Z6Fa2tBVnDL9iaoeNDB qfEC6BJLCvnecvtCt3YsmG+xr56v8mmZlWIMx4ki6Lq0yFiAMM4/Pc6kA2LT57bOg1C0 rXrMWNdN19C68DizmDxXZ0QMRKZUBi82NXc1hviKcbx7gb6LbAdAiAImE9XeBtXvMb/7 j+dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728560060; x=1729164860; 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=Gi2KcUYCbZkPlsUdwrNEo9QLrpmnXM+YJIWNYO7+o8Y=; b=q/LpXL714TNanl2beTwo2H1RQim1V+eF7aQ7Pewtk00mA9PrNyV4Pz1tZym3AsHN9K Od3lxw4tUFMdDY+1WXx7TvLZ7N0nXITrLzpkjw5MqME4qcQjtNw51pOsJVMs+jj2zIy7 /ALumqfJrwtPYqFm1P/ELTaX3djmWK3Ha8ttMxLm3+OIkHojlSO3ZYeL0GBsfOXBaDBD aIxWdU8yfIE518X7ikGGQ8bIdUzeOiCIry2OsMwSaWahfTSy/FVcpo/xMnSA+vgJ7feZ XxJdKJvTWdEzp8slbQ06M48R+QBvYPAi9eeUUud9WQGZrF9WAJY0UAmqxyDZbuwOBZMg QaSg== X-Gm-Message-State: AOJu0YxEP1TGGm3R2/d3WNrzzzjWvLN/a6U4MxHF3B6oNsu6Ae648Oj8 /gmMOewmiwqz1gR1l1IM+KPPN+PPmoln3WaTdysYhqvdwcuJCi/p50t4CCWr2AM= X-Google-Smtp-Source: AGHT+IG0T9Kw9rtdvh8MtWNWqvxS8ro6kLfwIAoOvd9amat2XPjlnHbF8UXzNiDyhtYS8hL41xf2rA== X-Received: by 2002:a17:907:7f8e:b0:a8d:4954:c209 with SMTP id a640c23a62f3a-a99a13ae710mr266075066b.22.1728560060101; Thu, 10 Oct 2024 04:34:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 04:34:18 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 13:34:00 +0200 Subject: [PATCH RFC 22/28] ARM: entry: Move work processing to C MIME-Version: 1.0 Message-Id: <20241010-arm-generic-entry-v1-22-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_043421_559125_F9A4E0FE X-CRM114-Status: GOOD ( 14.40 ) 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 At the end of a syscall software interrupt and every time we exit an interrupt handler we check if there is work to do, i.e. if the current thread (userspace or kernel daemon) has set the _TIF_SYSCALL_WORK flag. Move this processing over to the C entry code. Signed-off-by: Linus Walleij --- arch/arm/kernel/entry-common.S | 14 +------------- arch/arm/kernel/entry.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 33bc9e7c5b32..5385574c4339 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -42,19 +42,7 @@ ret_fast_syscall: /* do_rseq_syscall needs interrupts enabled. */ mov r0, sp @ 'regs' bl syscall_exit_to_user_mode - ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing - movs r1, r1, lsl #16 - beq 2f - - tst r1, #_TIF_SYSCALL_WORK - beq 1f - - b 2f - -1: mov r0, sp @ 'regs' - bl do_work_pending - -2: asm_irqentry_exit_to_user_mode + asm_irqentry_exit_to_user_mode #ifdef CONFIG_GCC_PLUGIN_STACKLEAK bl stackleak_erase_on_task_stack diff --git a/arch/arm/kernel/entry.c b/arch/arm/kernel/entry.c index 472338047337..0e3960844b94 100644 --- a/arch/arm/kernel/entry.c +++ b/arch/arm/kernel/entry.c @@ -1,10 +1,16 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include #include +static inline bool has_syscall_work(unsigned long flags) +{ + return unlikely(flags & _TIF_SYSCALL_WORK); +} + long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) { trace_hardirqs_on(); @@ -18,8 +24,12 @@ long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) void syscall_exit_to_user_mode(struct pt_regs *regs) { + unsigned long flags = read_thread_flags(); + rseq_syscall(regs); local_irq_disable(); + if (has_syscall_work(flags)) + do_work_pending(regs, flags); } noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs)