Group the different TSSes into a cpu_tss structure. And pack this
structure to make sure there is no padding between 'tss' and 'iomap'.
This commit is contained in:
parent
a566db57e8
commit
ad750876f8
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: genassym.cf,v 1.62 2017/10/28 20:57:17 bouyer Exp $
|
||||
# $NetBSD: genassym.cf,v 1.63 2018/01/04 12:34:15 maxv Exp $
|
||||
|
||||
#
|
||||
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -233,7 +233,7 @@ 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_RSP0 offsetof(struct cpu_info, ci_tss.tss_rsp0)
|
||||
define CPU_INFO_RSP0 offsetof(struct cpu_info, ci_tss.tss.tss_rsp0)
|
||||
define CPU_INFO_NSYSCALL offsetof(struct cpu_info, ci_data.cpu_nsyscall)
|
||||
define CPU_INFO_NTRAP offsetof(struct cpu_info, ci_data.cpu_ntrap)
|
||||
define CPU_INFO_NINTR offsetof(struct cpu_info, ci_data.cpu_nintr)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.281 2018/01/02 18:54:26 maxv Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.282 2018/01/04 12:34:15 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.281 2018/01/02 18:54:26 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.282 2018/01/04 12:34:15 maxv Exp $");
|
||||
|
||||
/* #define XENDEBUG_LOW */
|
||||
|
||||
|
@ -502,7 +502,7 @@ x86_64_proc0_pcb_ldt_init(void)
|
|||
void
|
||||
cpu_init_tss(struct cpu_info *ci)
|
||||
{
|
||||
struct x86_64_tss *tss = &ci->ci_tss;
|
||||
struct x86_64_tss *tss = &ci->ci_tss.tss;
|
||||
uintptr_t p;
|
||||
|
||||
tss->tss_iobase = IOMAP_INVALOFF << 16;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: genassym.cf,v 1.104 2017/09/17 09:04:51 maxv Exp $
|
||||
# $NetBSD: genassym.cf,v 1.105 2018/01/04 12:34:15 maxv Exp $
|
||||
|
||||
#
|
||||
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -249,11 +249,11 @@ define CPU_INFO_FPCURLWP offsetof(struct cpu_info, ci_fpcurlwp)
|
|||
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_TSS offsetof(struct cpu_info, ci_tss)
|
||||
define CPU_INFO_TSS offsetof(struct cpu_info, ci_tss.tss)
|
||||
define CPU_INFO_TSS_SEL offsetof(struct cpu_info, ci_tss_sel)
|
||||
define CPU_INFO_ESP0 offsetof(struct cpu_info, ci_tss.tss_esp0)
|
||||
define CPU_INFO_IOBASE offsetof(struct cpu_info, ci_tss.tss_iobase)
|
||||
define CPU_INFO_IOMAP offsetof(struct cpu_info, ci_iomap)
|
||||
define CPU_INFO_ESP0 offsetof(struct cpu_info, ci_tss.tss.tss_esp0)
|
||||
define CPU_INFO_IOBASE offsetof(struct cpu_info, ci_tss.tss.tss_iobase)
|
||||
define CPU_INFO_IOMAP offsetof(struct cpu_info, ci_tss.iomap)
|
||||
define IOMAP_INVALOFF IOMAP_INVALOFF
|
||||
define CPU_INFO_NSYSCALL offsetof(struct cpu_info, ci_data.cpu_nsyscall)
|
||||
define CPU_INFO_NTRAP offsetof(struct cpu_info, ci_data.cpu_ntrap)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.800 2017/12/31 08:29:38 maxv Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.801 2018/01/04 12:34:15 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.800 2017/12/31 08:29:38 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.801 2018/01/04 12:34:15 maxv Exp $");
|
||||
|
||||
#include "opt_beep.h"
|
||||
#include "opt_compat_freebsd.h"
|
||||
|
@ -581,9 +581,9 @@ cpu_set_tss_gates(struct cpu_info *ci)
|
|||
|
||||
doubleflt_stack = (void *)uvm_km_alloc(kernel_map, USPACE, 0,
|
||||
UVM_KMF_WIRED);
|
||||
tss_init(&ci->ci_doubleflt_tss, doubleflt_stack, IDTVEC(tss_trap08));
|
||||
tss_init(&ci->ci_tss.dblflt_tss, doubleflt_stack, IDTVEC(tss_trap08));
|
||||
|
||||
setsegment(&sd, &ci->ci_doubleflt_tss, sizeof(struct i386tss) - 1,
|
||||
setsegment(&sd, &ci->ci_tss.dblflt_tss, sizeof(struct i386tss) - 1,
|
||||
SDT_SYS386TSS, SEL_KPL, 0, 0);
|
||||
ci->ci_gdt[GTRAPTSS_SEL].sd = sd;
|
||||
|
||||
|
@ -602,10 +602,10 @@ cpu_set_tss_gates(struct cpu_info *ci)
|
|||
|
||||
ddbipi_stack = (void *)uvm_km_alloc(kernel_map, USPACE, 0,
|
||||
UVM_KMF_WIRED);
|
||||
tss_init(&ci->ci_ddbipi_tss, ddbipi_stack,
|
||||
tss_init(&ci->ci_tss.ddbipi_tss, ddbipi_stack,
|
||||
x2apic_mode ? Xx2apic_intrddbipi : Xintrddbipi);
|
||||
|
||||
setsegment(&sd, &ci->ci_ddbipi_tss, sizeof(struct i386tss) - 1,
|
||||
setsegment(&sd, &ci->ci_tss.ddbipi_tss, sizeof(struct i386tss) - 1,
|
||||
SDT_SYS386TSS, SEL_KPL, 0, 0);
|
||||
ci->ci_gdt[GIPITSS_SEL].sd = sd;
|
||||
|
||||
|
@ -620,7 +620,7 @@ cpu_set_tss_gates(struct cpu_info *ci)
|
|||
void
|
||||
cpu_init_tss(struct cpu_info *ci)
|
||||
{
|
||||
struct i386tss *tss = &ci->ci_tss;
|
||||
struct i386tss *tss = &ci->ci_tss.tss;
|
||||
|
||||
tss->tss_iobase = IOMAP_INVALOFF << 16;
|
||||
tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpu.h,v 1.84 2017/12/28 08:30:36 maxv Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.85 2018/01/04 12:34:15 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -83,6 +83,15 @@ struct pmap;
|
|||
#define NIOPORTS 1024 /* # of ports we allow to be mapped */
|
||||
#define IOMAPSIZE (NIOPORTS / 8) /* I/O bitmap size in bytes */
|
||||
|
||||
struct cpu_tss {
|
||||
#ifdef i386
|
||||
struct i386tss dblflt_tss;
|
||||
struct i386tss ddbipi_tss;
|
||||
#endif
|
||||
struct i386tss tss;
|
||||
uint8_t iomap[IOMAPSIZE];
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* a bunch of this belongs in cpuvar.h; move it later..
|
||||
*/
|
||||
|
@ -173,13 +182,6 @@ struct cpu_info {
|
|||
u_int ci_cflush_lsize; /* CLFLUSH insn line size */
|
||||
struct x86_cache_info ci_cinfo[CAI_COUNT];
|
||||
|
||||
union descriptor *ci_gdt;
|
||||
|
||||
#ifdef i386
|
||||
struct i386tss ci_doubleflt_tss;
|
||||
struct i386tss ci_ddbipi_tss;
|
||||
#endif
|
||||
|
||||
#ifdef PAE
|
||||
uint32_t ci_pae_l3_pdirpa; /* PA of L3 PD */
|
||||
pd_entry_t * ci_pae_l3_pdir; /* VA pointer to L3 PD */
|
||||
|
@ -213,8 +215,11 @@ struct cpu_info {
|
|||
device_t ci_temperature; /* Intel coretemp(4) or equivalent */
|
||||
device_t ci_vm; /* Virtual machine guest driver */
|
||||
|
||||
struct i386tss ci_tss; /* Per-cpu TSS; shared among LWPs */
|
||||
char ci_iomap[IOMAPSIZE]; /* I/O Bitmap */
|
||||
/*
|
||||
* Segmentation-related data.
|
||||
*/
|
||||
union descriptor *ci_gdt;
|
||||
struct cpu_tss ci_tss; /* Per-cpu TSSes; shared among LWPs */
|
||||
int ci_tss_sel; /* TSS selector of this cpu */
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: intr.c,v 1.114 2018/01/04 01:01:59 knakahara Exp $ */
|
||||
/* $NetBSD: intr.c,v 1.115 2018/01/04 12:34:15 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
|
||||
|
@ -133,7 +133,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.114 2018/01/04 01:01:59 knakahara Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.115 2018/01/04 12:34:15 maxv Exp $");
|
||||
|
||||
#include "opt_intrdebug.h"
|
||||
#include "opt_multiprocessor.h"
|
||||
|
@ -1529,7 +1529,7 @@ cpu_intr_init(struct cpu_info *ci)
|
|||
ci->ci_intrstack = (char *)istack + redzone_const_or_zero(PAGE_SIZE) +
|
||||
INTRSTACKSIZE - 33 * sizeof(register_t);
|
||||
#if defined(__x86_64__)
|
||||
ci->ci_tss.tss_ist[0] = (uintptr_t)ci->ci_intrstack & ~0xf;
|
||||
ci->ci_tss.tss.tss_ist[0] = (uintptr_t)ci->ci_intrstack & ~0xf;
|
||||
#endif /* defined(__x86_64__) */
|
||||
#endif /* defined(INTRSTACKSIZE) */
|
||||
ci->ci_idepth = -1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pmap.c,v 1.273 2018/01/03 09:46:41 maxv Exp $ */
|
||||
/* $NetBSD: pmap.c,v 1.274 2018/01/04 12:34:15 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
|
||||
|
@ -170,7 +170,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.273 2018/01/03 09:46:41 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.274 2018/01/04 12:34:15 maxv Exp $");
|
||||
|
||||
#include "opt_user_ldt.h"
|
||||
#include "opt_lockdebug.h"
|
||||
|
@ -2897,8 +2897,8 @@ pmap_load(void)
|
|||
|
||||
#ifdef i386
|
||||
#ifndef XEN
|
||||
ci->ci_tss.tss_ldt = pmap->pm_ldt_sel;
|
||||
ci->ci_tss.tss_cr3 = pcb->pcb_cr3;
|
||||
ci->ci_tss.tss.tss_ldt = pmap->pm_ldt_sel;
|
||||
ci->ci_tss.tss.tss_cr3 = pcb->pcb_cr3;
|
||||
#endif /* !XEN */
|
||||
#endif /* i386 */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sys_machdep.c,v 1.43 2017/10/21 08:27:19 maxv Exp $ */
|
||||
/* $NetBSD: sys_machdep.c,v 1.44 2018/01/04 12:34:15 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.43 2017/10/21 08:27:19 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.44 2018/01/04 12:34:15 maxv Exp $");
|
||||
|
||||
#include "opt_mtrr.h"
|
||||
#include "opt_pmc.h"
|
||||
|
@ -482,9 +482,9 @@ x86_set_ioperm(struct lwp *l, void *args, register_t *retval)
|
|||
|
||||
kpreempt_disable();
|
||||
ci = curcpu();
|
||||
memcpy(ci->ci_iomap, pcb->pcb_iomap, sizeof(ci->ci_iomap));
|
||||
ci->ci_tss.tss_iobase =
|
||||
((uintptr_t)ci->ci_iomap - (uintptr_t)&ci->ci_tss) << 16;
|
||||
memcpy(ci->ci_tss.iomap, pcb->pcb_iomap, sizeof(ci->ci_tss.iomap));
|
||||
ci->ci_tss.tss.tss_iobase =
|
||||
((uintptr_t)&ci->ci_tss.iomap - (uintptr_t)&ci->ci_tss.tss) << 16;
|
||||
kpreempt_enable();
|
||||
|
||||
return error;
|
||||
|
|
Loading…
Reference in New Issue