Skip to contentSkip to conversation

x86: add memory clobber in switch_to()

RFC PATCH Applied Vegard Nossum 2 participants 2 messages Sep 14, 2008 – Sep 15, 2008

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86: add memory clobber in switch_to()

There are more places which have segment register reloads without adding memory clobbers. Should we fix them up? Here's one of them:

Quoted 1 line

From 5f135687f7730fbdd979b6fb408fd3ca08a0a678 Mon Sep 17 00:00:00 2001

From: Vegard Nossum <[email protected]>
Date: Sun, 14 Sep 2008 18:53:22 +0200
Subject: [PATCH] x86: add memory clobber in switch_to()

Segment registers are reloaded, so we should add a memory clobber. The generated assembly code is identical in my tests, but this doesn't mean it is necessarily true for all configurations/compilers.

x86_64 already has the memory clobber.

---
 include/asm-x86/system.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
include/asm-x86/system.h +4 -1
index 983ce37..fed6482 100644
@@ -64,7 +64,10 @@ do {									\
 		       							\
 		       /* regparm parameters for __switch_to(): */	\
 		       [prev]     "a" (prev),				\
-		       [next]     "d" (next));				\
+		       [next]     "d" (next)				\
+									\
+		     : /* reloaded segment registers */			\
+			"memory");					\
 } while (0)
 
 /*
Signature · 1 line
1.5.5.1
Applied
#1 lore raw
Quoted 2 lines · Vegard Nossum

There are more places which have segment register reloads without adding memory clobbers. Should we fix them up? Here's one of them:

yes, i think so.

Quoted 8 lines
Quoted 1 line

From 5f135687f7730fbdd979b6fb408fd3ca08a0a678 Mon Sep 17 00:00:00 2001

From: Vegard Nossum <[email protected]>
Date: Sun, 14 Sep 2008 18:53:22 +0200
Subject: [PATCH] x86: add memory clobber in switch_to()

Segment registers are reloaded, so we should add a memory clobber. The generated assembly code is identical in my tests, but this doesn't mean it is necessarily true for all configurations/compilers.

applied to tip/x86/core, thanks Vegard.

Ingo