ia64/xen-unstable

view xen/arch/x86/hvm/vmx/x86_32/exits.S @ 16989:92734271810a

vmx realmode: Emulate protected-mode transition while CS and SS have
bad selector values (bottom two bits non-zero).

Allows opensuse 10.3 install CD to boot. Unfortunately SUSE Linux 10.1
install CD still fails to work...

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Feb 05 15:45:10 2008 +0000 (2008-02-05)
parents 2324110ef2c6
children 9d0e86d8c1d1
line source
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>
26 #define VMRESUME .byte 0x0f,0x01,0xc3
27 #define VMLAUNCH .byte 0x0f,0x01,0xc2
28 #define VMREAD(off) .byte 0x0f,0x78,0x44,0x24,off
29 #define VMWRITE(off) .byte 0x0f,0x79,0x44,0x24,off
31 /* VMCS field encodings */
32 #define GUEST_RSP 0x681c
33 #define GUEST_RIP 0x681e
34 #define GUEST_RFLAGS 0x6820
36 #define GET_CURRENT(reg) \
37 movl $STACK_SIZE-4, reg; \
38 orl %esp, reg; \
39 andl $~3,reg; \
40 movl (reg),reg;
42 #define HVM_SAVE_ALL_NOSEGREGS \
43 pushl %eax; \
44 pushl %ebp; \
45 pushl %edi; \
46 pushl %esi; \
47 pushl %edx; \
48 pushl %ecx; \
49 pushl %ebx;
51 #define HVM_RESTORE_ALL_NOSEGREGS \
52 popl %ebx; \
53 popl %ecx; \
54 popl %edx; \
55 popl %esi; \
56 popl %edi; \
57 popl %ebp; \
58 popl %eax
60 ALIGN
61 ENTRY(vmx_asm_vmexit_handler)
62 HVM_SAVE_ALL_NOSEGREGS
64 movl $GUEST_RIP,%eax
65 VMREAD(UREGS_eip)
66 movl $GUEST_RSP,%eax
67 VMREAD(UREGS_esp)
68 movl $GUEST_RFLAGS,%eax
69 VMREAD(UREGS_eflags)
71 #ifndef NDEBUG
72 movw $0xbeef,%ax
73 movw %ax,UREGS_error_code(%esp)
74 movw %ax,UREGS_entry_vector(%esp)
75 movw %ax,UREGS_saved_upcall_mask(%esp)
76 movw %ax,UREGS_cs(%esp)
77 movw %ax,UREGS_ds(%esp)
78 movw %ax,UREGS_es(%esp)
79 movw %ax,UREGS_fs(%esp)
80 movw %ax,UREGS_gs(%esp)
81 movw %ax,UREGS_ss(%esp)
82 #endif
84 movl %esp,%eax
85 push %eax
86 call vmx_vmexit_handler
87 addl $4,%esp
88 jmp vmx_asm_do_vmentry
90 ALIGN
91 vmx_process_softirqs:
92 sti
93 call do_softirq
94 jmp vmx_asm_do_vmentry
96 ALIGN
97 ENTRY(vmx_asm_do_vmentry)
98 GET_CURRENT(%ebx)
99 cli # tests must not race interrupts
101 movl VCPU_processor(%ebx),%eax
102 shl $IRQSTAT_shift,%eax
103 cmpl $0,irq_stat(%eax,1)
104 jnz vmx_process_softirqs
106 call vmx_intr_assist
107 movl VCPU_hvm_guest_cr2(%ebx),%eax
108 movl %eax,%cr2
109 call vmx_trace_vmentry
111 movl $GUEST_RIP,%eax
112 VMWRITE(UREGS_eip)
113 movl $GUEST_RSP,%eax
114 VMWRITE(UREGS_esp)
115 movl $GUEST_RFLAGS,%eax
116 VMWRITE(UREGS_eflags)
118 #ifndef VMXASSIST
119 testb $0xff,VCPU_vmx_emul(%ebx)
120 jnz vmx_goto_realmode
121 #endif
123 cmpb $0,VCPU_vmx_launched(%ebx)
124 je vmx_launch
126 /*vmx_resume:*/
127 HVM_RESTORE_ALL_NOSEGREGS
128 VMRESUME
129 pushf
130 call vm_resume_fail
131 ud2
133 vmx_launch:
134 movb $1,VCPU_vmx_launched(%ebx)
135 HVM_RESTORE_ALL_NOSEGREGS
136 VMLAUNCH
137 pushf
138 call vm_launch_fail
139 ud2
141 #ifndef VMXASSIST
142 vmx_goto_realmode:
143 sti
144 movl %esp,%eax
145 push %eax
146 call vmx_realmode
147 addl $4,%esp
148 jmp vmx_asm_do_vmentry
149 #endif