test_srs_x64.cpp
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #include <test.h>
23 #include <intrinsics/srs_x64.h>
24 
25 using namespace x64;
26 
35 
36 extern "C" uint16_t
38 { return g_es; }
39 
40 extern "C" void
41 __write_es(uint16_t val) noexcept
42 { g_es = val; }
43 
44 extern "C" uint16_t
46 { return g_cs; }
47 
48 extern "C" void
49 __write_cs(uint16_t val) noexcept
50 { g_cs = val; }
51 
52 extern "C" uint16_t
54 { return g_ss; }
55 
56 extern "C" void
57 __write_ss(uint16_t val) noexcept
58 { g_ss = val; }
59 
60 extern "C" uint16_t
62 { return g_ds; }
63 
64 extern "C" void
65 __write_ds(uint16_t val) noexcept
66 { g_ds = val; }
67 
68 extern "C" uint16_t
70 { return g_fs; }
71 
72 extern "C" void
73 __write_fs(uint16_t val) noexcept
74 { g_fs = val; }
75 
76 extern "C" uint16_t
78 { return g_gs; }
79 
80 extern "C" void
81 __write_gs(uint16_t val) noexcept
82 { g_gs = val; }
83 
84 extern "C" uint16_t
86 { return g_ldtr; }
87 
88 extern "C" void
89 __write_ldtr(uint16_t val) noexcept
90 { g_ldtr = val; }
91 
92 extern "C" uint16_t
94 { return g_tr; }
95 
96 extern "C" void
97 __write_tr(uint16_t val) noexcept
98 { g_tr = val; }
99 
100 void
101 intrinsics_ut::test_srs_x64_es()
102 {
103  segment_register::es::set(0xFFFFU);
104  this->expect_true(segment_register::es::get() == 0xFFFFU);
105 
107  this->expect_true(segment_register::es::get() == 0x0U);
108 }
109 
110 void
111 intrinsics_ut::test_srs_x64_es_rpl()
112 {
115 
118 
121 
124 }
125 
126 void
127 intrinsics_ut::test_srs_x64_es_ti()
128 {
131 
134 }
135 
136 void
137 intrinsics_ut::test_srs_x64_es_index()
138 {
141 
144 
147 
150 }
151 
152 void
153 intrinsics_ut::test_srs_x64_cs()
154 {
155  segment_register::cs::set(0xFFFFU);
156  this->expect_true(segment_register::cs::get() == 0xFFFFU);
157 
159  this->expect_true(segment_register::cs::get() == 0x0U);
160 }
161 
162 void
163 intrinsics_ut::test_srs_x64_cs_rpl()
164 {
167 
170 
173 
176 }
177 
178 void
179 intrinsics_ut::test_srs_x64_cs_ti()
180 {
183 
186 }
187 
188 void
189 intrinsics_ut::test_srs_x64_cs_index()
190 {
193 
196 
199 
202 }
203 
204 void
205 intrinsics_ut::test_srs_x64_ss()
206 {
207  segment_register::ss::set(0xFFFFU);
208  this->expect_true(segment_register::ss::get() == 0xFFFFU);
209 
211  this->expect_true(segment_register::ss::get() == 0x0U);
212 }
213 
214 void
215 intrinsics_ut::test_srs_x64_ss_rpl()
216 {
219 
222 
225 
228 }
229 
230 void
231 intrinsics_ut::test_srs_x64_ss_ti()
232 {
235 
238 }
239 
240 void
241 intrinsics_ut::test_srs_x64_ss_index()
242 {
245 
248 
251 
254 }
255 
256 void
257 intrinsics_ut::test_srs_x64_ds()
258 {
259  segment_register::ds::set(0xFFFFU);
260  this->expect_true(segment_register::ds::get() == 0xFFFFU);
261 
263  this->expect_true(segment_register::ds::get() == 0x0U);
264 }
265 
266 void
267 intrinsics_ut::test_srs_x64_ds_rpl()
268 {
271 
274 
277 
280 }
281 
282 void
283 intrinsics_ut::test_srs_x64_ds_ti()
284 {
287 
290 }
291 
292 void
293 intrinsics_ut::test_srs_x64_ds_index()
294 {
297 
300 
303 
306 }
307 
308 void
309 intrinsics_ut::test_srs_x64_fs()
310 {
311  segment_register::fs::set(0xFFFFU);
312  this->expect_true(segment_register::fs::get() == 0xFFFFU);
313 
315  this->expect_true(segment_register::fs::get() == 0x0U);
316 }
317 
318 void
319 intrinsics_ut::test_srs_x64_fs_rpl()
320 {
323 
326 
329 
332 }
333 
334 void
335 intrinsics_ut::test_srs_x64_fs_ti()
336 {
339 
342 }
343 
344 void
345 intrinsics_ut::test_srs_x64_fs_index()
346 {
349 
352 
355 
358 }
359 
360 void
361 intrinsics_ut::test_srs_x64_gs()
362 {
363  segment_register::gs::set(0xFFFFU);
364  this->expect_true(segment_register::gs::get() == 0xFFFFU);
365 
367  this->expect_true(segment_register::gs::get() == 0x0U);
368 }
369 
370 void
371 intrinsics_ut::test_srs_x64_gs_rpl()
372 {
375 
378 
381 
384 }
385 
386 void
387 intrinsics_ut::test_srs_x64_gs_ti()
388 {
391 
394 }
395 
396 void
397 intrinsics_ut::test_srs_x64_gs_index()
398 {
401 
404 
407 
410 }
411 
412 void
413 intrinsics_ut::test_srs_x64_ldtr()
414 {
416  this->expect_true(segment_register::ldtr::get() == 0xFFFFU);
417 
419  this->expect_true(segment_register::ldtr::get() == 0x0U);
420 }
421 
422 void
423 intrinsics_ut::test_srs_x64_ldtr_rpl()
424 {
427 
430 
433 
436 }
437 
438 void
439 intrinsics_ut::test_srs_x64_ldtr_ti()
440 {
443 
446 }
447 
448 void
449 intrinsics_ut::test_srs_x64_ldtr_index()
450 {
453 
456 
459 
462 }
463 
464 void
465 intrinsics_ut::test_srs_x64_tr()
466 {
467  segment_register::tr::set(0xFFFFU);
468  this->expect_true(segment_register::tr::get() == 0xFFFFU);
469 
471  this->expect_true(segment_register::tr::get() == 0x0U);
472 }
473 
474 void
475 intrinsics_ut::test_srs_x64_tr_rpl()
476 {
479 
482 
485 
488 }
489 
490 void
491 intrinsics_ut::test_srs_x64_tr_ti()
492 {
495 
498 }
499 
500 void
501 intrinsics_ut::test_srs_x64_tr_index()
502 {
505 
508 
511 
514 }
void set(T val) noexcept
Definition: srs_x64.h:405
void __write_gs(uint16_t val) noexcept
void __write_fs(uint16_t val) noexcept
void set(bool val) noexcept
Definition: srs_x64.h:381
auto get() noexcept
Definition: srs_x64.h:90
void set(T val) noexcept
Definition: srs_x64.h:213
void set(T val) noexcept
Definition: srs_x64.h:165
void set(T val) noexcept
Definition: srs_x64.h:299
auto get() noexcept
Definition: srs_x64.h:161
void set(bool val) noexcept
Definition: srs_x64.h:285
void set(T val) noexcept
Definition: srs_x64.h:443
void __write_ds(uint16_t val) noexcept
segment_register::type g_es
void set(T val) noexcept
Definition: srs_x64.h:225
void set(T val) noexcept
Definition: srs_x64.h:357
segment_register::type g_gs
uint16_t __read_ds(void) noexcept
void set(T val) noexcept
Definition: srs_x64.h:69
void set(T val) noexcept
Definition: srs_x64.h:417
segment_register::type g_ss
segment_register::type g_cs
void set(T val) noexcept
Definition: srs_x64.h:117
void set(T val) noexcept
Definition: srs_x64.h:81
uint16_t __read_gs(void) noexcept
auto get() noexcept
Definition: srs_x64.h:113
void set(T val) noexcept
Definition: srs_x64.h:203
void uint64_t uint64_t uint64_t *rdx noexcept
segment_register::type g_ds
segment_register::type g_fs
void set(bool val) noexcept
Definition: srs_x64.h:189
void set(T val) noexcept
Definition: srs_x64.h:177
void set(T val) noexcept
Definition: srs_x64.h:395
void __write_es(uint16_t val) noexcept
void set(bool val) noexcept
Definition: srs_x64.h:429
void set(bool val) noexcept
Definition: srs_x64.h:333
void set(T val) noexcept
Definition: srs_x64.h:261
void __write_ss(uint16_t val) noexcept
segment_register::type g_ldtr
void set(bool val) noexcept
Definition: srs_x64.h:141
auto get() noexcept
Definition: srs_x64.h:209
auto get() noexcept
Definition: srs_x64.h:257
auto get() noexcept
Definition: srs_x64.h:401
uint16_t __read_ss(void) noexcept
void set(T val) noexcept
Definition: srs_x64.h:321
auto get() noexcept
Definition: srs_x64.h:65
void set(T val) noexcept
Definition: srs_x64.h:155
void set(T val) noexcept
Definition: srs_x64.h:347
uint16_t __read_tr(void) noexcept
uint16_t __read_fs(void) noexcept
void set(T val) noexcept
Definition: srs_x64.h:369
segment_register::type g_tr
void __write_ldtr(uint16_t val) noexcept
void set(T val) noexcept
Definition: srs_x64.h:129
auto get() noexcept
Definition: srs_x64.h:305
void __write_tr(uint16_t val) noexcept
#define expect_false(a)
void set(bool val) noexcept
Definition: srs_x64.h:93
void set(T val) noexcept
Definition: srs_x64.h:273
void set(T val) noexcept
Definition: srs_x64.h:309
Definition: cache_x64.h:31
void __write_cs(uint16_t val) noexcept
void set(T val) noexcept
Definition: srs_x64.h:251
auto get() noexcept
Definition: srs_x64.h:353
void set(T val) noexcept
Definition: srs_x64.h:107
#define expect_true(a)
uint16_t __read_ldtr(void) noexcept
uint16_t __read_es(void) noexcept
void set(bool val) noexcept
Definition: srs_x64.h:237
uint16_t __read_cs(void) noexcept