Module Name:    src
Committed By:   maxv
Date:           Sun Aug 13 08:07:52 UTC 2017

Modified Files:
        src/sys/arch/amd64/amd64: process_machdep.c

Log Message:
Mmh, restore %cs and %ss on Xen. Otherwise (unpriv) userland could set a
non-three ring, causing the hypervisor to send a fatal interrupt to the
kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/process_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/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.34 src/sys/arch/amd64/amd64/process_machdep.c:1.35
--- src/sys/arch/amd64/amd64/process_machdep.c:1.34	Sun Aug 13 07:16:44 2017
+++ src/sys/arch/amd64/amd64/process_machdep.c	Sun Aug 13 08:07:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.35 2017/08/13 08:07:52 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -74,8 +74,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.35 2017/08/13 08:07:52 maxv Exp $");
 
+#include "opt_xen.h"
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/time.h>
@@ -155,6 +156,12 @@ process_write_regs(struct lwp *l, const 
 	tf->tf_err = err;
 	tf->tf_trapno = trapno;
 
+#ifdef XEN
+	/* see comment in cpu_setmcontext */
+	tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
+	tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+#endif
+
 	return 0;
 }
 

Reply via email to