Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1897846ybh; Sun, 8 Mar 2020 16:24:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv0HpGKAbN7ih3omDOaY1jVuFzMfBvrMooHtaagd6Ggt2m6t3IYFMmeWJmQymVtmByiKy/e X-Received: by 2002:aca:5014:: with SMTP id e20mr9947166oib.34.1583709891412; Sun, 08 Mar 2020 16:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583709891; cv=none; d=google.com; s=arc-20160816; b=thdb+rSteB6NtYm8FM+hy9D8Tcy1CkEa1PAFX/8BmoupkXunv72LVZYUHjOuh31P+j bYYwlmSY70ExqSKA4gvYfn31dNpf7a4+KO/jiHpdqAkqqcsnbt9ccQaIyerr0oYR0/LP x2sEWrB2upb4xGnxuQpKpHeD5/D4OHLaNb1VYHoHJ4YnSSPYYdUV4qk9uaJh2jNgGeje 5nk4C+DikcrcpDq9lxu4OqrEaHdpksLvQmxmcq2KEIFj0trQHwM4tNvZav8+AzAlq7fd 1A7HU7b6Q9psooe1+eV+98pEnkPx63Qn52EL+YsGR9QkNC9pOjrce4IL9oqbvEFqUm4b jhiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id; bh=gzz+4Nf5gyl+Jt6YALjlfhjjdW+lUFx5uLpSmRlXkhw=; b=CDLiRmxVO/p+qy5gNL1uC3QkouPN3ABOiCFn6ZvY2pM4hdTQqSPnWv1plEdUAn3aIc mzYhmcOPWJ+jO9FWWVWrdK18Mc6FLipSDbXCt13JbPwK2zQFULGZ1kWg5Kj7zqTLtKOl JnpYBi6ztkwVIJgVF+w+jxuAS+mhylovY/LU8QEzsPU0Zdyg4RrUT2ka3ORZbAGRrF4g gj3Ht6mVxYFX6LkjCUYp2A3bt2Vg9MyoO++BWp+WsisthZ3wvpBE49s2wrlQlTqcp62D ukj8DKk5k15kPEKkmZ4dKdwfmD/GgRJ14BMA5tvRjbvteNrnCK7UDLFs5pFVGuq3+lJT z7Bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si5189518oti.316.2020.03.08.16.24.39; Sun, 08 Mar 2020 16:24:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgCHXX7 (ORCPT + 99 others); Sun, 8 Mar 2020 19:23:59 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:57244 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgCHXX4 (ORCPT ); Sun, 8 Mar 2020 19:23:56 -0400 Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jB5Gj-00035b-ST; Mon, 09 Mar 2020 00:23:39 +0100 Received: from nanos.tec.linutronix.de (localhost [IPv6:::1]) by nanos.tec.linutronix.de (Postfix) with ESMTP id 3DE491040AE; Mon, 9 Mar 2020 00:23:30 +0100 (CET) Message-Id: <20200308222609.932307492@linutronix.de> User-Agent: quilt/0.65 Date: Sun, 08 Mar 2020 23:24:09 +0100 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Frederic Weisbecker , Alexandre Chartre Subject: [patch part-II V2 10/13] x86/entry/common: Split prepare_exit_to_usermode() and syscall_return_slowpath() References: <20200308222359.370649591@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split the functions into traceable and probale parts and a part protected from instrumentation. This is required because after calling user_exit_irqsoff() kprobes and tracepoints/function entry/exit which can be utilized by e.g. BPF are not longer safe vs. RCU. Preparatory step to move irq flags tracing to C code. Signed-off-by: Thomas Gleixner --- V2: New patch to reduce the churn --- arch/x86/entry/common.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -206,7 +206,7 @@ static void exit_to_usermode_loop(struct } /* Called with IRQs disabled. */ -__visible inline void prepare_exit_to_usermode(struct pt_regs *regs) +static noinline void __prepare_exit_to_usermode(struct pt_regs *regs) { struct thread_info *ti = current_thread_info(); u32 cached_flags; @@ -245,11 +245,16 @@ static void exit_to_usermode_loop(struct */ ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED); #endif +} - user_enter_irqoff(); +__visible inline notrace void prepare_exit_to_usermode(struct pt_regs *regs) +{ + __prepare_exit_to_usermode(regs); + user_enter_irqoff(); mds_user_clear_cpu_buffers(); } +NOKPROBE_SYMBOL(prepare_exit_to_usermode); #define SYSCALL_EXIT_WORK_FLAGS \ (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ @@ -277,11 +282,7 @@ static void syscall_slow_exit_work(struc tracehook_report_syscall_exit(regs, step); } -/* - * Called with IRQs on and fully valid regs. Returns with IRQs off in a - * state such that we can immediately switch to user mode. - */ -__visible inline void syscall_return_slowpath(struct pt_regs *regs) +static void __syscall_return_slowpath(struct pt_regs *regs) { struct thread_info *ti = current_thread_info(); u32 cached_flags = READ_ONCE(ti->flags); @@ -302,8 +303,18 @@ static void syscall_slow_exit_work(struc syscall_slow_exit_work(regs, cached_flags); local_irq_disable(); +} + +/* + * Called with IRQs on and fully valid regs. Returns with IRQs off in a + * state such that we can immediately switch to user mode. + */ +__visible inline notrace void syscall_return_slowpath(struct pt_regs *regs) +{ + __syscall_return_slowpath(regs); prepare_exit_to_usermode(regs); } +NOKPROBE_SYMBOL(syscall_return_slowpath); #ifdef CONFIG_X86_64 static __always_inline