Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2452563ybh; Fri, 24 Jul 2020 13:14:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU6U5TVmubkQZqhZ147hLuKwsbB0MD8RbYCO/wVCjPYpO/9nc+/H4dENb4XqvM32pJ8Nyr X-Received: by 2002:a50:a45d:: with SMTP id v29mr10497848edb.284.1595621697590; Fri, 24 Jul 2020 13:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595621697; cv=none; d=google.com; s=arc-20160816; b=ZJ8LXZqMQZW83+b89tbeBFoAtwPclxs0CyLn7yZ2YwzO0pE5lJmcx3QeneEdiXHd5+ TLbwa4Js9rFirZfOujM5/BT22AKJyoewQzgl+p4t7YARuEa99vBbieNcoK2XBbxqOMou VSq7a4evxlGHVtia42avkbNtyybt+PtsZzyj3a2Ys4/Z9jBR3ehQD/KrZZMIJ3NmKtA9 Vt14hypojc0nMzSMjPfNiUV1/RqawYRupjL/2eFOUrbCda2qKQQaRwNU2D5Weuf8hEF7 9mwTfTqjNpcu7tlR98okoKzc1GbtPWT0/axgq+LWz8QFgm+lPXZy05cXk/iGy5SL4t1j 6omQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=pgEhe2xKmBx6bGkHyWN4MMGdg/XYN639maFaa3NJwVk=; b=MnUmTAMQw4PKdG0KmILPi1wXMkVdMYHKgubSMe6qezr7CjPiN+KedN1eItQqUPbP9P aczVl2O8shel/+8U3PE2I3yUGuGunXg7EPGkU0lBgDk613mgXqnI8POLgqivwh34judi 7V0319gHc6FMRiBgkCH+9ZwTyg9oC128x6xT5NvHqHs03qMgDXrUJnD3X915eAyhawUY PhxWGn/Ni8htfzS4GTAjSRk2A6VZBHNKVnjrtVvPydTzVMMalel6Kee94si9g5mD1Bjl 5nSzaRknyrUAGvzRAkHGPK2Pn37me1MWHH0b3JIQo8Qu6abC/RHszVIzbz//SKsYROSb +evQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=j1EyvPoG; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si1115189edl.585.2020.07.24.13.14.35; Fri, 24 Jul 2020 13:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=j1EyvPoG; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727060AbgGXUL7 (ORCPT + 99 others); Fri, 24 Jul 2020 16:11:59 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:40240 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgGXULo (ORCPT ); Fri, 24 Jul 2020 16:11:44 -0400 Date: Fri, 24 Jul 2020 20:11:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595621502; 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=pgEhe2xKmBx6bGkHyWN4MMGdg/XYN639maFaa3NJwVk=; b=j1EyvPoGvoz9L6SNbZd4MHPWirjzXphKDEBE+eiQb1C5amghcZytbmMiRm7QaN1OWMZf30 1e82NjarIWUReY2ZTUyo3o4iXeNAZIAD+K76oFMaqHukvJk/Tb9KnV52XoiAlgOUrELhfl fsZgE0TFdxV8DUFdN3KRuKfbJGaF8FPbfybH2fzdK7shOAX2JQiVGsxSDfa1OkpwV4Jnro qeWLD3XE/MJYuU901Gn8sFwG2g+F5Zkw5JL5a2Bu9EjPuGUfG2SWV4jaL4SfA85JUl2USe NQcJBR/J+Qphp/MjEF9D7PGi4gGZ+YfiwF3ywIhJ26fGCtFxsl5LG4Wtz6NAug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595621502; 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=pgEhe2xKmBx6bGkHyWN4MMGdg/XYN639maFaa3NJwVk=; b=N0mS93g6IHACVTVPeFsPJK25Ow42ZmhGrWRIFeLU8W3glpitfP9djbQ4hPnR7fWyCDprtl F0EvP6pTa5ftwzCQ== From: "tip-bot2 for Thomas Gleixner" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/entry: Move user return notifier out of loop Cc: Thomas Gleixner , x86 , LKML In-Reply-To: <20200722220520.159112003@linutronix.de> References: <20200722220520.159112003@linutronix.de> MIME-Version: 1.0 Message-ID: <159562150201.4006.16095309587701890873.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/entry branch of tip: Commit-ID: a377ac1cd9d7b9ac8d546dceb3d74956fbfd443f Gitweb: https://git.kernel.org/tip/a377ac1cd9d7b9ac8d546dceb3d74956fbfd443f Author: Thomas Gleixner AuthorDate: Thu, 23 Jul 2020 00:00:02 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 24 Jul 2020 15:04:58 +02:00 x86/entry: Move user return notifier out of loop Guests and user space share certain MSRs. KVM sets these MSRs to guest values once and does not set them back to user space values on every VM exit to spare the costly MSR operations. User return notifiers ensure that these MSRs are set back to the correct values before returning to user space in exit_to_usermode_loop(). There is no reason to evaluate the TIF flag indicating that user return notifiers need to be invoked in the loop. The important point is that they are invoked before returning to user space. Move the invocation out of the loop into the section which does the last preperatory steps before returning to user space. That section is not preemptible and runs with interrupts disabled until the actual return. Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200722220520.159112003@linutronix.de --- arch/x86/entry/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 68d5c86..9415ae5 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -208,7 +208,7 @@ static long syscall_trace_enter(struct pt_regs *regs) #define EXIT_TO_USERMODE_LOOP_FLAGS \ (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE | \ - _TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY | _TIF_PATCH_PENDING) + _TIF_NEED_RESCHED | _TIF_PATCH_PENDING) static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags) { @@ -242,9 +242,6 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags) rseq_handle_notify_resume(NULL, regs); } - if (cached_flags & _TIF_USER_RETURN_NOTIFY) - fire_user_return_notifiers(); - /* Disable IRQs and retry */ local_irq_disable(); @@ -273,6 +270,9 @@ static void __prepare_exit_to_usermode(struct pt_regs *regs) /* Reload ti->flags; we may have rescheduled above. */ cached_flags = READ_ONCE(ti->flags); + if (cached_flags & _TIF_USER_RETURN_NOTIFY) + fire_user_return_notifiers(); + if (unlikely(cached_flags & _TIF_IO_BITMAP)) tss_update_io_bitmap();