2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <platforms.h>
31 #include <i386/asm64.h>
32 #include <i386/proc_reg.h>
33 #include <i386/postcode.h>
34 #include <i386/vmx/vmx_asm.h>
40 /* align below right */
43 .word Times(8,GDTSZ)-1
44 /* XXX really want .quad here */
46 .long KERNEL_UBER_BASE_HI32 /* must be in uber-space */
50 /* align below right */
53 .word Times(16,IDTSZ)-1
54 /* XXX really want .quad here */
55 .long EXT(master_idt64)
56 .long KERNEL_UBER_BASE_HI32 /* must be in uber-space */
64 POSTCODE(ML_LOAD_DESC64_ENTRY)
66 lgdt EXT(gdtptr64) /* load GDT */
68 POSTCODE(ML_LOAD_DESC64_GDT)
70 lidt EXT(idtptr64) /* load IDT */
72 POSTCODE(ML_LOAD_DESC64_IDT)
74 movw $(KERNEL_LDT),%ax /* get LDT segment */
75 lldt %ax /* load LDT */
77 POSTCODE(ML_LOAD_DESC64_LDT)
79 movw $(KERNEL_TSS),%ax
80 ltr %ax /* set up KTSS */
82 POSTCODE(ML_LOAD_DESC64_EXIT)
90 /* (int32_t selector) */
104 Entry(set_64bit_debug_regs)
105 /* x86_debug_state64_t *ds */
112 mov DS64_DR0(%edx), %rax
114 mov DS64_DR1(%edx), %rax
116 mov DS64_DR2(%edx), %rax
118 mov DS64_DR3(%edx), %rax
149 /* %rax = %edx:%eax */
168 shr $32, %rdx // %edx:%eax = %cr3
182 /* FXSAVE and FXRSTOR operate in a mode dependent fashion, hence these variants.
183 * Must be called with interrupts disabled.
203 /* MOD 0x4, ECX, 0x1 */
211 /* MOD 0x5, ECX 0x1 */
219 * __vmxon -- Enter VMX Operation
220 * int __vmxon(addr64_t v);
226 mov $(VMX_FAIL_INVALID), %ecx
227 mov $(VMX_FAIL_VALID), %edx
228 mov $(VMX_SUCCEED), %eax
229 vmxon 8(%rbp) /* physical addr passed on stack */
230 cmovcl %ecx, %eax /* CF = 1, ZF = 0 */
231 cmovzl %edx, %eax /* CF = 0, ZF = 1 */
238 * __vmxoff -- Leave VMX Operation
239 * int __vmxoff(void);
245 mov $(VMX_FAIL_INVALID), %ecx
246 mov $(VMX_FAIL_VALID), %edx
247 mov $(VMX_SUCCEED), %eax
249 cmovcl %ecx, %eax /* CF = 1, ZF = 0 */
250 cmovzl %edx, %eax /* CF = 0, ZF = 1 */
256 #endif /* CONFIG_VMX */