vmcs_intel_x64_64bit_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 //
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 #ifndef VMCS_INTEL_X64_64BIT_CONTROL_FIELDS_H
23 #define VMCS_INTEL_X64_64BIT_CONTROL_FIELDS_H
24 
25 #include <bitmanip.h>
26 #include <vmcs/vmcs_intel_x64.h>
28 
35 
36 template<class MA, class CA, class M,
37  class = typename std::enable_if<std::is_integral<MA>::value>::type,
38  class = typename std::enable_if<std::is_integral<CA>::value>::type,
39  class = typename std::enable_if<std::is_integral<M>::value>::type>
40 auto set_vm_function_control(bool val, MA msr_addr, CA ctls_addr,
41  const char *name, M mask, bool field_exists)
42 {
43  if (!field_exists)
44  {
45  throw std::logic_error("set_vm_function_control failed: "_s + name
46  + " control doesn't exist");
47  }
48 
49  if (!val)
50  intel_x64::vm::write(ctls_addr, (intel_x64::vm::read(ctls_addr, name) & ~mask), name);
51 
52  if (val)
53  {
54  auto allowed1 = (intel_x64::msrs::get(msr_addr) & mask) != 0;
55 
56  if (!allowed1)
57  {
58  throw std::logic_error("set_vm_function_control failed: "_s + name
59  + " control is not allowed to be set to 1");
60  }
61 
62  intel_x64::vm::write(ctls_addr, (intel_x64::vm::read(ctls_addr, name) | mask), name);
63  }
64 }
65 
66 template<class MA, class CA, class M,
67  class = typename std::enable_if<std::is_integral<MA>::value>::type,
68  class = typename std::enable_if<std::is_integral<CA>::value>::type,
69  class = typename std::enable_if<std::is_integral<M>::value>::type>
70 auto set_vm_function_control_if_allowed(bool val, MA msr_addr, CA ctls_addr,
71  const char *name, M mask,
72  bool verbose, bool field_exists) noexcept
73 {
74  if (!field_exists)
75  {
76  bfwarning << "set_vm_function_control_if_allowed failed: " << name
77  << " function control doesn't exist" << '\n';
78  return;
79  }
80 
81  if (!val)
82  intel_x64::vm::write(ctls_addr, (intel_x64::vm::read(ctls_addr, name) & ~mask), name);
83 
84  if (val)
85  {
86  auto allowed1 = (intel_x64::msrs::get(msr_addr) & mask) != 0;
87 
88  if (!allowed1 && verbose)
89  {
90  bfwarning << "set_vm_function_control failed: " << name
91  << " function control is not allowed to be set to 1";
92  }
93 
94  intel_x64::vm::write(ctls_addr, (intel_x64::vm::read(ctls_addr, name) | mask), name);
95  }
96 }
97 
98 // *INDENT-OFF*
99 
100 namespace intel_x64
101 {
102 namespace vmcs
103 {
104 
105 namespace address_of_io_bitmap_a
106 {
107  constexpr const auto addr = 0x0000000000002000UL;
108  constexpr const auto name = "address_of_io_bitmap_a";
109 
110  inline bool exists() noexcept
111  { return true; }
112 
113  inline auto get()
114  { return get_vmcs_field(addr, name, exists()); }
115 
116  inline auto get_if_exists(bool verbose = false) noexcept
117  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
118 
119  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
120  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
121 
122  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
123  void set_if_exists(T val, bool verbose = false) noexcept
124  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
125 }
126 
127 namespace address_of_io_bitmap_b
128 {
129  constexpr const auto addr = 0x0000000000002002UL;
130  constexpr const auto name = "address_of_io_bitmap_b";
131 
132  inline bool exists() noexcept
133  { return true; }
134 
135  inline auto get()
136  { return get_vmcs_field(addr, name, exists()); }
137 
138  inline auto get_if_exists(bool verbose = false) noexcept
139  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
140 
141  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
142  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
143 
144  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
145  void set_if_exists(T val, bool verbose = false) noexcept
146  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
147 }
148 
149 namespace address_of_msr_bitmap
150 {
151  constexpr const auto addr = 0x0000000000002004UL;
152  constexpr const auto name = "address_of_msr_bitmap";
153 
154  inline bool exists() noexcept
156 
157  inline auto get()
158  { return get_vmcs_field(addr, name, exists()); }
159 
160  inline auto get_if_exists(bool verbose = false) noexcept
161  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
162 
163  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
164  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
165 
166  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
167  void set_if_exists(T val, bool verbose = false) noexcept
168  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
169 }
170 
171 namespace vm_exit_msr_store_address
172 {
173  constexpr const auto addr = 0x0000000000002006UL;
174  constexpr const auto name = "vm_exit_msr_store_address";
175 
176  inline bool exists() noexcept
177  { return true; }
178 
179  inline auto get()
180  { return get_vmcs_field(addr, name, exists()); }
181 
182  inline auto get_if_exists(bool verbose = false) noexcept
183  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
184 
185  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
186  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
187 
188  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
189  void set_if_exists(T val, bool verbose = false) noexcept
190  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
191 }
192 
193 namespace vm_exit_msr_load_address
194 {
195  constexpr const auto addr = 0x0000000000002008UL;
196  constexpr const auto name = "vm_exit_msr_load_address";
197 
198  inline bool exists() noexcept
199  { return true; }
200 
201  inline auto get()
202  { return get_vmcs_field(addr, name, exists()); }
203 
204  inline auto get_if_exists(bool verbose = false) noexcept
205  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
206 
207  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
208  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
209 
210  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
211  void set_if_exists(T val, bool verbose = false) noexcept
212  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
213 }
214 
215 namespace vm_entry_msr_load_address
216 {
217  constexpr const auto addr = 0x000000000000200AUL;
218  constexpr const auto name = "vm_entry_msr_load_address";
219 
220  inline bool exists() noexcept
221  { return true; }
222 
223  inline auto get()
224  { return get_vmcs_field(addr, name, exists()); }
225 
226  inline auto get_if_exists(bool verbose = false) noexcept
227  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
228 
229  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
230  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
231 
232  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
233  void set_if_exists(T val, bool verbose = false) noexcept
234  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
235 }
236 
237 namespace executive_vmcs_pointer
238 {
239  constexpr const auto addr = 0x000000000000200CUL;
240  constexpr const auto name = "executive_vmcs_pointer";
241 
242  inline bool exists() noexcept
243  { return true; }
244 
245  inline auto get()
246  { return get_vmcs_field(addr, name, exists()); }
247 
248  inline auto get_if_exists(bool verbose = false) noexcept
249  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
250 
251  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
252  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
253 
254  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
255  void set_if_exists(T val, bool verbose = false) noexcept
256  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
257 }
258 
259 namespace pml_address
260 {
261  constexpr const auto addr = 0x000000000000200EUL;
262  constexpr const auto name = "pml_address";
263 
264  inline bool exists() noexcept
265  {
268  }
269 
270  inline auto get()
271  { return get_vmcs_field(addr, name, exists()); }
272 
273  inline auto get_if_exists(bool verbose = false) noexcept
274  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
275 
276  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
277  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
278 
279  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
280  void set_if_exists(T val, bool verbose = false) noexcept
281  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
282 }
283 
284 namespace tsc_offset
285 {
286  constexpr const auto addr = 0x0000000000002010UL;
287  constexpr const auto name = "tsc_offset";
288 
289  inline bool exists() noexcept
290  { return true; }
291 
292  inline auto get()
293  { return get_vmcs_field(addr, name, exists()); }
294 
295  inline auto get_if_exists(bool verbose = false) noexcept
296  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
297 
298  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
299  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
300 
301  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
302  void set_if_exists(T val, bool verbose = false) noexcept
303  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
304 }
305 
306 namespace virtual_apic_address
307 {
308  constexpr const auto addr = 0x0000000000002012UL;
309  constexpr const auto name = "virtual_apic_address";
310 
311  inline bool exists() noexcept
313 
314  inline auto get()
315  { return get_vmcs_field(addr, name, exists()); }
316 
317  inline auto get_if_exists(bool verbose = false) noexcept
318  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
319 
320  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
321  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
322 
323  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
324  void set_if_exists(T val, bool verbose = false) noexcept
325  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
326 }
327 
328 namespace apic_access_address
329 {
330  constexpr const auto addr = 0x0000000000002014UL;
331  constexpr const auto name = "apic_access_address";
332 
333  inline bool exists() noexcept
334  {
337  }
338 
339  inline auto get()
340  { return get_vmcs_field(addr, name, exists()); }
341 
342  inline auto get_if_exists(bool verbose = false) noexcept
343  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
344 
345  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
346  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
347 
348  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
349  void set_if_exists(T val, bool verbose = false) noexcept
350  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
351 }
352 
353 namespace posted_interrupt_descriptor_address
354 {
355  constexpr const auto addr = 0x0000000000002016UL;
356  constexpr const auto name = "posted_interrupt_descriptor_address";
357 
358  inline bool exists() noexcept
360 
361  inline auto get()
362  { return get_vmcs_field(addr, name, exists()); }
363 
364  inline auto get_if_exists(bool verbose = false) noexcept
365  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
366 
367  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
368  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
369 
370  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
371  void set_if_exists(T val, bool verbose = false) noexcept
372  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
373 }
374 
375 namespace vm_function_controls
376 {
377  constexpr const auto addr = 0x0000000000002018UL;
378  constexpr const auto name = "vm_function_controls";
379  constexpr const auto msr_addr = 0x00000491U;
380 
381  inline bool exists() noexcept
382  {
385  }
386 
387  inline auto get()
388  { return get_vmcs_field(addr, name, exists()); }
389 
390  inline auto get_if_exists(bool verbose = false) noexcept
391  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
392 
393  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
394  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
395 
396  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
397  void set_if_exists(T val, bool verbose = false) noexcept
398  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
399 
400  namespace eptp_switching
401  {
402  constexpr const auto mask = 0x0000000000000001UL;
403  constexpr const auto from = 0;
404  constexpr const auto name = "eptp_switching";
405 
406  inline auto is_enabled()
407  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
408 
409  inline auto is_enabled_if_exists(bool verbose = false) noexcept
410  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
411 
412  inline auto is_disabled()
413  { return is_bit_cleared(get_vmcs_field(addr, name, exists()), from); }
414 
415  inline auto is_disabled_if_exists(bool verbose = false) noexcept
416  { return is_bit_cleared(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
417 
418  inline void enable()
419  { set_vm_function_control(true, msr_addr, addr, name, mask, exists()); }
420 
421  inline void enable_if_allowed(bool verbose = false) noexcept
422  { set_vm_function_control_if_allowed(true, msr_addr, addr, name, mask, verbose, exists()); }
423 
424  inline void disable()
425  { set_vm_function_control(false, msr_addr, addr, name, mask, exists()); }
426 
427  inline void disable_if_allowed(bool verbose = false) noexcept
428  { set_vm_function_control_if_allowed(false, msr_addr, addr, name, mask, verbose, exists()); }
429  }
430 
431  namespace reserved
432  {
433  constexpr const auto mask = 0xFFFFFFFFFFFFFFFEUL;
434  constexpr const auto from = 0;
435  constexpr const auto name = "reserved";
436 
437  inline auto get()
438  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
439 
440  inline auto get_if_exists(bool verbose = false) noexcept
441  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
442 
443  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
444  void set(T val)
445  {
446  auto&& field = get_vmcs_field(addr, name, exists());
447  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
448  }
449 
450  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
451  void set_if_exists(T val, bool verbose = false) noexcept
452  {
453  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
454  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
455  }
456  }
457 }
458 
459 namespace ept_pointer
460 {
461  constexpr const auto addr = 0x000000000000201AUL;
462  constexpr const auto name = "ept_pointer";
463 
464  inline bool exists() noexcept
465  {
468  }
469 
470  inline auto get()
471  { return get_vmcs_field(addr, name, exists()); }
472 
473  inline auto get_if_exists(bool verbose = false) noexcept
474  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
475 
476  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
477  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
478 
479  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
480  void set_if_exists(T val, bool verbose = false) noexcept
481  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
482 
483  namespace memory_type
484  {
485  constexpr const auto mask = 0x0000000000000007UL;
486  constexpr const auto from = 0;
487  constexpr const auto name = "memory_type";
488 
489  constexpr const auto uncacheable = 0U;
490  constexpr const auto write_back = 6U;
491 
492  inline auto get()
493  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
494 
495  inline auto get_if_exists(bool verbose = false) noexcept
496  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
497 
498  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
499  void set(T val)
500  {
501  auto&& field = get_vmcs_field(addr, name, exists());
502  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
503  }
504 
505  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
506  void set_if_exists(T val, bool verbose = false) noexcept
507  {
508  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
509  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
510  }
511  }
512 
513  namespace page_walk_length_minus_one
514  {
515  constexpr const auto mask = 0x0000000000000038UL;
516  constexpr const auto from = 3;
517  constexpr const auto name = "page_walk_length_minus_one";
518 
519  inline auto get()
520  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
521 
522  inline auto get_if_exists(bool verbose = false) noexcept
523  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
524 
525  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
526  void set(T val)
527  {
528  auto&& field = get_vmcs_field(addr, name, exists());
529  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
530  }
531 
532  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
533  void set_if_exists(T val, bool verbose = false) noexcept
534  {
535  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
536  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
537  }
538  }
539 
540  namespace accessed_and_dirty_flags
541  {
542  constexpr const auto mask = 0x0000000000000040UL;
543  constexpr const auto from = 6;
544  constexpr const auto name = "accessed_and_dirty_flags";
545 
546  inline auto is_enabled()
547  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
548 
549  inline auto is_enabled_if_exists(bool verbose = false) noexcept
550  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
551 
552  inline auto is_disabled()
553  { return is_bit_cleared(get_vmcs_field(addr, name, exists()), from); }
554 
555  inline auto is_disabled_if_exists(bool verbose = false) noexcept
556  { return is_bit_cleared(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
557 
558  inline void enable()
559  {
560  auto&& field = get_vmcs_field(addr, name, exists());
561  set_vmcs_field(set_bit(field, from), addr, name, exists());
562  }
563 
564  inline void enable_if_exists(bool verbose = false) noexcept
565  {
566  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
567  set_vmcs_field_if_exists(set_bit(field, from), addr, name, verbose, exists());
568  }
569 
570  inline void disable()
571  {
572  auto&& field = get_vmcs_field(addr, name, exists());
573  set_vmcs_field(clear_bit(field, from), addr, name, exists());
574  }
575 
576  inline void disable_if_exists(bool verbose = false) noexcept
577  {
578  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
579  set_vmcs_field_if_exists(clear_bit(field, from), addr, name, verbose, exists());
580  }
581  }
582 
583  namespace phys_addr
584  {
585  constexpr const auto mask = 0x0000FFFFFFFFF000UL;
586  constexpr const auto from = 0;
587  constexpr const auto name = "phys_addr";
588 
589  inline auto get()
590  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
591 
592  inline auto get_if_exists(bool verbose = false) noexcept
593  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
594 
595  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
596  void set(T val)
597  {
598  auto&& field = get_vmcs_field(addr, name, exists());
599  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
600  }
601 
602  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
603  void set_if_exists(T val, bool verbose = false) noexcept
604  {
605  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
606  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
607  }
608  }
609 
610  namespace reserved
611  {
612  constexpr const auto mask = 0xFFFF000000000F80UL;
613  constexpr const auto from = 0;
614  constexpr const auto name = "reserved";
615 
616  inline auto get()
617  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
618 
619  inline auto get_if_exists(bool verbose = false) noexcept
620  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
621 
622  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
623  void set(T val)
624  {
625  auto&& field = get_vmcs_field(addr, name, exists());
626  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
627  }
628 
629  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
630  void set_if_exists(T val, bool verbose = false) noexcept
631  {
632  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
633  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
634  }
635  }
636 }
637 
638 namespace eoi_exit_bitmap_0
639 {
640  constexpr const auto addr = 0x000000000000201CUL;
641  constexpr const auto name = "eoi_exit_bitmap_0";
642 
643  inline bool exists() noexcept
644  {
647  }
648 
649  inline auto get()
650  { return get_vmcs_field(addr, name, exists()); }
651 
652  inline auto get_if_exists(bool verbose = false) noexcept
653  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
654 
655  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
656  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
657 
658  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
659  void set_if_exists(T val, bool verbose = false) noexcept
660  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
661 }
662 
663 namespace eoi_exit_bitmap_1
664 {
665  constexpr const auto addr = 0x000000000000201EUL;
666  constexpr const auto name = "eoi_exit_bitmap_1";
667 
668  inline bool exists() noexcept
669  {
672  }
673 
674  inline auto get()
675  { return get_vmcs_field(addr, name, exists()); }
676 
677  inline auto get_if_exists(bool verbose = false) noexcept
678  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
679 
680  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
681  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
682 
683  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
684  void set_if_exists(T val, bool verbose = false) noexcept
685  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
686 }
687 
688 namespace eoi_exit_bitmap_2
689 {
690  constexpr const auto addr = 0x0000000000002020UL;
691  constexpr const auto name = "eoi_exit_bitmap_2";
692 
693  inline bool exists() noexcept
694  {
697  }
698 
699  inline auto get()
700  { return get_vmcs_field(addr, name, exists()); }
701 
702  inline auto get_if_exists(bool verbose = false) noexcept
703  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
704 
705  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
706  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
707 
708  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
709  void set_if_exists(T val, bool verbose = false) noexcept
710  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
711 }
712 
713 namespace eoi_exit_bitmap_3
714 {
715  constexpr const auto addr = 0x0000000000002022UL;
716  constexpr const auto name = "eoi_exit_bitmap_3";
717 
718  inline bool exists() noexcept
719  {
722  }
723 
724  inline auto get()
725  { return get_vmcs_field(addr, name, exists()); }
726 
727  inline auto get_if_exists(bool verbose = false) noexcept
728  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
729 
730  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
731  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
732 
733  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
734  void set_if_exists(T val, bool verbose = false) noexcept
735  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
736 }
737 
738 namespace eptp_list_address
739 {
740  constexpr const auto addr = 0x0000000000002024UL;
741  constexpr const auto name = "eptp_list_address";
742 
743  inline bool exists() noexcept
744  {
748  }
749 
750  inline auto get()
751  { return get_vmcs_field(addr, name, exists()); }
752 
753  inline auto get_if_exists(bool verbose = false) noexcept
754  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
755 
756  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
757  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
758 
759  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
760  void set_if_exists(T val, bool verbose = false) noexcept
761  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
762 }
763 
764 namespace vmread_bitmap_address
765 {
766  constexpr const auto addr = 0x0000000000002026UL;
767  constexpr const auto name = "vmread_bitmap_address";
768 
769  inline bool exists() noexcept
770  {
773  }
774 
775  inline auto get()
776  { return get_vmcs_field(addr, name, exists()); }
777 
778  inline auto get_if_exists(bool verbose = false) noexcept
779  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
780 
781  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
782  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
783 
784  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
785  void set_if_exists(T val, bool verbose = false) noexcept
786  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
787 }
788 
789 namespace vmwrite_bitmap_address
790 {
791  constexpr const auto addr = 0x0000000000002028UL;
792  constexpr const auto name = "vmwrite_bitmap_address";
793 
794  inline bool exists() noexcept
795  {
798  }
799 
800  inline auto get()
801  { return get_vmcs_field(addr, name, exists()); }
802 
803  inline auto get_if_exists(bool verbose = false) noexcept
804  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
805 
806  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
807  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
808 
809  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
810  void set_if_exists(T val, bool verbose = false) noexcept
811  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
812 }
813 
814 namespace virtualization_exception_information_address
815 {
816  constexpr const auto addr = 0x000000000000202AUL;
817  constexpr const auto name = "virtualization_exception_information_address";
818 
819  inline bool exists() noexcept
820  {
823  }
824 
825  inline auto get()
826  { return get_vmcs_field(addr, name, exists()); }
827 
828  inline auto get_if_exists(bool verbose = false) noexcept
829  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
830 
831  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
832  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
833 
834  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
835  void set_if_exists(T val, bool verbose = false) noexcept
836  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
837 }
838 
839 namespace xss_exiting_bitmap
840 {
841  constexpr const auto addr = 0x000000000000202CUL;
842  constexpr const auto name = "xss_exiting_bitmap";
843 
844  inline bool exists() noexcept
845  {
848  }
849 
850  inline auto get()
851  { return get_vmcs_field(addr, name, exists()); }
852 
853  inline auto get_if_exists(bool verbose = false) noexcept
854  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
855 
856  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
857  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
858 
859  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
860  void set_if_exists(T val, bool verbose = false) noexcept
861  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
862 }
863 
864 }
865 }
866 
867 // *INDENT-ON*
868 
869 #endif
auto get_vmcs_field_if_exists(T addr, const char *name, bool verbose, bool exists)
auto set_vm_function_control(bool val, MA msr_addr, CA ctls_addr, const char *name, M mask, bool field_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
auto get_if_exists(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
constexpr const auto addr
auto get_if_exists(bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto get_if_exists(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
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto is_bit_cleared(T t, B b) noexcept
Definition: bitmanip.h:54
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto get_if_exists(bool verbose=false) noexcept
void write(field_type field, value_type value, name_type name="")
constexpr const auto name
auto get(A addr) noexcept
auto clear_bit(T t, B b) noexcept
Definition: bitmanip.h:36
constexpr const auto reserved
Definition: vcpuid.h:33
auto set_vmcs_field(V val, A addr, const char *name, bool exists)
auto set_bit(T t, B b) noexcept
Definition: bitmanip.h:30
bool exists() noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto get_bits(T t, M m) noexcept
Definition: bitmanip.h:65
auto read(field_type field, name_type name="")
auto get_vmcs_field(T addr, const char *name, 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
auto set_vm_function_control_if_allowed(bool val, MA msr_addr, CA ctls_addr, const char *name, M mask, bool verbose, bool field_exists) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto is_bit_set(T t, B b) noexcept
Definition: bitmanip.h:48
void set_if_exists(T val, bool verbose=false) noexcept
auto set_bits(T t, M m, V v) noexcept
Definition: bitmanip.h:72
void set_if_exists(T val, bool verbose=false) noexcept