summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2004-02-01 19:22:30 +0000
committerderaadt <deraadt@openbsd.org>2004-02-01 19:22:30 +0000
commitc9d6b72888ce0963724e680ffb2d7ea74a762f0b (patch)
treef25c3ea0947eee22a9aa8bca19472eb77d3b8915
parentuse VIA xstore-rng and xcrypt-* instructions, now that gas groks them (diff)
downloadwireguard-openbsd-c9d6b72888ce0963724e680ffb2d7ea74a762f0b.tar.xz
wireguard-openbsd-c9d6b72888ce0963724e680ffb2d7ea74a762f0b.zip
Use "pushfl; popfl" sequence before each xcrypt-* instruction. According
to the manual, any load into the EFLAGS register clears bit 30, resulting in key reload. This is the mechanism that permits multi-process use of the xcrypt-* instruction..
-rw-r--r--sys/arch/i386/i386/machdep.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 66186a600da..2e6837f7741 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.270 2004/02/01 19:20:30 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.271 2004/02/01 19:22:30 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -1450,21 +1450,25 @@ viac3_crypto(void *cw, void *src, void *dst, void *key, int rep,
: "memory", "cc");
break;
case VIAC3_CRYPTOP_ECB:
+ __asm __volatile("pushfl; popfl");
__asm __volatile("rep xcrypt-ecb" :
: "a" (iv), "b" (key), "c" (rep), "d" (cw), "S" (src), "D" (dst)
: "memory", "cc");
break;
case VIAC3_CRYPTOP_CBC:
+ __asm __volatile("pushfl; popfl");
__asm __volatile("rep xcrypt-cbc" :
: "a" (iv), "b" (key), "c" (rep), "d" (cw), "S" (src), "D" (dst)
: "memory", "cc");
break;
case VIAC3_CRYPTOP_CFB:
+ __asm __volatile("pushfl; popfl");
__asm __volatile("rep xcrypt-cfb" :
: "a" (iv), "b" (key), "c" (rep), "d" (cw), "S" (src), "D" (dst)
: "memory", "cc");
break;
case VIAC3_CRYPTOP_OFB:
+ __asm __volatile("pushfl; popfl");
__asm __volatile("rep xcrypt-ofb" :
: "a" (iv), "b" (key), "c" (rep), "d" (cw), "S" (src), "D" (dst)
: "memory", "cc");