summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/sync_core.h
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2020-12-04 08:07:03 +0300
committerThomas Gleixner <tglx@linutronix.de>2020-12-09 11:37:42 +0300
commita493d1ca1a03b532871f1da27f8dbda2b28b04c4 (patch)
tree61407e37eea602bd636baf5cc44105c85dcb8bf6 /arch/x86/include/asm/sync_core.h
parent0477e92881850d44910a7e94fc2c46f96faa131f (diff)
downloadlinux-a493d1ca1a03b532871f1da27f8dbda2b28b04c4.tar.xz
x86/membarrier: Get rid of a dubious optimization
sync_core_before_usermode() had an incorrect optimization. If the kernel returns from an interrupt, it can get to usermode without IRET. It just has to schedule to a different task in the same mm and do SYSRET. Fortunately, there were no callers of sync_core_before_usermode() that could have had in_irq() or in_nmi() equal to true, because it's only ever called from the scheduler. While at it, clarify a related comment. Fixes: 70216e18e519 ("membarrier: Provide core serializing command, *_SYNC_CORE") Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/5afc7632be1422f91eaf7611aaaa1b5b8580a086.1607058304.git.luto@kernel.org
Diffstat (limited to 'arch/x86/include/asm/sync_core.h')
-rw-r--r--arch/x86/include/asm/sync_core.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/include/asm/sync_core.h b/arch/x86/include/asm/sync_core.h
index 0fd4a9dfb29c..ab7382f92aff 100644
--- a/arch/x86/include/asm/sync_core.h
+++ b/arch/x86/include/asm/sync_core.h
@@ -98,12 +98,13 @@ static inline void sync_core_before_usermode(void)
/* With PTI, we unconditionally serialize before running user code. */
if (static_cpu_has(X86_FEATURE_PTI))
return;
+
/*
- * Return from interrupt and NMI is done through iret, which is core
- * serializing.
+ * Even if we're in an interrupt, we might reschedule before returning,
+ * in which case we could switch to a different thread in the same mm
+ * and return using SYSRET or SYSEXIT. Instead of trying to keep
+ * track of our need to sync the core, just sync right away.
*/
- if (in_irq() || in_nmi())
- return;
sync_core();
}