From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 586991E3DD6 for ; Tue, 7 Jan 2025 09:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736242922; cv=none; b=q/zCaWonINSEg8CrmJsGC/6iu7qrU+8L7a8yu8Xt237x+OCK5lbKe0N53xEZ6IzLqG57LjSnn1zdroNqhbsw9JE+UXNmZFili6AS9UZN5rKF9l+RghXAtagXWr+uXKTESEb+RgLidqQMmCwKERb7/wqnN+aWHsncIzSCA1hZE1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736242922; c=relaxed/simple; bh=6HxqPg0av9QQUsN3LYkBPGsjUjHhG0hpCBVxrgy534Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pDDu0279JcCLUfLAGBdx/zwbyhjx8OoWnFC8G4ppsEX1WMmz+30og+mXCK1Kz2ZgbjUSlDSpGMUOFFIINksXXoXR+2S3RdP+BxrcPKxcBobuhzaCXLvZx2ESHi106MNowx+ZdKo8rMw2fP3X7PPn90QIcn+pWfaYgH3YPcW/4fQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=V/IxRL2V; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="V/IxRL2V" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5d3e9f60bf4so27460232a12.3 for ; Tue, 07 Jan 2025 01:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736242916; x=1736847716; darn=vger.kernel.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=deVa2FvUEOHV8lxaYOobNw6K9tuy+tyk/0Of0h0Ki9g=; b=V/IxRL2Vx06sr8pNAOB/0Xusszy0nfs0Lgl0mKJ715iUsiCX9zjsXgoSmG5Tu3ZHPv Vjr8jgbgnzyucpITa3iq3rf3xDfcAwJj+zT4bafaGVdwOG4IBzIoVBWTjuPp4Yx9uBbr iFqj4VuZ9vrFqKj1s83C3lEzsfWm6emnpkTBgPfQWV6l9oGPgubigIYLfEjAHTxgV2x9 8Rbq64b1Sx3TPicHWjOspEV491FBUgDOuvUcXxPw3xy7kNrfVZ8OTUh7mD+eHQ6m83Iz GLpFp6A+Ocq3c4J5Gqo0/oJrtUXbdKi2wsd/RAiPasTS7nxds4UMD6Dt/aa8ky7uiBf/ ag/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736242916; x=1736847716; 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=deVa2FvUEOHV8lxaYOobNw6K9tuy+tyk/0Of0h0Ki9g=; b=IQkrhMA3Njxu37sH+EW8a7ztc4XSSJuxHT3iygHH3eot9C9R2+d61BHT+XqlCmjRwl 5H+QhVqeugJ6nZPD74T3T0D04fndtBptyFw3VckKsbJcE6kz5iBnaG3g1lNLQa06qPOJ RWHItItG1ZbYzm85mdNYYnLMnV5Mhr4ljxseHaLVGon73EwQE6/IunH8SUqQedXjqxrC bUzOJs+sm8E8bTJZfsQXjl7FtHwF2H5r5Us5uuYBceJaSDfLtKmH/6SN1VPt4KqqG+Wi pSl9R9TCGP1flfra9gTnH+wVZJz30w7/1QQ1tc22arP/4jFn2MPTTl/Mrg44T86j0o1P x17Q== X-Forwarded-Encrypted: i=1; AJvYcCV7q4kVOXEBpby07SEZbNqMMgr+VSMzB5On5HJkNwZCJGmugFELvw72EOMtxkeIhVddaEghMqetLPIbJOQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9rMipIbSV4Kx4yP7iqvbu68VzJxBf5KfJ+GeOkSiXTgi9N8te 3mTUZuwSphHCzV9ALolyp0zg9rgZSMPGMyQRZTbpigWMKT0unrDkTG5ipUWa4F4= X-Gm-Gg: ASbGncvX86+n0b3iToJjUer+sQiDfGHeOuFmh0Z4b80/y9irwoCaHzz2vVmCF4Rqwd7 jcCMvEFBtayFW0P0vYueDR3cQyyl8/knxLFoeDvoqC9VBtIokxx/vsq7v6caNlptnnmymf25Jfp dKynypEi/MlaAH4DVOy+Ajf90yYQbqXAsveRlG2h7ZOgq9/jvkgQsmNDYiQRgRlSL+hPUMF2f7J 8A2j8etklwMBkc7dIz49GvVUdyXS+F0oa5C9rSOc/mYJVvv0JN2lKF60ywzZrMNYvE= X-Google-Smtp-Source: AGHT+IEI7jiLjIgZysIlEX73yDDpgFYYpjbOqnnBoDztE8NoLaevmNECfxbufOxFIll7IK31jTg9iA== X-Received: by 2002:a17:907:7f22:b0:aa6:7c36:3423 with SMTP id a640c23a62f3a-aac2d4472f0mr5322819166b.1.1736242915603; Tue, 07 Jan 2025 01:41:55 -0800 (PST) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aac0f012229sm2356901166b.133.2025.01.07.01.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 01:41:55 -0800 (PST) From: Linus Walleij Date: Tue, 07 Jan 2025 10:41:38 +0100 Subject: [PATCH RFC v3 22/30] ARM: entry: Move work processing to C Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250107-arm-generic-entry-v3-22-4e5f3c15db2d@linaro.org> References: <20250107-arm-generic-entry-v3-0-4e5f3c15db2d@linaro.org> In-Reply-To: <20250107-arm-generic-entry-v3-0-4e5f3c15db2d@linaro.org> To: Dmitry Vyukov , 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.2 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 33bc9e7c5b32f62474724f1d47f97af24dba53bf..5385574c4339714f3d8b5ab6894f27466b89f932 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 47233804733752aef0f2fec6f54badeab18e98d0..0e3960844b94b14325eb00ce7dd791b36c43ac3c 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) -- 2.47.1