Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4209023ybv; Tue, 25 Feb 2020 15:31:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzSMnxRPkZMrsZrbVm2iq4/e+MnNbo5uxua9yHN3W/1eDAW+Ckan7lRxxpmSR/Y4Vx4+XLQ X-Received: by 2002:a9d:2ae5:: with SMTP id e92mr811738otb.72.1582673473688; Tue, 25 Feb 2020 15:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582673473; cv=none; d=google.com; s=arc-20160816; b=MIz/XSbtVH0RVNXp7Wk5OipOS8OvkHaL6NHtbx/hE2aiDoqrVLzY3fDQh2EF0MUlYi O694xrQNtqMxQekmsgLkxieibx0QFaDK3tH/fx2iAL35jfkDPXTps7T+f9O8nsEIDcK0 dg4oFKhU5VApn6nShEwdg2jgxonkKB6tcn/BIWd8wNXONMmcQPO+eQzRFm+fz/A/NWPc xSUZCqg6rzsaR81aR2wrVIFtD18T2JaY0hwLJ2nNifGgw9JQMbi3QAXkQug4FQHJS8Yy EUoFXtJzTswMQPzkOkwCYSe9xcc0+Ztm89fYi0G3NUh9qqilkACK7ffyTlpmjFMHBRMR 4D3w== 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=q+ORCQQsPmtryj98gz4oWBvMuTL4nrcgRsuKjrbxOeU=; b=qm6YEnpUmV+Gk35GwS3SLKk53qa14lXnIVb6G4QzHf9CA8n2mW0SQv1c3cH687ogju ClpJ5UxfPMLRyTIf/C66fFmEtUMmWfwXiWaAEpJjzGapzuhlOrKAiOm6eJDeQlWfm2gS Xx1Yf7SwOJ9SOyr3LndsX/XMbMzPhmfodTmPyyCAAqCeXp9joPy84IJzwclOE/AJIWIN Q/BnGDn4Bu4jmeeCFJVnwBteOHaFr/QqwKHfv973nE7L5lRX49JjFPRG6mtSjF+2DKch qcarJzjj28g69gx9dpmGWSmBBordPz02lsSYhzurJqHgSlZQnR4X5YYFFkfpZlu7iWSn Ga0A== 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 l84si131700oig.5.2020.02.25.15.31.01; Tue, 25 Feb 2020 15:31:13 -0800 (PST) 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 S1729685AbgBYXaj (ORCPT + 99 others); Tue, 25 Feb 2020 18:30:39 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55524 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729489AbgBYXZu (ORCPT ); Tue, 25 Feb 2020 18:25:50 -0500 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 1j6ja6-0004aP-Gp; Wed, 26 Feb 2020 00:25:38 +0100 Received: from nanos.tec.linutronix.de (localhost [IPv6:::1]) by nanos.tec.linutronix.de (Postfix) with ESMTP id 3C91D104097; Wed, 26 Feb 2020 00:25:33 +0100 (CET) Message-Id: <20200225221305.719921962@linutronix.de> User-Agent: quilt/0.65 Date: Tue, 25 Feb 2020 23:08:06 +0100 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Paolo Bonzini , Arnd Bergmann Subject: [patch 5/8] x86/entry/common: Provide trace/kprobe safe exit to user space functions References: <20200225220801.571835584@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 prepare_enter_to_user_mode() and mark it notrace/noprobe so the irq flags tracing on return can be put into it. Signed-off-by: Thomas Gleixner --- arch/x86/entry/common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -196,7 +196,7 @@ static void exit_to_usermode_loop(struct } /* Called with IRQs disabled. */ -__visible inline void prepare_exit_to_usermode(struct pt_regs *regs) +static inline void __prepare_exit_to_usermode(struct pt_regs *regs) { struct thread_info *ti = current_thread_info(); u32 cached_flags; @@ -241,6 +241,12 @@ static void exit_to_usermode_loop(struct mds_user_clear_cpu_buffers(); } +__visible inline notrace void prepare_exit_to_usermode(struct pt_regs *regs) +{ + __prepare_exit_to_usermode(regs); +} +NOKPROBE_SYMBOL(prepare_exit_to_usermode); + #define SYSCALL_EXIT_WORK_FLAGS \ (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT) @@ -271,7 +277,7 @@ static void syscall_slow_exit_work(struc * 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) +__visible inline notrace void syscall_return_slowpath(struct pt_regs *regs) { struct thread_info *ti = current_thread_info(); u32 cached_flags = READ_ONCE(ti->flags); @@ -292,8 +298,9 @@ static void syscall_slow_exit_work(struc syscall_slow_exit_work(regs, cached_flags); local_irq_disable(); - prepare_exit_to_usermode(regs); + __prepare_exit_to_usermode(regs); } +NOKPROBE_SYMBOL(syscall_return_slowpath); #ifdef CONFIG_X86_64 static __always_inline @@ -417,7 +424,7 @@ static __always_inline long do_fast_sysc /* User code screwed up. */ local_irq_disable(); regs->ax = -EFAULT; - prepare_exit_to_usermode(regs); + __prepare_exit_to_usermode(regs); return 0; /* Keep it simple: use IRET. */ }