All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/entry: Clarify the RF saving/restoring situation with SYSCALL/SYSRET
@ 2016-08-03 10:19 Borislav Petkov
  2016-08-03 16:42 ` Andy Lutomirski
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2016-08-03 10:19 UTC (permalink / raw)
  To: X86 ML; +Cc: LKML, Andy Lutomirski

From: Borislav Petkov <bp@suse.de>

Clarify why exactly RF cannot be restored properly by SYSRET to avoid
confusion.

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
---
 arch/x86/entry/entry_64.S | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 8956eae04c25..80ad6d0fe38b 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -288,11 +288,15 @@ return_from_SYSCALL_64:
 	jne	opportunistic_sysret_failed
 
 	/*
-	 * SYSRET can't restore RF.  SYSRET can restore TF, but unlike IRET,
-	 * restoring TF results in a trap from userspace immediately after
-	 * SYSRET.  This would cause an infinite loop whenever #DB happens
-	 * with register state that satisfies the opportunistic SYSRET
-	 * conditions.  For example, single-stepping this user code:
+	 * SYSCALL clears RF when it saves rFLAGS in R11 so SYSRET cannot
+	 * restore RF properly. If the slowpath sets it for whatever reason, we
+	 * need to restore it correctly.
+	 *
+	 * SYSRET can restore TF, but unlike IRET, restoring TF results in a
+	 * trap from userspace immediately after SYSRET.  This would cause an
+	 * infinite loop whenever #DB happens with register state that satisfies
+	 * the opportunistic SYSRET conditions.  For example, single-stepping
+	 * this user code:
 	 *
 	 *           movq	$stuck_here, %rcx
 	 *           pushfq
-- 
2.8.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-10 18:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03 10:19 [PATCH] x86/entry: Clarify the RF saving/restoring situation with SYSCALL/SYSRET Borislav Petkov
2016-08-03 16:42 ` Andy Lutomirski
2016-08-03 17:14   ` Borislav Petkov
2016-08-03 17:24     ` Andy Lutomirski
2016-08-03 17:54       ` Borislav Petkov
2016-08-10 18:10     ` [tip:x86/urgent] " tip-bot for Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.