PERFORCE change 29731 for review

Peter Wemm peter at FreeBSD.org
Fri Apr 25 14:12:44 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=29731

Change 29731 by peter at peter_daintree on 2003/04/25 14:12:33

	Make some guesses about what fast_syscall could look like.  It isn't
	enabled on the cpu yet though.  This is still pretty rough, and the
	swapgs stuff is commented out since the PCPU stuff is commented out,
	hence it doesn't gain anything yet.

Affected files ...

.. //depot/projects/hammer/sys/x86_64/x86_64/exception.s#24 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/x86_64/exception.s#24 (text+ko) ====

@@ -191,6 +191,68 @@
 	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.
+ * swapgs gives us access to our PCPU space only.
+ * XXX The PCPU stuff is stubbed out right now...
+ */
+IDTVEC(fast_syscall)
+	#swapgs
+	movq	%rsp,PCPU(SCRATCH_RSP)
+	movq	common_tss+COMMON_TSS_RSP0,%rsp
+	sti
+	/* Now emulate a trapframe. Ugh. */
+	subq	$TF_SIZE,%rsp
+	movq	$KUDSEL,TF_SS(%rsp)
+	/* defer TF_RSP till we have a spare register */
+	movq	%r11,TF_RFLAGS(%rsp)
+	movq	$KUCSEL,TF_CS(%rsp)
+	movq	%rcx,TF_RIP(%rsp)	/* %rcx original value is in %r10 */
+	movq	$2,TF_ERR(%rsp)
+	movq	%rdi,TF_RDI(%rsp)	/* arg 1 */
+	movq	%rsi,TF_RSI(%rsp)	/* arg 2 */
+	movq	%rdx,TF_RDX(%rsp)	/* arg 3 */
+	movq	%r10,TF_RCX(%rsp)	/* arg 4 */
+	movq	%r8,TF_R8(%rsp)		/* arg 5 */
+	movq	%r9,TF_R9(%rsp)		/* arg 6 */
+	movq	%rax,TF_RAX(%rsp)	/* syscall number */
+	movq	%rbx,TF_RBX(%rsp)	/* C preserved */
+	movq	%rbp,TF_RBP(%rsp)	/* C preserved */
+	movq	%r12,TF_R12(%rsp)	/* C preserved */
+	movq	%r13,TF_R13(%rsp)	/* C preserved */
+	movq	%r14,TF_R14(%rsp)	/* C preserved */
+	movq	%r15,TF_R15(%rsp)	/* C preserved */
+	movq	PCPU(SCRATCH_RSP),%r12	/* %r12 already saved */
+	movq	%r12,TF_RSP(%rsp)	/* user stack pointer */
+	call	syscall
+	/* simplified from doreti */
+1:	/* Check for and handle AST's on return to userland */
+	cli
+	movq	PCPU(CURTHREAD),%rax
+	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
+	je	2f
+	sti
+	movq	%rsp, %rdi
+	call	ast
+	jmp	1b
+2:	/* restore preserved registers */
+	movq	TF_RSP(%rsp),%rdi	/* user stack pointer */
+	movq	TF_RAX(%rsp),%rax	/* return value 1 */
+	movq	TF_RDX(%rsp),%rdx	/* return value 2 */
+	movq	TF_RBX(%rsp),%rbx	/* C preserved */
+	movq	TF_RBP(%rsp),%rbp	/* C preserved */
+	movq	TF_R12(%rsp),%r12	/* C preserved */
+	movq	TF_R13(%rsp),%r13	/* C preserved */
+	movq	TF_R14(%rsp),%r14	/* C preserved */
+	movq	TF_R15(%rsp),%r15	/* C preserved */
+	movq	TF_R11(%rsp),%r11	/* original %rflags */
+	movq	TF_RIP(%rsp),%rcx	/* original %rip */
+	sti
+	#swapgs
+	sysret
+
 ENTRY(fork_trampoline)
 	movq	%r12, %rdi		/* function */
 	movq	%rbx, %rsi		/* arg1 */


More information about the p4-projects mailing list