Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Mar 2008 01:43:16 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 137457 for review
Message-ID:  <200803120143.m2C1hG7m073166@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803120143.m2C1hG7m073166>