ia64/xen-unstable

view xen/arch/x86/hvm/vmx/x86_64/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,0x47,((off)-UREGS_rip)
29 #define VMWRITE(off) .byte 0x0f,0x79,0x47,((off)-UREGS_rip)
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 movq $STACK_SIZE-8, reg; \
38 orq %rsp, reg; \
39 andq $~7,reg; \
40 movq (reg),reg;
42 #define HVM_SAVE_ALL_NOSEGREGS \
43 pushq %rdi; \
44 pushq %rsi; \
45 pushq %rdx; \
46 pushq %rcx; \
47 pushq %rax; \
48 pushq %r8; \
49 pushq %r9; \
50 pushq %r10; \
51 pushq %r11; \
52 pushq %rbx; \
53 pushq %rbp; \
54 pushq %r12; \
55 pushq %r13; \
56 pushq %r14; \
57 pushq %r15;
59 #define HVM_RESTORE_ALL_NOSEGREGS \
60 popq %r15; \
61 popq %r14; \
62 popq %r13; \
63 popq %r12; \
64 popq %rbp; \
65 popq %rbx; \
66 popq %r11; \
67 popq %r10; \
68 popq %r9; \
69 popq %r8; \
70 popq %rax; \
71 popq %rcx; \
72 popq %rdx; \
73 popq %rsi; \
74 popq %rdi
76 ALIGN
77 ENTRY(vmx_asm_vmexit_handler)
78 HVM_SAVE_ALL_NOSEGREGS
80 leaq UREGS_rip(%rsp),%rdi
81 movl $GUEST_RIP,%eax
82 /*VMREAD(UREGS_rip)*/
83 .byte 0x0f,0x78,0x07 /* vmread %rax,(%rdi) */
84 movl $GUEST_RSP,%eax
85 VMREAD(UREGS_rsp)
86 movl $GUEST_RFLAGS,%eax
87 VMREAD(UREGS_eflags)
89 #ifndef NDEBUG
90 movw $0xbeef,%ax
91 movw %ax,UREGS_error_code(%rsp)
92 movw %ax,UREGS_entry_vector(%rsp)
93 movw %ax,UREGS_saved_upcall_mask(%rsp)
94 movw %ax,UREGS_cs(%rsp)
95 movw %ax,UREGS_ds(%rsp)
96 movw %ax,UREGS_es(%rsp)
97 movw %ax,UREGS_fs(%rsp)
98 movw %ax,UREGS_gs(%rsp)
99 movw %ax,UREGS_ss(%rsp)
100 #endif
102 movq %rsp,%rdi
103 call vmx_vmexit_handler
104 jmp vmx_asm_do_vmentry
106 ALIGN
107 vmx_process_softirqs:
108 sti
109 call do_softirq
110 jmp vmx_asm_do_vmentry
112 ALIGN
113 ENTRY(vmx_asm_do_vmentry)
114 GET_CURRENT(%rbx)
115 cli # tests must not race interrupts
117 movl VCPU_processor(%rbx),%eax
118 shl $IRQSTAT_shift,%rax
119 leaq irq_stat(%rip),%rdx
120 cmpl $0,(%rdx,%rax,1)
121 jnz vmx_process_softirqs
123 call vmx_intr_assist
124 movq VCPU_hvm_guest_cr2(%rbx),%rax
125 movq %rax,%cr2
126 call vmx_trace_vmentry
128 leaq UREGS_rip(%rsp),%rdi
129 movl $GUEST_RIP,%eax
130 /*VMWRITE(UREGS_rip)*/
131 .byte 0x0f,0x79,0x07 /* vmwrite (%rdi),%rax */
132 movl $GUEST_RSP,%eax
133 VMWRITE(UREGS_rsp)
134 movl $GUEST_RFLAGS,%eax
135 VMWRITE(UREGS_eflags)
137 #ifndef VMXASSIST
138 testb $0xff,VCPU_vmx_emul(%rbx)
139 jnz vmx_goto_realmode
140 #endif
142 cmpb $0,VCPU_vmx_launched(%rbx)
143 je vmx_launch
145 /*vmx_resume:*/
146 HVM_RESTORE_ALL_NOSEGREGS
147 VMRESUME
148 pushfq
149 call vm_resume_fail
150 ud2
152 vmx_launch:
153 movb $1,VCPU_vmx_launched(%rbx)
154 HVM_RESTORE_ALL_NOSEGREGS
155 VMLAUNCH
156 pushfq
157 call vm_launch_fail
158 ud2
160 #ifndef VMXASSIST
161 vmx_goto_realmode:
162 sti
163 movq %rsp,%rdi
164 call vmx_realmode
165 jmp vmx_asm_do_vmentry
166 #endif