VirtualBox

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

Last change on this file since 84794 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.2 KB
Line 
1; $Id: bs3-c32-Trap32Generic.asm 82968 2020-02-04 10:35:17Z vboxsync $
2;; @file
3; BS3Kit - Trap, 32-bit assembly handlers.
4;
5
6;
7; Copyright (C) 2007-2020 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
41BS3_EXTERN_DATA16 g_uBs3CpuDetected
42BS3_EXTERN_DATA16 g_apfnBs3TrapHandlers_c32
43BS3_EXTERN_SYSTEM16 Bs3Gdt
44TMPL_BEGIN_TEXT
45BS3_EXTERN_CMN Bs3TrapDefaultHandler
46BS3_EXTERN_CMN Bs3RegCtxRestore
47TMPL_BEGIN_TEXT
48
49
50;*********************************************************************************************************************************
51;* Global Variables *
52;*********************************************************************************************************************************
53BS3_BEGIN_DATA16
54;; Easy to access flat address of Bs3Trap32GenericEntries.
55BS3_GLOBAL_DATA g_Bs3Trap32GenericEntriesFlatAddr, 4
56 dd Bs3Trap32GenericEntries wrt FLAT
57;; Easy to access flat address of Bs3Trap32DoubleFaultHandler.
58BS3_GLOBAL_DATA g_Bs3Trap32DoubleFaultHandlerFlatAddr, 4
59 dd Bs3Trap32DoubleFaultHandler wrt FLAT
60
61
62TMPL_BEGIN_TEXT
63
64;;
65; Generic entry points for IDT handlers, 8 byte spacing.
66;
67BS3_PROC_BEGIN Bs3Trap32GenericEntries
68%macro Bs3Trap32GenericEntryNoErr 1
69 push byte 0 ; 2 byte: fake error code.
70 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value.
71 jmp near %1 ; 5 byte
72 ALIGNCODE(2)
73%assign i i+1
74%endmacro
75
76%macro Bs3Trap32GenericEntryErrCd 1
77 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value.
78 jmp near %1 ; 5 byte
79 db 0cch, 0cch ; 2 byte: padding.
80 ALIGNCODE(2)
81%assign i i+1
82%endmacro
83
84%assign i 0 ; start counter.
85 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 0
86 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1
87 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 2
88 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 3
89 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 4
90 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 5
91 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 6
92 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 7
93 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 8
94 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 9
95 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; a
96 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; b
97 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; c
98 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; d
99 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; e
100 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; f (reserved)
101 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 10
102 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 11
103 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 12
104 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 13
105 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 14
106 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 15 (reserved)
107 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 16 (reserved)
108 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 17 (reserved)
109 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 18 (reserved)
110 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 19 (reserved)
111 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1a (reserved)
112 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1b (reserved)
113 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1c (reserved)
114 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1d (reserved)
115 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 1e
116 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1f (reserved)
117%rep 224
118 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt
119%endrep
120BS3_PROC_END Bs3Trap32GenericEntries
121AssertCompile(Bs3Trap32GenericEntries_EndProc - Bs3Trap32GenericEntries == 10*256)
122
123
124;;
125; Trap or interrupt with error code, faked if necessary.
126;
127BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt
128 push ebp ; 0
129 mov ebp, esp
130 pushfd ; -04h
131 cld
132 push eax ; -08h
133 push edi ; -0ch
134 lea eax, [esp + (4+1+1)*4] ; 4 pushes above, 1 exception number push, 1 error code.
135 push eax ; -10h = handler ESP
136 add eax, 3*4 ; 3 dword iret frame
137 push eax ; -14h = caller ESP if same CPL
138 push ss ; -18h
139 push ds ; -1ch
140
141 ; Make sure we've got a flat DS. It makes everything so much simpler.
142 mov ax, ss
143 and al, 3
144 AssertCompile(BS3_SEL_RING_SHIFT == 8)
145 mov ah, al
146 add ax, BS3_SEL_R0_DS32
147 mov ds, ax
148
149 ;
150 ; We may be comming from 16-bit code with a 16-bit SS. Thunk it as
151 ; the C code may assume flat SS and we'll mess up by using EBP/ESP/EDI
152 ; instead of BP/SP/SS:DI. ASSUMES standard GDT selector.
153 ;
154 mov ax, ss
155 lar eax, ax
156 test eax, X86LAR_F_D
157 jz .stack_thunk
158 mov ax, ss
159 and al, 3
160 AssertCompile(BS3_SEL_RING_SHIFT == 8)
161 mov ah, al
162 add ax, BS3_SEL_R0_SS32
163 mov ss, ax
164 jmp .stack_flat
165.stack_thunk:
166 mov di, ss
167 and edi, X86_SEL_MASK_OFF_RPL
168 mov al, [X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8 + edi + Bs3Gdt wrt FLAT]
169 mov ah, [X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8 + edi + Bs3Gdt wrt FLAT]
170 shl eax, 16
171 mov ax, [X86DESCGENERIC_BIT_OFF_BASE_LOW / 8 + edi + Bs3Gdt wrt FLAT] ; eax = SS.base
172 movzx ebp, bp ; SS:BP -> flat EBP.
173 add ebp, eax
174 movzx edi, sp ; SS:SP -> flat ESP in EAX.
175 add edi, eax
176 mov ax, ss
177 and al, 3
178 AssertCompile(BS3_SEL_RING_SHIFT == 8)
179 mov ah, al
180 add ax, BS3_SEL_R0_SS32
181 mov ss, ax
182 mov esp, edi
183 sub dword [ebp - 10h], (4+1)*4 ; Recalc handler ESP in case of wraparound.
184 add word [ebp - 10h], (4+1)*4
185 sub dword [ebp - 10h], (4+1+3)*4 ; Recalc caller ESP in case of wraparound.
186 add word [ebp - 10h], (4+1+3)*4
187.stack_flat:
188
189 ; Reserve space for the register and trap frame.
190 mov eax, (BS3TRAPFRAME_size + 7) / 8
191AssertCompileSizeAlignment(BS3TRAPFRAME, 8)
192.more_zeroed_space:
193 push dword 0
194 push dword 0
195 dec eax
196 jnz .more_zeroed_space
197 mov edi, esp ; edi points to trapframe structure.
198
199 ; Copy stuff from the stack over.
200 mov eax, [ebp + 8]
201;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts.
202 mov [edi + BS3TRAPFRAME.uErrCd], eax
203 mov al, [ebp + 4]
204 mov [edi + BS3TRAPFRAME.bXcpt], al
205 mov eax, [ebp]
206 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], eax
207 mov eax, [ebp - 04h]
208 mov [edi + BS3TRAPFRAME.fHandlerRfl], eax
209 mov eax, [ebp - 08h]
210 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax
211 mov eax, [ebp - 0ch]
212 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], eax
213 mov eax, [ebp - 10h]
214 mov [edi + BS3TRAPFRAME.uHandlerRsp], eax
215 mov eax, [ebp - 14h]
216 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], eax
217 mov ax, [ebp - 18h]
218 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], ax
219 mov [edi + BS3TRAPFRAME.uHandlerSs], ax
220 mov ax, [ebp - 1ch]
221 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], ax
222
223 lea ebp, [ebp + 8] ; iret - 4 (i.e. ebp frame chain location)
224 jmp bs3Trap32GenericCommon
225BS3_PROC_END bs3Trap32GenericTrapErrCode
226
227
228;;
229; Common context saving code and dispatching.
230;
231; @param edi Pointer to the trap frame. The following members have been
232; filled in by the previous code:
233; - bXcpt
234; - uErrCd
235; - fHandlerRfl
236; - uHandlerRsp
237; - uHandlerSs
238; - Ctx.rax
239; - Ctx.rbp
240; - Ctx.rdi
241; - Ctx.rsp - assuming same CPL
242; - Ctx.ds
243; - Ctx.ss
244;
245; @param ebp Pointer to the dword before the iret frame, i.e. where ebp
246; would be saved if this was a normal call.
247;
248; @remarks This is a separate function for hysterical raisins.
249;
250BS3_PROC_BEGIN bs3Trap32GenericCommon
251 ;
252 ; Fake EBP frame.
253 ;
254 mov eax, [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp]
255 mov [ebp], eax
256
257 ;
258 ; Save the remaining GPRs and segment registers.
259 ;
260 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx
261 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx
262 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ebx
263 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi
264 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.es], es
265 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], fs
266 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], gs
267
268 ;
269 ; Load 32-bit data selector for the DPL we're executing at into DS and ES.
270 ; Save the handler CS value first.
271 ;
272 mov ax, cs
273 mov [edi + BS3TRAPFRAME.uHandlerCs], ax
274 and al, 3
275 AssertCompile(BS3_SEL_RING_SHIFT == 8)
276 mov ah, al
277 add ax, BS3_SEL_R0_DS32
278 mov ds, ax
279 mov es, ax
280
281 ;
282 ; Copy and update the mode now that we've got a flat DS.
283 ;
284 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
285 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], al
286 and al, ~BS3_MODE_CODE_MASK
287 or al, BS3_MODE_CODE_32
288 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], al
289
290 ;
291 ; Copy iret info.
292 ;
293 mov ecx, [ebp + 4]
294 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx
295 mov ecx, [ebp + 12]
296 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx
297 mov cx, [ebp + 8]
298 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
299 test dword [ebp + 12], X86_EFL_VM
300 jnz .iret_frame_v8086
301 mov ax, ss
302 and al, 3
303 and cl, 3
304 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl
305 cmp cl, al
306 je .iret_frame_same_cpl
307
308.iret_frame_different_cpl:
309 mov ecx, [ebp + 16]
310 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
311 mov cx, [ebp + 20]
312 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
313 mov byte [edi + BS3TRAPFRAME.cbIretFrame], 5*4
314 jmp .iret_frame_done
315
316.iret_frame_v8086:
317 mov byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], 3
318 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], BS3_MODE_CODE_V86 ; paranoia ^ 2
319 movzx ecx, word [ebp + 16]
320 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
321 mov cx, [ebp + 20]
322 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
323 mov cx, [ebp + 24]
324 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
325 mov cx, [ebp + 28]
326 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
327 mov cx, [ebp + 32]
328 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx
329 mov cx, [ebp + 36]
330 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx
331 mov byte [edi + BS3TRAPFRAME.cbIretFrame], 9*4
332 jmp .iret_frame_done
333
334.iret_frame_same_cpl: ; (caller already set SS:RSP and uHandlerRsp for same CPL iret frames)
335 mov byte [edi + BS3TRAPFRAME.cbIretFrame], 3*4
336
337.iret_frame_done:
338 ;
339 ; Control registers.
340 ;
341 str ax
342 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax
343 sldt ax
344 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], ax
345
346 mov ax, ss
347 test al, 3
348 jnz .skip_crX_because_cpl_not_0
349
350 mov eax, cr3
351 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], eax
352.save_cr0_cr2_cr4: ; The double fault code joins us here.
353 mov eax, cr0
354 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], eax
355 mov eax, cr2
356 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], eax
357
358 test byte [1 + BS3_DATA16_WRT(g_uBs3CpuDetected)], (BS3CPU_F_CPUID >> 8) ; CR4 first appeared in later 486es.
359 jz .skip_cr4_because_not_there
360 mov eax, cr4
361 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], eax
362 jmp .set_flags
363
364.skip_cr4_because_not_there:
365 mov byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR4
366 jmp .set_flags
367
368.skip_crX_because_cpl_not_0:
369 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], \
370 BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR4
371 smsw [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0]
372.set_flags:
373 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64
374
375 ;
376 ; Dispatch it to C code.
377 ;
378.dispatch_to_handler:
379 movzx ebx, byte [edi + BS3TRAPFRAME.bXcpt]
380 mov eax, [ebx * 4 + BS3_DATA16_WRT(_g_apfnBs3TrapHandlers_c32)]
381 or eax, eax
382 jnz .call_handler
383 mov eax, Bs3TrapDefaultHandler
384.call_handler:
385 push edi
386 call eax
387
388 ;
389 ; Resume execution using trap frame.
390 ;
391 push 0
392 add edi, BS3TRAPFRAME.Ctx
393 push edi
394 call Bs3RegCtxRestore
395.panic:
396 hlt
397 jmp .panic
398BS3_PROC_END bs3Trap32GenericCommon
399
400
401;;
402; Helper.
403;
404; @retruns Flat address in eax.
405; @param ax
406; @uses eax
407;
408bs3Trap32TssInAxToFlatInEax:
409 ; Get the GDT base address and find the descriptor address (EAX)
410 sub esp, 8+2
411 sgdt [esp]
412 and eax, 0fff8h
413 add eax, [esp + 2] ; GDT base address.
414 add esp, 8+2
415
416 ; Get the flat TSS address from the descriptor.
417 mov al, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8)]
418 mov ah, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8)]
419 shl eax, 16
420 mov ax, [eax + (X86DESCGENERIC_BIT_OFF_BASE_LOW / 8)]
421 ret
422
423;;
424; Double fault handler.
425;
426; We don't have to load any selectors or clear anything in EFLAGS because the
427; TSS specified sane values which got loaded during the task switch.
428;
429BS3_PROC_BEGIN Bs3Trap32DoubleFaultHandler
430 push 0 ; We'll copy the rip from the other TSS here later to create a more sensible call chain.
431 push ebp
432 mov ebp, esp
433
434 pushfd ; Get handler flags.
435 pop ecx
436
437 xor edx, edx ; NULL register.
438
439 ;
440 ; Allocate a zero filled trap frame.
441 ;
442 mov eax, (BS3TRAPFRAME_size + 7) / 8
443AssertCompileSizeAlignment(BS3TRAPFRAME, 8)
444.more_zeroed_space:
445 push edx
446 push edx
447 dec eax
448 jz .more_zeroed_space
449 mov edi, esp
450
451 ;
452 ; Fill in the non-context trap frame bits.
453 ;
454 mov [edi + BS3TRAPFRAME.fHandlerRfl], ecx
455 mov word [edi + BS3TRAPFRAME.bXcpt], X86_XCPT_DF
456 mov [edi + BS3TRAPFRAME.uHandlerCs], cs
457 mov [edi + BS3TRAPFRAME.uHandlerSs], ss
458 lea ecx, [ebp + 3*4] ; two pushes, one error code.
459 mov [edi + BS3TRAPFRAME.uHandlerRsp], ecx
460 mov ecx, [ebp + 8]
461 mov [edi + BS3TRAPFRAME.uErrCd], ecx
462
463 ;
464 ; Copy the register state from the previous task segment.
465 ;
466
467 ; Find our TSS.
468 str ax
469 call bs3Trap32TssInAxToFlatInEax
470
471 ; Find the previous TSS.
472 mov ax, [eax + X86TSS32.selPrev]
473 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax
474 call bs3Trap32TssInAxToFlatInEax
475
476 ; Do the copying.
477 mov ecx, [eax + X86TSS32.eax]
478 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ecx
479 mov ecx, [eax + X86TSS32.ecx]
480 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx
481 mov ecx, [eax + X86TSS32.edx]
482 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], ecx
483 mov ecx, [eax + X86TSS32.ebx]
484 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ecx
485 mov ecx, [eax + X86TSS32.esp]
486 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
487 mov ecx, [eax + X86TSS32.ebp]
488 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ecx
489 mov [ebp], ecx ; For better call stacks.
490 mov ecx, [eax + X86TSS32.esi]
491 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx
492 mov ecx, [eax + X86TSS32.edi]
493 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], ecx
494 mov ecx, [eax + X86TSS32.esi]
495 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx
496 mov ecx, [eax + X86TSS32.eflags]
497 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx
498 mov ecx, [eax + X86TSS32.eip]
499 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx
500 mov [ebp + 4], ecx ; For better call stacks.
501 mov cx, [eax + X86TSS32.cs]
502 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
503 mov cx, [eax + X86TSS32.ds]
504 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
505 mov cx, [eax + X86TSS32.es]
506 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
507 mov cx, [eax + X86TSS32.fs]
508 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx
509 mov cx, [eax + X86TSS32.gs]
510 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx
511 mov cx, [eax + X86TSS32.ss]
512 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
513 mov cx, [eax + X86TSS32.selLdt] ; Note! This isn't necessarily the ldtr at the time of the fault.
514 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx
515 mov cx, [eax + X86TSS32.cr3] ; Note! This isn't necessarily the cr3 at the time of the fault.
516 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], ecx
517
518 ;
519 ; Set CPL; copy and update mode.
520 ;
521 mov cl, [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss]
522 and cl, 3
523 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl
524
525 mov cl, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
526 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], cl
527 and cl, ~BS3_MODE_CODE_MASK
528 or cl, BS3_MODE_CODE_32
529 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], cl
530
531 ;
532 ; Join code paths with the generic handler code.
533 ;
534 jmp bs3Trap32GenericCommon.save_cr0_cr2_cr4
535BS3_PROC_END Bs3Trap32DoubleFaultHandler
536
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