From owner-p4-projects@FreeBSD.ORG Fri Apr 25 14:45:27 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A35D837B405; Fri, 25 Apr 2003 14:45:26 -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 3DD4537B401 for ; Fri, 25 Apr 2003 14:45:26 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A2EB043FE5 for ; Fri, 25 Apr 2003 14:45:25 -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 h3PLjP0U054072 for ; Fri, 25 Apr 2003 14:45:25 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h3PLjPT0054066 for perforce@freebsd.org; Fri, 25 Apr 2003 14:45:25 -0700 (PDT) Date: Fri, 25 Apr 2003 14:45:25 -0700 (PDT) Message-Id: <200304252145.h3PLjPT0054066@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 29737 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: Fri, 25 Apr 2003 21:45:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=29737 Change 29737 by peter@peter_daintree on 2003/04/25 14:45:09 enable syscall instruction. Note that MSR_LSTAR isn't set, so that when compatability mode is enabled, it must point to something. Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/exception.s#25 edit .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#83 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/exception.s#25 (text+ko) ==== @@ -251,7 +251,7 @@ movq TF_RIP(%rsp),%rcx /* original %rip */ sti #swapgs - sysret + sysretq ENTRY(fork_trampoline) movq %r12, %rdi /* function */ ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#83 (text+ko) ==== @@ -643,7 +643,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(int0x80_syscall); + IDTVEC(xmm), IDTVEC(int0x80_syscall), IDTVEC(fast_syscall); void sdtossd(sd, ssd) @@ -1118,7 +1118,11 @@ int gsel_tss, off, x; struct region_descriptor r_gdt, r_idt; struct pcpu *pc; + u_int64_t msr; + /* Turn on PTE NX (no execute) bit */ + msr = rdmsr(MSR_EFER) | EFER_NXE; + wrmsr(MSR_EFER, msr); create_pagetables(); /* XXX do %cr0 as well */ @@ -1242,6 +1246,14 @@ gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); ltr(gsel_tss); + /* Set up the fast syscall stuff */ + msr = rdmsr(MSR_EFER) | EFER_SCE; + wrmsr(MSR_EFER, msr); + wrmsr(MSR_LSTAR, (uint64_t)IDTVEC(fast_syscall)); + msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) | + ((u_int64_t)GSEL(GUCODE_SEL, SEL_UPL) << 48); + wrmsr(MSR_STAR, msr); + getmemsize(kmdp, physfree); init_param2(physmem);