From owner-p4-projects@FreeBSD.ORG Sat Apr 5 00:50:27 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0794337B404; Sat, 5 Apr 2003 00:50:27 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 97EAD37B401 for ; Sat, 5 Apr 2003 00:50:26 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA8BF43F3F for ; Sat, 5 Apr 2003 00:50:25 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h358oP0U037540 for ; Sat, 5 Apr 2003 00:50:25 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h358oPCC037534 for perforce@freebsd.org; Sat, 5 Apr 2003 00:50:25 -0800 (PST) Date: Sat, 5 Apr 2003 00:50:25 -0800 (PST) Message-Id: <200304050850.h358oPCC037534@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 28196 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Apr 2003 08:50:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=28196 Change 28196 by peter@peter_overcee on 2003/04/05 00:50:22 More hack-n-slash to get more things to compile. Wimp out on the XMM fpu regs stuff though. procfs is the last thing I'm worried about right now. Affected files ... .. //depot/projects/hammer/sys/x86_64/include/reg.h#5 edit .. //depot/projects/hammer/sys/x86_64/include/ucontext.h#8 edit .. //depot/projects/hammer/sys/x86_64/x86_64/exception.s#12 edit .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#36 edit .. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#19 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/include/reg.h#5 (text+ko) ==== @@ -85,19 +85,19 @@ unsigned int r_fs; unsigned int r_es; unsigned int r_ds; - unsigned int r_edi; - unsigned int r_esi; - unsigned int r_ebp; - unsigned int r_ebx; - unsigned int r_edx; - unsigned int r_ecx; - unsigned int r_eax; + unsigned int r_rdi; + unsigned int r_rsi; + unsigned int r_rbp; + unsigned int r_rbx; + unsigned int r_rdx; + unsigned int r_rcx; + unsigned int r_rax; unsigned int r_trapno; unsigned int r_err; - unsigned int r_eip; + unsigned int r_rip; unsigned int r_cs; - unsigned int r_eflags; - unsigned int r_esp; + unsigned int r_rflags; + unsigned int r_rsp; unsigned int r_ss; unsigned int r_gs; }; @@ -111,30 +111,15 @@ * simplified struct. This may be too much detail. Perhaps * an array of unsigned longs is best. */ - unsigned long fpr_env[7]; - unsigned char fpr_acc[8][10]; - unsigned long fpr_ex_sw; - unsigned char fpr_pad[64]; + unsigned long fpr_env[4]; + unsigned char fpr_acc[8][16]; + unsigned char fpr_xacc[16][16]; }; -/* - * Register set accessible via /proc/$pid/dbregs. - */ struct dbreg { - unsigned int dr[8]; /* debug registers */ - /* Index 0-3: debug address registers */ - /* Index 4-5: reserved */ - /* Index 6: debug status */ - /* Index 7: debug control */ + unsigned long grrr; }; -#define DBREG_DR7_EXEC 0x00 /* break on execute */ -#define DBREG_DR7_WRONLY 0x01 /* break on write */ -#define DBREG_DR7_RDWR 0x03 /* break on read or write */ -#define DBREG_DRX(d,x) ((d)->dr[(x)]) /* reference dr0 - dr7 by - register number */ - - #ifdef _KERNEL /* * XXX these interfaces are MI, so they should be declared in a MI place. ==== //depot/projects/hammer/sys/x86_64/include/ucontext.h#8 (text+ko) ==== @@ -37,41 +37,40 @@ * sigcontext. So that we can support sigcontext * and ucontext_t at the same time. */ - int mc_onstack; /* XXX - sigcontext compat. */ - int mc_gs; /* machine state (struct trapframe) */ - int mc_fs; - int mc_es; - int mc_ds; - int mc_edi; - int mc_esi; - int mc_ebp; - int mc_ebx; - int mc_edx; - int mc_ecx; - int mc_eax; - int mc_trapno; - int mc_err; - int mc_eip; - int mc_cs; - int mc_eflags; - int mc_esp; - int mc_ss; + long mc_onstack; /* XXX - sigcontext compat. */ + long mc_gs; /* machine state (struct trapframe) */ + long mc_fs; + long mc_es; + long mc_ds; + long mc_rdi; + long mc_rsi; + long mc_rbp; + long mc_rbx; + long mc_rdx; + long mc_rcx; + long mc_rax; + long mc_trapno; + long mc_err; + long mc_rip; + long mc_cs; + long mc_rflags; + long mc_rsp; + long mc_ss; - int mc_len; /* sizeof(mcontext_t) */ + long mc_len; /* sizeof(mcontext_t) */ #define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */ -#define _MC_FPFMT_387 0x10001 #define _MC_FPFMT_XMM 0x10002 - int mc_fpformat; + long mc_fpformat; #define _MC_FPOWNED_NONE 0x20000 /* FP state not used */ #define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */ #define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */ - int mc_ownedfp; - int mc_spare1[1]; /* align next field to 16 bytes */ + long mc_ownedfp; + long mc_spare1[1]; /* align next field to 16 bytes */ /* * See for the internals of mc_fpstate[]. */ - int mc_fpstate[128] __aligned(16); - int mc_spare2[8]; + long mc_fpstate[128] __aligned(16); + long mc_spare2[8]; } mcontext_t; #endif /* !_MACHINE_UCONTEXT_H_ */ ==== //depot/projects/hammer/sys/x86_64/x86_64/exception.s#12 (text+ko) ==== @@ -166,9 +166,11 @@ jmp doreti /* - * SYSCALL CALL GATE (old entry point for a.out binaries) + * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80) * - * The intersegment call has been set up to specify one dummy parameter. + * Even though the name says 'int0x80', this is actually a TGT (trap gate) + * rather then an IGT (interrupt gate). Thus interrupts are enabled on + * entry just as they are for a normal syscall. * * This leaves a place to put eflags so that the call frame can be * converted to a trap frame. Note that the eflags is (semi-)bogusly @@ -178,48 +180,6 @@ * and clobber the saved cs/eip. */ SUPERALIGN_TEXT -IDTVEC(lcall_syscall) - pushfq /* save eflags */ - popq 16(%rsp) /* shuffle into tf_eflags */ - pushq $7 /* sizeof "lcall 7,0" */ - subq $8,%rsp /* skip over tf_trapno */ - pushq %rax - pushq %rcx - pushq %rdx - pushq %rbx - pushq %rbp - pushq %rsi - pushq %rdi - pushq %r8 - pushq %r9 - pushq %r10 - pushq %r11 - pushq %r12 - pushq %r13 - pushq %r14 - pushq %r15 - pushq %ds - pushq %ds - pushq %es - pushq %fs - mov $KDSEL,%ax /* switch to kernel segments */ - mov %ax,%ds - mov %ax,%es - mov $KPSEL,%ax - mov %ax,%fs - FAKE_MCOUNT(13*4(%rsp)) - call syscall - MEXITCOUNT - jmp doreti - -/* - * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80) - * - * Even though the name says 'int0x80', this is actually a TGT (trap gate) - * rather then an IGT (interrupt gate). Thus interrupts are enabled on - * entry just as they are for a normal syscall. - */ - SUPERALIGN_TEXT IDTVEC(int0x80_syscall) pushq $2 /* sizeof "int 0x80" */ subq $8,%rsp /* skip over tf_trapno */ ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#36 (text+ko) ==== @@ -125,8 +125,6 @@ static void fpstate_drop(struct thread *td); static void get_fpcontext(struct thread *td, mcontext_t *mcp); static int set_fpcontext(struct thread *td, const mcontext_t *mcp); -static void set_fpregs_xmm(struct save87 *, struct savexmm *); -static void fill_fpregs_xmm(struct savexmm *, struct save87 *); SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL) int _udatasel, _ucodesel; @@ -134,7 +132,9 @@ /* These are written in 32 bit mode */ u_int32_t modulep; /* phys addr of metadata table */ -u_int32_t IdlePTD; /* phys addr of kernel PTD */ +pd_entry_t *IdlePTD; /* phys addr of kernel PTD */ +pdp_entry_t *IdlePDP; /* phys addr of kernel level 3 */ +pml4_entry_t *IdlePML4; /* phys addr of kernel level 4 */ struct user *proc0uarea; /* address of proc 0 uarea space */ vm_offset_t proc0kstack; /* address of proc 0 kstack space */ @@ -234,7 +234,7 @@ PROC_LOCK_ASSERT(p, MA_OWNED); psp = p->p_sigacts; regs = td->td_frame; - oonstack = sigonstack(regs->tf_esp); + oonstack = sigonstack(regs->tf_rsp); /* Save user context. */ bzero(&sf, sizeof(sf)); @@ -258,9 +258,9 @@ p->p_sigstk.ss_flags |= SS_ONSTACK; #endif } else - sp = (char *)regs->tf_esp - sizeof(struct sigframe); + sp = (char *)regs->tf_rsp - sizeof(struct sigframe); /* Align to 16 bytes. */ - sfp = (struct sigframe *)((unsigned int)sp & ~0xF); + sfp = (struct sigframe *)((unsigned long)sp & ~0xF); PROC_UNLOCK(p); /* Translate the signal if appropriate. */ @@ -299,9 +299,9 @@ sigexit(td, SIGILL); } - regs->tf_esp = (int)sfp; - regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode); - regs->tf_eflags &= ~PSL_T; + regs->tf_rsp = (long)sfp; + regs->tf_rip = PS_STRINGS - *(p->p_sysent->sv_szsigcode); + regs->tf_rflags &= ~PSL_T; regs->tf_cs = _ucodesel; regs->tf_ds = _udatasel; regs->tf_es = _udatasel; @@ -332,29 +332,30 @@ struct proc *p = td->td_proc; struct trapframe *regs; const ucontext_t *ucp; - int cs, eflags, error, ret; + long rflags; + int cs, error, ret; error = copyin(uap->sigcntxp, &uc, sizeof(uc)); if (error != 0) return (error); ucp = &uc; regs = td->td_frame; - eflags = ucp->uc_mcontext.mc_eflags; + rflags = ucp->uc_mcontext.mc_rflags; /* * Don't allow users to change privileged or reserved flags. */ /* * XXX do allow users to change the privileged flag PSL_RF. - * The cpu sets PSL_RF in tf_eflags for faults. Debuggers - * should sometimes set it there too. tf_eflags is kept in + * The cpu sets PSL_RF in tf_rflags for faults. Debuggers + * should sometimes set it there too. tf_rflags is kept in * the signal context during signal handling and there is no * other place to remember it, so the PSL_RF bit may be * corrupted by the signal handler without us knowing. * Corruption of the PSL_RF bit at worst causes one more or * one less debugger trap, so allowing it is fairly harmless. */ - if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - printf("sigreturn: eflags = 0x%x\n", eflags); + if (!EFL_SECURE(rflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) { + printf("sigreturn: rflags = 0x%x\n", rflags); return (EINVAL); } @@ -366,7 +367,7 @@ cs = ucp->uc_mcontext.mc_cs; if (!CS_SECURE(cs)) { printf("sigreturn: cs = 0x%x\n", cs); - trapsignal(p, SIGBUS, T_PROTFLT); + trapsignal(td, SIGBUS, T_PROTFLT); return (EINVAL); } @@ -473,27 +474,15 @@ load_gs(_udatasel); bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_eip = entry; - regs->tf_esp = stack; - regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T); + regs->tf_rip = entry; + regs->tf_rsp = stack; + regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T); regs->tf_ss = _udatasel; regs->tf_ds = _udatasel; regs->tf_es = _udatasel; regs->tf_fs = _udatasel; regs->tf_cs = _ucodesel; - /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */ - regs->tf_ebx = ps_strings; - - /* - * Initialize the math emulator (if any) for the current process. - * Actually, just clear the bit that says that the emulator has - * been initialized. Initialization is delayed until the process - * traps to the emulator (if it is done at all) mainly because - * emulators don't provide an entry point for initialization. - */ - td->td_pcb->pcb_flags &= ~FP_SOFTFP; - /* * Arrange to trap the next npx or `fwait' instruction (see npx.c * for why fwait must be trapped at least if there is an npx or an @@ -518,13 +507,6 @@ * soon. */ fpstate_drop(td); - - /* - * XXX - Linux emulator - * Make sure sure edx is 0x0 on entry. Linux binaries depend - * on it. - */ - td->td_retval[1] = 0; } void @@ -568,11 +550,9 @@ * Initialize segments & interrupt table */ -int _default_ldt; union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */ static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ -union descriptor ldt[NLDT]; /* local descriptor table */ int private_tss; /* flag indicating private tss */ @@ -620,25 +600,7 @@ 0, 0, 0, /* unused - default 32 vs 16 bit size */ 0 /* limit granularity (byte/page units)*/ }, -/* GLDT_SEL 4 LDT Descriptor */ -{ (int) ldt, /* segment base address */ - sizeof(ldt)-1, /* length - all address space */ - SDT_SYSLDT, /* segment type */ - SEL_UPL, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 0, /* unused - default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, -/* GUSERLDT_SEL 5 User LDT Descriptor per process */ -{ (int) ldt, /* segment base address */ - (512 * sizeof(union descriptor)-1), /* length */ - SDT_SYSLDT, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 0, /* unused - default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, -/* GPANIC_SEL 6 Panic Tss Descriptor */ +/* GPANIC_SEL 4 Panic Tss Descriptor */ { (int) &dblfault_tss, /* segment base address */ sizeof(struct i386tss)-1,/* length - all address space */ SDT_SYSTSS, /* segment type */ @@ -649,63 +611,6 @@ 0 /* limit granularity (byte/page units)*/ }, }; -static struct soft_segment_descriptor ldt_segs[] = { - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Code Descriptor for user */ -{ 0x0, /* segment base address */ - 0xfffff, /* length - all address space */ - SDT_MEMERA, /* segment type */ - SEL_UPL, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 1, /* default 32 vs 16 bit size */ - 1 /* limit granularity (byte/page units)*/ }, - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Data Descriptor for user */ -{ 0x0, /* segment base address */ - 0xfffff, /* length - all address space */ - SDT_MEMRWA, /* segment type */ - SEL_UPL, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 1, /* default 32 vs 16 bit size */ - 1 /* limit granularity (byte/page units)*/ }, -}; - void setidt(idx, func, typ, dpl, selec) int idx; @@ -734,7 +639,7 @@ IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(fpusegm), IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot), IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align), - IDTVEC(xmm), IDTVEC(lcall_syscall), IDTVEC(int0x80_syscall); + IDTVEC(xmm), IDTVEC(int0x80_syscall); void sdtossd(sd, ssd) @@ -820,14 +725,6 @@ if (smap->length == 0) goto next_run; -#ifndef PAE - if (smap->base >= 0xffffffff) { - printf("%uK of memory above 4GB ignored\n", - (u_int)(smap->length / 1024)); - goto next_run; - } -#endif - for (i = 0; i <= physmap_idx; i += 2) { if (smap->base < physmap[i + 1]) { if (boothowto & RB_VERBOSE) @@ -851,7 +748,8 @@ physmap[physmap_idx] = smap->base; physmap[physmap_idx + 1] = smap->base + smap->length; next_run: ; - } #error "while not end of smap table from loader" + } while (1 /* XXX more to go */); +#error "while not end of smap table from loader" /* * Perform "base memory" related probes & setup based on SMAP @@ -885,7 +783,7 @@ /* * If we failed above, try memory map with INT 15:E801 */ -#error get smap from loader +#error "get smap from loader" else { /* * Prefer the RTC value for extended memory. @@ -1090,7 +988,6 @@ init386(first) int first; { - struct gate_descriptor *gdp; caddr_t kmdp; int gsel_tss, off, x; struct region_descriptor r_gdt, r_idt; @@ -1154,20 +1051,6 @@ mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_RECURSE); mtx_init(&icu_lock, "icu", NULL, MTX_SPIN | MTX_NOWITNESS); - /* make ldt memory segments */ - /* - * XXX - VM_MAXUSER_ADDRESS is an end address, not a max. And it - * should be spelled ...MAX_USER... - */ - ldt_segs[LUCODE_SEL].ssd_limit = atop(VM_MAXUSER_ADDRESS - 1); - ldt_segs[LUDATA_SEL].ssd_limit = atop(VM_MAXUSER_ADDRESS - 1); - for (x = 0; x < sizeof ldt_segs / sizeof ldt_segs[0]; x++) - ssdtosd(&ldt_segs[x], &ldt[x].sd); - - _default_ldt = GSEL(GLDT_SEL, SEL_KPL); - lldt(_default_ldt); - PCPU_SET(currentldt, _default_ldt); - /* exceptions */ for (x = 0; x < NIDT; x++) setidt(x, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, @@ -1261,11 +1144,10 @@ dblfault_tss.tss_cr3 = (int)IdlePTD; #endif dblfault_tss.tss_eip = (int)dblfault_handler; - dblfault_tss.tss_eflags = PSL_KERNEL; + dblfault_tss.tss_rflags = PSL_KERNEL; dblfault_tss.tss_ds = dblfault_tss.tss_es = dblfault_tss.tss_fs = dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL); dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL); - dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL); getmemsize(first); init_param2(physmem); @@ -1278,27 +1160,6 @@ msgbufinit(msgbufp, MSGBUF_SIZE); - /* make a call gate to reenter kernel with */ - gdp = &ldt[LSYS5CALLS_SEL].gd; - - x = (int) &IDTVEC(lcall_syscall); - gdp->gd_looffset = x; - gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL); - gdp->gd_stkcpy = 1; - gdp->gd_type = SDT_SYS386CGT; - gdp->gd_dpl = SEL_UPL; - gdp->gd_p = 1; - gdp->gd_hioffset = x >> 16; - - /* XXX does this work? */ - ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL]; - ldt[LSOL26CALLS_SEL] = ldt[LSYS5CALLS_SEL]; - - /* transfer to user mode */ - - _ucodesel = LSEL(LUCODE_SEL, SEL_UPL); - _udatasel = LSEL(LUDATA_SEL, SEL_UPL); - /* setup proc 0's pcb */ thread0.td_pcb->pcb_flags = 0; /* XXXKSE */ #ifdef PAE @@ -1317,14 +1178,14 @@ int ptrace_set_pc(struct thread *td, unsigned long addr) { - td->td_frame->tf_eip = addr; + td->td_frame->tf_rip = addr; return (0); } int ptrace_single_step(struct thread *td) { - td->td_frame->tf_eflags |= PSL_T; + td->td_frame->tf_rflags |= PSL_T; return (0); } @@ -1338,17 +1199,17 @@ regs->r_fs = tp->tf_fs; regs->r_es = tp->tf_es; regs->r_ds = tp->tf_ds; - regs->r_edi = tp->tf_edi; - regs->r_esi = tp->tf_esi; - regs->r_ebp = tp->tf_ebp; - regs->r_ebx = tp->tf_ebx; - regs->r_edx = tp->tf_edx; - regs->r_ecx = tp->tf_ecx; - regs->r_eax = tp->tf_eax; - regs->r_eip = tp->tf_eip; + regs->r_rdi = tp->tf_rdi; + regs->r_rsi = tp->tf_rsi; + regs->r_rbp = tp->tf_rbp; + regs->r_rbx = tp->tf_rbx; + regs->r_rdx = tp->tf_rdx; + regs->r_rcx = tp->tf_rcx; + regs->r_rax = tp->tf_rax; + regs->r_rip = tp->tf_rip; regs->r_cs = tp->tf_cs; - regs->r_eflags = tp->tf_eflags; - regs->r_esp = tp->tf_esp; + regs->r_rflags = tp->tf_rflags; + regs->r_rsp = tp->tf_rsp; regs->r_ss = tp->tf_ss; pcb = td->td_pcb; regs->r_gs = pcb->pcb_gs; @@ -1362,23 +1223,23 @@ struct trapframe *tp; tp = td->td_frame; - if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) || + if (!EFL_SECURE(regs->r_rflags, tp->tf_rflags) || !CS_SECURE(regs->r_cs)) return (EINVAL); tp->tf_fs = regs->r_fs; tp->tf_es = regs->r_es; tp->tf_ds = regs->r_ds; - tp->tf_edi = regs->r_edi; - tp->tf_esi = regs->r_esi; - tp->tf_ebp = regs->r_ebp; - tp->tf_ebx = regs->r_ebx; - tp->tf_edx = regs->r_edx; - tp->tf_ecx = regs->r_ecx; - tp->tf_eax = regs->r_eax; - tp->tf_eip = regs->r_eip; + tp->tf_rdi = regs->r_rdi; + tp->tf_rsi = regs->r_rsi; + tp->tf_rbp = regs->r_rbp; + tp->tf_rbx = regs->r_rbx; + tp->tf_rdx = regs->r_rdx; + tp->tf_rcx = regs->r_rcx; + tp->tf_rax = regs->r_rax; + tp->tf_rip = regs->r_rip; tp->tf_cs = regs->r_cs; - tp->tf_eflags = regs->r_eflags; - tp->tf_esp = regs->r_esp; + tp->tf_rflags = regs->r_rflags; + tp->tf_rsp = regs->r_rsp; tp->tf_ss = regs->r_ss; pcb = td->td_pcb; pcb->pcb_gs = regs->r_gs; @@ -1386,15 +1247,15 @@ } static void -fill_fpregs_xmm(sv_xmm, sv_87) - struct savexmm *sv_xmm; - struct save87 *sv_87; +fill_fpregs_xmm(struct savefpu *sv_xmm, struct fpreg *fpregs) { - register struct env87 *penv_87 = &sv_87->sv_env; +#if 0 + register struct env87 *penv_87 = &fpregs->sv_env; register struct envxmm *penv_xmm = &sv_xmm->sv_env; int i; - bzero(sv_87, sizeof(*sv_87)); + /* pcb -> fpregs */ + bzero(fpregs, sizeof(*fpregs)); /* FPU control/status */ penv_87->en_cw = penv_xmm->en_cw; @@ -1409,17 +1270,19 @@ /* FPU registers */ for (i = 0; i < 8; ++i) sv_87->sv_ac[i] = sv_xmm->sv_fp[i].fp_acc; +#endif + printf("implement fill_fpregs_xmm\n"); } static void -set_fpregs_xmm(sv_87, sv_xmm) - struct save87 *sv_87; - struct savexmm *sv_xmm; +set_fpregs_xmm(struct fpreg *fpregs, struct savefpu *sv_xmm) { - register struct env87 *penv_87 = &sv_87->sv_env; +#if 0 + register struct env87 *penv_87 = &fpregs->sv_env; register struct envxmm *penv_xmm = &sv_xmm->sv_env; int i; + /* fpregs -> pcb */ /* FPU control/status */ penv_xmm->en_cw = penv_87->en_cw; penv_xmm->en_sw = penv_87->en_sw; @@ -1433,13 +1296,15 @@ /* FPU registers */ for (i = 0; i < 8; ++i) sv_xmm->sv_fp[i].fp_acc = sv_87->sv_ac[i]; +#endif + printf("implement set_fpregs_xmm\n"); } int fill_fpregs(struct thread *td, struct fpreg *fpregs) { - fill_fpregs_xmm(&td->td_pcb->pcb_save.sv_xmm, (struct save87 *)fpregs); + fill_fpregs_xmm(&td->td_pcb->pcb_save, fpregs); return (0); } @@ -1447,7 +1312,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs) { - set_fpregs_xmm((struct save87 *)fpregs, &td->td_pcb->pcb_save.sv_xmm); + set_fpregs_xmm(fpregs, &td->td_pcb->pcb_save); return (0); } @@ -1461,22 +1326,22 @@ tp = td->td_frame; - mcp->mc_onstack = sigonstack(tp->tf_esp); + mcp->mc_onstack = sigonstack(tp->tf_rsp); mcp->mc_gs = td->td_pcb->pcb_gs; mcp->mc_fs = tp->tf_fs; mcp->mc_es = tp->tf_es; mcp->mc_ds = tp->tf_ds; - mcp->mc_edi = tp->tf_edi; - mcp->mc_esi = tp->tf_esi; - mcp->mc_ebp = tp->tf_ebp; - mcp->mc_ebx = tp->tf_ebx; - mcp->mc_edx = tp->tf_edx; - mcp->mc_ecx = tp->tf_ecx; - mcp->mc_eax = tp->tf_eax; - mcp->mc_eip = tp->tf_eip; + mcp->mc_rdi = tp->tf_rdi; + mcp->mc_rsi = tp->tf_rsi; + mcp->mc_rbp = tp->tf_rbp; + mcp->mc_rbx = tp->tf_rbx; + mcp->mc_rdx = tp->tf_rdx; + mcp->mc_rcx = tp->tf_rcx; + mcp->mc_rax = tp->tf_rax; + mcp->mc_rip = tp->tf_rip; mcp->mc_cs = tp->tf_cs; - mcp->mc_eflags = tp->tf_eflags; - mcp->mc_esp = tp->tf_esp; + mcp->mc_rflags = tp->tf_rflags; + mcp->mc_rsp = tp->tf_rsp; mcp->mc_ss = tp->tf_ss; mcp->mc_len = sizeof(*mcp); get_fpcontext(td, mcp); @@ -1493,27 +1358,28 @@ set_mcontext(struct thread *td, const mcontext_t *mcp) { struct trapframe *tp; - int eflags, ret; + long rflags; + int ret; tp = td->td_frame; if (mcp->mc_len != sizeof(*mcp)) return (EINVAL); - eflags = (mcp->mc_eflags & PSL_USERCHANGE) | - (tp->tf_eflags & ~PSL_USERCHANGE); + rflags = (mcp->mc_rflags & PSL_USERCHANGE) | + (tp->tf_rflags & ~PSL_USERCHANGE); if ((ret = set_fpcontext(td, mcp)) == 0) { tp->tf_fs = mcp->mc_fs; tp->tf_es = mcp->mc_es; tp->tf_ds = mcp->mc_ds; - tp->tf_edi = mcp->mc_edi; - tp->tf_esi = mcp->mc_esi; - tp->tf_ebp = mcp->mc_ebp; - tp->tf_ebx = mcp->mc_ebx; - tp->tf_edx = mcp->mc_edx; - tp->tf_ecx = mcp->mc_ecx; - tp->tf_eax = mcp->mc_eax; - tp->tf_eip = mcp->mc_eip; - tp->tf_eflags = eflags; - tp->tf_esp = mcp->mc_esp; + tp->tf_rdi = mcp->mc_rdi; + tp->tf_rsi = mcp->mc_rsi; + tp->tf_rbp = mcp->mc_rbp; + tp->tf_rbx = mcp->mc_rbx; + tp->tf_rdx = mcp->mc_rdx; + tp->tf_rcx = mcp->mc_rcx; + tp->tf_rax = mcp->mc_rax; + tp->tf_rip = mcp->mc_rip; + tp->tf_rflags = rflags; + tp->tf_rsp = mcp->mc_rsp; tp->tf_ss = mcp->mc_ss; td->td_pcb->pcb_gs = mcp->mc_gs; ret = 0; ==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#19 (text+ko) ==== @@ -95,8 +95,6 @@ static void trap_fatal(struct trapframe *, vm_offset_t); void dblfault_handler(void); -extern inthand_t IDTVEC(lcall_syscall); - #define MAX_TRAP_MSG 28 static char *trap_msg[] = { "", /* 0 unused */ @@ -437,23 +435,6 @@ break; case T_TRCTRAP: /* trace trap */ - if (frame.tf_rip == (long)IDTVEC(lcall_syscall)) { - /* - * We've just entered system mode via the - * syscall lcall. Continue single stepping - * silently until the syscall handler has - * saved the flags. - */ - goto out; - } - if (frame.tf_rip == (long)IDTVEC(lcall_syscall) + 1) { - /* - * The syscall handler has now saved the - * flags. Stop single stepping it. - */ - frame.tf_rflags &= ~PSL_T; - goto out; - } /* * FALLTHROUGH (TRCTRAP kernel mode, kernel address) */