1 | /* |
---|
2 | * exits.S: VMX architecture-specific exit handling. |
---|
3 | * Copyright (c) 2004, Intel Corporation. |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or modify it |
---|
6 | * under the terms and conditions of the GNU General Public License, |
---|
7 | * version 2, as published by the Free Software Foundation. |
---|
8 | * |
---|
9 | * This program is distributed in the hope it will be useful, but WITHOUT |
---|
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
12 | * more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License along with |
---|
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
16 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
---|
17 | */ |
---|
18 | #include <xen/config.h> |
---|
19 | #include <xen/errno.h> |
---|
20 | #include <xen/softirq.h> |
---|
21 | #include <asm/asm_defns.h> |
---|
22 | #include <asm/apicdef.h> |
---|
23 | #include <asm/page.h> |
---|
24 | #include <public/xen.h> |
---|
25 | |
---|
26 | #define GET_CURRENT(reg) \ |
---|
27 | movl $STACK_SIZE-4, reg; \ |
---|
28 | orl %esp, reg; \ |
---|
29 | andl $~3,reg; \ |
---|
30 | movl (reg),reg; |
---|
31 | |
---|
32 | #define HVM_SAVE_ALL_NOSEGREGS \ |
---|
33 | movl $0, 0xc(%esp); /* XXX why do we need to force eflags==0 ?? */ \ |
---|
34 | pushl %eax; \ |
---|
35 | pushl %ebp; \ |
---|
36 | pushl %edi; \ |
---|
37 | pushl %esi; \ |
---|
38 | pushl %edx; \ |
---|
39 | pushl %ecx; \ |
---|
40 | pushl %ebx; |
---|
41 | |
---|
42 | #define HVM_RESTORE_ALL_NOSEGREGS \ |
---|
43 | popl %ebx; \ |
---|
44 | popl %ecx; \ |
---|
45 | popl %edx; \ |
---|
46 | popl %esi; \ |
---|
47 | popl %edi; \ |
---|
48 | popl %ebp; \ |
---|
49 | popl %eax |
---|
50 | |
---|
51 | ALIGN |
---|
52 | ENTRY(vmx_asm_vmexit_handler) |
---|
53 | HVM_SAVE_ALL_NOSEGREGS |
---|
54 | movl %esp,%eax |
---|
55 | push %eax |
---|
56 | call vmx_vmexit_handler |
---|
57 | addl $4,%esp |
---|
58 | jmp vmx_asm_do_vmentry |
---|
59 | |
---|
60 | ALIGN |
---|
61 | vmx_process_softirqs: |
---|
62 | sti |
---|
63 | call do_softirq |
---|
64 | jmp vmx_asm_do_vmentry |
---|
65 | |
---|
66 | ALIGN |
---|
67 | ENTRY(vmx_asm_do_vmentry) |
---|
68 | GET_CURRENT(%ebx) |
---|
69 | cli # tests must not race interrupts |
---|
70 | |
---|
71 | movl VCPU_processor(%ebx),%eax |
---|
72 | shl $IRQSTAT_shift,%eax |
---|
73 | cmpl $0,irq_stat(%eax,1) |
---|
74 | jnz vmx_process_softirqs |
---|
75 | |
---|
76 | call vmx_intr_assist |
---|
77 | movl VCPU_vmx_cr2(%ebx),%eax |
---|
78 | movl %eax,%cr2 |
---|
79 | call vmx_trace_vmentry |
---|
80 | |
---|
81 | cmpl $0,VCPU_vmx_launched(%ebx) |
---|
82 | je vmx_launch |
---|
83 | |
---|
84 | /*vmx_resume:*/ |
---|
85 | HVM_RESTORE_ALL_NOSEGREGS |
---|
86 | /* VMRESUME */ |
---|
87 | .byte 0x0f,0x01,0xc3 |
---|
88 | pushf |
---|
89 | call vm_resume_fail |
---|
90 | ud2 |
---|
91 | |
---|
92 | vmx_launch: |
---|
93 | movl $1,VCPU_vmx_launched(%ebx) |
---|
94 | HVM_RESTORE_ALL_NOSEGREGS |
---|
95 | /* VMLAUNCH */ |
---|
96 | .byte 0x0f,0x01,0xc2 |
---|
97 | pushf |
---|
98 | call vm_launch_fail |
---|
99 | ud2 |
---|