VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bootsector2-cpu-hidden-regs-1.asm@ 104620

Last change on this file since 104620 was 98103, checked in by vboxsync, 22 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: 8.3 KB
Line 
1; $Id: bootsector2-cpu-hidden-regs-1.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; Bootsector that shows/tests the content of hidden CPU registers.
4;
5; Requires VMMDevTesting. Enable it via VBoxManage:
6; VBoxManage setextradata bs-cpu-hidden-regs-1 VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled 1
7
8;
9; Copyright (C) 2007-2023 Oracle and/or its affiliates.
10;
11; This file is part of VirtualBox base platform packages, as
12; available from https://www.virtualbox.org.
13;
14; This program is free software; you can redistribute it and/or
15; modify it under the terms of the GNU General Public License
16; as published by the Free Software Foundation, in version 3 of the
17; License.
18;
19; This program is distributed in the hope that it will be useful, but
20; WITHOUT ANY WARRANTY; without even the implied warranty of
21; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22; General Public License for more details.
23;
24; You should have received a copy of the GNU General Public License
25; along with this program; if not, see <https://www.gnu.org/licenses>.
26;
27; The contents of this file may alternatively be used under the terms
28; of the Common Development and Distribution License Version 1.0
29; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
30; in the VirtualBox distribution, in which case the provisions of the
31; CDDL are applicable instead of those of the GPL.
32;
33; You may elect to license modified versions of this file under the
34; terms and conditions of either the GPL or the CDDL or both.
35;
36; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
37;
38
39
40%include "iprt/asmdefs.mac"
41%include "iprt/x86.mac"
42%include "VBox/VMMDevTesting.mac"
43
44;
45; Include and execute the init code.
46;
47 %define BS2_INIT_RM
48 %define BS2_INC_PE16
49 %define BS2_INC_PE32
50 %define BS2_INC_PP32
51 %define BS2_INC_LM64
52 %define BS2_WITH_TRAPS
53 %define BS2_WITH_MANUAL_LTR
54 %include "bootsector2-common-init-code.mac"
55
56
57;
58; The benchmark driver
59;
60BEGINPROC main
61 ;
62 ; Test prologue.
63 ;
64 mov ax, .s_szTstName
65 call TestInit_r86
66 call Bs2EnableA20_r86
67 call Bs2PanicIfVMMDevTestingIsMissing_r86
68
69 call reportPostBiosValues
70 call rmTests
71 call doTests_rm_pe32
72 call doTests_rm_pp32
73 call doTests_rm_lm64
74
75 ;
76 ; We're done.
77 ;
78 call TestTerm_r86
79 call Bs2Panic
80
81.s_szTstName:
82 db 'tstCpuHidRegs', 0
83ENDPROC main
84
85
86;
87; Reports the values of interesting hidden registers as we start the test, i.e.
88; right after the BIOS completed.
89;
90BEGINPROC reportPostBiosValues
91 push ax
92 push bx
93 mov ax, .s_szTstInitial
94 call TestSub_r86
95
96 mov ax, .s_szzStart
97 call TestValueRegSZZ_rm
98
99.done
100 pop bx
101 pop ax
102 ret
103
104.s_szzStart:
105 db 'BIOS - ldtr:ldtr', 0;
106 db 'BIOS - ldtr_base:ldtr_base', 0;
107 db 'BIOS - ldtr_limit:ldtr_lim', 0;
108 db 'BIOS - ldtr_attr:ldtr_attr', 0;
109 db 'BIOS - tr:tr', 0;
110 db 'BIOS - tr_base:tr_base', 0;
111 db 'BIOS - tr_limit:tr_lim', 0;
112 db 'BIOS - tr_attr:tr_attr', 0;
113 db 'BIOS - cs:cs', 0;
114 db 'BIOS - cs_base:cs_base', 0;
115 db 'BIOS - cs_limit:cs_lim', 0;
116 db 'BIOS - cs_attr:cs_attr', 0;
117 db 'BIOS - ss:ss', 0;
118 db 'BIOS - ss_base:ss_base', 0;
119 db 'BIOS - ss_limit:ss_lim', 0;
120 db 'BIOS - ss_attr:ss_attr', 0;
121 db 'BIOS - ds:ds', 0;
122 db 'BIOS - ds_base:ds_base', 0;
123 db 'BIOS - ds_limit:ds_lim', 0;
124 db 'BIOS - ds_attr:ds_attr', 0;
125 db 0,0,0,0 ; terminator
126.s_szTstInitial:
127 db 'Post BIOS Values', 0
128ENDPROC reportPostBiosValues
129
130
131;
132; Reports the values of interesting hidden registers as we start the test, i.e.
133; right after the BIOS completed.
134;
135BEGINPROC rmTests
136 push eax
137 push ebx
138 pushfd
139 cli
140
141 mov ax, .s_szTstRM
142 call TestSub_r86
143
144 ; Check if CS changes when leaving protected mode.
145 mov ax, .s_szzRMPre
146 call TestValueRegSZZ_rm
147 mov byte [cs:.s_dwDummy], 1
148 call Bs2EnterMode_rm_pe32
149BITS 32
150 mov eax, .s_szzProt32
151 call TestValueRegSZZ_pe32
152 ; mov word [cs:.s_dwDummy], 2 - this shall GP(CS).
153 call Bs2ExitMode_pe32
154BITS 16
155 mov ax, .s_szzRMPost
156 call TestValueRegSZZ_rm
157 mov dword [cs:.s_dwDummy], 3
158
159 ;
160 ; What happens if we make CS32 execute-only and return to real-mode.
161 ;
162 mov byte [cs:.s_dwDummy], 1
163 call Bs2EnterMode_rm_pe16
164 jmp BS2_SEL_CS16_EO:.loaded_cs16_eo
165.loaded_cs16_eo:
166 mov eax, .s_szzProtEO
167 call TestValueRegSZZ_pe16
168 ; mov ax, word [cs:.s_dwDummy] - this shall GP(CS).
169 ; mov word [cs:.s_dwDummy], 2 - this shall GP(CS).
170
171 ; Leave real-mode ourselves.
172 mov eax, cr0
173 and eax, ~X86_CR0_PE
174 mov cr0, eax
175
176 ; All but cs gets reloaded.
177 xor ax, ax
178 mov ss, ax
179 mov ds, ax
180 mov es, ax
181 mov fs, ax
182 mov gs, ax
183
184 ; Display CS and do a test.
185 mov ax, .s_szzRMEO
186 call TestValueRegSZZ_rm
187
188 mov ax, [cs:.s_dwDummy] ; works on intel
189 mov dword [cs:.s_dwDummy], 3 ; ditto
190
191 jmp far 0000:.load_rm_cs
192.load_rm_cs:
193 ; Display CS to check that it remained unchanged.
194 mov ax, .s_szzRMEO2
195 call TestValueRegSZZ_rm
196
197 ; Cleanup everything properly.
198 call Bs2EnterMode_rm_pe32
199BITS 32
200 call Bs2ExitMode_pe32
201BITS 16
202
203 popfd
204 pop ebx
205 pop eax
206 ret
207
208.s_dwDummy:
209 dd 0
210.s_szzRMPre:
211 db 'RM Pre - cs:cs', 0;
212 db 'RM Pre - cs_base:cs_base', 0;
213 db 'RM Pre - cs_limit:cs_lim', 0;
214 db 'RM Pre - cs_attr:cs_attr', 0;
215 db 0,0,0,0 ; terminator
216.s_szzProt32:
217 db 'Prot32 - cs:cs', 0;
218 db 'Prot32 - cs_base:cs_base', 0;
219 db 'Prot32 - cs_limit:cs_lim', 0;
220 db 'Prot32 - cs_attr:cs_attr', 0;
221 db 0,0,0,0 ; terminator
222.s_szzRMPost:
223 db 'RM Post - cs:cs', 0;
224 db 'RM Post - cs_base:cs_base', 0;
225 db 'RM Post - cs_limit:cs_lim', 0;
226 db 'RM Post - cs_attr:cs_attr', 0;
227 db 0,0,0,0 ; terminator
228.s_szzProtEO:
229 db 'Prot 16 EO,L-1,NA - cs:cs', 0;
230 db 'Prot 16 EO,L-1,NA - cs_base:cs_base', 0;
231 db 'Prot 16 EO,L-1,NA - cs_limit:cs_lim', 0;
232 db 'Prot 16 EO,L-1,NA - cs_attr:cs_attr', 0;
233 db 0,0,0,0 ; terminator
234.s_szzRMEO:
235 db 'RM Post EO,L-1,NA - cs:cs', 0;
236 db 'RM Post EO,L-1,NA - cs_base:cs_base', 0;
237 db 'RM Post EO,L-1,NA - cs_limit:cs_lim', 0;
238 db 'RM Post EO,L-1,NA - cs_attr:cs_attr', 0;
239 db 0,0,0,0 ; terminator
240.s_szzRMEO2:
241 db 'RM CS(0) EO,L-1 - cs:cs', 0;
242 db 'RM CS(0) EO,L-1 - cs_base:cs_base', 0;
243 db 'RM CS(0) EO,L-1 - cs_limit:cs_lim', 0;
244 db 'RM CS(0) EO,L-1 - cs_attr:cs_attr', 0;
245 db 0,0,0,0 ; terminator
246.s_szTstRM:
247 db 'Real Mode Test', 0
248ENDPROC rmTests
249
250
251
252;
253; Instantiate the template code.
254;
255%include "bootsector2-template-footer.mac" ; reset the initial environemnt.
256
257%define TMPL_RM
258%include "bootsector2-cpu-hidden-regs-1-template.mac"
259;%define TMPL_CMN_V86
260;%include "bootsector2-cpu-hidden-regs-1-template.mac"
261%define TMPL_PE16
262%include "bootsector2-cpu-hidden-regs-1-template.mac"
263%define TMPL_PE32
264%include "bootsector2-cpu-hidden-regs-1-template.mac"
265;%define TMPL_PP16
266;%include "bootsector2-cpu-hidden-regs-1-template.mac"
267%define TMPL_PP32
268%include "bootsector2-cpu-hidden-regs-1-template.mac"
269;%define TMPL_PAE16
270;%include "bootsector2-cpu-hidden-regs-1-template.mac"
271;%define TMPL_PAE32
272;%include "bootsector2-cpu-hidden-regs-1-template.mac"
273;%define TMPL_LM16
274;%include "bootsector2-cpu-hidden-regs-1-template.mac"
275;%define TMPL_LM32
276;%include "bootsector2-cpu-hidden-regs-1-template.mac"
277%define TMPL_LM64
278%include "bootsector2-cpu-hidden-regs-1-template.mac"
279
280
281;
282; End sections and image.
283;
284%include "bootsector2-common-end.mac"
285
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