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 446E9C88E53 for ; Tue, 15 Sep 2026 11:33:45 +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=5pDTYibtotoJl0CfBpt6utVDR2mfl4I4vpQdvs8YOz4=; b=WUBMYUuQpat0kGnjfepKtpS3yJ r2hrqO4xSIvN5ZMYFbs+NWUBuk1rIHnXoVaHFQKSi8DLIusI7eO1APvoQmPrh0lQ4eqAPk9n5WKfg 9tatHM7OJd3CezCau1K2ThkZcg45o+5jmmuTrvYvUGKjNqagXCjnvghJm33RfWpEoqYNz4wPknmwC cbZjN8L+RsxqnjqW4vBomJOud8/H47mpc9zXIU35jIts4R6jipK4WgZij9TSBk3xcqwi5DV7Mv1e1 CB1gAr+mG8yQNvxDskzSI1XlTnuLv3z8Gb4Vdljog2o84QMPGf2AeguhEjSGCUeB9uojLwi1tj143 fHW3BluQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x6RPt-000000069Ux-1g6J; Tue, 15 Sep 2026 11:33:37 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x6RPg-000000069Hj-26l3; Tue, 15 Sep 2026 11:33:27 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E7EE2602C4; Tue, 15 Sep 2026 11:33:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75E0B1F00893; Tue, 15 Sep 2026 11:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789472003; bh=5pDTYibtotoJl0CfBpt6utVDR2mfl4I4vpQdvs8YOz4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=b3o4OfqwaaazxAeRj/9Gk+rfkrUg7U0vI6JKs41UHHO10m4El4MPR0Sa+EE2Gn36Z JbZmIMb8qLAtadMRwVadqK0bIP8UDUY4u9lCU6f1ugKbhwheYaNkZU/jT+i4Dv1Jl9 iSky0rNqGXpj8pMhwujZIwbQHG7ClelfVDOe+So8VfCSthJENcXqjh0059JfLailqW emN+KAXu8UUFnpvYfDn0atcumjm+ShG8MC7FrqvcAxOpAeul4vea+zYnk6otK0pmNa VCFcB52eVERu7FbBBcw9uj72b8Lk1KHXA5mpSreLxYJMokQq6XzH3u5VGfdEMuIA0u VKtgipEWo0wug== From: Christian Brauner Date: Tue, 15 Sep 2026 13:31:02 +0200 Subject: [PATCH RFC POC 16/50] sparc: commit fds on syscall exit MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260915-work-fd-reserve-unify-folded-v1-16-4d5217d6b246@kernel.org> References: <20260915-work-fd-reserve-unify-folded-v1-0-4d5217d6b246@kernel.org> In-Reply-To: <20260915-work-fd-reserve-unify-folded-v1-0-4d5217d6b246@kernel.org> To: Linus Torvalds Cc: Alexander Viro , Jann Horn , Jan Kara , Ingo Molnar , Peter Zijlstra , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oleg Nesterov , linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, Jens Axboe , io-uring@vger.kernel.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, bpf@vger.kernel.org, David Airlie , virtualization@lists.linux.dev, kvm@vger.kernel.org, kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, "Christian Brauner (Amutable)" X-Mailer: b4 0.17-dev-db0b7 X-Developer-Signature: v=1; a=openpgp-sha256; l=6251; i=brauner@kernel.org; h=from:subject:message-id; bh=pmbItuaGjYhqGPqyFZ/vQ3bw6O4Agi1po5EvnXuKgAA=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWSt1KmNrfkT+/ZOoMD81otBR7+qPEnjKjXl+DDvernoB 8aVLipdHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABPRrmH4Z/WrKjlPiWfpjeMh +/UOr9OUYuVN+MrcGf8r+7t7cIlFMyPD/eNVJ7U/2tpNS1Kb+nTNq0L7h/NS/upwScjx8VlbzD3 GAwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 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 Add TIF_FD_SLOTS and test it together with the other syscall exit work on the way out of a system call. A task that reserved descriptors calls syscall_trace() on sparc32 and syscall_trace_leave() on sparc64. Signed-off-by: Christian Brauner (Amutable) --- arch/sparc/include/asm/thread_info_32.h | 2 ++ arch/sparc/include/asm/thread_info_64.h | 9 ++++++++- arch/sparc/kernel/entry.S | 2 +- arch/sparc/kernel/ptrace_32.c | 4 ++++ arch/sparc/kernel/ptrace_64.c | 4 ++++ arch/sparc/kernel/syscalls.S | 4 +++- 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h index fdaf7b171e0a..fbd7af6bb427 100644 --- a/arch/sparc/include/asm/thread_info_32.h +++ b/arch/sparc/include/asm/thread_info_32.h @@ -105,6 +105,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ +#define TIF_FD_SLOTS 6 /* syscall prepared descriptors */ #define TIF_USEDFPU 8 /* FPU was used by this task * this quantum (SMP) */ #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling @@ -117,6 +118,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define _TIF_SIGPENDING (1< +#include #include #include #include @@ -437,6 +438,9 @@ asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p) { int ret = 0; + if (syscall_exit_p && test_thread_flag(TIF_FD_SLOTS)) + fd_slots_commit(regs); + if (test_thread_flag(TIF_SYSCALL_TRACE)) { if (syscall_exit_p) ptrace_report_syscall_exit(regs, 0); diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c index 825ddf55fece..499b30c505fd 100644 --- a/arch/sparc/kernel/ptrace_64.c +++ b/arch/sparc/kernel/ptrace_64.c @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -1110,6 +1111,9 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs) if (test_thread_flag(TIF_NOHZ)) user_exit(); + if (test_thread_flag(TIF_FD_SLOTS)) + fd_slots_commit(regs); + audit_syscall_exit(regs); if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S index 96fe8763d70c..086fb8eaf133 100644 --- a/arch/sparc/kernel/syscalls.S +++ b/arch/sparc/kernel/syscalls.S @@ -269,10 +269,12 @@ ret_sys_call: ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2 sllx %g2, 32, %g2 + /* Reload the flags, the syscall may have set TIF_FD_SLOTS. */ + ldx [%g6 + TI_FLAGS], %l0 cmp %o0, -ERESTART_RESTARTBLOCK bgeu,pn %xcc, 1f - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 + andcc %l0, _TIF_SYSCALL_EXIT_WORK, %g0 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc 2: -- 2.53.0