VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm@ 60044

Last change on this file since 60044 was 59984, checked in by vboxsync, 9 years ago

bs3kit: Updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.6 KB
Line 
1; $Id: bs3-c32-Trap32Generic.asm 59984 2016-03-11 00:56:10Z vboxsync $
2;; @file
3; BS3Kit - Trap, 32-bit assembly handlers.
4;
5
6;
7; Copyright (C) 2007-2016 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27;*********************************************************************************************************************************
28;* Header Files *
29;*********************************************************************************************************************************
30%include "bs3kit-template-header.mac"
31
32%ifndef TMPL_32BIT
33 %error "32-bit only template"
34%endif
35
36
37;*********************************************************************************************************************************
38;* External Symbols *
39;*********************************************************************************************************************************
40BS3_EXTERN_DATA16 g_bBs3CurrentMode
41TMPL_BEGIN_TEXT
42BS3_EXTERN_CMN Bs3TrapDefaultHandler
43BS3_EXTERN_CMN Bs3RegCtxRestore
44TMPL_BEGIN_TEXT
45
46
47;*********************************************************************************************************************************
48;* Global Variables *
49;*********************************************************************************************************************************
50BS3_BEGIN_DATA16
51;; Easy to access flat address of Bs3Trap32GenericEntries.
52BS3_GLOBAL_DATA g_Bs3Trap32GenericEntriesFlatAddr, 4
53 dd Bs3Trap32GenericEntries wrt FLAT
54;; Easy to access flat address of Bs3Trap32DoubleFaultHandler.
55BS3_GLOBAL_DATA g_Bs3Trap32DoubleFaultHandlerFlatAddr, 4
56 dd Bs3Trap32DoubleFaultHandler wrt FLAT
57
58BS3_BEGIN_DATA32
59;; Pointer C trap handlers.
60BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c32, 1024
61 resd 256
62
63
64
65;;
66; Generic entry points for IDT handlers, 8 byte spacing.
67;
68BS3_PROC_BEGIN Bs3Trap32GenericEntries
69%macro Bs3Trap32GenericEntry 1
70 db 06ah, i ; push imm8 - note that this is a signextended value.
71 jmp %1
72 ALIGNCODE(8)
73%assign i i+1
74%endmacro
75
76%assign i 0 ; start counter.
77 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 0
78 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1
79 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 2
80 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 3
81 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 4
82 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 5
83 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 6
84 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 7
85 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 8
86 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 9
87 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; a
88 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; b
89 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; c
90 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; d
91 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; e
92 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; f (reserved)
93 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 10
94 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 11
95 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 12
96 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 13
97 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 14
98 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 15 (reserved)
99 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 16 (reserved)
100 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 17 (reserved)
101 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 18 (reserved)
102 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 19 (reserved)
103 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1a (reserved)
104 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1b (reserved)
105 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1c (reserved)
106 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1d (reserved)
107 Bs3Trap32GenericEntry bs3Trap32GenericTrapErrCode ; 1e
108 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt ; 1f (reserved)
109%rep 224
110 Bs3Trap32GenericEntry bs3Trap32GenericTrapOrInt
111%endrep
112BS3_PROC_END Bs3Trap32GenericEntries
113
114
115
116
117;;
118; Trap or interrupt (no error code).
119;
120BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt
121 pushfd
122 cli
123 cld
124
125 sub esp, BS3TRAPFRAME_size
126 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax
127 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ebp
128 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx
129 lea ebp, [esp + BS3TRAPFRAME_size + 4] ; iret - 4 (i.e. ebp frame chain location)
130
131 mov edx, [esp + BS3TRAPFRAME_size]
132 mov [esp + BS3TRAPFRAME.fHandlerRfl], edx
133
134 movzx edx, byte [esp + BS3TRAPFRAME_size + 4]
135 mov [esp + BS3TRAPFRAME.bXcpt], edx
136
137 xor edx, edx
138 mov [esp + BS3TRAPFRAME.uErrCd], edx
139 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx
140 jmp bs3Trap32GenericCommon
141BS3_PROC_END bs3Trap32GenericTrapOrInt
142
143
144;;
145; Trap with error code.
146;
147BS3_PROC_BEGIN bs3Trap32GenericTrapErrCode
148 pushfd
149 cli
150 cld
151
152 sub esp, BS3TRAPFRAME_size
153 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax
154 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ebp
155 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx
156 lea ebp, [esp + BS3TRAPFRAME_size + 8] ; iret - 4 (i.e. ebp frame chain location)
157
158 mov edx, [esp + BS3TRAPFRAME_size]
159 mov [esp + BS3TRAPFRAME.fHandlerRfl], edx
160
161 movzx edx, byte [esp + BS3TRAPFRAME_size + 4]
162 mov [esp + BS3TRAPFRAME.bXcpt], edx
163
164 mov edx, [esp + BS3TRAPFRAME_size + 8]
165;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts.
166 mov [esp + BS3TRAPFRAME.uErrCd], edx
167 xor edx, edx
168 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx
169 jmp bs3Trap32GenericCommon
170BS3_PROC_END bs3Trap32GenericTrapErrCode
171
172
173;;
174; Common context saving code and dispatching.
175;
176; @param esp Pointer to the trap frame. The following members have been
177; filled in by the previous code:
178; - bXcpt
179; - uErrCd
180; - fHandlerRFL
181; - Ctx.eax (except upper dword)
182; - Ctx.edx (except upper dword)
183; - Ctx.ebp (except upper dword)
184;
185; @param ebp Pointer to the dword before the iret frame, i.e. where ebp
186; would be saved if this was a normal call.
187; @param edx Zero (0).
188;
189BS3_PROC_BEGIN bs3Trap32GenericCommon
190 ;
191 ; Fake EBP frame.
192 ;
193 mov eax, [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp]
194 mov [ebp], eax
195
196 ;
197 ; Save the remaining GPRs and segment registers.
198 ;
199 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx
200 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ebx
201 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], edi
202 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi
203 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], ds
204 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.es], es
205 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], fs
206 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], gs
207
208 ;
209 ; Load 32-bit data selector for the DPL we're executing at into DS and ES.
210 ; Save the handler SS and CS values first.
211 ;
212 mov ax, cs
213 mov [esp + BS3TRAPFRAME.uHandlerCs], ax
214 mov ax, ss
215 mov [esp + BS3TRAPFRAME.uHandlerSs], ax
216 and ax, 3
217 mov cx, ax
218 shl ax, BS3_SEL_RING_SHIFT
219 or ax, cx
220 add ax, BS3_SEL_R0_DS32
221 mov ds, ax
222 mov es, ax
223
224 ;
225 ; Copy and update the mode now that we've got a flat DS.
226 ;
227 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
228 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], al
229 and al, ~BS3_MODE_CODE_MASK
230 or al, BS3_MODE_CODE_32
231 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], al
232
233 ;
234 ; Copy iret info.
235 ;
236 mov ecx, [ebp + 4]
237 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx
238 mov ecx, [ebp + 12]
239 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx
240 mov cx, [ebp + 8]
241 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
242 test dword [ebp + 12], X86_EFL_VM
243 jnz .iret_frame_v8086
244 mov ax, ss
245 and al, 3
246 and cl, 3
247 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl
248 cmp cl, al
249 je .iret_frame_same_cpl
250
251.iret_frame_different_cpl:
252 mov ecx, [ebp + 16]
253 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
254 mov cx, [ebp + 20]
255 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
256 lea eax, [ebp + 24]
257 mov [esp + BS3TRAPFRAME.uHandlerRsp], eax
258 jmp .iret_frame_done
259
260.iret_frame_same_cpl:
261 lea ecx, [ebp + 12]
262 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
263 mov [esp + BS3TRAPFRAME.uHandlerRsp], ecx
264 mov cx, ss
265 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
266 jmp .iret_frame_done
267
268.iret_frame_v8086:
269 mov byte [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], 3
270 or byte [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], BS3_MODE_CODE_V86 ; paranoia ^ 2
271 movzx ecx, word [ebp + 16]
272 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
273 mov cx, [ebp + 20]
274 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
275 mov cx, [ebp + 24]
276 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
277 mov cx, [ebp + 28]
278 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
279 mov cx, [ebp + 32]
280 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx
281 mov cx, [ebp + 36]
282 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx
283 lea eax, [ebp + 40]
284 mov [esp + BS3TRAPFRAME.uHandlerRsp], eax
285 jmp .iret_frame_done
286
287.iret_frame_done:
288 ;
289 ; Control registers.
290 ;
291 mov eax, cr0
292 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], eax
293 mov eax, cr2
294 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], eax
295 mov eax, cr3
296 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], eax
297 mov eax, cr4
298 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], eax
299 str ax
300 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax
301 sldt ax
302 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], ax
303
304 ;
305 ; Set context bit width and clear all upper dwords and unused register members.
306 ;
307.clear_and_dispatch_to_handler: ; The double fault code joins us here.
308 xor edx, edx
309 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.abPadding], dx
310 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.abPadding + 2], edx
311 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax + 4], edx
312 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx + 4], edx
313 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx + 4], edx
314 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx + 4], edx
315 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp + 4], edx
316 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp + 4], edx
317 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi + 4], edx
318 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi + 4], edx
319 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r8 + 4], edx
320 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r9 + 4], edx
321 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r10 + 4], edx
322 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r11 + 4], edx
323 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r12 + 4], edx
324 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r13 + 4], edx
325 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r14 + 4], edx
326 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.r15 + 4], edx
327 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags + 4], edx
328 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rip + 4], edx
329 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0 + 4], edx
330 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2 + 4], edx
331 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3 + 4], edx
332 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4 + 4], edx
333
334 ;
335 ; Dispatch it to C code.
336 ;
337 movzx ebx, byte [esp + BS3TRAPFRAME.bXcpt]
338 mov eax, [ebx * 4 + BS3_DATA16_WRT(_g_apfnBs3TrapHandlers_c32)]
339 or eax, eax
340 jnz .call_handler
341 mov eax, Bs3TrapDefaultHandler
342.call_handler:
343 mov edi, esp
344 push edi
345 call eax
346
347 ;
348 ; Resume execution using trap frame.
349 ;
350 push 0
351 add edi, BS3TRAPFRAME.Ctx
352 push edi
353 call Bs3RegCtxRestore
354.panic:
355 hlt
356 jmp .panic
357BS3_PROC_END bs3Trap32GenericCommon
358
359
360;;
361; Helper.
362;
363; @retruns Flat address in eax.
364; @param ax
365; @uses eax
366;
367bs3Trap32TssInAxToFlatInEax:
368 ; Get the GDT base address and find the descriptor address (EAX)
369 sub esp, 8+2
370 sgdt [esp]
371 and eax, 0fff8h
372 add eax, [esp + 2] ; GDT base address.
373 add esp, 8+2
374
375 ; Get the flat TSS address from the descriptor.
376 mov al, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8)]
377 mov ah, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8)]
378 shl eax, 16
379 mov ax, [eax + (X86DESCGENERIC_BIT_OFF_BASE_LOW / 8)]
380 ret
381
382;;
383; Double fault handler.
384;
385; We don't have to load any selectors or clear anything in EFLAGS because the
386; TSS specified sane values which got loaded during the task switch.
387;
388BS3_PROC_BEGIN Bs3Trap32DoubleFaultHandler
389 push 0 ; We'll copy the rip from the other TSS here later to create a more sensible call chain.
390 push ebp
391 mov ebp, esp
392
393 ;
394 ; Fill in the non-context trap frame bits.
395 ;
396 pushfd ; Get handler flags.
397 pop ecx
398 xor edx, edx ; NULL register.
399
400 sub esp, BS3TRAPFRAME_size ; Allocate trap frame.
401 mov [esp + BS3TRAPFRAME.fHandlerRfl], ecx
402 mov word [esp + BS3TRAPFRAME.bXcpt], X86_XCPT_DF
403 mov [esp + BS3TRAPFRAME.uHandlerCs], cs
404 mov [esp + BS3TRAPFRAME.uHandlerSs], ss
405 lea ecx, [ebp + 12]
406 mov [esp + BS3TRAPFRAME.uHandlerRsp], ecx
407 mov [esp + BS3TRAPFRAME.uHandlerRsp + 4], edx
408 mov ecx, [ebp + 8]
409 mov [esp + BS3TRAPFRAME.uErrCd], ecx
410 mov [esp + BS3TRAPFRAME.uErrCd + 4], edx
411
412 ;
413 ; Copy the register state from the previous task segment.
414 ;
415
416 ; Find our TSS.
417 str ax
418 call bs3Trap32TssInAxToFlatInEax
419
420 ; Find the previous TSS.
421 mov ax, [eax + X86TSS32.selPrev]
422 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax
423 call bs3Trap32TssInAxToFlatInEax
424
425 ; Do the copying.
426 mov ecx, [eax + X86TSS32.eax]
427 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ecx
428 mov ecx, [eax + X86TSS32.ecx]
429 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx
430 mov ecx, [eax + X86TSS32.edx]
431 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], ecx
432 mov ecx, [eax + X86TSS32.ebx]
433 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ecx
434 mov ecx, [eax + X86TSS32.esp]
435 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
436 mov ecx, [eax + X86TSS32.ebp]
437 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ecx
438 mov [ebp], ecx ; For better call stacks.
439 mov ecx, [eax + X86TSS32.esi]
440 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx
441 mov ecx, [eax + X86TSS32.edi]
442 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], ecx
443 mov ecx, [eax + X86TSS32.esi]
444 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx
445 mov ecx, [eax + X86TSS32.eflags]
446 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx
447 mov ecx, [eax + X86TSS32.eip]
448 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx
449 mov [ebp + 4], ecx ; For better call stacks.
450 mov cx, [eax + X86TSS32.cs]
451 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
452 mov cx, [eax + X86TSS32.ds]
453 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
454 mov cx, [eax + X86TSS32.es]
455 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
456 mov cx, [eax + X86TSS32.fs]
457 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx
458 mov cx, [eax + X86TSS32.gs]
459 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx
460 mov cx, [eax + X86TSS32.ss]
461 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
462 mov cx, [eax + X86TSS32.selLdt] ; Note! This isn't necessarily the ldtr at the time of the fault.
463 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx
464 mov cx, [eax + X86TSS32.cr3] ; Note! This isn't necessarily the cr3 at the time of the fault.
465 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], ecx
466
467 ;
468 ; Set CPL; copy and update mode.
469 ;
470 mov cl, [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.ss]
471 and cl, 3
472 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl
473
474 mov cl, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
475 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], cl
476 and cl, ~BS3_MODE_CODE_MASK
477 or cl, BS3_MODE_CODE_32
478 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], cl
479
480 ;
481 ; Control registers.
482 ;
483 mov ecx, cr0
484 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], ecx
485 mov ecx, cr2
486 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], ecx
487 mov ecx, cr4
488 mov [esp + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], ecx
489
490 ;
491 ; Join code paths with the generic handler code.
492 ;
493 jmp bs3Trap32GenericCommon.clear_and_dispatch_to_handler
494BS3_PROC_END Bs3Trap32DoubleFaultHandler
495
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