on Xen the GDT has to be updated though HYPERVISOR_update_descriptor().
Export i386/i386/gdt.c:update_descriptor() and use it in x86_set_sdbase(), as a direct write to the GDT will cause a kernel trap. Fix PR port-xen/41401.
This commit is contained in:
parent
bcf861f849
commit
cc56ebe228
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gdt.c,v 1.47 2009/03/21 14:41:29 ad Exp $ */
|
||||
/* $NetBSD: gdt.c,v 1.48 2009/05/17 18:24:23 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.47 2009/03/21 14:41:29 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.48 2009/05/17 18:24:23 bouyer Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
#include "opt_xen.h"
|
||||
@ -66,7 +66,7 @@ void gdt_grow(int);
|
||||
int gdt_get_slot1(int);
|
||||
void gdt_put_slot1(int, int);
|
||||
|
||||
static void
|
||||
void
|
||||
update_descriptor(union descriptor *table, union descriptor *entry)
|
||||
{
|
||||
#ifndef XEN
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: segments.h,v 1.52 2009/03/21 22:17:13 ad Exp $ */
|
||||
/* $NetBSD: segments.h,v 1.53 2009/05/17 18:24:23 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
@ -197,6 +197,7 @@ void setsegment(struct segment_descriptor *, const void *, size_t, int, int,
|
||||
void setgdt(int, const void *, size_t, int, int, int, int);
|
||||
void unsetgate(struct gate_descriptor *);
|
||||
void cpu_init_idt(void);
|
||||
void update_descriptor(union descriptor *, union descriptor *);
|
||||
|
||||
#if !defined(XEN)
|
||||
void idt_init(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys_machdep.c,v 1.18 2009/03/29 09:24:52 ad Exp $ */
|
||||
/* $NetBSD: sys_machdep.c,v 1.19 2009/05/17 18:24:24 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.18 2009/03/29 09:24:52 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.19 2009/05/17 18:24:24 bouyer Exp $");
|
||||
|
||||
#include "opt_mtrr.h"
|
||||
#include "opt_perfctrs.h"
|
||||
@ -591,7 +591,7 @@ int
|
||||
x86_set_sdbase(void *arg, char which, lwp_t *l, bool direct)
|
||||
{
|
||||
#ifdef i386
|
||||
struct segment_descriptor sd;
|
||||
union descriptor usd;
|
||||
struct pcb *pcb;
|
||||
vaddr_t base;
|
||||
int error;
|
||||
@ -604,28 +604,30 @@ x86_set_sdbase(void *arg, char which, lwp_t *l, bool direct)
|
||||
return error;
|
||||
}
|
||||
|
||||
sd.sd_lobase = base & 0xffffff;
|
||||
sd.sd_hibase = (base >> 24) & 0xff;
|
||||
sd.sd_lolimit = 0xffff;
|
||||
sd.sd_hilimit = 0xf;
|
||||
sd.sd_type = SDT_MEMRWA;
|
||||
sd.sd_dpl = SEL_UPL;
|
||||
sd.sd_p = 1;
|
||||
sd.sd_xx = 0;
|
||||
sd.sd_def32 = 1;
|
||||
sd.sd_gran = 1;
|
||||
usd.sd.sd_lobase = base & 0xffffff;
|
||||
usd.sd.sd_hibase = (base >> 24) & 0xff;
|
||||
usd.sd.sd_lolimit = 0xffff;
|
||||
usd.sd.sd_hilimit = 0xf;
|
||||
usd.sd.sd_type = SDT_MEMRWA;
|
||||
usd.sd.sd_dpl = SEL_UPL;
|
||||
usd.sd.sd_p = 1;
|
||||
usd.sd.sd_xx = 0;
|
||||
usd.sd.sd_def32 = 1;
|
||||
usd.sd.sd_gran = 1;
|
||||
|
||||
kpreempt_disable();
|
||||
pcb = &l->l_addr->u_pcb;
|
||||
if (which == 'f') {
|
||||
memcpy(&pcb->pcb_fsd, &sd, sizeof(sd));
|
||||
memcpy(&pcb->pcb_fsd, &usd.sd,
|
||||
sizeof(struct segment_descriptor));
|
||||
if (l == curlwp) {
|
||||
memcpy(&curcpu()->ci_gdt[GUFS_SEL], &sd, sizeof(sd));
|
||||
update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &usd);
|
||||
}
|
||||
} else /* which == 'g' */ {
|
||||
memcpy(&pcb->pcb_gsd, &sd, sizeof(sd));
|
||||
memcpy(&pcb->pcb_gsd, &usd.sd,
|
||||
sizeof(struct segment_descriptor));
|
||||
if (l == curlwp) {
|
||||
memcpy(&curcpu()->ci_gdt[GUGS_SEL], &sd, sizeof(sd));
|
||||
update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &usd);
|
||||
}
|
||||
}
|
||||
kpreempt_enable();
|
||||
|
Loading…
Reference in New Issue
Block a user