From patchwork Thu Dec 21 22:19:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 182458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp719892dyi; Thu, 21 Dec 2023 14:20:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1JYsoPYWFZzRdhQlgbgPruVlCE5T12ioVeLSirrGMLlQpb0rGwuuYHviiFRX7e8rbBZNG X-Received: by 2002:a05:6a20:7b23:b0:195:24c6:3f78 with SMTP id s35-20020a056a207b2300b0019524c63f78mr271823pzh.32.1703197233092; Thu, 21 Dec 2023 14:20:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703197233; cv=none; d=google.com; s=arc-20160816; b=notlvPvQR9pRzJ4UmCVHwQgYas75ijnjgIIARXiWy4K8kTGK0mk/bXckus3swSsyaj sVXt/uqNoQyDg1ktVK6qYwX7iT0DZFIK7IaQWaUNU+uF5AOoI98q8sYYuDpG0MVRaFFG 1gl3NhZtUhm38D+ieRgnxMkB4Poe7crA5FCY7OeVPYwsba61bjDLFkQbKfs8TqFIiroF 8kByeGhlaDIpMsuuB9Uksxpuz5Wp3R0i1zvKgGSVsQyXzKnJ8ymx4wQYtRk2UN6XZk2v 0/3iPEV1Z8CSzgFFFP8vZn35GrsEPG8QPJgPpOAsXV0ZdgIc6yYubvK/PYsTsQI6Alqa cSpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=SVIfz86zLwDDAzvuPStrRVhoyaKHOi+EzjyorsIZCvQ=; fh=9TrmOC1MurzYghjyvBuCOr6rGb7BmcQpO9EEY+4xJHo=; b=nDcz2KIpbtgnjFl5t+YVp9aYGZ50x7omkDxuORXU7fDYM3b4uA5nH6Lhf91I/QGFMD gj+68ViWDBiLW61U3PEck+oFAAXAvue8x2oezE0lnTTMWpvITYNFh9Zmm5flttkiZc0Q YpZF97Dv/d4lvqNw0g/3BUF5uy7/cBmi/VZN1wZ/ml7V8/UtW9QYXsqB/yiCJbT+AEoT FEw5sR9xqU4uSPb8GlbTQH2/7RHj5VI4H4o4SzIz0k+TX5Qx/8QZBYQlunU0SUg746tr Fi2GkFJv4V4ZltfBfEs8A8VLW5d+jLGTvcWHh1qiEpISd66ezMqnlB/JL5pH7gRqF4ea jlUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xtbMQ6JL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-9124-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9124-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x34-20020a17090a6c2500b0028c05688216si374876pjj.32.2023.12.21.14.20.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 14:20:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9124-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xtbMQ6JL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-9124-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9124-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D6C3F283F39 for ; Thu, 21 Dec 2023 22:20:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDAB778E9E; Thu, 21 Dec 2023 22:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xtbMQ6JL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wGZV6Vhn" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A973558224; Thu, 21 Dec 2023 22:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Thu, 21 Dec 2023 22:19:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703197193; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SVIfz86zLwDDAzvuPStrRVhoyaKHOi+EzjyorsIZCvQ=; b=xtbMQ6JLFZD/a2qE3T6a5X0bo4rYX6Ks3svUmkpNIwzN08WaUHmOGLoJlxX/vyCuyFgku9 W0Ek2Tc90jOzh2VsS7wpzO3VkdZa17hvbWUCVRF2k2Unz88Xumojc+nByw4YkitxcyaSn+ MFyT2xMNFhct56DIj9smUrkTLbYZ8eM/1X2jbcvSkxPGntIaCwCBjPlEqXxjwtkyfp0ky1 zB4Bu8KO7ma6sJVFQDcMW/JVSNxtK4TQvpGPPIYJaGLCI8JNPXs//OJFrBOpX1T9i+t08b cl8iAZuXxt5/4Uxn1p4ETb9zOqUESPajw3O4yK58VH0D3j5OelnheGnZciPBHw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703197193; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SVIfz86zLwDDAzvuPStrRVhoyaKHOi+EzjyorsIZCvQ=; b=wGZV6VhnaCh9whg69nG1wneAfIrErtGfosChpxm08s5xfUsnEk2USmqMkXgvsXQg3+dtX2 X9yJTDI5SDPMLsBg== From: "tip-bot2 for Sven Schnelle" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/entry] entry: Move syscall_enter_from_user_mode() to header file Cc: Sven Schnelle , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231218074520.1998026-4-svens@linux.ibm.com> References: <20231218074520.1998026-4-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170319719260.398.4829837604529644212.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785931741781683794 X-GMAIL-MSGID: 1785931741781683794 The following commit has been merged into the core/entry branch of tip: Commit-ID: 221a164035fd8b554a44bd7c4bf8e7715a497561 Gitweb: https://git.kernel.org/tip/221a164035fd8b554a44bd7c4bf8e7715a497561 Author: Sven Schnelle AuthorDate: Mon, 18 Dec 2023 08:45:20 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 21 Dec 2023 23:12:18 +01:00 entry: Move syscall_enter_from_user_mode() to header file To allow inlining of syscall_enter_from_user_mode(), move it to entry-common.h. Signed-off-by: Sven Schnelle Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20231218074520.1998026-4-svens@linux.ibm.com --- include/linux/entry-common.h | 27 +++++++++++++++++++++++++-- kernel/entry/common.c | 32 +------------------------------- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index c420539..b0fb775 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -134,6 +134,9 @@ static __always_inline void enter_from_user_mode(struct pt_regs *regs) */ void syscall_enter_from_user_mode_prepare(struct pt_regs *regs); +long syscall_trace_enter(struct pt_regs *regs, long syscall, + unsigned long work); + /** * syscall_enter_from_user_mode_work - Check and handle work before invoking * a syscall @@ -157,7 +160,15 @@ void syscall_enter_from_user_mode_prepare(struct pt_regs *regs); * ptrace_report_syscall_entry(), __secure_computing(), trace_sys_enter() * 2) Invocation of audit_syscall_entry() */ -long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall); +static __always_inline long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall) +{ + unsigned long work = READ_ONCE(current_thread_info()->syscall_work); + + if (work & SYSCALL_WORK_ENTER) + syscall = syscall_trace_enter(regs, syscall, work); + + return syscall; +} /** * syscall_enter_from_user_mode - Establish state and check and handle work @@ -176,7 +187,19 @@ long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall); * Returns: The original or a modified syscall number. See * syscall_enter_from_user_mode_work() for further explanation. */ -long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall); +static __always_inline long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) +{ + long ret; + + enter_from_user_mode(regs); + + instrumentation_begin(); + local_irq_enable(); + ret = syscall_enter_from_user_mode_work(regs, syscall); + instrumentation_end(); + + return ret; +} /** * local_irq_enable_exit_to_user - Exit to user variant of local_irq_enable() diff --git a/kernel/entry/common.c b/kernel/entry/common.c index 0616f23..88cb3c8 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -25,7 +25,7 @@ static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) } } -static long syscall_trace_enter(struct pt_regs *regs, long syscall, +long syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long work) { long ret = 0; @@ -65,36 +65,6 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall, return ret ? : syscall; } -static __always_inline long -__syscall_enter_from_user_work(struct pt_regs *regs, long syscall) -{ - unsigned long work = READ_ONCE(current_thread_info()->syscall_work); - - if (work & SYSCALL_WORK_ENTER) - syscall = syscall_trace_enter(regs, syscall, work); - - return syscall; -} - -long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall) -{ - return __syscall_enter_from_user_work(regs, syscall); -} - -noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) -{ - long ret; - - enter_from_user_mode(regs); - - instrumentation_begin(); - local_irq_enable(); - ret = __syscall_enter_from_user_work(regs, syscall); - instrumentation_end(); - - return ret; -} - noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs) { enter_from_user_mode(regs);