From nobody Tue Dec 16 21:10:39 2025 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B782233343C; Thu, 4 Dec 2025 08:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764836525; cv=none; b=bKBEIefdBsPo01g3vYIq/FfB6oEXu8Pi/mU00RKP0hF/6WyHHs5GB/mwiNUsyegel1/7lx2E4WK5UPhQKa5ElcdOd28EK3A+S/xKfpIqdutXB02V9WA7kpubVjJCcQ5WeIeCVpo+/draCLGrFJ8QgV8UjkFNCJ9k6ath3Kkx/JM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764836525; c=relaxed/simple; bh=aG3AtmF12usEsGwSmhyCvpHZGV9MRNSl927bSKCYh7A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SJaG9Ed/ySbtuAEqWuryEWN7Pljd5OVqVZN+KuDhC6dTVbO7ZxY+S2ZhipGI7CCt3zYjPRwMpOmg0NpnZXtfJqp8P3nzzptSPsCYYgz587bxHVMYCRDVjcyPCSJC+z08CrHaOpIsNkiaMUOrXV0Tt3CaHHHEJfKcqbi1q8EXc5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=NhK9ppcL; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="NhK9ppcL" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=zPp8W18dzKYIBqBnjquNPhOqVoaG0FMhWX+NDOwrn4c=; b=NhK9ppcLQDrNCw6cFujodotPhX3lZNsAYQNqCP8YKfcc/cLjXC0ysfx2bhBsk3gljIdo4ME5L t4mGHzez+44xFycMyLfskDGBQffytq++yacV/eJ079CyOIhY9ouaEB5YCfDg2WblY9xKeN1diCb Ta7gWv+Fyi7FZoqRY6VdHpg= Received: from mail.maildlp.com (unknown [172.19.163.17]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4dMS9b4GmZzLlTc; Thu, 4 Dec 2025 16:20:03 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 05BDF1A0188; Thu, 4 Dec 2025 16:21:56 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Dec 2025 16:21:54 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v9 11/16] entry: Split syscall_exit_to_user_mode_work() for arch reuse Date: Thu, 4 Dec 2025 16:21:18 +0800 Message-ID: <20251204082123.2792067-12-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251204082123.2792067-1-ruanjinjie@huawei.com> References: <20251204082123.2792067-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" In the generic entry code, the beginning of syscall_exit_to_user_mode_work() can be reused on arm64 so it makes sense to split it. In preparation for moving arm64 over to the generic entry code, split out syscall_exit_to_user_mode_prepare() helper from syscall_exit_to_user_mode_work(). No functional changes. Reviewed-by: Kevin Brodsky Reviewed-by: Thomas Gleixner Signed-off-by: Jinjie Ruan --- include/linux/entry-common.h | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 7177436f0f9e..cd6dacb2d8bf 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -137,20 +137,11 @@ static __always_inline long syscall_enter_from_user_m= ode(struct pt_regs *regs, l */ void syscall_exit_work(struct pt_regs *regs, unsigned long work); =20 -/** - * syscall_exit_to_user_mode_work - Handle work before returning to user m= ode - * @regs: Pointer to currents pt_regs - * - * Same as step 1 and 2 of syscall_exit_to_user_mode() but without calling - * exit_to_user_mode() to perform the final transition to user mode. - * - * Calling convention is the same as for syscall_exit_to_user_mode() and it - * returns with all work handled and interrupts disabled. The caller must - * invoke exit_to_user_mode() before actually switching to user mode to - * make the final state transitions. Interrupts must stay disabled between - * return from this function and the invocation of exit_to_user_mode(). +/* + * Syscall specific exit to user mode preparation. Runs with interrupts + * enabled. */ -static __always_inline void syscall_exit_to_user_mode_work(struct pt_regs = *regs) +static __always_inline void syscall_exit_to_user_mode_prepare(struct pt_re= gs *regs) { unsigned long work =3D READ_ONCE(current_thread_info()->syscall_work); unsigned long nr =3D syscall_get_nr(current, regs); @@ -171,6 +162,24 @@ static __always_inline void syscall_exit_to_user_mode_= work(struct pt_regs *regs) */ if (unlikely(work & SYSCALL_WORK_EXIT)) syscall_exit_work(regs, work); +} + +/** + * syscall_exit_to_user_mode_work - Handle work before returning to user m= ode + * @regs: Pointer to currents pt_regs + * + * Same as step 1 and 2 of syscall_exit_to_user_mode() but without calling + * exit_to_user_mode() to perform the final transition to user mode. + * + * Calling convention is the same as for syscall_exit_to_user_mode() and it + * returns with all work handled and interrupts disabled. The caller must + * invoke exit_to_user_mode() before actually switching to user mode to + * make the final state transitions. Interrupts must stay disabled between + * return from this function and the invocation of exit_to_user_mode(). + */ +static __always_inline void syscall_exit_to_user_mode_work(struct pt_regs = *regs) +{ + syscall_exit_to_user_mode_prepare(regs); local_irq_disable_exit_to_user(); exit_to_user_mode_prepare(regs); } --=20 2.34.1