ia64/xen-unstable

view xen/arch/x86/x86_32/supervisor_mode_kernel.S @ 19835:edfdeb150f27

Fix buildsystem to detect udev > version 124

udev removed the udevinfo symlink from versions higher than 123 and
xen's build-system could not detect if udev is in place and has the
required version.

Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:02:37 2009 +0100 (2009-06-25)
parents 4e22d660ece3
children
line source
1 /*
2 * Handle stack fixup for guest running in RING 0.
3 *
4 * Copyright (c) 2006 Ian Campbell
5 *
6 * When a guest kernel is allowed to run in RING 0 a hypercall,
7 * interrupt or exception interrupting the guest kernel will not cause
8 * a privilege level change and therefore the stack will not be swapped
9 * to the Xen stack.
10 *
11 * To fix this we look for RING 0 activation frames with a stack
12 * pointer below HYPERVISOR_VIRT_START (indicating a guest kernel
13 * frame) and fix this up by locating the Xen stack via the TSS
14 * and moving the activation frame to the Xen stack. In the process we
15 * convert the frame into an inter-privilege frame returning to RING 1
16 * so that we can catch and reverse the process on exit.
17 */
19 #include <xen/config.h>
20 #include <asm/asm_defns.h>
21 #include <public/xen.h>
23 #define guestreg(field) ((field)-UREGS_eip+36)
25 # Upon entry the stack should be the Xen stack and contain:
26 # %ss, %esp, EFLAGS, %cs|1, %eip, RETURN
27 # On exit the stack should be %ss:%esp (i.e. the guest stack)
28 # and contain:
29 # EFLAGS, %cs, %eip, RETURN
30 ALIGN
31 ENTRY(restore_ring0_guest)
32 pusha
34 # Point %gs:%esi to guest stack.
35 RRG0: movw guestreg(UREGS_ss)(%esp),%gs
36 movl guestreg(UREGS_esp)(%esp),%esi
38 # Copy EFLAGS, %cs, %eip, RETURN, PUSHA from Xen stack to guest stack.
39 movl $12,%ecx /* 12 32-bit values */
41 1: subl $4,%esi
42 movl -4(%esp,%ecx,4),%eax
43 RRG1: movl %eax,%gs:(%esi)
44 loop 1b
46 RRG2: andl $~3,%gs:guestreg(UREGS_cs)(%esi)
48 movl %gs,%eax
50 # We need to do this because these registers are not present
51 # on the guest stack so they cannot be restored by the code in
52 # restore_all_guest.
53 RRG3: mov guestreg(UREGS_ds)(%esp),%ds
54 RRG4: mov guestreg(UREGS_es)(%esp),%es
55 RRG5: mov guestreg(UREGS_fs)(%esp),%fs
56 RRG6: mov guestreg(UREGS_gs)(%esp),%gs
58 RRG7: movl %eax,%ss
59 movl %esi,%esp
61 popa
62 ret
63 .section __ex_table,"a"
64 .long RRG0,domain_crash_synchronous
65 .long RRG1,domain_crash_synchronous
66 .long RRG2,domain_crash_synchronous
67 .long RRG3,domain_crash_synchronous
68 .long RRG4,domain_crash_synchronous
69 .long RRG5,domain_crash_synchronous
70 .long RRG6,domain_crash_synchronous
71 .long RRG7,domain_crash_synchronous
72 .previous
74 # Upon entry the stack should be a guest stack and contain:
75 # EFLAGS, %cs, %eip, ERROR, RETURN
76 # On exit the stack should be the Xen stack and contain:
77 # %ss, %esp, EFLAGS, %cs|1, %eip, ERROR, RETURN
78 ALIGN
79 ENTRY(fixup_ring0_guest_stack)
80 pushl %eax
81 pushl %ecx
82 pushl %ds
83 pushl %gs
84 pushl %esi
86 movw $__HYPERVISOR_DS,%ax
87 movw %ax,%ds
89 # Point %gs:%esi to guest stack frame.
90 movw %ss,%ax
91 movw %ax,%gs
92 movl %esp,%esi
93 # Account for entries on the guest stack:
94 # * Pushed by normal exception/interrupt/hypercall mechanisms
95 # * EFLAGS, %cs, %eip, ERROR == 4 words.
96 # * Pushed by the fixup routine
97 # * [RETURN], %eax, %ecx, %ds, %gs and %esi == 6 words.
98 addl $((6+4)*4),%esi
100 # %gs:%esi now points to the guest stack before the
101 # interrupt/exception occurred.
103 movl $PER_CPU_GDT_ENTRY*8,%ecx
104 lsll %ecx,%ecx
105 shll $7,%ecx # Each TSS entry is 0x80 bytes
106 addl $init_tss,%ecx
108 # Load Xen stack from TSS.
109 movw TSS_ss0(%ecx),%ax
110 TRP1: movw %ax,%ss
111 movl TSS_esp0(%ecx),%esp
113 pushl %gs
114 pushl %esi
116 # Move EFLAGS, %cs, %eip, ERROR, RETURN, %eax, %ecx, %ds, %gs, %esi
117 # from guest stack to Xen stack.
118 movl $10,%ecx
119 1: subl $4,%esp
120 subl $4,%esi
121 TRP2: movl %gs:(%esi),%eax
122 movl %eax,(%esp)
123 loop 1b
125 # CS = CS|1 to simulate RING1 stack frame.
126 orl $1,32(%esp)
128 popl %esi
129 popl %gs
130 popl %ds
131 popl %ecx
132 popl %eax
133 ret
134 .section __ex_table,"a"
135 .long TRP1,domain_crash_synchronous
136 .long TRP2,domain_crash_synchronous
137 .previous
139 domain_crash_synchronous_string:
140 .asciz "domain_crash_sync called from supervisor_mode_kernel.S (%lx)\n"
142 domain_crash_synchronous:
143 pushl $domain_crash_synchronous_string
144 call printk
145 jmp __domain_crash_synchronous