From owner-p4-projects@FreeBSD.ORG Tue May 13 20:18:37 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2133537B404; Tue, 13 May 2003 20:18:37 -0700 (PDT) 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 A7DD837B401 for ; Tue, 13 May 2003 20:18:36 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2CBE543F3F for ; Tue, 13 May 2003 20:18:36 -0700 (PDT) (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 h4E3Ia0U072998 for ; Tue, 13 May 2003 20:18:36 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4E3IZYq072995 for perforce@freebsd.org; Tue, 13 May 2003 20:18:35 -0700 (PDT) Date: Tue, 13 May 2003 20:18:35 -0700 (PDT) Message-Id: <200305140318.h4E3IZYq072995@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 31118 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: Wed, 14 May 2003 03:18:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=31118 Change 31118 by peter@peter_hammer on 2003/05/13 20:17:52 Move int0x80 handler into the i386 emulator support code. Note, if you have any old-style binaries that use int $0x80 still, it would be a really good thing to recompile them before booting this kernel. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/exception.S#12 edit .. //depot/projects/hammer/sys/amd64/amd64/machdep.c#32 edit .. //depot/projects/hammer/sys/amd64/amd64/trap.c#15 edit .. //depot/projects/hammer/sys/amd64/ia32/ia32_exception.S#1 add .. //depot/projects/hammer/sys/amd64/ia32/ia32_syscall.c#1 add .. //depot/projects/hammer/sys/conf/files.amd64#12 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/exception.S#12 (text+ko) ==== @@ -218,40 +218,6 @@ jmp alltraps_pushregs_no_rdi /* - * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80) - * - * This is a SDT_SYSIDT entry point (unlike the i386 port) so that we - * can do a swapgs before enabling interrupts. This is critical because - * if we took an interrupt before swapgs, the interrupt code would see - * that it originated in supervisor mode and skip the swapgs. - */ - SUPERALIGN_TEXT -IDTVEC(int0x80_syscall) - swapgs - sti - pushq $2 /* sizeof "int 0x80" */ - subq $TF_ERR,%rsp /* skip over tf_trapno */ - movq %rdi,TF_RDI(%rsp) - movq %rsi,TF_RSI(%rsp) - movq %rdx,TF_RDX(%rsp) - movq %rcx,TF_RCX(%rsp) - movq %r8,TF_R8(%rsp) - movq %r9,TF_R9(%rsp) - movq %rax,TF_RAX(%rsp) - movq %rbx,TF_RBX(%rsp) - movq %rbp,TF_RBP(%rsp) - movq %r10,TF_R10(%rsp) - movq %r11,TF_R11(%rsp) - movq %r12,TF_R12(%rsp) - movq %r13,TF_R13(%rsp) - movq %r14,TF_R14(%rsp) - movq %r15,TF_R15(%rsp) - FAKE_MCOUNT(13*4(%rsp)) - call ia32_syscall - MEXITCOUNT - jmp doreti - -/* * Fast syscall entry point. We enter here with just our new %cs/%ss set, * and the new privilige level. We are still running on the old user stack * pointer. We have to juggle a few things around to find our stack etc. @@ -353,6 +319,7 @@ */ .text SUPERALIGN_TEXT + .globl doreti .type doreti,@function doreti: FAKE_MCOUNT(bintr) /* init "from" bintr -> doreti */ ==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#32 (text+ko) ==== @@ -683,7 +683,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(dblfault), IDTVEC(int0x80_syscall), + IDTVEC(xmm), IDTVEC(dblfault), IDTVEC(fast_syscall), IDTVEC(fast_syscall32); void @@ -1254,7 +1254,6 @@ setidt(17, &IDTVEC(align), SDT_SYSIGT, SEL_KPL, 0); setidt(18, &IDTVEC(mchk), SDT_SYSIGT, SEL_KPL, 0); setidt(19, &IDTVEC(xmm), SDT_SYSIGT, SEL_KPL, 0); - setidt(0x80, &IDTVEC(int0x80_syscall), SDT_SYSIGT, SEL_UPL, 0); r_idt.rd_limit = sizeof(idt0) - 1; r_idt.rd_base = (long) idt; ==== //depot/projects/hammer/sys/amd64/amd64/trap.c#15 (text+ko) ==== @@ -817,174 +817,3 @@ mtx_assert(&sched_lock, MA_NOTOWNED); mtx_assert(&Giant, MA_NOTOWNED); } - -void ia32_syscall(struct trapframe frame); -void -ia32_syscall(struct trapframe frame) -{ - caddr_t params; - int i; - struct sysent *callp; - struct thread *td = curthread; - struct proc *p = td->td_proc; - register_t orig_tf_rflags; - u_int sticks; - int error; - int narg; - u_int32_t args[8]; - u_int64_t args64[8]; - u_int code; - - /* - * note: PCPU_LAZY_INC() can only be used if we can afford - * occassional inaccuracy in the count. - */ - cnt.v_syscall++; - - sticks = td->td_sticks; - td->td_frame = &frame; - if (td->td_ucred != p->p_ucred) - cred_update_thread(td); - params = (caddr_t)frame.tf_rsp + sizeof(u_int32_t); - code = frame.tf_rax; - orig_tf_rflags = frame.tf_rflags; - - if (p->p_sysent->sv_prepsyscall) { - /* - * The prep code is MP aware. - */ - (*p->p_sysent->sv_prepsyscall)(&frame, args, &code, ¶ms); - } else { - /* - * Need to check if this is a 32 bit or 64 bit syscall. - * fuword is MP aware. - */ - if (code == SYS_syscall) { - /* - * Code is first argument, followed by actual args. - */ - code = fuword32(params); - params += sizeof(int); - } else if (code == SYS___syscall) { - /* - * Like syscall, but code is a quad, so as to maintain - * quad alignment for the rest of the arguments. - * We use a 32-bit fetch in case params is not - * aligned. - */ - code = fuword32(params); - params += sizeof(quad_t); - } - } - - if (p->p_sysent->sv_mask) - code &= p->p_sysent->sv_mask; - - if (code >= p->p_sysent->sv_size) - callp = &p->p_sysent->sv_table[0]; - else - callp = &p->p_sysent->sv_table[code]; - - narg = callp->sy_narg & SYF_ARGMASK; - - /* - * copyin and the ktrsyscall()/ktrsysret() code is MP-aware - */ - if (params != NULL && narg != 0) - error = copyin(params, (caddr_t)args, - (u_int)(narg * sizeof(int))); - else - error = 0; - - for (i = 0; i < narg; i++) - args64[i] = args[i]; - -#ifdef KTRACE - if (KTRPOINT(td, KTR_SYSCALL)) - ktrsyscall(code, narg, args64); -#endif - /* - * Try to run the syscall without Giant if the syscall - * is MP safe. - */ - if ((callp->sy_narg & SYF_MPSAFE) == 0) - mtx_lock(&Giant); - - if (error == 0) { - td->td_retval[0] = 0; - td->td_retval[1] = frame.tf_rdx; - - STOPEVENT(p, S_SCE, narg); - - error = (*callp->sy_call)(td, args64); - } - - switch (error) { - case 0: - frame.tf_rax = td->td_retval[0]; - frame.tf_rdx = td->td_retval[1]; - frame.tf_rflags &= ~PSL_C; - break; - - case ERESTART: - /* - * Reconstruct pc, assuming lcall $X,y is 7 bytes, - * int 0x80 is 2 bytes. We saved this in tf_err. - */ - frame.tf_rip -= frame.tf_err; - break; - - case EJUSTRETURN: - break; - - default: - if (p->p_sysent->sv_errsize) { - if (error >= p->p_sysent->sv_errsize) - error = -1; /* XXX */ - else - error = p->p_sysent->sv_errtbl[error]; - } - frame.tf_rax = error; - frame.tf_rflags |= PSL_C; - break; - } - - /* - * Release Giant if we previously set it. - */ - if ((callp->sy_narg & SYF_MPSAFE) == 0) - mtx_unlock(&Giant); - - /* - * Traced syscall. - */ - if (orig_tf_rflags & PSL_T) { - frame.tf_rflags &= ~PSL_T; - trapsignal(td, SIGTRAP, 0); - } - - /* - * Handle reschedule and other end-of-syscall issues - */ - userret(td, &frame, sticks); - -#ifdef KTRACE - if (KTRPOINT(td, KTR_SYSRET)) - ktrsysret(code, error, td->td_retval[0]); -#endif - - /* - * This works because errno is findable through the - * register set. If we ever support an emulation where this - * is not the case, this code will need to be revisited. - */ - STOPEVENT(p, S_SCX, code); - -#ifdef DIAGNOSTIC - cred_free_thread(td); -#endif - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); -} ==== //depot/projects/hammer/sys/conf/files.amd64#12 (text+ko) ==== @@ -82,6 +82,8 @@ amd64/ia32/ia32_sysvec.c optional ia32 amd64/ia32/ia32_signal.c optional ia32 amd64/ia32/ia32_sigtramp.S optional ia32 +amd64/ia32/ia32_exception.S optional ia32 +amd64/ia32/ia32_syscall.c optional ia32 kern/imgact_elf32.c optional ia32 # This file tells config what files go into building a kernel,