vmcs_intel_x64_natural_width_control_fields.h
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 // Author: Connor Davis <davisc@ainfosec.com>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 #ifndef VMCS_INTEL_X64_NATURAL_WIDTH_CONTROL_FIELDS_H
24 #define VMCS_INTEL_X64_NATURAL_WIDTH_CONTROL_FIELDS_H
25 
26 #include <bitmanip.h>
27 #include <vmcs/vmcs_intel_x64.h>
28 
35 
36 // *INDENT-OFF*
37 
38 namespace intel_x64
39 {
40 namespace vmcs
41 {
42 
43 namespace cr0_guest_host_mask
44 {
45  constexpr const auto addr = 0x0000000000006000UL;
46  constexpr const auto name = "cr0_guest_host_mask";
47 
48  inline auto exists() noexcept
49  { return true; }
50 
51  inline auto get()
52  { return get_vmcs_field(addr, name, exists()); }
53 
54  inline auto get_if_exists(bool verbose = false) noexcept
55  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
56 
57  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
58  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
59 
60  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
61  void set_if_exists(T val, bool verbose = false) noexcept
62  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
63 }
64 
65 namespace cr4_guest_host_mask
66 {
67  constexpr const auto addr = 0x0000000000006002UL;
68  constexpr const auto name = "cr4_guest_host_mask";
69 
70  inline auto exists() noexcept
71  { return true; }
72 
73  inline auto get()
74  { return get_vmcs_field(addr, name, exists()); }
75 
76  inline auto get_if_exists(bool verbose = false) noexcept
77  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
78 
79  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
80  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
81 
82  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
83  void set_if_exists(T val, bool verbose = false) noexcept
84  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
85 }
86 
87 namespace cr0_read_shadow
88 {
89  constexpr const auto addr = 0x0000000000006004UL;
90  constexpr const auto name = "cr0_read_shadow";
91 
92  inline auto exists() noexcept
93  { return true; }
94 
95  inline auto get()
96  { return get_vmcs_field(addr, name, exists()); }
97 
98  inline auto get_if_exists(bool verbose = false) noexcept
99  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
100 
101  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
102  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
103 
104  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
105  void set_if_exists(T val, bool verbose = false) noexcept
106  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
107 }
108 
109 namespace cr4_read_shadow
110 {
111  constexpr const auto addr = 0x0000000000006006UL;
112  constexpr const auto name = "cr4_read_shadow";
113 
114  inline auto exists() noexcept
115  { return true; }
116 
117  inline auto get()
118  { return get_vmcs_field(addr, name, exists()); }
119 
120  inline auto get_if_exists(bool verbose = false) noexcept
121  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
122 
123  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
124  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
125 
126  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
127  void set_if_exists(T val, bool verbose = false) noexcept
128  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
129 }
130 
131 namespace cr3_target_value_0
132 {
133  constexpr const auto addr = 0x0000000000006008UL;
134  constexpr const auto name = "cr3_target_value_0";
135 
136  inline auto exists() noexcept
137  { return true; }
138 
139  inline auto get()
140  { return get_vmcs_field(addr, name, exists()); }
141 
142  inline auto get_if_exists(bool verbose = false) noexcept
143  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
144 
145  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
146  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
147 
148  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
149  void set_if_exists(T val, bool verbose = false) noexcept
150  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
151 }
152 
153 namespace cr3_target_value_1
154 {
155  constexpr const auto addr = 0x000000000000600AUL;
156  constexpr const auto name = "cr3_target_value_1";
157 
158  inline auto exists() noexcept
159  { return true; }
160 
161  inline auto get()
162  { return get_vmcs_field(addr, name, exists()); }
163 
164  inline auto get_if_exists(bool verbose = false) noexcept
165  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
166 
167  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
168  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
169 
170  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
171  void set_if_exists(T val, bool verbose = false) noexcept
172  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
173 }
174 
175 namespace cr3_target_value_2
176 {
177  constexpr const auto addr = 0x000000000000600CUL;
178  constexpr const auto name = "cr3_target_value_2";
179 
180  inline auto exists() noexcept
181  { return true; }
182 
183  inline auto get()
184  { return get_vmcs_field(addr, name, exists()); }
185 
186  inline auto get_if_exists(bool verbose = false) noexcept
187  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
188 
189  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
190  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
191 
192  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
193  void set_if_exists(T val, bool verbose = false) noexcept
194  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
195 }
196 
197 namespace cr3_target_value_3
198 {
199  constexpr const auto addr = 0x000000000000600EUL;
200  constexpr const auto name = "cr3_target_value_3";
201 
202  inline auto exists() noexcept
203  { return true; }
204 
205  inline auto get()
206  { return get_vmcs_field(addr, name, exists()); }
207 
208  inline auto get_if_exists(bool verbose = false) noexcept
209  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
210 
211  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
212  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
213 
214  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
215  void set_if_exists(T val, bool verbose = false) noexcept
216  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
217 }
218 
219 }
220 }
221 
222 // *INDENT-ON*
223 
224 #endif
auto get_vmcs_field_if_exists(T addr, const char *name, bool verbose, bool exists)
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto set_vmcs_field_if_exists(V val, A addr, const char *name, bool verbose, bool exists) noexcept
void uint64_t uint64_t uint64_t *rdx noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto set_vmcs_field(V val, A addr, const char *name, bool exists)
void set_if_exists(T val, bool verbose=false) noexcept
auto get_vmcs_field(T addr, const char *name, bool exists)
void set_if_exists(T val, bool verbose=false) noexcept