CPUMR0A.asm revision e64031e20c39650a7bc902a3e1aba613b9415dee
52676b598e9afd834db7f3e62a983044038e92bevboxsync; CPUM - Guest Context Assembly Routines.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync; Copyright (C) 2006-2007 Oracle Corporation
52676b598e9afd834db7f3e62a983044038e92bevboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
52676b598e9afd834db7f3e62a983044038e92bevboxsync; available from http://www.virtualbox.org. This file is free software;
52676b598e9afd834db7f3e62a983044038e92bevboxsync; you can redistribute it and/or modify it under the terms of the GNU
52676b598e9afd834db7f3e62a983044038e92bevboxsync; General Public License (GPL) as published by the Free Software
52676b598e9afd834db7f3e62a983044038e92bevboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
52676b598e9afd834db7f3e62a983044038e92bevboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
52676b598e9afd834db7f3e62a983044038e92bevboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
52676b598e9afd834db7f3e62a983044038e92bevboxsync;*******************************************************************************
52676b598e9afd834db7f3e62a983044038e92bevboxsync;* Header Files *
52676b598e9afd834db7f3e62a983044038e92bevboxsync;*******************************************************************************
52676b598e9afd834db7f3e62a983044038e92bevboxsync%ifdef IN_RING3
52676b598e9afd834db7f3e62a983044038e92bevboxsync %error "The jump table doesn't link on leopard."
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync;*******************************************************************************
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync;* Defined Constants And Macros *
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync;*******************************************************************************
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync;; The offset of the XMM registers in X86FXSTATE.
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync; Use define because I'm too lazy to convert the struct.
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync%define XMM_OFF_IN_X86FXSTATE 160
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync;*******************************************************************************
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync;* External Symbols *
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync;*******************************************************************************
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncextern NAME(SUPR0AbsIs64bit)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncextern NAME(SUPR0Abs64bitKernelCS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncextern NAME(SUPR0Abs64bitKernelSS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncextern NAME(SUPR0Abs64bitKernelDS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncextern NAME(SUPR0AbsKernelCS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync;*******************************************************************************
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync;* Global Variables *
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync;*******************************************************************************
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync; Store the SUPR0AbsIs64bit absolute value here so we can cmp/test without
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync; needing to clobber a register. (This trick doesn't quite work for PE btw.
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync; but that's not relevant atm.)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncGLOBALNAME g_fCPUMIs64bitHost
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync dd NAME(SUPR0AbsIs64bit)
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync; Saves the host FPU/XMM state and restores the guest state.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync; @returns 0
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync; @param pCPUMCPU x86:[esp+4] GCC:rdi MSC:rcx CPUMCPU pointer
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsyncBEGINPROC cpumR0SaveHostRestoreGuestFPUState
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync%ifdef RT_ARCH_AMD64
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync %ifdef RT_OS_WINDOWS
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov xDX, rcx
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov xDX, rdi
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov xDX, dword [esp + 4]
fe479db82741c317766a2b9035cbd92f3f5a745cvboxsync pushf ; The darwin kernel can get upset or upset things if an
fe479db82741c317766a2b9035cbd92f3f5a745cvboxsync cli ; interrupt occurs while we're doing fxsave/fxrstor/cr0.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync ; Switch the state.
dcd6dbbce6129153995caa1e77b258639f6bc030vboxsync or dword [xDX + CPUMCPU.fUseFlags], (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov xAX, cr0 ; Make sure its safe to access the FPU state.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov xCX, xAX ; save old CR0
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync and xAX, ~(X86_CR0_TS | X86_CR0_EM)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov cr0, xAX ;; @todo optimize this.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync cmp byte [NAME(g_fCPUMIs64bitHost)], 0
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync jz .legacy_mode
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync db 0xea ; jmp far .sixtyfourbit_mode
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync dd .sixtyfourbit_mode, NAME(SUPR0Abs64bitKernelCS)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync.legacy_mode:
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync fxsave [xDX + CPUMCPU.Host.fpu] ; ASSUMES that all VT-x/AMD-V boxes sports fxsave/fxrstor (safe assumption)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync fxrstor [xDX + CPUMCPU.Guest.fpu]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync%ifdef VBOX_WITH_KERNEL_USING_XMM
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync ; Restore the non-volatile xmm registers. ASSUMING 64-bit windows
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync lea r11, [xDX + CPUMCPU.Host.fpu + XMM_OFF_IN_X86FXSTATE]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm6, [r11 + 060h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm7, [r11 + 070h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm8, [r11 + 080h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm9, [r11 + 090h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm10, [r11 + 0a0h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm11, [r11 + 0b0h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm12, [r11 + 0c0h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm13, [r11 + 0d0h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm14, [r11 + 0e0h]
bb33bc2ad72088bbb39737f7145a6cfbe1f65780vboxsync movdqa xmm15, [r11 + 0f0h]
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov cr0, xCX ; and restore old CR0 again ;; @todo optimize this.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync xor eax, eax
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsyncALIGNCODE(16)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync.sixtyfourbit_mode:
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync and edx, 0ffffffffh
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync fxsave [rdx + CPUMCPU.Host.fpu]
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync fxrstor [rdx + CPUMCPU.Guest.fpu]
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync jmp far [.fpret wrt rip]
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync.fpret: ; 16:32 Pointer to .the_end.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync dd .done, NAME(SUPR0AbsKernelCS)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsyncENDPROC cpumR0SaveHostRestoreGuestFPUState
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync%ifndef RT_ARCH_AMD64
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync%ifdef VBOX_WITH_64_BITS_GUESTS
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync%ifndef VBOX_WITH_HYBRID_32BIT_KERNEL
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync; Saves the host FPU/XMM state
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync; @returns 0
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync; @param pCPUMCPU x86:[esp+4] GCC:rdi MSC:rcx CPUMCPU pointer
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsyncBEGINPROC cpumR0SaveHostFPUState
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync mov xDX, dword [esp + 4]
c5a332cfb15a444b40d1564a0c1e73899c1a3b2bvboxsync pushf ; The darwin kernel can get upset or upset things if an
c5a332cfb15a444b40d1564a0c1e73899c1a3b2bvboxsync cli ; interrupt occurs while we're doing fxsave/fxrstor/cr0.
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync ; Switch the state.
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync or dword [xDX + CPUMCPU.fUseFlags], (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM)
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync mov xAX, cr0 ; Make sure its safe to access the FPU state.
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync mov xCX, xAX ; save old CR0
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync and xAX, ~(X86_CR0_TS | X86_CR0_EM)
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync mov cr0, xAX ;; @todo optimize this.
e9e3e0dde7d0aa3a9f0aa54638a613dbf1736408vboxsync fxsave [xDX + CPUMCPU.Host.fpu] ; ASSUMES that all VT-x/AMD-V boxes support fxsave/fxrstor (safe assumption)
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync mov cr0, xCX ; and restore old CR0 again ;; @todo optimize this.
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync xor eax, eax
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsyncENDPROC cpumR0SaveHostFPUState
3bf5a39c9314b43d8fe91e4ed18b977e2f87659dvboxsync; Saves the guest FPU/XMM state and restores the host state.
52676b598e9afd834db7f3e62a983044038e92bevboxsync; @returns 0
52676b598e9afd834db7f3e62a983044038e92bevboxsync; @param pCPUMCPU x86:[esp+4] GCC:rdi MSC:rcx CPUMCPU pointer
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncBEGINPROC cpumR0SaveGuestRestoreHostFPUState
52676b598e9afd834db7f3e62a983044038e92bevboxsync%ifdef RT_ARCH_AMD64
52676b598e9afd834db7f3e62a983044038e92bevboxsync %ifdef RT_OS_WINDOWS
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xDX, rcx
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xDX, rdi
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xDX, dword [esp + 4]
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync ; Only restore FPU if guest has used it.
52676b598e9afd834db7f3e62a983044038e92bevboxsync ; Using fxrstor should ensure that we're not causing unwanted exception on the host.
52676b598e9afd834db7f3e62a983044038e92bevboxsync test dword [xDX + CPUMCPU.fUseFlags], CPUM_USED_FPU
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync jz short .fpu_not_used
fe479db82741c317766a2b9035cbd92f3f5a745cvboxsync pushf ; The darwin kernel can get upset or upset things if an
fe479db82741c317766a2b9035cbd92f3f5a745cvboxsync cli ; interrupt occurs while we're doing fxsave/fxrstor/cr0.
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov xAX, cr0 ; Make sure it's safe to access the FPU state.
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xCX, xAX ; save old CR0
52676b598e9afd834db7f3e62a983044038e92bevboxsync and xAX, ~(X86_CR0_TS | X86_CR0_EM)
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov cr0, xAX ;; @todo optimize this.
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync cmp byte [NAME(g_fCPUMIs64bitHost)], 0
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync jz .legacy_mode
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync db 0xea ; jmp far .sixtyfourbit_mode
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync dd .sixtyfourbit_mode, NAME(SUPR0Abs64bitKernelCS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.legacy_mode:
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL
e9e3e0dde7d0aa3a9f0aa54638a613dbf1736408vboxsync fxsave [xDX + CPUMCPU.Guest.fpu] ; ASSUMES that all VT-x/AMD-V boxes support fxsave/fxrstor (safe assumption)
52676b598e9afd834db7f3e62a983044038e92bevboxsync fxrstor [xDX + CPUMCPU.Host.fpu]
90f2027a781d66b7498ed1e5684e087e4d9d3b1bvboxsync mov cr0, xCX ; and restore old CR0 again ;; @todo optimize this.
52676b598e9afd834db7f3e62a983044038e92bevboxsync and dword [xDX + CPUMCPU.fUseFlags], ~CPUM_USED_FPU
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.fpu_not_used:
52676b598e9afd834db7f3e62a983044038e92bevboxsync xor eax, eax
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncALIGNCODE(16)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.sixtyfourbit_mode:
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync and edx, 0ffffffffh
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync fxrstor [rdx + CPUMCPU.Host.fpu]
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync jmp far [.fpret wrt rip]
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.fpret: ; 16:32 Pointer to .the_end.
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync dd .done, NAME(SUPR0AbsKernelCS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncENDPROC cpumR0SaveGuestRestoreHostFPUState
52676b598e9afd834db7f3e62a983044038e92bevboxsync; Sets the host's FPU/XMM state
52676b598e9afd834db7f3e62a983044038e92bevboxsync; @returns 0
52676b598e9afd834db7f3e62a983044038e92bevboxsync; @param pCPUMCPU x86:[esp+4] GCC:rdi MSC:rcx CPUMCPU pointer
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncBEGINPROC cpumR0RestoreHostFPUState
52676b598e9afd834db7f3e62a983044038e92bevboxsync%ifdef RT_ARCH_AMD64
52676b598e9afd834db7f3e62a983044038e92bevboxsync %ifdef RT_OS_WINDOWS
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xDX, rcx
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xDX, rdi
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xDX, dword [esp + 4]
52676b598e9afd834db7f3e62a983044038e92bevboxsync ; Restore FPU if guest has used it.
52676b598e9afd834db7f3e62a983044038e92bevboxsync ; Using fxrstor should ensure that we're not causing unwanted exception on the host.
52676b598e9afd834db7f3e62a983044038e92bevboxsync test dword [xDX + CPUMCPU.fUseFlags], CPUM_USED_FPU
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync jz short .fpu_not_used
fe479db82741c317766a2b9035cbd92f3f5a745cvboxsync pushf ; The darwin kernel can get upset or upset things if an
fe479db82741c317766a2b9035cbd92f3f5a745cvboxsync cli ; interrupt occurs while we're doing fxsave/fxrstor/cr0.
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xAX, cr0
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov xCX, xAX ; save old CR0
52676b598e9afd834db7f3e62a983044038e92bevboxsync and xAX, ~(X86_CR0_TS | X86_CR0_EM)
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov cr0, xAX
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync cmp byte [NAME(g_fCPUMIs64bitHost)], 0
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync jz .legacy_mode
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync db 0xea ; jmp far .sixtyfourbit_mode
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync dd .sixtyfourbit_mode, NAME(SUPR0Abs64bitKernelCS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.legacy_mode:
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL
52676b598e9afd834db7f3e62a983044038e92bevboxsync fxrstor [xDX + CPUMCPU.Host.fpu]
52676b598e9afd834db7f3e62a983044038e92bevboxsync mov cr0, xCX ; and restore old CR0 again
52676b598e9afd834db7f3e62a983044038e92bevboxsync and dword [xDX + CPUMCPU.fUseFlags], ~CPUM_USED_FPU
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.fpu_not_used:
52676b598e9afd834db7f3e62a983044038e92bevboxsync xor eax, eax
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncALIGNCODE(16)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.sixtyfourbit_mode:
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync and edx, 0ffffffffh
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync fxrstor [rdx + CPUMCPU.Host.fpu]
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync jmp far [.fpret wrt rip]
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync.fpret: ; 16:32 Pointer to .the_end.
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsync dd .done, NAME(SUPR0AbsKernelCS)
a41a001e5a4dd3f39faab90b412243ced6d59394vboxsyncENDPROC cpumR0RestoreHostFPUState
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
409950536f73e7c9a387f7d548122ae6bffae950vboxsync; DECLASM(void) cpumR0SaveDRx(uint64_t *pa4Regs);
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncALIGNCODE(16)
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncBEGINPROC cpumR0SaveDRx
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef RT_ARCH_AMD64
409950536f73e7c9a387f7d548122ae6bffae950vboxsync %ifdef ASM_CALL64_GCC
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xCX, rdi
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xCX, dword [esp + 4]
c5a332cfb15a444b40d1564a0c1e73899c1a3b2bvboxsync pushf ; Just to be on the safe side.
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
409950536f73e7c9a387f7d548122ae6bffae950vboxsync cmp byte [NAME(g_fCPUMIs64bitHost)], 0
409950536f73e7c9a387f7d548122ae6bffae950vboxsync jz .legacy_mode
409950536f73e7c9a387f7d548122ae6bffae950vboxsync db 0xea ; jmp far .sixtyfourbit_mode
409950536f73e7c9a387f7d548122ae6bffae950vboxsync dd .sixtyfourbit_mode, NAME(SUPR0Abs64bitKernelCS)
409950536f73e7c9a387f7d548122ae6bffae950vboxsync.legacy_mode:
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL
409950536f73e7c9a387f7d548122ae6bffae950vboxsync ; Do the job.
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xAX, dr0
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xDX, dr1
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [xCX], xAX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [xCX + 8 * 1], xDX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xAX, dr2
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xDX, dr3
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [xCX + 8 * 2], xAX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [xCX + 8 * 3], xDX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncALIGNCODE(16)
409950536f73e7c9a387f7d548122ae6bffae950vboxsync.sixtyfourbit_mode:
409950536f73e7c9a387f7d548122ae6bffae950vboxsync and ecx, 0ffffffffh
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov rax, dr0
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov rdx, dr1
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov r8, dr2
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov r9, dr3
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [rcx], rax
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [rcx + 8 * 1], rdx
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [rcx + 8 * 2], r8
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov [rcx + 8 * 3], r9
409950536f73e7c9a387f7d548122ae6bffae950vboxsync jmp far [.fpret wrt rip]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync.fpret: ; 16:32 Pointer to .the_end.
409950536f73e7c9a387f7d548122ae6bffae950vboxsync dd .done, NAME(SUPR0AbsKernelCS)
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncENDPROC cpumR0SaveDRx
409950536f73e7c9a387f7d548122ae6bffae950vboxsync; DECLASM(void) cpumR0LoadDRx(uint64_t const *pa4Regs);
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncALIGNCODE(16)
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncBEGINPROC cpumR0LoadDRx
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef RT_ARCH_AMD64
409950536f73e7c9a387f7d548122ae6bffae950vboxsync %ifdef ASM_CALL64_GCC
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xCX, rdi
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xCX, dword [esp + 4]
c5a332cfb15a444b40d1564a0c1e73899c1a3b2bvboxsync pushf ; Just to be on the safe side.
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
409950536f73e7c9a387f7d548122ae6bffae950vboxsync cmp byte [NAME(g_fCPUMIs64bitHost)], 0
409950536f73e7c9a387f7d548122ae6bffae950vboxsync jz .legacy_mode
409950536f73e7c9a387f7d548122ae6bffae950vboxsync db 0xea ; jmp far .sixtyfourbit_mode
409950536f73e7c9a387f7d548122ae6bffae950vboxsync dd .sixtyfourbit_mode, NAME(SUPR0Abs64bitKernelCS)
409950536f73e7c9a387f7d548122ae6bffae950vboxsync.legacy_mode:
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL
409950536f73e7c9a387f7d548122ae6bffae950vboxsync ; Do the job.
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xAX, [xCX]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xDX, [xCX + 8 * 1]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr0, xAX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr1, xDX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xAX, [xCX + 8 * 2]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov xDX, [xCX + 8 * 3]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr2, xAX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr3, xDX
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncALIGNCODE(16)
409950536f73e7c9a387f7d548122ae6bffae950vboxsync.sixtyfourbit_mode:
409950536f73e7c9a387f7d548122ae6bffae950vboxsync and ecx, 0ffffffffh
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov rax, [rcx]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov rdx, [rcx + 8 * 1]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov r8, [rcx + 8 * 2]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov r9, [rcx + 8 * 3]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr0, rax
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr1, rdx
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr2, r8
409950536f73e7c9a387f7d548122ae6bffae950vboxsync mov dr3, r9
409950536f73e7c9a387f7d548122ae6bffae950vboxsync jmp far [.fpret wrt rip]
409950536f73e7c9a387f7d548122ae6bffae950vboxsync.fpret: ; 16:32 Pointer to .the_end.
409950536f73e7c9a387f7d548122ae6bffae950vboxsync dd .done, NAME(SUPR0AbsKernelCS)
409950536f73e7c9a387f7d548122ae6bffae950vboxsyncENDPROC cpumR0LoadDRx
409950536f73e7c9a387f7d548122ae6bffae950vboxsync%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL_IN_R0