df4fd27737
different context support for 32 vs 64 bit processes. This simply omits the save/restore of the segment selector registers for non 32 bit processes. This avoids the rdmsr/rwmsr juggling when restoring %gs clobbers the kernel msr that holds the gsbase. However, I suspect it might be better to conditionally do this at user<->kernel transition where we wouldn't need to do the juggling in the first place. Or have per-thread extended context save/restore hooks.
215 lines
8.2 KiB
C
215 lines
8.2 KiB
C
/*-
|
|
* Copyright (c) 1982, 1990 The Regents of the University of California.
|
|
* All rights reserved.
|
|
*
|
|
* This code is derived from software contributed to Berkeley by
|
|
* William Jolitz.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
#include "opt_compat.h"
|
|
#include "opt_kstack_pages.h"
|
|
|
|
#include <sys/param.h>
|
|
#include <sys/systm.h>
|
|
#include <sys/assym.h>
|
|
#include <sys/bio.h>
|
|
#include <sys/buf.h>
|
|
#include <sys/proc.h>
|
|
#include <sys/errno.h>
|
|
#include <sys/mount.h>
|
|
#include <sys/mutex.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/resourcevar.h>
|
|
#include <sys/ucontext.h>
|
|
#include <sys/user.h>
|
|
#include <machine/tss.h>
|
|
#include <sys/vmmeter.h>
|
|
#include <vm/vm.h>
|
|
#include <vm/vm_param.h>
|
|
#include <vm/pmap.h>
|
|
#include <vm/vm_map.h>
|
|
#include <sys/user.h>
|
|
#include <sys/proc.h>
|
|
#include <net/if.h>
|
|
#include <netinet/in.h>
|
|
#include <nfs/nfsproto.h>
|
|
#include <nfs/rpcv2.h>
|
|
#include <nfsclient/nfs.h>
|
|
#include <nfsclient/nfsdiskless.h>
|
|
#include <machine/apicreg.h>
|
|
#include <machine/cpu.h>
|
|
#include <machine/sigframe.h>
|
|
#include <machine/proc.h>
|
|
#include <machine/specialreg.h>
|
|
#include <machine/segments.h>
|
|
|
|
ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
|
|
ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
|
|
ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
|
|
ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
|
|
ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
|
|
|
|
ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
|
|
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
|
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
|
|
|
ASSYM(TDF_ASTPENDING, TDF_ASTPENDING);
|
|
ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
|
|
|
|
ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
|
|
ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
|
|
ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
|
|
ASSYM(UAREA_PAGES, UAREA_PAGES);
|
|
ASSYM(KSTACK_PAGES, KSTACK_PAGES);
|
|
ASSYM(PAGE_SIZE, PAGE_SIZE);
|
|
ASSYM(NPTEPG, NPTEPG);
|
|
ASSYM(NPDEPG, NPDEPG);
|
|
ASSYM(addr_PTmap, addr_PTmap);
|
|
ASSYM(addr_PDmap, addr_PDmap);
|
|
ASSYM(addr_PDPmap, addr_PDPmap);
|
|
ASSYM(addr_PML4map, addr_PML4map);
|
|
ASSYM(addr_PML4pml4e, addr_PML4pml4e);
|
|
ASSYM(PDESIZE, sizeof(pd_entry_t));
|
|
ASSYM(PTESIZE, sizeof(pt_entry_t));
|
|
ASSYM(PTESHIFT, PTESHIFT);
|
|
ASSYM(PAGE_SHIFT, PAGE_SHIFT);
|
|
ASSYM(PAGE_MASK, PAGE_MASK);
|
|
ASSYM(PDRSHIFT, PDRSHIFT);
|
|
ASSYM(PDPSHIFT, PDPSHIFT);
|
|
ASSYM(PML4SHIFT, PML4SHIFT);
|
|
ASSYM(val_KPDPI, KPDPI);
|
|
ASSYM(val_KPML4I, KPML4I);
|
|
ASSYM(val_PML4PML4I, PML4PML4I);
|
|
ASSYM(USRSTACK, USRSTACK);
|
|
ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
|
|
ASSYM(KERNBASE, KERNBASE);
|
|
ASSYM(DMAP_MIN_ADDRESS, DMAP_MIN_ADDRESS);
|
|
ASSYM(DMAP_MAX_ADDRESS, DMAP_MAX_ADDRESS);
|
|
ASSYM(MCLBYTES, MCLBYTES);
|
|
ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
|
|
ASSYM(PCB_R15, offsetof(struct pcb, pcb_r15));
|
|
ASSYM(PCB_R14, offsetof(struct pcb, pcb_r14));
|
|
ASSYM(PCB_R13, offsetof(struct pcb, pcb_r13));
|
|
ASSYM(PCB_R12, offsetof(struct pcb, pcb_r12));
|
|
ASSYM(PCB_RBP, offsetof(struct pcb, pcb_rbp));
|
|
ASSYM(PCB_RSP, offsetof(struct pcb, pcb_rsp));
|
|
ASSYM(PCB_RBX, offsetof(struct pcb, pcb_rbx));
|
|
ASSYM(PCB_RIP, offsetof(struct pcb, pcb_rip));
|
|
ASSYM(PCB_RFLAGS, offsetof(struct pcb, pcb_rflags));
|
|
ASSYM(PCB_FSBASE, offsetof(struct pcb, pcb_fsbase));
|
|
ASSYM(PCB_GSBASE, offsetof(struct pcb, pcb_gsbase));
|
|
ASSYM(PCB_DS, offsetof(struct pcb, pcb_ds));
|
|
ASSYM(PCB_ES, offsetof(struct pcb, pcb_es));
|
|
ASSYM(PCB_FS, offsetof(struct pcb, pcb_fs));
|
|
ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
|
|
ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
|
|
ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
|
|
ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
|
|
ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
|
|
ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
|
|
ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
|
|
ASSYM(PCB_DBREGS, PCB_DBREGS);
|
|
ASSYM(PCB_32BIT, PCB_32BIT);
|
|
|
|
ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
|
|
ASSYM(PCB_FULLCTX, PCB_FULLCTX);
|
|
ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
|
|
ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct savefpu));
|
|
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
|
|
|
|
ASSYM(PCB_SIZE, sizeof(struct pcb));
|
|
|
|
ASSYM(COMMON_TSS_RSP0, offsetof(struct amd64tss, tss_rsp0));
|
|
|
|
ASSYM(TF_R15, offsetof(struct trapframe, tf_r15));
|
|
ASSYM(TF_R14, offsetof(struct trapframe, tf_r14));
|
|
ASSYM(TF_R13, offsetof(struct trapframe, tf_r13));
|
|
ASSYM(TF_R12, offsetof(struct trapframe, tf_r12));
|
|
ASSYM(TF_R11, offsetof(struct trapframe, tf_r11));
|
|
ASSYM(TF_R10, offsetof(struct trapframe, tf_r10));
|
|
ASSYM(TF_R9, offsetof(struct trapframe, tf_r9));
|
|
ASSYM(TF_R8, offsetof(struct trapframe, tf_r8));
|
|
ASSYM(TF_RDI, offsetof(struct trapframe, tf_rdi));
|
|
ASSYM(TF_RSI, offsetof(struct trapframe, tf_rsi));
|
|
ASSYM(TF_RBP, offsetof(struct trapframe, tf_rbp));
|
|
ASSYM(TF_RBX, offsetof(struct trapframe, tf_rbx));
|
|
ASSYM(TF_RDX, offsetof(struct trapframe, tf_rdx));
|
|
ASSYM(TF_RCX, offsetof(struct trapframe, tf_rcx));
|
|
ASSYM(TF_RAX, offsetof(struct trapframe, tf_rax));
|
|
ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
|
|
ASSYM(TF_ADDR, offsetof(struct trapframe, tf_addr));
|
|
ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
|
|
ASSYM(TF_RIP, offsetof(struct trapframe, tf_rip));
|
|
ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
|
|
ASSYM(TF_RFLAGS, offsetof(struct trapframe, tf_rflags));
|
|
ASSYM(TF_RSP, offsetof(struct trapframe, tf_rsp));
|
|
ASSYM(TF_SS, offsetof(struct trapframe, tf_ss));
|
|
ASSYM(TF_SIZE, sizeof(struct trapframe));
|
|
|
|
ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
|
|
ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
|
|
ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_rflags));
|
|
ASSYM(ENOENT, ENOENT);
|
|
ASSYM(EFAULT, EFAULT);
|
|
ASSYM(ENAMETOOLONG, ENAMETOOLONG);
|
|
ASSYM(MAXCOMLEN, MAXCOMLEN);
|
|
ASSYM(MAXPATHLEN, MAXPATHLEN);
|
|
ASSYM(PC_SIZEOF, sizeof(struct pcpu));
|
|
ASSYM(PC_PRVSPACE, offsetof(struct pcpu, pc_prvspace));
|
|
ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
|
|
ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread));
|
|
ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread));
|
|
ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
|
|
ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
|
|
ASSYM(PC_SCRATCH_RSP, offsetof(struct pcpu, pc_scratch_rsp));
|
|
ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
|
|
ASSYM(PC_TSSP, offsetof(struct pcpu, pc_tssp));
|
|
ASSYM(PC_RSP0, offsetof(struct pcpu, pc_rsp0));
|
|
|
|
ASSYM(LA_VER, offsetof(struct LAPIC, version));
|
|
ASSYM(LA_TPR, offsetof(struct LAPIC, tpr));
|
|
ASSYM(LA_EOI, offsetof(struct LAPIC, eoi));
|
|
ASSYM(LA_SVR, offsetof(struct LAPIC, svr));
|
|
ASSYM(LA_ICR_LO, offsetof(struct LAPIC, icr_lo));
|
|
ASSYM(LA_ICR_HI, offsetof(struct LAPIC, icr_hi));
|
|
ASSYM(LA_ISR, offsetof(struct LAPIC, isr0));
|
|
|
|
ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
|
|
ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
|
|
ASSYM(KUCSEL, GSEL(GUCODE_SEL, SEL_UPL));
|
|
ASSYM(KUDSEL, GSEL(GUDATA_SEL, SEL_UPL));
|
|
ASSYM(KUC32SEL, GSEL(GUCODE32_SEL, SEL_UPL));
|
|
ASSYM(SEL_RPL_MASK, SEL_RPL_MASK);
|
|
|
|
ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
|
|
ASSYM(MTX_RECURSECNT, offsetof(struct mtx, mtx_recurse));
|