From patchwork Tue Dec 5 13:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 174052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3429054vqy; Tue, 5 Dec 2023 05:31:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH5S3NEYvpr0bFINxTHoi+kxFgUm4x84Ze4TPR7pIgzeyG/NTLJPF0xYZQZmx2KoJyXwF2 X-Received: by 2002:a17:90b:f86:b0:286:6cc0:885b with SMTP id ft6-20020a17090b0f8600b002866cc0885bmr955957pjb.72.1701783065820; Tue, 05 Dec 2023 05:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701783065; cv=none; d=google.com; s=arc-20160816; b=dLqC3gSsyeoO8d4O8UTHt5XqXzineziRayLvylS/V8w4SEeioI4Zrof6E4iTcixHRU ZCvlcMKQdwmjGYqibQfU8mkeIqVLLKPWBQF7EtSex1zsrPbQoDGAoZQqGYJj0XSqkvmw gJU4wqsXrJ6KzvlHEVmRLogRx3tYbsdiUC4PmgdRiDL1uAVKChbS0ryV+/zrjUgVfs7X DCTcRjEL58BeOAP2dMJniRBfPjhawK4y2Z2wJXThSJUOcqawc9DExHEd+x7NaFbAMz8A YJRyjpCM8ONPIbR+OjJYwvuiryyCGq9A9/3WQhkmOKCl79Mo7rWxRluVjOsknOGUFQzS Cw8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6ihL5NvRIOLsOPu0B41OLQgQb7BVJSoF09y4pnAe2uI=; fh=U2g0jiA3Tw7gpGNywwyfYnxP8tTSM1Q6YkOBxeYNVJ0=; b=eievuBBXG4Ivt3u2d+2iX1hpAHOpULYNcqD+0EZLu94a6U4XqAG2yMhbsuz7ogD4BV IOFD6INjLEnfChS7aEXWF5DhEk/TJtjZdou/tfSZDdPwTa+vaI4o/a0sAGt5PavvAWLq QTZsJX5u8cktqmQA6qfAXR1tVn4pX0qA/32dZ44dz9u0YmeCI3HHCobNSZrGX9mqw3tR cmgMWQqwEbUmWxn3j42X+gZbcBtUize65EAbIs02wFXLZvHYklMkQNfjfBEsyfSXK8Uh txcbZP2q9n5kGq8EY9yTQ5YidWNvGIuTGNY7yJYpw4arPWxq0eTDzZHeR4NONEV3qfJ+ StLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=POdtqm1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f8-20020a17090ace0800b00285864ca8a0si968971pju.180.2023.12.05.05.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 05:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=POdtqm1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0BBF080782BD; Tue, 5 Dec 2023 05:30:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442179AbjLENap (ORCPT + 99 others); Tue, 5 Dec 2023 08:30:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442202AbjLENam (ORCPT ); Tue, 5 Dec 2023 08:30:42 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FBDD1AA for ; Tue, 5 Dec 2023 05:30:48 -0800 (PST) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B5DMKM6009958; Tue, 5 Dec 2023 13:30:27 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=6ihL5NvRIOLsOPu0B41OLQgQb7BVJSoF09y4pnAe2uI=; b=POdtqm1rQKwGPcu6D1IU2fnqBB/DhXZK6L11REuvVd3gOqjjAmjqctGaVaabWzrhTm0j 8CC4GhE6Am0P0BtMciqngLFdgkUPNrfdlt0Hnj2OoBZ8Sznmf73vQW84E68JbQRnmJby OnGynS2jENkXUE2JfL2iFhegmDL4HWFLZB01t7+9y1eA6jlMm1NYB+2iJQ4NehVmLy33 +0VURI6hXKds6asJ19Q+Z8cYYNdI9k2tH+CeRnNTew9Mw+bGNU3uf8GZMzwrxHf8YJUk Ir1SrA/C1KMIPeV2wkHifqn5CF4G37l20lr8l5Jh6WEGykLBeKMVs4H3MLwMzxjCCav8 UQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ut4p9rbuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 Dec 2023 13:30:26 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3B5ArfTp009203; Tue, 5 Dec 2023 13:30:26 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3urgdkxqe0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 Dec 2023 13:30:26 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3B5DUOJd41550300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Dec 2023 13:30:24 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0376F2004B; Tue, 5 Dec 2023 13:30:24 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E810920040; Tue, 5 Dec 2023 13:30:23 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 5 Dec 2023 13:30:23 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id B5CF0E16C2; Tue, 5 Dec 2023 14:30:23 +0100 (CET) From: Sven Schnelle To: Thomas Gleixner , Peter Zijlstra , Andy Lutomirski Cc: linux-kernel@vger.kernel.org, Heiko Carstens Subject: [PATCH 2/3] move enter_from_user_mode() to header file Date: Tue, 5 Dec 2023 14:30:14 +0100 Message-Id: <20231205133015.752543-3-svens@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231205133015.752543-1-svens@linux.ibm.com> References: <20231205133015.752543-1-svens@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ItzOICmd-dOkjSLQXRpFsmrACIAo6_Vu X-Proofpoint-GUID: ItzOICmd-dOkjSLQXRpFsmrACIAo6_Vu 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-05_08,2023-12-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 adultscore=0 clxscore=1011 mlxlogscore=543 bulkscore=0 mlxscore=0 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312050105 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 05:30:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784448880215606537 X-GMAIL-MSGID: 1784448880215606537 To allow inlining of enter_from_user_mode(), move it to 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 f0f1a26dc638..e2c62d111318 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 6ba2bcfbe32c..90b995facd7a 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(); @@ -215,7 +195,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)