Add setusergs on Xen, and simplify.
This commit is contained in:
parent
9f3bfb0c1b
commit
395f538331
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpufunc.S,v 1.27 2016/11/27 14:49:21 kamil Exp $ */
|
||||
/* $NetBSD: cpufunc.S,v 1.28 2017/10/15 10:58:32 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -641,6 +641,7 @@ ENTRY(setfs)
|
|||
movw %di, %fs
|
||||
ret
|
||||
|
||||
#ifndef XEN
|
||||
ENTRY(setusergs)
|
||||
CLI(ax)
|
||||
swapgs
|
||||
|
@ -648,3 +649,4 @@ ENTRY(setusergs)
|
|||
swapgs
|
||||
STI(ax)
|
||||
ret
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.264 2017/10/11 16:56:26 maxv Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.265 2017/10/15 10:58:32 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.264 2017/10/11 16:56:26 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.265 2017/10/15 10:58:32 maxv Exp $");
|
||||
|
||||
/* #define XENDEBUG_LOW */
|
||||
|
||||
|
@ -2061,11 +2061,7 @@ cpu_fsgs_zero(struct lwp *l)
|
|||
tf->tf_fs = 0;
|
||||
tf->tf_gs = 0;
|
||||
setfs(0);
|
||||
#ifndef XEN
|
||||
setusergs(0);
|
||||
#else
|
||||
HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, 0);
|
||||
#endif
|
||||
if ((l->l_proc->p_flag & PK_32) == 0) {
|
||||
#ifndef XEN
|
||||
wrmsr(MSR_FSBASE, 0);
|
||||
|
@ -2103,11 +2099,7 @@ cpu_fsgs_reload(struct lwp *l, int fssel, int gssel)
|
|||
update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &pcb->pcb_fs);
|
||||
update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &pcb->pcb_gs);
|
||||
setfs(fssel);
|
||||
#ifndef XEN
|
||||
setusergs(gssel);
|
||||
#else
|
||||
HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, gssel);
|
||||
#endif
|
||||
tf->tf_fs = fssel;
|
||||
tf->tf_gs = gssel;
|
||||
kpreempt_enable();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sys_machdep.c,v 1.38 2017/08/30 15:44:01 maxv Exp $ */
|
||||
/* $NetBSD: sys_machdep.c,v 1.39 2017/10/15 10:58:32 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2007, 2009, 2017 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.38 2017/08/30 15:44:01 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.39 2017/10/15 10:58:32 maxv Exp $");
|
||||
|
||||
#include "opt_mtrr.h"
|
||||
#include "opt_pmc.h"
|
||||
|
@ -628,12 +628,7 @@ x86_set_sdbase32(void *arg, char which, lwp_t *l, bool direct)
|
|||
if (l == curlwp) {
|
||||
update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &usd);
|
||||
#ifdef __x86_64__
|
||||
#ifndef XEN
|
||||
setusergs(GSEL(GUGS_SEL, SEL_UPL));
|
||||
#else
|
||||
HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL,
|
||||
GSEL(GUGS_SEL, SEL_UPL));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
tf->tf_gs = GSEL(GUGS_SEL, SEL_UPL);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xenfunc.c,v 1.16 2017/02/05 10:42:21 maxv Exp $ */
|
||||
/* $NetBSD: xenfunc.c,v 1.17 2017/10/15 10:58:32 maxv Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.16 2017/02/05 10:42:21 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.17 2017/10/15 10:58:32 maxv Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
|
@ -216,3 +216,11 @@ rcr2(void)
|
|||
{
|
||||
return curcpu()->ci_vcpu->arch.cr2;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
void
|
||||
setusergs(int gssel)
|
||||
{
|
||||
HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, gssel);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue