Module Name: src
Committed By: maxv
Date: Fri Jan 26 14:38:46 UTC 2018
Modified Files:
src/sys/arch/amd64/amd64: machdep.c
Log Message:
Zero out the scratch value in the UTLS page during context switches. We
temporarily put %rax there when processing syscalls, and we wouldn't
want the new lwp to see the %rax value of the previous lwp.
To generate a diff of this commit:
cvs rdiff -u -r1.295 -r1.296 src/sys/arch/amd64/amd64/machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.295 src/sys/arch/amd64/amd64/machdep.c:1.296
--- src/sys/arch/amd64/amd64/machdep.c:1.295 Sun Jan 21 11:21:40 2018
+++ src/sys/arch/amd64/amd64/machdep.c Fri Jan 26 14:38:46 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.295 2018/01/21 11:21:40 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.296 2018/01/26 14:38:46 maxv Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.295 2018/01/21 11:21:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.296 2018/01/26 14:38:46 maxv Exp $");
/* #define XENDEBUG_LOW */
@@ -2522,6 +2522,7 @@ void
svs_lwp_switch(struct lwp *oldlwp, struct lwp *newlwp)
{
struct cpu_info *ci = curcpu();
+ struct svs_utls *utls;
struct pcb *pcb;
pt_entry_t *pte;
uintptr_t rsp0;
@@ -2551,6 +2552,9 @@ svs_lwp_switch(struct lwp *oldlwp, struc
KASSERT((ci->ci_svs_krsp0 % PAGE_SIZE) ==
(ci->ci_svs_ursp0 % PAGE_SIZE));
+ utls = (struct svs_utls *)ci->ci_svs_utls;
+ utls->scratch = 0;
+
/*
* Enter the user rsp0. We don't need to flush the TLB here, since
* the user page tables are not loaded.