From patchwork Mon Dec 18 07:45:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 180191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1086631dyi; Sun, 17 Dec 2023 23:48:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiUohIEjBdHuX/yyCHWJRK3ax9z9FOaEe2nMxdePeqv9X3SuAhuF37IZTGbaCzhZ1dZwu2 X-Received: by 2002:a17:902:704c:b0:1d0:6ffd:cec8 with SMTP id h12-20020a170902704c00b001d06ffdcec8mr8031520plt.129.1702885702589; Sun, 17 Dec 2023 23:48:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702885702; cv=none; d=google.com; s=arc-20160816; b=ScObRG/vpjIT7i1X0buSHtT4JFdF20iFhLdRAPwuDaVXAP9/4alh5mD1m9CM+bZGlj m+nY8BZH12zSOhKTB6f4PnuIDj3AvpHQHrcoRWDgGEs5b2sO+VNUGWdB31RY1posYfSO Xmh9oxHIXigkBLZuHNW+apgL6shEjedejwoLif3JFvu/VcIlfJtBnNjrguFHsRyqHO44 c0G2wg1GXkr2XyUDxnRxjjHUMsn45wPQ7EBclaVeksKRZ9yTwyhjqmaZpyKkmLH8WXfi r36zUMbvUomLX4Q2TiNAfDqcU6UUzmMtAaRmWT+f+sw/ODpWgrAwb32p79+PM9WAIIZ4 lbKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GEniAdUQCRgZQi4eZ2dmeoTq2XuNKM3RqrVv1xpRjaQ=; fh=U2g0jiA3Tw7gpGNywwyfYnxP8tTSM1Q6YkOBxeYNVJ0=; b=egdYhhvL8y3W8YhscgfeGMihcqN9XjMuSSnW2JJGbtk4Q3DzTI+ETScn72S0snA8EL oSRu0EO4itIiEriJvOXDpcS929k9ji6TeTsSOfJX8nNLGg2+At3Z+LT562Tt4V5JMzHf ozQxeXLNVYspi8g6IQqFwlpk4r3nQ4d31TuPFX0tDm0iNCxQkW7on4u1+N1w2QeJMU9z E3wRcxQGlAZ71/qEBk9K0oWijOE5yOE3WIBqem7ZlMWagb9eqADy3ubWoKZMZr4aZCnd qACiWnE+6nsoWcAyJyDY2JjMtHjdhCArb3sMfETd7X0Sf3LJvoIMI8v6bGMm8fnPZX5G RCOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Hj91gRty; spf=pass (google.com: domain of linux-kernel+bounces-3120-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3120-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x9-20020a170902ec8900b001d0c1ce3428si17658525plg.262.2023.12.17.23.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 23:48:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3120-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Hj91gRty; spf=pass (google.com: domain of linux-kernel+bounces-3120-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3120-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 67B6AB213DC for ; Mon, 18 Dec 2023 07:46:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 491AC107AD; Mon, 18 Dec 2023 07:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Hj91gRty" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 3819FE553 for ; Mon, 18 Dec 2023 07:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BI7ZUOS011115; Mon, 18 Dec 2023 07:45:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=GEniAdUQCRgZQi4eZ2dmeoTq2XuNKM3RqrVv1xpRjaQ=; b=Hj91gRtyb+4swPm66EqL/HxlZOlAg+zqSDPk2uJRuzHUQlen/h1EsScNh9Thhps/D236 YjI5LL+PlQHfLVowR/2Xdz2/fpmX47deXo+ZMX4C4AXml14+Xo9CCQy6m/K8CUg3RUhB Gf+r+wLmr6/g54nPhyIy0dI+8lf5GUOsDV8xnVbZ5tr9sDQWwlezIM+5ivcfZoBrCvI6 8L5JB4emlu5i1gTwi3Yh84twor+/WoaHnV6AQw767jbArVh3dGdA/vPhjkgXJDrFxNF1 5/GIl+2QQAKfdl+xH5NsLUlOiHKzblP6VO9NXH4ieN50389b1WANFVWPSAW8pcHkHo3a EA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v2dkmxp59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Dec 2023 07:45:27 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BI6PnG4010904; Mon, 18 Dec 2023 07:45:26 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3v1q7n7d8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Dec 2023 07:45:26 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BI7jOS711993726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Dec 2023 07:45:24 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F80520043; Mon, 18 Dec 2023 07:45:24 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EECA20040; Mon, 18 Dec 2023 07:45:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTPS; Mon, 18 Dec 2023 07:45:24 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 13E3FE1506; Mon, 18 Dec 2023 08:45:24 +0100 (CET) From: Sven Schnelle To: Thomas Gleixner , Peter Zijlstra , Andy Lutomirski Cc: linux-kernel@vger.kernel.org, Heiko Carstens Subject: [PATCH v2 2/3] entry: move enter_from_user_mode() to header file Date: Mon, 18 Dec 2023 08:45:19 +0100 Message-Id: <20231218074520.1998026-3-svens@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231218074520.1998026-1-svens@linux.ibm.com> References: <20231218074520.1998026-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tWRgv-oV7nog7uBoCnfkO3vE1TbX0oc8 X-Proofpoint-GUID: tWRgv-oV7nog7uBoCnfkO3vE1TbX0oc8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-18_04,2023-12-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 spamscore=0 mlxscore=0 phishscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxlogscore=578 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312180054 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785605078250692495 X-GMAIL-MSGID: 1785605078250692495 To allow inlining of enter_from_user_mode(), move it to entry-common.h. Signed-off-by: Sven Schnelle --- include/linux/entry-common.h | 15 ++++++++++++++- kernel/entry/common.c | 26 +++----------------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index b08aceb26e8e..e8f1e4bba1c1 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -102,7 +103,19 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) {} * done between establishing state and enabling interrupts. The caller must * enable interrupts before invoking syscall_enter_from_user_mode_work(). */ -void enter_from_user_mode(struct pt_regs *regs); +static __always_inline void enter_from_user_mode(struct pt_regs *regs) +{ + arch_enter_from_user_mode(regs); + lockdep_hardirqs_off(CALLER_ADDR0); + + CT_WARN_ON(__ct_state() != CONTEXT_USER); + user_exit_irqoff(); + + instrumentation_begin(); + kmsan_unpoison_entry_regs(regs); + trace_hardirqs_off_finish(); + instrumentation_end(); +} /** * syscall_enter_from_user_mode_prepare - Establish state and enable interrupts diff --git a/kernel/entry/common.c b/kernel/entry/common.c index 113bd3e8e73e..cd40cd1b4616 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -15,26 +15,6 @@ #define CREATE_TRACE_POINTS #include -/* See comment for enter_from_user_mode() in entry-common.h */ -static __always_inline void __enter_from_user_mode(struct pt_regs *regs) -{ - arch_enter_from_user_mode(regs); - lockdep_hardirqs_off(CALLER_ADDR0); - - CT_WARN_ON(__ct_state() != CONTEXT_USER); - user_exit_irqoff(); - - instrumentation_begin(); - kmsan_unpoison_entry_regs(regs); - trace_hardirqs_off_finish(); - instrumentation_end(); -} - -void noinstr enter_from_user_mode(struct pt_regs *regs) -{ - __enter_from_user_mode(regs); -} - static inline void syscall_enter_audit(struct pt_regs *regs, long syscall) { if (unlikely(audit_context())) { @@ -105,7 +85,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) { long ret; - __enter_from_user_mode(regs); + enter_from_user_mode(regs); instrumentation_begin(); local_irq_enable(); @@ -117,7 +97,7 @@ noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall) noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs) { - __enter_from_user_mode(regs); + enter_from_user_mode(regs); instrumentation_begin(); local_irq_enable(); instrumentation_end(); @@ -264,7 +244,7 @@ __visible noinstr void syscall_exit_to_user_mode(struct pt_regs *regs) noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs) { - __enter_from_user_mode(regs); + enter_from_user_mode(regs); } noinstr void irqentry_exit_to_user_mode(struct pt_regs *regs)