1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
From f022cb3771222d1effa738d4cb74c67ed61e86cc Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 4 May 2015 00:45:24 +0200
Subject: [PATCH gnumach 02/10] use pcb stack
---
i386/i386/locore.S | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/i386/i386/locore.S b/i386/i386/locore.S
index aa13c6b..f1ef044 100644
--- a/i386/i386/locore.S
+++ b/i386/i386/locore.S
@@ -592,7 +592,9 @@ ENTRY(thread_syscall_return)
or $(KERNEL_STACK_SIZE-1),%ecx
movl -3-IKS_SIZE(%ecx),%esp /* switch back to PCB stack */
movl %eax,R_EAX(%esp) /* save return value */
- /* XXX make this work with sysenter */
+ /* YYY make this work with sysenter */
+ cmpl $0xffffffff, R_TRAPNO(%esp)
+ je return_from_sysenter
jmp _return_from_trap
ENTRY(call_continuation)
@@ -1254,6 +1256,22 @@ ENTRY(sysenter_entry)
mov %esp, %ebp /* to access the sysenter stack */
cld /* clear direction flag */
+ CPU_NUMBER(%edx)
+ movl CX(EXT(kernel_stack),%edx),%ebx
+ /* get current kernel stack */
+ movl %ebx, %ecx
+ or $(KERNEL_STACK_SIZE-1),%ecx
+ movl -3-IKS_SIZE(%ecx), %esp /* switch to PCB stack */
+
+ /* Create trap save area. */
+ subl $(6 * 4), %esp /* Unused. We save the
+ arguments in userspace. */
+ pushl $0x7fffffff /* trap number */
+ pushl $0x12345678 /* unused */
+ pushl SE_STACK_POINTER(%ebp) /* ecx */
+ pushl SE_RETURN_ADDRESS(%ebp) /* edx */
+ subl $(5 * 4), %esp /* Unused. We save the
+ arguments in userspace. */
pushl %ds /* save the segment registers */
pushl %es
pushl %fs
@@ -1265,11 +1283,8 @@ ENTRY(sysenter_entry)
mov %cx,%fs
mov %cx,%gs
- CPU_NUMBER(%edx)
- movl CX(EXT(kernel_stack),%edx),%ebx
- /* get current kernel stack */
- xchgl %ebx, %esp /* switch stacks */
- pushl %ebx /* save sysenter sp */
+ xchgl %ebx, %esp /* switch to kernel stack */
+ pushl %ebx /* save pcb stack pointer */
movl %esp,%ebx /* save kernel sp for argument
unwinding */
@@ -1328,16 +1343,15 @@ se_args_0:
/* call procedure */
cli /* xxx: sti/cli where ? */
movl %ebx, %esp /* clean parameters from stack */
+ popl %esp /* switch to pcb stack */
return_from_sysenter:
+ movl %eax, R_EAX(%esp) /* save return value */
/* xxx: process ast */
- popl %esp /* restore sysenter sp */
popl %gs /* restore segment registers */
popl %fs
popl %es
popl %ds
-
- movl SE_RETURN_ADDRESS(%ebp), %edx
- movl SE_STACK_POINTER(%ebp), %ecx
+ popa
sti /* xxx: sti/cli where ? */
sysexit
--
2.1.4
|