From owner-p4-projects@FreeBSD.ORG Wed Mar 12 01:43:16 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 856B51065746; Wed, 12 Mar 2008 01:43:16 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 433291065741 for ; Wed, 12 Mar 2008 01:43:16 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 310788FC20 for ; Wed, 12 Mar 2008 01:43:16 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m2C1hGTv073168 for ; Wed, 12 Mar 2008 01:43:16 GMT (envelope-from peter-gmail@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m2C1hG7m073166 for perforce@freebsd.org; Wed, 12 Mar 2008 01:43:16 GMT (envelope-from peter-gmail@wemm.org) Date: Wed, 12 Mar 2008 01:43:16 GMT Message-Id: <200803120143.m2C1hG7m073166@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter-gmail@wemm.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 137457 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Mar 2008 01:43:16 -0000 http://perforce.freebsd.org/chv.cgi?CH=137457 Change 137457 by peter@peter_melody on 2008/03/12 01:42:55 Handle arriving via cpu_throw. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#44 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#44 (text+ko) ==== @@ -80,6 +80,8 @@ movq TD_PCB(%rsi),%rdx /* newtd->td_proc */ movq PCB_CR3(%rdx),%rdx movq %rdx,%cr3 /* new address space */ + xorl %r9d,%r9d /* Old pcb pointer */ + movq TD_PCB(%rsi),%r8 jmp swact END(cpu_throw) @@ -106,10 +108,8 @@ movq %rbx,PCB_RBX(%r8) movq %rax,PCB_RIP(%r8) -#if 0 /* Save copy of pcb pointer */ movq %r8,%r9 -#endif testl $PCB_32BIT,PCB_FLAGS(%r8) jnz store_gs /* static predict not taken */ @@ -170,17 +170,22 @@ * At this point, we've switched address spaces and are ready * to load up the rest of the next context. */ -#if 1 - movq TD_PCB(%rsi),%r8 -#endif /* Skip loading user fsbase/gsbase for kthreads */ testl $TDP_KTHREAD,TD_PFLAGS(%rsi) - jnz 2f + jnz do_tss + + testq %r9,%r9 + jz no_pcb + cmpq PCB_FSBASE(%r9),%r10 + cmpq PCB_GSBASE(%r9),%r11 + jmp check_bases +no_pcb: + movq $-1,%r10 /* Illegal value - force reload on cpu_throw */ + movq %r10,%r11 - movq TD_PCB(%rdi),%r9 +check_bases: movq PCB_FSBASE(%r8),%r10 - cmpq PCB_FSBASE(%r9),%r10 jz 1f /* Restore userland %fs */ movl $MSR_FSBASE,%ecx @@ -189,8 +194,7 @@ wrmsr 1: - movq PCB_GSBASE(%r8),%r10 - cmpq PCB_GSBASE(%r9),%r10 + movq PCB_GSBASE(%r8),%r11 jz 2f /* Restore userland %gs */ movl $MSR_KGSBASE,%ecx @@ -198,6 +202,7 @@ movl PCB_GSBASE+4(%r8),%edx wrmsr 2: +do_tss: /* Update the TSS_RSP0 pointer for the next interrupt */ movq PCPU(TSSP), %rax