VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-ExtCtxRestore.asm

Last change on this file was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1; $Id: bs3-cmn-ExtCtxRestore.asm 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; BS3Kit - Bs3ExtCtxRestore.
4;
5
6;
7; Copyright (C) 2007-2024 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37%include "bs3kit-template-header.mac"
38
39extern BS3_CMN_NM(Bs3RegSetXcr0)
40
41
42;;
43; Restores the extended CPU context (FPU, SSE, AVX, ++).
44;
45; @param pExtCtx
46;
47BS3_PROC_BEGIN_CMN Bs3ExtCtxRestore, BS3_PBC_NEAR
48 push xBP
49 mov xBP, xSP
50 push sAX
51 push sCX
52 push sDX
53 push xBX
54BONLY16 push es
55
56%if ARCH_BITS == 16
57 les bx, [xBP + xCB + cbCurRetAddr]
58 mov al, [es:bx + BS3EXTCTX.enmMethod]
59 cmp al, BS3EXTCTXMETHOD_XSAVE
60 je .do_16_xsave
61 cmp al, BS3EXTCTXMETHOD_FXSAVE
62 je .do_16_fxsave
63 cmp al, BS3EXTCTXMETHOD_ANCIENT
64 je .do_16_ancient
65 int3
66
67.do_16_ancient:
68 frstor [es:bx + BS3EXTCTX.Ctx]
69 jmp .return
70
71.do_16_fxsave:
72 fxrstor [es:bx + BS3EXTCTX.Ctx]
73 jmp .return
74
75.do_16_xsave:
76 push dword [es:bx + BS3EXTCTX.fXcr0Nominal + 4]
77 push dword [es:bx + BS3EXTCTX.fXcr0Nominal]
78 call BS3_CMN_NM(Bs3RegSetXcr0)
79
80 mov eax, [es:bx + BS3EXTCTX.fXcr0Nominal]
81 mov edx, [es:bx + BS3EXTCTX.fXcr0Nominal + 4]
82 xrstor [es:bx + BS3EXTCTX.Ctx]
83
84 push dword [es:bx + BS3EXTCTX.fXcr0Saved + 4]
85 push dword [es:bx + BS3EXTCTX.fXcr0Saved]
86 call BS3_CMN_NM(Bs3RegSetXcr0)
87
88 add xSP, 4 * 2 * 2 ; clean up both calls
89 ;jmp .return
90
91%else
92BONLY32 mov ebx, [xBP + xCB + cbCurRetAddr]
93BONLY64 mov rbx, rcx
94
95 mov al, [xBX + BS3EXTCTX.enmMethod]
96 cmp al, BS3EXTCTXMETHOD_XSAVE
97 je .do_xsave
98 cmp al, BS3EXTCTXMETHOD_FXSAVE
99 je .do_fxsave
100 cmp al, BS3EXTCTXMETHOD_ANCIENT
101 je .do_ancient
102 int3
103
104.do_ancient:
105 frstor [xBX + BS3EXTCTX.Ctx]
106 jmp .return
107
108.do_fxsave:
109BONLY32 fxrstor [xBX + BS3EXTCTX.Ctx]
110BONLY64 fxrstor64 [xBX + BS3EXTCTX.Ctx]
111 jmp .return
112
113.do_xsave:
114 %if ARCH_BITS == 32
115 push dword [xBX + BS3EXTCTX.fXcr0Nominal + 4]
116 push dword [xBX + BS3EXTCTX.fXcr0Nominal]
117 call BS3_CMN_NM(Bs3RegSetXcr0)
118
119 mov eax, [xBX + BS3EXTCTX.fXcr0Nominal]
120 mov edx, [xBX + BS3EXTCTX.fXcr0Nominal + 4]
121 xrstor [xBX + BS3EXTCTX.Ctx]
122
123 push dword [xBX + BS3EXTCTX.fXcr0Saved + 4]
124 push dword [xBX + BS3EXTCTX.fXcr0Saved]
125 call BS3_CMN_NM(Bs3RegSetXcr0)
126
127 add xSP, 4 * 2 * 2 ; clean up both calls
128 %else
129 mov rcx, [xBX + BS3EXTCTX.fXcr0Nominal]
130 push rcx ; just for reserving parameter dumping space needed by Bs3RegSetXcr0
131 call BS3_CMN_NM(Bs3RegSetXcr0)
132
133 mov eax, [xBX + BS3EXTCTX.fXcr0Nominal]
134 mov edx, [xBX + BS3EXTCTX.fXcr0Nominal + 4]
135 xrstor64 [xBX + BS3EXTCTX.Ctx]
136
137 mov rcx, [xBX + BS3EXTCTX.fXcr0Saved]
138 call BS3_CMN_NM(Bs3RegSetXcr0)
139
140 add xSP, 8 ; clean up parameter space
141 ;jmp .return
142 %endif
143%endif
144
145.return:
146BONLY16 pop es
147 pop xBX
148 pop sDX
149 pop sCX
150 pop sAX
151 mov xSP, xBP
152 pop xBP
153 ret
154BS3_PROC_END_CMN Bs3ExtCtxRestore
155
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette