vmcs_intel_x64_16bit_host_state_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_16BIT_HOST_STATE_FIELDS_H
24 #define VMCS_INTEL_X64_16BIT_HOST_STATE_FIELDS_H
25 
26 #include <vmcs/vmcs_intel_x64.h>
27 
34 
35 // *INDENT-OFF*
36 
37 namespace intel_x64
38 {
39 namespace vmcs
40 {
41 
42 namespace host_es_selector
43 {
44  constexpr const auto addr = 0x0000000000000C00UL;
45  constexpr const auto name = "host_es_selector";
46 
47  inline bool exists() noexcept
48  { return true; }
49 
50  inline auto get()
51  { return get_vmcs_field(addr, name, exists()); }
52 
53  inline auto get_if_exists(bool verbose = false) noexcept
54  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
55 
56  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
57  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
58 
59  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
60  void set_if_exists(T val, bool verbose = false) noexcept
61  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
62 
63  namespace rpl
64  {
65  constexpr const auto mask = 0x00000003U;
66  constexpr const auto from = 0;
67  constexpr const auto name = "rpl";
68 
69  inline auto get()
70  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
71 
72  inline auto get_if_exists(bool verbose = false) noexcept
73  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
74 
75  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
76  void set(T val)
77  {
78  auto&& field = get_vmcs_field(addr, name, exists());
79  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
80  }
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  {
85  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
86  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
87  }
88  }
89 
90  namespace ti
91  {
92  constexpr const auto mask = 0x00000004U;
93  constexpr const auto from = 2;
94  constexpr const auto name = "ti";
95 
96  inline auto get()
97  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
98 
99  inline auto get_if_exists(bool verbose = false) noexcept
100  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
101 
102  inline void set(bool b)
103  {
104  auto&& field = get_vmcs_field(addr, name, exists());
105  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
106  }
107 
108  inline void set_if_exists(bool b, bool verbose = false) noexcept
109  {
110  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
111  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
112  }
113  }
114 
115  namespace index
116  {
117  constexpr const auto mask = 0x0000FFF8U;
118  constexpr const auto from = 3;
119  constexpr const auto name = "index";
120 
121  inline auto get()
122  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
123 
124  inline auto get_if_exists(bool verbose = false) noexcept
125  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
126 
127  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
128  void set(T val)
129  {
130  auto&& field = get_vmcs_field(addr, name, exists());
131  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
132  }
133 
134  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
135  void set_if_exists(T val, bool verbose = false) noexcept
136  {
137  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
138  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
139  }
140  }
141 }
142 
143 namespace host_cs_selector
144 {
145  constexpr const auto addr = 0x0000000000000C02UL;
146  constexpr const auto name = "host_cs_selector";
147 
148  inline bool exists() noexcept
149  { return true; }
150 
151  inline auto get()
152  { return get_vmcs_field(addr, name, exists()); }
153 
154  inline auto get_if_exists(bool verbose = false) noexcept
155  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
156 
157  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
158  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
159 
160  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
161  void set_if_exists(T val, bool verbose = false) noexcept
162  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
163 
164  namespace rpl
165  {
166  constexpr const auto mask = 0x00000003U;
167  constexpr const auto from = 0;
168  constexpr const auto name = "rpl";
169 
170  inline auto get()
171  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
172 
173  inline auto get_if_exists(bool verbose = false) noexcept
174  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
175 
176  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
177  void set(T val)
178  {
179  auto&& field = get_vmcs_field(addr, name, exists());
180  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
181  }
182 
183  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
184  void set_if_exists(T val, bool verbose = false) noexcept
185  {
186  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
187  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
188  }
189  }
190 
191  namespace ti
192  {
193  constexpr const auto mask = 0x00000004U;
194  constexpr const auto from = 2;
195  constexpr const auto name = "ti";
196 
197  inline auto get()
198  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
199 
200  inline auto get_if_exists(bool verbose = false) noexcept
201  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
202 
203  inline void set(bool b)
204  {
205  auto&& field = get_vmcs_field(addr, name, exists());
206  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
207  }
208 
209  inline void set_if_exists(bool b, bool verbose = false) noexcept
210  {
211  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
212  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
213  }
214  }
215 
216  namespace index
217  {
218  constexpr const auto mask = 0x0000FFF8U;
219  constexpr const auto from = 3;
220  constexpr const auto name = "index";
221 
222  inline auto get()
223  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
224 
225  inline auto get_if_exists(bool verbose = false) noexcept
226  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
227 
228  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
229  void set(T val)
230  {
231  auto&& field = get_vmcs_field(addr, name, exists());
232  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
233  }
234 
235  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
236  void set_if_exists(T val, bool verbose = false) noexcept
237  {
238  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
239  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
240  }
241  }
242 }
243 
244 namespace host_ss_selector
245 {
246  constexpr const auto addr = 0x0000000000000C04UL;
247  constexpr const auto name = "host_ss_selector";
248 
249  inline bool exists() noexcept
250  { return true; }
251 
252  inline auto get()
253  { return get_vmcs_field(addr, name, exists()); }
254 
255  inline auto get_if_exists(bool verbose = false) noexcept
256  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
257 
258  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
259  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
260 
261  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
262  void set_if_exists(T val, bool verbose = false) noexcept
263  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
264 
265  namespace rpl
266  {
267  constexpr const auto mask = 0x00000003U;
268  constexpr const auto from = 0;
269  constexpr const auto name = "rpl";
270 
271  inline auto get()
272  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
273 
274  inline auto get_if_exists(bool verbose = false) noexcept
275  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
276 
277  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
278  void set(T val)
279  {
280  auto&& field = get_vmcs_field(addr, name, exists());
281  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
282  }
283 
284  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
285  void set_if_exists(T val, bool verbose = false) noexcept
286  {
287  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
288  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
289  }
290  }
291 
292  namespace ti
293  {
294  constexpr const auto mask = 0x00000004U;
295  constexpr const auto from = 2;
296  constexpr const auto name = "ti";
297 
298  inline auto get()
299  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
300 
301  inline auto get_if_exists(bool verbose = false) noexcept
302  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
303 
304  inline void set(bool b)
305  {
306  auto&& field = get_vmcs_field(addr, name, exists());
307  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
308  }
309 
310  inline void set_if_exists(bool b, bool verbose = false) noexcept
311  {
312  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
313  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
314  }
315  }
316 
317  namespace index
318  {
319  constexpr const auto mask = 0x0000FFF8U;
320  constexpr const auto from = 3;
321  constexpr const auto name = "index";
322 
323  inline auto get()
324  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
325 
326  inline auto get_if_exists(bool verbose = false) noexcept
327  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
328 
329  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
330  void set(T val)
331  {
332  auto&& field = get_vmcs_field(addr, name, exists());
333  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
334  }
335 
336  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
337  void set_if_exists(T val, bool verbose = false) noexcept
338  {
339  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
340  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
341  }
342  }
343 }
344 
345 namespace host_ds_selector
346 {
347  constexpr const auto addr = 0x0000000000000C06UL;
348  constexpr const auto name = "host_ds_selector";
349 
350  inline bool exists() noexcept
351  { return true; }
352 
353  inline auto get()
354  { return get_vmcs_field(addr, name, exists()); }
355 
356  inline auto get_if_exists(bool verbose = false) noexcept
357  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
358 
359  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
360  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
361 
362  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
363  void set_if_exists(T val, bool verbose = false) noexcept
364  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
365 
366  namespace rpl
367  {
368  constexpr const auto mask = 0x00000003U;
369  constexpr const auto from = 0;
370  constexpr const auto name = "rpl";
371 
372  inline auto get()
373  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
374 
375  inline auto get_if_exists(bool verbose = false) noexcept
376  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
377 
378  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
379  void set(T val)
380  {
381  auto&& field = get_vmcs_field(addr, name, exists());
382  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
383  }
384 
385  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
386  void set_if_exists(T val, bool verbose = false) noexcept
387  {
388  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
389  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
390  }
391  }
392 
393  namespace ti
394  {
395  constexpr const auto mask = 0x00000004U;
396  constexpr const auto from = 2;
397  constexpr const auto name = "ti";
398 
399  inline auto get()
400  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
401 
402  inline auto get_if_exists(bool verbose = false) noexcept
403  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
404 
405  inline void set(bool b)
406  {
407  auto&& field = get_vmcs_field(addr, name, exists());
408  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
409  }
410 
411  inline void set_if_exists(bool b, bool verbose = false) noexcept
412  {
413  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
414  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
415  }
416  }
417 
418  namespace index
419  {
420  constexpr const auto mask = 0x0000FFF8U;
421  constexpr const auto from = 3;
422  constexpr const auto name = "index";
423 
424  inline auto get()
425  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
426 
427  inline auto get_if_exists(bool verbose = false) noexcept
428  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
429 
430  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
431  void set(T val)
432  {
433  auto&& field = get_vmcs_field(addr, name, exists());
434  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
435  }
436 
437  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
438  void set_if_exists(T val, bool verbose = false) noexcept
439  {
440  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
441  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
442  }
443  }
444 }
445 
446 namespace host_fs_selector
447 {
448  constexpr const auto addr = 0x0000000000000C08UL;
449  constexpr const auto name = "host_fs_selector";
450 
451  inline bool exists() noexcept
452  { return true; }
453 
454  inline auto get()
455  { return get_vmcs_field(addr, name, exists()); }
456 
457  inline auto get_if_exists(bool verbose = false) noexcept
458  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
459 
460  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
461  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
462 
463  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
464  void set_if_exists(T val, bool verbose = false) noexcept
465  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
466 
467  namespace rpl
468  {
469  constexpr const auto mask = 0x00000003U;
470  constexpr const auto from = 0;
471  constexpr const auto name = "rpl";
472 
473  inline auto get()
474  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
475 
476  inline auto get_if_exists(bool verbose = false) noexcept
477  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
478 
479  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
480  void set(T val)
481  {
482  auto&& field = get_vmcs_field(addr, name, exists());
483  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
484  }
485 
486  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
487  void set_if_exists(T val, bool verbose = false) noexcept
488  {
489  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
490  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
491  }
492  }
493 
494  namespace ti
495  {
496  constexpr const auto mask = 0x00000004U;
497  constexpr const auto from = 2;
498  constexpr const auto name = "ti";
499 
500  inline auto get()
501  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
502 
503  inline auto get_if_exists(bool verbose = false) noexcept
504  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
505 
506  inline void set(bool b)
507  {
508  auto&& field = get_vmcs_field(addr, name, exists());
509  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
510  }
511 
512  inline void set_if_exists(bool b, bool verbose = false) noexcept
513  {
514  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
515  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
516  }
517  }
518 
519  namespace index
520  {
521  constexpr const auto mask = 0x0000FFF8U;
522  constexpr const auto from = 3;
523  constexpr const auto name = "index";
524 
525  inline auto get()
526  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
527 
528  inline auto get_if_exists(bool verbose = false) noexcept
529  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
530 
531  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
532  void set(T val)
533  {
534  auto&& field = get_vmcs_field(addr, name, exists());
535  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
536  }
537 
538  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
539  void set_if_exists(T val, bool verbose = false) noexcept
540  {
541  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
542  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
543  }
544  }
545 }
546 
547 namespace host_gs_selector
548 {
549  constexpr const auto addr = 0x0000000000000C0AUL;
550  constexpr const auto name = "host_gs_selector";
551 
552  inline bool exists() noexcept
553  { return true; }
554 
555  inline auto get()
556  { return get_vmcs_field(addr, name, exists()); }
557 
558  inline auto get_if_exists(bool verbose = false) noexcept
559  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
560 
561  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
562  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
563 
564  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
565  void set_if_exists(T val, bool verbose = false) noexcept
566  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
567 
568  namespace rpl
569  {
570  constexpr const auto mask = 0x00000003U;
571  constexpr const auto from = 0;
572  constexpr const auto name = "rpl";
573 
574  inline auto get()
575  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
576 
577  inline auto get_if_exists(bool verbose = false) noexcept
578  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
579 
580  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
581  void set(T val)
582  {
583  auto&& field = get_vmcs_field(addr, name, exists());
584  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
585  }
586 
587  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
588  void set_if_exists(T val, bool verbose = false) noexcept
589  {
590  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
591  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
592  }
593  }
594 
595  namespace ti
596  {
597  constexpr const auto mask = 0x00000004U;
598  constexpr const auto from = 2;
599  constexpr const auto name = "ti";
600 
601  inline auto get()
602  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
603 
604  inline auto get_if_exists(bool verbose = false) noexcept
605  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
606 
607  inline void set(bool b)
608  {
609  auto&& field = get_vmcs_field(addr, name, exists());
610  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
611  }
612 
613  inline void set_if_exists(bool b, bool verbose = false) noexcept
614  {
615  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
616  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
617  }
618  }
619 
620  namespace index
621  {
622  constexpr const auto mask = 0x0000FFF8U;
623  constexpr const auto from = 3;
624  constexpr const auto name = "index";
625 
626  inline auto get()
627  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
628 
629  inline auto get_if_exists(bool verbose = false) noexcept
630  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
631 
632  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
633  void set(T val)
634  {
635  auto&& field = get_vmcs_field(addr, name, exists());
636  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
637  }
638 
639  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
640  void set_if_exists(T val, bool verbose = false) noexcept
641  {
642  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
643  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
644  }
645  }
646 }
647 
648 namespace host_tr_selector
649 {
650  constexpr const auto addr = 0x0000000000000C0CUL;
651  constexpr const auto name = "host_tr_selector";
652 
653  inline bool exists() noexcept
654  { return true; }
655 
656  inline auto get()
657  { return get_vmcs_field(addr, name, exists()); }
658 
659  inline auto get_if_exists(bool verbose = false) noexcept
660  { return get_vmcs_field_if_exists(addr, name, verbose, exists()); }
661 
662  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
663  void set(T val) { set_vmcs_field(val, addr, name, exists()); }
664 
665  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
666  void set_if_exists(T val, bool verbose = false) noexcept
667  { set_vmcs_field_if_exists(val, addr, name, verbose, exists()); }
668 
669  namespace rpl
670  {
671  constexpr const auto mask = 0x00000003U;
672  constexpr const auto from = 0;
673  constexpr const auto name = "rpl";
674 
675  inline auto get()
676  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
677 
678  inline auto get_if_exists(bool verbose = false) noexcept
679  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
680 
681  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
682  void set(T val)
683  {
684  auto&& field = get_vmcs_field(addr, name, exists());
685  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
686  }
687 
688  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
689  void set_if_exists(T val, bool verbose = false) noexcept
690  {
691  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
692  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
693  }
694  }
695 
696  namespace ti
697  {
698  constexpr const auto mask = 0x00000004U;
699  constexpr const auto from = 2;
700  constexpr const auto name = "ti";
701 
702  inline auto get()
703  { return is_bit_set(get_vmcs_field(addr, name, exists()), from); }
704 
705  inline auto get_if_exists(bool verbose = false) noexcept
706  { return is_bit_set(get_vmcs_field_if_exists(addr, name, verbose, exists()), from); }
707 
708  inline void set(bool b)
709  {
710  auto&& field = get_vmcs_field(addr, name, exists());
711  set_vmcs_field(b ? set_bit(field, from) : clear_bit(field, from), addr, name, exists());
712  }
713 
714  inline void set_if_exists(bool b, bool verbose = false) noexcept
715  {
716  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
717  set_vmcs_field_if_exists(b ? set_bit(field, from) : clear_bit(field, from), addr, name, verbose, exists());
718  }
719  }
720 
721  namespace index
722  {
723  constexpr const auto mask = 0x0000FFF8U;
724  constexpr const auto from = 3;
725  constexpr const auto name = "index";
726 
727  inline auto get()
728  { return get_bits(get_vmcs_field(addr, name, exists()), mask) >> from; }
729 
730  inline auto get_if_exists(bool verbose = false) noexcept
731  { return get_bits(get_vmcs_field_if_exists(addr, name, verbose, exists()), mask) >> from; }
732 
733  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
734  void set(T val)
735  {
736  auto&& field = get_vmcs_field(addr, name, exists());
737  set_vmcs_field(set_bits(field, mask, (val << from)), addr, name, exists());
738  }
739 
740  template<class T, class = typename std::enable_if<std::is_integral<T>::value>::type>
741  void set_if_exists(T val, bool verbose = false) noexcept
742  {
743  auto&& field = get_vmcs_field_if_exists(addr, name, verbose, exists());
744  set_vmcs_field_if_exists(set_bits(field, mask, (val << from)), addr, name, verbose, exists());
745  }
746  }
747 }
748 
749 }
750 }
751 
752 // *INDENT-ON*
753 
754 #endif
void set_if_exists(T val, bool verbose=false) noexcept
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(bool b, 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
void set_if_exists(bool b, 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(bool b, bool verbose=false) noexcept
void set_if_exists(bool b, 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
auto index(const T virt, const F from)
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
void set_if_exists(bool b, bool verbose=false) noexcept
void set_if_exists(T val, bool verbose=false) noexcept
auto clear_bit(T t, B b) noexcept
Definition: bitmanip.h:36
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
auto get_bits(T t, M m) noexcept
Definition: bitmanip.h:65
auto get_vmcs_field(T addr, const char *name, bool exists)
void set_if_exists(bool b, bool verbose=false) noexcept
void set_if_exists(bool b, 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
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