From patchwork Mon Dec 11 02:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luming Yu X-Patchwork-Id: 1874276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SpRBJ6d8rz20Gb for ; Mon, 11 Dec 2023 13:52:56 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SpRBJ2PBDz30gs for ; Mon, 11 Dec 2023 13:52:56 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=shingroup.cn (client-ip=43.155.80.173; helo=bg5.exmail.qq.com; envelope-from=luming.yu@shingroup.cn; receiver=lists.ozlabs.org) Received: from bg5.exmail.qq.com (bg5.exmail.qq.com [43.155.80.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4SpRB63K0jz2xWc for ; Mon, 11 Dec 2023 13:52:46 +1100 (AEDT) X-QQ-mid: bizesmtp64t1702263093txwc5r18 Received: from HX09040029.powercore.com.cn ( [58.34.117.194]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 11 Dec 2023 10:51:30 +0800 (CST) X-QQ-SSF: 01400000000000402000000A0000000 X-QQ-FEAT: l3A5VUsUnUlcsmarVtr1L2MyOzd1tHeCEh7Lba7DnyL7XM6lBjjwpWggANvlj 37vbA2o6jXMMSVExU4hOP923LNECzG2mlYCsrEbEER10kpMLd1ytTJRAIkQMo/DuMHtbIq4 y7fJQxL4aAsCJeZVhKdXRgPujuV96APRS6oMgV7j95XrdcP1Lt7xOBkczU19oMf2JlCRWUI 2i+ILVZ4gDfP7RyUPHDErBcMfhs59sqmk8UESE/ptvWETVMLOy3gUMLpsfja5FudKa+tMpM j30u0h0S/JI0R4dHOKGgVStzn6hC5bwesVf243JoatAujmU6Xn1YuJTs5CsPSNSx+AusESV Ns98AtgEeIccij1Lya9L3/jc15C/ZrmM9K8k7SpfwczAOSjEfCdLCpSjan8rfPvrkHQxBlY pHhEmqIBhuU= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9599634464750526515 From: Luming Yu To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu Subject: [PATCH 1/1] powerpc/debug: implement HAVE_USER_RETURN_NOTIFIER Date: Mon, 11 Dec 2023 10:50:54 +0800 Message-ID: <475A60AEEAA99F6C+20231211025054.885-1-luming.yu@shingroup.cn> X-Mailer: git-send-email 2.42.0.windows.2 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shenghui.qu@shingroup.cn, Luming Yu , dawei.li@shingroup.cn, ke.zhao@shingroup.cn, luming.yu@gmail.com Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The support for user return notifier infrastructure is hooked into powerpc architecture. --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/entry-common.h | 16 ++++++++++++++++ arch/powerpc/include/asm/thread_info.h | 2 ++ arch/powerpc/kernel/process.c | 2 ++ 4 files changed, 21 insertions(+) create mode 100644 arch/powerpc/include/asm/entry-common.h diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index c10229c0243c..b968068cc04a 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -277,6 +277,7 @@ config PPC select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13) select HAVE_STATIC_CALL if PPC32 select HAVE_SYSCALL_TRACEPOINTS + select HAVE_USER_RETURN_NOTIFIER select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_GEN select HOTPLUG_SMT if HOTPLUG_CPU diff --git a/arch/powerpc/include/asm/entry-common.h b/arch/powerpc/include/asm/entry-common.h new file mode 100644 index 000000000000..51f1eb767696 --- /dev/null +++ b/arch/powerpc/include/asm/entry-common.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef ARCH_POWERPC_ENTRY_COMMON_H +#define ARCH_POWERPC_ENTRY_COMMON_H + +#include + +static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, + unsigned long ti_work) +{ + if (ti_work & _TIF_USER_RETURN_NOTIFY) + fire_user_return_notifiers(); +} + +#define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare + +#endif diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h index bf5dde1a4114..47e226032f9c 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h @@ -117,6 +117,7 @@ void arch_setup_new_exec(void); #endif #define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_32BIT 20 /* 32 bit binary */ +#define TIF_USER_RETURN_NOTIFY 21 /* notify kernel of userspace return */ /* as above, but as bit values */ #define _TIF_SYSCALL_TRACE (1< #include #include +#include #include #include @@ -1386,6 +1387,7 @@ struct task_struct *__switch_to(struct task_struct *prev, if (current->thread.regs) restore_math(current->thread.regs); #endif /* CONFIG_PPC_BOOK3S_64 */ + propagate_user_return_notify(prev, new); return last; }