test_rflags_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/rflags_x64.h>
24 
25 using namespace x64;
26 
28 
29 extern "C" uint64_t
31 { return g_rflags; }
32 
33 void
34 intrinsics_ut::test_rflags_x64()
35 {
36  g_rflags = 0xFFFFFFFFU;
37  this->expect_true(rflags::get() == 0xFFFFFFFFU);
38 
39  rflags::dump();
40 
41  g_rflags = 0x0U;
42  this->expect_true(rflags::get() == 0x0U);
43 }
44 
45 void
46 intrinsics_ut::test_rflags_x64_carry_flag()
47 {
50 
53 }
54 
55 void
56 intrinsics_ut::test_rflags_x64_parity_flag()
57 {
60 
63 }
64 
65 void
66 intrinsics_ut::test_rflags_x64_auxiliary_carry_flag()
67 {
70 
73 }
74 
75 void
76 intrinsics_ut::test_rflags_x64_zero_flag()
77 {
80 
83 }
84 
85 void
86 intrinsics_ut::test_rflags_x64_sign_flag()
87 {
90 
93 }
94 
95 void
96 intrinsics_ut::test_rflags_x64_trap_flag()
97 {
100 
103 }
104 
105 void
106 intrinsics_ut::test_rflags_x64_interrupt_enable_flag()
107 {
110 
113 }
114 
115 void
116 intrinsics_ut::test_rflags_x64_direction_flag()
117 {
120 
123 }
124 
125 void
126 intrinsics_ut::test_rflags_x64_overflow_flag()
127 {
130 
133 }
134 
135 void
136 intrinsics_ut::test_rflags_x64_privilege_level()
137 {
140 
143 }
144 
145 void
146 intrinsics_ut::test_rflags_x64_nested_task()
147 {
150 
151  g_rflags = ~rflags::nested_task::mask;
153 }
154 
155 void
156 intrinsics_ut::test_rflags_x64_resume_flag()
157 {
160 
161  g_rflags = ~rflags::nested_task::mask;
163 }
164 
165 void
166 intrinsics_ut::test_rflags_x64_virtual_8086_mode()
167 {
170 
171  g_rflags = ~rflags::nested_task::mask;
173 }
174 
175 void
176 intrinsics_ut::test_rflags_x64_alignment_check_access_control()
177 {
180 
181  g_rflags = ~rflags::nested_task::mask;
183 }
184 
185 void
186 intrinsics_ut::test_rflags_x64_virtual_interupt_flag()
187 {
190 
191  g_rflags = ~rflags::nested_task::mask;
193 }
194 
195 void
196 intrinsics_ut::test_rflags_x64_virtual_interupt_pending()
197 {
200 
201  g_rflags = ~rflags::nested_task::mask;
203 }
204 
205 void
206 intrinsics_ut::test_rflags_x64_id_flag()
207 {
210 
211  g_rflags = ~rflags::nested_task::mask;
213 }
214 
215 void
216 intrinsics_ut::test_rflags_x64_reserved()
217 {
219  this->expect_true(rflags::reserved::get() == 0xFFFFFFFFFFC08028UL);
220 
221  g_rflags = ~rflags::reserved::mask;
222  this->expect_true(rflags::reserved::get() == 0UL);
223 }
224 
225 void
226 intrinsics_ut::test_rflags_x64_always_disabled()
227 {
229  this->expect_true(rflags::always_disabled::get() == 0xFFFFFFFFFFC08028UL);
230 
233 }
234 
235 void
236 intrinsics_ut::test_rflags_x64_always_enabled()
237 {
240 
243 }
constexpr const auto mask
Definition: rflags_x64.h:96
auto get() noexcept
Definition: rflags_x64.h:160
constexpr const auto mask
Definition: rflags_x64.h:116
auto get() noexcept
Definition: rflags_x64.h:80
auto get() noexcept
Definition: rflags_x64.h:90
constexpr const auto mask
Definition: cpuid_x64.h:85
auto get() noexcept
Definition: rflags_x64.h:100
constexpr const auto mask
Definition: rflags_x64.h:136
auto get() noexcept
Definition: rflags_x64.h:220
constexpr const auto mask
Definition: rflags_x64.h:236
void dump() noexcept
Definition: rflags_x64.h:244
constexpr const auto mask
Definition: rflags_x64.h:86
auto get() noexcept
Definition: rflags_x64.h:150
auto get() noexcept
Definition: rflags_x64.h:60
auto get() noexcept
Definition: rflags_x64.h:210
void uint64_t uint64_t uint64_t *rdx noexcept
constexpr const auto mask
Definition: rflags_x64.h:66
constexpr const auto mask
Definition: rflags_x64.h:156
constexpr const auto mask
Definition: rflags_x64.h:56
auto get() noexcept
Definition: rflags_x64.h:50
constexpr const auto mask
Definition: rflags_x64.h:126
constexpr const auto mask
Definition: rflags_x64.h:166
constexpr const auto mask
Definition: rflags_x64.h:76
uint64_t value_type
Definition: rflags_x64.h:39
constexpr const auto mask
Definition: rflags_x64.h:46
constexpr const auto mask
Definition: rflags_x64.h:206
constexpr const auto mask
Definition: rflags_x64.h:216
constexpr const auto mask
Definition: rflags_x64.h:146
#define expect_false(a)
rflags::value_type g_rflags
Definition: cache_x64.h:31
auto get() noexcept
Definition: rflags_x64.h:41
uint64_t __read_rflags(void) noexcept
#define expect_true(a)
constexpr const auto mask
Definition: rflags_x64.h:226