Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Mar 2004 10:42:00 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 47996 for review
Message-ID:  <200403021842.i22Ig0wQ088623@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=47996

Change 47996 by peter@peter_daintree on 2004/03/02 10:41:06

	check in some uncommitted changes

Affected files ...

.. //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#20 edit
.. //depot/projects/hammer/sys/amd64/amd64/genassym.c#31 edit
.. //depot/projects/hammer/sys/amd64/include/pcb.h#16 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#20 (text+ko) ====

@@ -42,6 +42,12 @@
 
 #include "assym.s"
 
+#ifdef SMP
+#define LK	lock ;
+#else
+#define LK
+#endif
+
 /*****************************************************************************/
 /* Scheduling                                                                */
 /*****************************************************************************/
@@ -66,10 +72,7 @@
 	/* release bit from old pm_active */
 	movq	TD_PROC(%rdi), %rdx		/* oldtd->td_proc */
 	movq	P_VMSPACE(%rdx), %rdx		/* proc->p_vmspace */
-#ifdef SMP
-	lock
-#endif
-	btrl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* clear old */
+	LK btrl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* clear old */
 1:
 	movq	TD_PCB(%rsi),%rdx		/* newtd->td_proc */
 	movq	PCB_CR3(%rdx),%rdx
@@ -77,10 +80,7 @@
 	/* set bit in new pm_active */
 	movq	TD_PROC(%rsi),%rdx
 	movq	P_VMSPACE(%rdx), %rdx
-#ifdef SMP
-	lock
-#endif
-	btsl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* set new */
+	LK btsl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* set new */
 	jmp	sw1
 
 /*
@@ -92,13 +92,7 @@
  * %rsi = newtd
  */
 ENTRY(cpu_switch)
-
 	/* Switch to new thread.  First, save context. */
-#ifdef INVARIANTS
-	testq	%rdi,%rdi			/* no thread? */
-	jz	badsw2				/* no, panic */
-#endif
-
 	movq	TD_PCB(%rdi),%r8
 
 	movq	(%rsp),%rax			/* Hardware registers */
@@ -113,6 +107,17 @@
 	pushfq					/* PSL */
 	popq	PCB_RFLAGS(%r8)
 
+	testl	$PCB_32BIT,PCB_FLAGS(%r8)
+	jz	1f				/* no, skip over */
+
+	/* Save segment selector numbers */
+	movl	%ds,PCB_DS(%r8)
+	movl	%es,PCB_ES(%r8)
+	movl	%fs,PCB_FS(%r8)
+	movl	%gs,PCB_GS(%r8)
+	jmp	2f
+1:
+
 	/* Save userland %fs */
 	movl	$MSR_FSBASE,%ecx
 	rdmsr
@@ -124,13 +129,8 @@
 	rdmsr
 	movl	%eax,PCB_GSBASE(%r8)
 	movl	%edx,PCB_GSBASE+4(%r8)
+2:
 
-	/* Save segment selector numbers */
-	movl	%ds,PCB_DS(%r8)
-	movl	%es,PCB_ES(%r8)
-	movl	%fs,PCB_FS(%r8)
-	movl	%gs,PCB_GS(%r8)
-
 	/* Test if debug registers should be saved. */
 	testl	$PCB_DBREGS,PCB_FLAGS(%r8)
 	jz	1f				/* no, skip over */
@@ -164,10 +164,6 @@
 1:
 
 	/* Save is done.  Now fire up new thread. Leave old vmspace. */
-#ifdef INVARIANTS
-	testq	%rsi,%rsi			/* no thread? */
-	jz	badsw3				/* no, panic */
-#endif
 	movq	TD_PCB(%rsi),%r8
 
 	/* switch address space */
@@ -185,18 +181,12 @@
 	/* Release bit from old pmap->pm_active */
 	movq	TD_PROC(%rdi), %rdx		/* oldproc */
 	movq	P_VMSPACE(%rdx), %rdx
-#ifdef SMP
-	lock
-#endif
-	btrl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* clear old */
+	LK btrl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* clear old */
 
 	/* Set bit in new pmap->pm_active */
 	movq	TD_PROC(%rsi),%rdx		/* newproc */
 	movq	P_VMSPACE(%rdx), %rdx
-#ifdef SMP
-	lock
-#endif
-	btsl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* set new */
+	LK btsl	%eax, VM_PMAP+PM_ACTIVE(%rdx)	/* set new */
 
 sw1:
 	/*
@@ -205,6 +195,9 @@
 	 */
 	movq	TD_PCB(%rsi),%r8
 
+	testl	$PCB_32BIT,PCB_FLAGS(%r8)
+	jz	1f				/* no, skip over */
+
 	/* Restore segment selector numbers */
 	movl	PCB_DS(%r8),%ds
 	movl	PCB_ES(%r8),%es
@@ -215,6 +208,8 @@
 	rdmsr
 	movl	PCB_GS(%r8),%gs
 	wrmsr
+	jmp	2f
+1:
 
 	/* Restore userland %fs */
 	movl	$MSR_FSBASE,%ecx
@@ -227,6 +222,7 @@
 	movl	PCB_GSBASE(%r8),%eax
 	movl	PCB_GSBASE+4(%r8),%edx
 	wrmsr
+2:
 
 	/* Update the TSS_RSP0 pointer for the next interrupt */
 	movq	PCPU(TSSP), %rax
@@ -272,79 +268,8 @@
 	orq	%rcx,%rax
 	movq	%rax,%dr7
 1:
-
 	ret
 
-#ifdef INVARIANTS
-badsw1:
-	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
-	movq	$0,%rdi
-	movq	$0,%rsi
-	leaq	sw0_1,%rdx
-	call	__panic
-sw0_1:	.asciz	"cpu_throw: no newthread supplied"
-
-badsw2:
-	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
-	movq	$0,%rdi
-	movq	$0,%rsi
-	leaq	sw0_2,%rdx
-	call	__panic
-sw0_2:	.asciz	"cpu_switch: no curthread supplied"
-
-badsw3:
-	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
-	movq	$0,%rdi
-	movq	$0,%rsi
-	leaq	sw0_3,%rdx
-	call	__panic
-sw0_3:	.asciz	"cpu_switch: no newthread supplied"
-#endif
-
-noswitch:	.asciz	"cpu_switch: called!"
-nothrow:	.asciz	"cpu_throw: called!"
 /*
  * savectx(pcb)
  * Update pcb, saving current processor state.

==== //depot/projects/hammer/sys/amd64/amd64/genassym.c#31 (text+ko) ====

@@ -142,6 +142,7 @@
 ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
 ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
 ASSYM(PCB_DBREGS, PCB_DBREGS);
+ASSYM(PCB_32BIT, PCB_32BIT);
 
 ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
 ASSYM(PCB_FULLCTX, PCB_FULLCTX);

==== //depot/projects/hammer/sys/amd64/include/pcb.h#16 (text+ko) ====

@@ -75,6 +75,7 @@
 	u_long	pcb_flags;
 #define	PCB_DBREGS	0x02	/* process using debug registers */
 #define	PCB_FPUINITDONE	0x08	/* fpu state is initialized */
+#define	PCB_32BIT	0x40	/* process has 32 bit context (segs etc) */
 #define	PCB_FULLCTX	0x80	/* full context restore on sysret */
 
 	caddr_t	pcb_onfault;	/* copyin/out fault recovery */



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