Don't reload LDTR unless a new value, which only happens for USER_LDT.
This commit is contained in:
parent
5e605a64f7
commit
b698c03c2c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpufunc.S,v 1.12 2008/05/10 16:21:41 ad Exp $ */
|
||||
/* $NetBSD: cpufunc.S,v 1.13 2008/05/11 16:23:05 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -67,6 +67,11 @@ NENTRY(lidt)
|
|||
ret
|
||||
|
||||
NENTRY(lldt)
|
||||
cmpl %edi, CPUVAR(CURLDT)
|
||||
jne 1f
|
||||
ret
|
||||
1:
|
||||
movl %edi, CPUVAR(CURLDT)
|
||||
lldt %di
|
||||
ret
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: genassym.cf,v 1.32 2008/05/11 15:32:20 ad Exp $
|
||||
# $NetBSD: genassym.cf,v 1.33 2008/05/11 16:23:05 ad Exp $
|
||||
|
||||
#
|
||||
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -242,6 +242,7 @@ define TLBSTATE_LAZY TLBSTATE_LAZY
|
|||
define TLBSTATE_STALE TLBSTATE_STALE
|
||||
define CPU_INFO_TLB_EVCNT offsetof(struct cpu_info, ci_tlb_evcnt)
|
||||
define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp)
|
||||
define CPU_INFO_CURLDT offsetof(struct cpu_info, ci_curldt)
|
||||
define CPU_INFO_IDLELWP offsetof(struct cpu_info, ci_data.cpu_idlelwp)
|
||||
define CPU_INFO_PMAP offsetof(struct cpu_info, ci_pmap)
|
||||
define CPU_INFO_CPUMASK offsetof(struct cpu_info, ci_cpumask)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: genassym.cf,v 1.71 2008/05/11 15:32:20 ad Exp $
|
||||
# $NetBSD: genassym.cf,v 1.72 2008/05/11 16:23:05 ad Exp $
|
||||
|
||||
#
|
||||
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -307,6 +307,7 @@ define TLBSTATE_LAZY TLBSTATE_LAZY
|
|||
define TLBSTATE_STALE TLBSTATE_STALE
|
||||
define CPU_INFO_TLB_EVCNT offsetof(struct cpu_info, ci_tlb_evcnt)
|
||||
define CPU_INFO_CURLWP offsetof(struct cpu_info, ci_curlwp)
|
||||
define CPU_INFO_CURLDT offsetof(struct cpu_info, ci_curldt)
|
||||
define CPU_INFO_IDLELWP offsetof(struct cpu_info, ci_data.cpu_idlelwp)
|
||||
define CPU_INFO_PMAP offsetof(struct cpu_info, ci_pmap)
|
||||
define CPU_INFO_CPUMASK offsetof(struct cpu_info, ci_cpumask)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: i386func.S,v 1.13 2008/05/11 12:43:35 ad Exp $ */
|
||||
/* $NetBSD: i386func.S,v 1.14 2008/05/11 16:23:05 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: i386func.S,v 1.13 2008/05/11 12:43:35 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: i386func.S,v 1.14 2008/05/11 16:23:05 ad Exp $");
|
||||
|
||||
#include <machine/specialreg.h>
|
||||
#include <machine/segments.h>
|
||||
|
@ -51,6 +51,11 @@ END(invlpg)
|
|||
|
||||
ENTRY(lldt)
|
||||
movl 4(%esp), %eax
|
||||
cmpl %eax, CPUVAR(CURLDT)
|
||||
jne 1f
|
||||
ret
|
||||
1:
|
||||
movl %eax, CPUVAR(CURLDT)
|
||||
lldt %ax
|
||||
ret
|
||||
END(lldt)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpu.h,v 1.2 2008/05/11 15:59:50 ad Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.3 2008/05/11 16:23:05 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -111,6 +111,7 @@ struct cpu_info {
|
|||
#define TLBSTATE_VALID 0 /* all user tlbs are valid */
|
||||
#define TLBSTATE_LAZY 1 /* tlbs are valid but won't be kept uptodate */
|
||||
#define TLBSTATE_STALE 2 /* we might have stale user tlbs */
|
||||
int ci_curldt; /* current LDT descriptor */
|
||||
uint64_t ci_scratch;
|
||||
|
||||
#ifdef XEN
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpu.c,v 1.42 2008/05/11 15:59:51 ad Exp $ */
|
||||
/* $NetBSD: cpu.c,v 1.43 2008/05/11 16:23:05 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -62,7 +62,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.42 2008/05/11 15:59:51 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.43 2008/05/11 16:23:05 ad Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_multiprocessor.h"
|
||||
|
@ -147,6 +147,7 @@ struct cpu_info cpu_info_primary __aligned(CACHE_LINE_SIZE) = {
|
|||
.ci_self = &cpu_info_primary,
|
||||
.ci_idepth = -1,
|
||||
.ci_curlwp = &lwp0,
|
||||
.ci_curldt = -1,
|
||||
#ifdef TRAPLOG
|
||||
.ci_tlog_base = &tlog_primary,
|
||||
#endif /* !TRAPLOG */
|
||||
|
@ -299,6 +300,7 @@ cpu_attach(device_t parent, device_t self, void *aux)
|
|||
ci = (struct cpu_info *)((ptr + CACHE_LINE_SIZE - 1) &
|
||||
~(CACHE_LINE_SIZE - 1));
|
||||
memset(ci, 0, sizeof(*ci));
|
||||
ci->ci_curldt = -1;
|
||||
#if defined(MULTIPROCESSOR)
|
||||
if (cpu_info[cpunum] != NULL) {
|
||||
printf("\n");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpu.c,v 1.23 2008/05/11 15:59:51 ad Exp $ */
|
||||
/* $NetBSD: cpu.c,v 1.24 2008/05/11 16:23:05 ad Exp $ */
|
||||
/* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */
|
||||
|
||||
/*-
|
||||
|
@ -66,7 +66,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.23 2008/05/11 15:59:51 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.24 2008/05/11 16:23:05 ad Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_multiprocessor.h"
|
||||
|
@ -153,6 +153,7 @@ struct cpu_info cpu_info_primary = {
|
|||
.ci_self = &cpu_info_primary,
|
||||
.ci_idepth = -1,
|
||||
.ci_curlwp = &lwp0,
|
||||
.ci_curldt = -1;
|
||||
#ifdef TRAPLOG
|
||||
.ci_tlog = &tlog_primary,
|
||||
#endif
|
||||
|
@ -231,6 +232,7 @@ cpu_attach(device_t parent, device_t self, void *aux)
|
|||
*/
|
||||
if (caa->cpu_role == CPU_ROLE_AP) {
|
||||
ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
ci->ci_curldt = -1;
|
||||
if (phycpu_info[cpunum] != NULL)
|
||||
panic("cpu at apic id %d already attached?", cpunum);
|
||||
phycpu_info[cpunum] = ci;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xenfunc.c,v 1.6 2008/04/30 00:16:30 cegger Exp $ */
|
||||
/* $NetBSD: xenfunc.c,v 1.7 2008/05/11 16:23:05 ad Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.6 2008/04/30 00:16:30 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.7 2008/05/11 16:23:05 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
|
@ -68,13 +68,19 @@ invlpg(vaddr_t addr)
|
|||
void
|
||||
lldt(u_short sel)
|
||||
{
|
||||
struct cpu_info *ci;
|
||||
|
||||
ci = curcpu();
|
||||
|
||||
if (ci->ci_curldt == sel)
|
||||
return;
|
||||
/* __PRINTK(("ldt %x\n", IDXSELN(sel))); */
|
||||
if (sel == GSEL(GLDT_SEL, SEL_KPL))
|
||||
xen_set_ldt((vaddr_t)ldt, NLDT);
|
||||
else
|
||||
xen_set_ldt(cpu_info_primary.ci_gdt[IDXSELN(sel)].ld.ld_base,
|
||||
cpu_info_primary.ci_gdt[IDXSELN(sel)].ld.ld_entries);
|
||||
xen_set_ldt(ci->ci_gdt[IDXSELN(sel)].ld.ld_base,
|
||||
ci->ci_gdt[IDXSELN(sel)].ld.ld_entries);
|
||||
ci->ci_curldt = sel;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue